downshift 1.29.1 → 1.30.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"downshift.umd.min.js","sources":["../src/set-a11y-status.js","../src/utils.js","../src/downshift.js","../src/index.js"],"sourcesContent":["// istanbul ignore next\nlet statusDiv =\n typeof document === 'undefined'\n ? null\n : document.getElementById('a11y-status-message')\n\nlet statuses = []\n\nfunction setStatus(status) {\n const isSameAsLast = statuses[statuses.length - 1] === status\n if (isSameAsLast) {\n statuses = [...statuses, status]\n } else {\n statuses = [status]\n }\n const div = getStatusDiv()\n\n // Remove previous children\n while (div.lastChild) {\n div.removeChild(div.firstChild)\n }\n\n statuses.filter(Boolean).forEach((statusItem, index) => {\n div.appendChild(getStatusChildDiv(statusItem, index))\n })\n}\n\nfunction getStatusChildDiv(status, index) {\n const display = index === statuses.length - 1 ? 'block' : 'none'\n\n const childDiv = document.createElement('div')\n childDiv.style.display = display\n childDiv.textContent = status\n\n return childDiv\n}\n\nfunction getStatusDiv() {\n if (statusDiv) {\n return statusDiv\n }\n statusDiv = document.createElement('div')\n statusDiv.setAttribute('id', 'a11y-status-message')\n statusDiv.setAttribute('role', 'status')\n statusDiv.setAttribute('aria-live', 'assertive')\n statusDiv.setAttribute('aria-relevant', 'additions text')\n Object.assign(statusDiv.style, {\n border: '0',\n clip: 'rect(0 0 0 0)',\n height: '1px',\n margin: '-1px',\n overflow: 'hidden',\n padding: '0',\n position: 'absolute',\n width: '1px',\n })\n document.body.appendChild(statusDiv)\n return statusDiv\n}\n\nexport default setStatus\n","let idCounter = 0\n\n/**\n * Accepts a parameter and returns it if it's a function\n * or a noop function if it's not. This allows us to\n * accept a callback, but not worry about it if it's not\n * passed.\n * @param {Function} cb the callback\n * @return {Function} a function\n */\nfunction cbToCb(cb) {\n return typeof cb === 'function' ? cb : noop\n}\nfunction noop() {}\n\nfunction findParent(finder, node, rootNode) {\n if (node !== null && node !== rootNode.parentNode) {\n if (finder(node)) {\n if (node === document.body && node.scrollTop === 0) {\n // in chrome body.scrollTop always return 0\n return document.documentElement\n }\n return node\n } else {\n return findParent(finder, node.parentNode, rootNode)\n }\n } else {\n return null\n }\n}\n\n/**\n * Get the closest element that scrolls\n * @param {HTMLElement} node - the child element to start searching for scroll parent at\n * @param {HTMLElement} rootNode - the root element of the component\n * @return {HTMLElement} the closest parentNode that scrolls\n */\nconst getClosestScrollParent = findParent.bind(\n null,\n node => node.scrollHeight > node.clientHeight,\n)\n\n/**\n * Scroll node into view if necessary\n * @param {HTMLElement} node - the element that should scroll into view\n * @param {HTMLElement} rootNode - the root element of the component\n * @param {Boolean} alignToTop - align element to the top of the visible area of the scrollable ancestor\n */\n// eslint-disable-next-line complexity\nfunction scrollIntoView(node, rootNode) {\n const scrollParent = getClosestScrollParent(node, rootNode)\n if (scrollParent === null) {\n return\n }\n const scrollParentStyles = getComputedStyle(scrollParent)\n const scrollParentRect = scrollParent.getBoundingClientRect()\n const scrollParentBorderTopWidth = parseInt(\n scrollParentStyles.borderTopWidth,\n 10,\n )\n const scrollParentBorderBottomWidth = parseInt(\n scrollParentStyles.borderBottomWidth,\n 10,\n )\n const bordersWidth =\n scrollParentBorderTopWidth + scrollParentBorderBottomWidth\n const scrollParentTop = scrollParentRect.top + scrollParentBorderTopWidth\n const nodeRect = node.getBoundingClientRect()\n\n if (nodeRect.top < 0 && scrollParentRect.top < 0) {\n scrollParent.scrollTop += nodeRect.top\n return\n }\n\n if (nodeRect.top < 0) {\n // the item is above the viewport and the parent is not above the viewport\n scrollParent.scrollTop += nodeRect.top - scrollParentTop\n return\n }\n\n if (nodeRect.top > 0 && scrollParentRect.top < 0) {\n if (\n scrollParentRect.bottom > 0 &&\n nodeRect.bottom + bordersWidth > scrollParentRect.bottom\n ) {\n // the item is below scrollable area\n scrollParent.scrollTop +=\n nodeRect.bottom - scrollParentRect.bottom + bordersWidth\n }\n // item and parent top are on different sides of view top border (do nothing)\n return\n }\n\n const nodeOffsetTop = nodeRect.top + scrollParent.scrollTop\n const nodeTop = nodeOffsetTop - scrollParentTop\n if (nodeTop < scrollParent.scrollTop) {\n // the item is above the scrollable area\n scrollParent.scrollTop = nodeTop\n } else if (\n nodeTop + nodeRect.height + bordersWidth >\n scrollParent.scrollTop + scrollParentRect.height\n ) {\n // the item is below the scrollable area\n scrollParent.scrollTop =\n nodeTop + nodeRect.height - scrollParentRect.height + bordersWidth\n }\n // the item is within the scrollable area (do nothing)\n}\n\n/**\n * Simple debounce implementation. Will call the given\n * function once after the time given has passed since\n * it was last called.\n * @param {Function} fn the function to call after the time\n * @param {Number} time the time to wait\n * @return {Function} the debounced function\n */\nfunction debounce(fn, time) {\n let timeoutId\n return wrapper\n function wrapper(...args) {\n if (timeoutId) {\n clearTimeout(timeoutId)\n }\n timeoutId = setTimeout(() => {\n timeoutId = null\n fn(...args)\n }, time)\n }\n}\n\n/**\n * This is intended to be used to compose event handlers.\n * They are executed in order until one of them sets\n * `event.preventDownshiftDefault = true`.\n * @param {Function} fns the event handler functions\n * @return {Function} the event handler to add to an element\n */\nfunction composeEventHandlers(...fns) {\n return (event, ...args) =>\n fns.some(fn => {\n fn && fn(event, ...args)\n // TODO: remove everything after the || in the next breaking change\n return event.preventDownshiftDefault || event.defaultPrevented\n })\n}\n\n/**\n * This generates a unique ID for an instance of Downshift\n * @return {String} the unique ID\n */\nfunction generateId() {\n return String(idCounter++)\n}\n\n/**\n * This is only used in tests\n * @param {Number} num The number to set the idCounter to\n */\nfunction setIdCounter(num) {\n idCounter = num\n}\n\n/**\n * Resets idCounter to 0. Used for SSR.\n */\nfunction resetIdCounter() {\n idCounter = 0\n}\n\n/**\n * Returns the first argument that is not undefined\n * @param {...*} args the arguments\n * @return {*} the defined value\n */\nfunction firstDefined(...args) {\n return args.find(a => typeof a !== 'undefined')\n}\n\n// eslint-disable-next-line complexity\nfunction getA11yStatusMessage({\n isOpen,\n highlightedItem,\n selectedItem,\n resultCount,\n previousResultCount,\n itemToString,\n}) {\n if (!isOpen) {\n if (selectedItem) {\n return itemToString(selectedItem)\n } else {\n return ''\n }\n }\n const resultCountChanged = resultCount !== previousResultCount\n if (!resultCount) {\n return 'No results.'\n } else if (!highlightedItem || resultCountChanged) {\n return `${resultCount} ${\n resultCount === 1 ? 'result is' : 'results are'\n } available, use up and down arrow keys to navigate.`\n }\n return itemToString(highlightedItem)\n}\n\n/**\n * Takes an argument and if it's an array, returns the first item in the array\n * otherwise returns the argument\n * @param {*} arg the maybe-array\n * @param {*} defaultValue the value if arg is falsey not defined\n * @return {*} the arg or it's first item\n */\nfunction unwrapArray(arg, defaultValue) {\n arg = Array.isArray(arg) ? /* istanbul ignore next (preact) */ arg[0] : arg\n if (!arg && defaultValue) {\n return defaultValue\n } else {\n return arg\n }\n}\n\n/**\n * @param {Object} element (P)react element\n * @return {Boolean} whether it's a DOM element\n */\nfunction isDOMElement(element) {\n /* istanbul ignore if */\n if (element.nodeName) {\n // then this is preact\n return typeof element.nodeName === 'string'\n } else {\n // then we assume this is react\n return typeof element.type === 'string'\n }\n}\n\n/**\n * @param {Object} element (P)react element\n * @return {Object} the props\n */\nfunction getElementProps(element) {\n // props for react, attributes for preact\n return element.props || /* istanbul ignore next (preact) */ element.attributes\n}\n\n/**\n * Throws a helpful error message for required properties. Useful\n * to be used as a default in destructuring or object params.\n * @param {String} fnName the function name\n * @param {String} propName the prop name\n */\nfunction requiredProp(fnName, propName) {\n throw new Error(`The property \"${propName}\" is required in \"${fnName}\"`)\n}\n\nconst stateKeys = [\n 'highlightedIndex',\n 'inputValue',\n 'isOpen',\n 'selectedItem',\n 'type',\n]\n/**\n * @param {Object} state The state object\n * @return {Object} State that is relevant to downshift\n */\nfunction pickState(state = {}) {\n const result = {}\n stateKeys.forEach(k => {\n if (state.hasOwnProperty(k)) {\n result[k] = state[k]\n }\n })\n return result\n}\n\nexport {\n cbToCb,\n composeEventHandlers,\n debounce,\n scrollIntoView,\n findParent,\n generateId,\n firstDefined,\n getA11yStatusMessage,\n unwrapArray,\n isDOMElement,\n getElementProps,\n noop,\n requiredProp,\n setIdCounter,\n resetIdCounter,\n pickState,\n isPlainObject,\n}\n\n/**\n * Simple check if the value passed is object literal\n * @param {*} obj any things\n * @return {Boolean} whether it's object literal\n */\nfunction isPlainObject(obj) {\n return Object.prototype.toString.call(obj) === '[object Object]'\n}\n","/* eslint camelcase:0 */\n\nimport React, {Component} from 'react'\nimport PropTypes from 'prop-types'\nimport preval from 'preval.macro'\nimport setA11yStatus from './set-a11y-status'\nimport {\n cbToCb,\n composeEventHandlers,\n debounce,\n scrollIntoView,\n generateId,\n firstDefined,\n getA11yStatusMessage,\n unwrapArray,\n isDOMElement,\n getElementProps,\n noop,\n requiredProp,\n pickState,\n isPlainObject,\n} from './utils'\n\nclass Downshift extends Component {\n static propTypes = {\n children: PropTypes.func,\n render: PropTypes.func,\n defaultHighlightedIndex: PropTypes.number,\n defaultSelectedItem: PropTypes.any,\n defaultInputValue: PropTypes.string,\n defaultIsOpen: PropTypes.bool,\n getA11yStatusMessage: PropTypes.func,\n itemToString: PropTypes.func,\n onChange: PropTypes.func,\n onSelect: PropTypes.func,\n onStateChange: PropTypes.func,\n onInputValueChange: PropTypes.func,\n onUserAction: PropTypes.func,\n onOuterClick: PropTypes.func,\n selectedItemChanged: PropTypes.func,\n stateReducer: PropTypes.func,\n itemCount: PropTypes.number,\n id: PropTypes.string,\n environment: PropTypes.shape({\n addEventListener: PropTypes.func,\n removeEventListener: PropTypes.func,\n document: PropTypes.shape({\n getElementById: PropTypes.func,\n activeElement: PropTypes.any,\n body: PropTypes.any,\n }),\n }),\n // things we keep in state for uncontrolled components\n // but can accept as props for controlled components\n /* eslint-disable react/no-unused-prop-types */\n selectedItem: PropTypes.any,\n isOpen: PropTypes.bool,\n inputValue: PropTypes.string,\n highlightedIndex: PropTypes.number,\n breakingChanges: PropTypes.shape({\n resetInputOnSelection: PropTypes.bool,\n }),\n /* eslint-enable */\n }\n\n static defaultProps = {\n defaultHighlightedIndex: null,\n defaultSelectedItem: null,\n defaultInputValue: '',\n defaultIsOpen: false,\n getA11yStatusMessage,\n itemToString: i => {\n if (i == null) {\n return ''\n }\n if (process.env.NODE_ENV !== 'production' && isPlainObject(i)) {\n //eslint-disable-next-line no-console\n console.warn(\n 'downshift: An object was passed to the default implementation of `itemToString`. You should probably provide your own `itemToString` implementation. Please refer to the `itemToString` API documentation.',\n 'The object that was passed:',\n i,\n )\n }\n return String(i)\n },\n onStateChange: () => {},\n onInputValueChange: () => {},\n onUserAction: () => {},\n onChange: () => {},\n onSelect: () => {},\n onOuterClick: () => {},\n selectedItemChanged: (prevItem, item) => prevItem !== item,\n environment:\n typeof window === 'undefined' /* istanbul ignore next (ssr) */\n ? {}\n : window,\n stateReducer: (state, stateToSet) => stateToSet,\n breakingChanges: {},\n }\n\n static stateChangeTypes = {\n unknown: '__autocomplete_unknown__',\n mouseUp: '__autocomplete_mouseup__',\n itemMouseEnter: '__autocomplete_item_mouseenter__',\n keyDownArrowUp: '__autocomplete_keydown_arrow_up__',\n keyDownArrowDown: '__autocomplete_keydown_arrow_down__',\n keyDownEscape: '__autocomplete_keydown_escape__',\n keyDownEnter: '__autocomplete_keydown_enter__',\n clickItem: '__autocomplete_click_item__',\n blurInput: '__autocomplete_blur_input__',\n changeInput: '__autocomplete_change_input__',\n keyDownSpaceButton: '__autocomplete_keydown_space_button__',\n clickButton: '__autocomplete_click_button__',\n blurButton: '__autocomplete_blur_button__',\n controlledPropUpdatedSelectedItem:\n '__autocomplete_controlled_prop_updated_selected_item__',\n }\n\n constructor(...args) {\n super(...args)\n const state = this.getState({\n highlightedIndex: this.props.defaultHighlightedIndex,\n isOpen: this.props.defaultIsOpen,\n inputValue: this.props.defaultInputValue,\n selectedItem: this.props.defaultSelectedItem,\n })\n if (state.selectedItem) {\n state.inputValue = this.props.itemToString(state.selectedItem)\n }\n this.state = state\n this.id = this.props.id || `downshift-${generateId()}`\n }\n\n input = null\n items = []\n // itemCount can be changed asynchronously\n // from within downshift (so it can't come from a prop)\n // this is why we store it as an instance and use\n // getItemCount rather than just use items.length\n // (to support windowing + async)\n itemCount = null\n previousResultCount = 0\n\n /**\n * Gets the state based on internal state or props\n * If a state value is passed via props, then that\n * is the value given, otherwise it's retrieved from\n * stateToMerge\n *\n * This will perform a shallow merge of the given state object\n * with the state coming from props\n * (for the controlled component scenario)\n * This is used in state updater functions so they're referencing\n * the right state regardless of where it comes from.\n *\n * @param {Object} stateToMerge defaults to this.state\n * @return {Object} the state\n */\n getState(stateToMerge = this.state) {\n return Object.keys(stateToMerge).reduce((state, key) => {\n state[key] = this.isControlledProp(key)\n ? this.props[key]\n : stateToMerge[key]\n return state\n }, {})\n }\n\n /**\n * This determines whether a prop is a \"controlled prop\" meaning it is\n * state which is controlled by the outside of this component rather\n * than within this component.\n * @param {String} key the key to check\n * @return {Boolean} whether it is a controlled controlled prop\n */\n isControlledProp(key) {\n return this.props[key] !== undefined\n }\n\n getItemCount() {\n // things read better this way. They're in priority order:\n // 1. `this.itemCount`\n // 2. `this.props.itemCount`\n // 3. `this.items.length`\n /* eslint-disable no-negated-condition */\n if (this.itemCount != null) {\n return this.itemCount\n } else if (this.props.itemCount !== undefined) {\n return this.props.itemCount\n } else {\n return this.items.length\n }\n /* eslint-enable no-negated-condition */\n }\n\n setItemCount = count => (this.itemCount = count)\n unsetItemCount = () => (this.itemCount = null)\n\n getItemNodeFromIndex = index => {\n return this.props.environment.document.getElementById(this.getItemId(index))\n }\n\n setHighlightedIndex = (\n highlightedIndex = this.props.defaultHighlightedIndex,\n otherStateToSet = {},\n ) => {\n otherStateToSet = pickState(otherStateToSet)\n this.internalSetState({highlightedIndex, ...otherStateToSet})\n }\n\n scrollHighlightedItemIntoView = () => {\n /* istanbul ignore else (react-native) */\n if (preval`module.exports = process.env.BUILD_REACT_NATIVE !== 'true'`) {\n const node = this.getItemNodeFromIndex(this.getState().highlightedIndex)\n const rootNode = this._rootNode\n scrollIntoView(node, rootNode)\n }\n }\n\n openAndHighlightDefaultIndex = (otherStateToSet = {}) => {\n this.setHighlightedIndex(undefined, {isOpen: true, ...otherStateToSet})\n }\n\n highlightDefaultIndex = (otherStateToSet = {}) => {\n this.setHighlightedIndex(undefined, otherStateToSet)\n }\n\n moveHighlightedIndex = (amount, otherStateToSet) => {\n if (this.getState().isOpen) {\n this.changeHighlightedIndex(amount, otherStateToSet)\n } else {\n this.openAndHighlightDefaultIndex(otherStateToSet)\n }\n }\n\n // eslint-disable-next-line complexity\n changeHighlightedIndex = (moveAmount, otherStateToSet) => {\n const itemsLastIndex = this.getItemCount() - 1\n if (itemsLastIndex < 0) {\n return\n }\n const {highlightedIndex} = this.getState()\n let baseIndex = highlightedIndex\n if (baseIndex === null) {\n baseIndex = moveAmount > 0 ? -1 : itemsLastIndex + 1\n }\n let newIndex = baseIndex + moveAmount\n if (newIndex < 0) {\n newIndex = itemsLastIndex\n } else if (newIndex > itemsLastIndex) {\n newIndex = 0\n }\n this.setHighlightedIndex(newIndex, otherStateToSet)\n }\n\n clearSelection = cb => {\n this.internalSetState(\n {\n selectedItem: null,\n inputValue: '',\n isOpen: false,\n },\n cb,\n )\n }\n\n selectItem = (item, otherStateToSet, cb) => {\n otherStateToSet = pickState(otherStateToSet)\n this.internalSetState(\n {\n isOpen: false,\n highlightedIndex: this.props.defaultHighlightedIndex,\n selectedItem: item,\n inputValue:\n this.isControlledProp('selectedItem') &&\n this.props.breakingChanges.resetInputOnSelection\n ? this.props.defaultInputValue\n : this.props.itemToString(item),\n ...otherStateToSet,\n },\n cb,\n )\n }\n\n selectItemAtIndex = (itemIndex, otherStateToSet, cb) => {\n const item = this.items[itemIndex]\n if (item == null) {\n return\n }\n this.selectItem(item, otherStateToSet, cb)\n }\n\n selectHighlightedItem = (otherStateToSet, cb) => {\n return this.selectItemAtIndex(\n this.getState().highlightedIndex,\n otherStateToSet,\n cb,\n )\n }\n\n // any piece of our state can live in two places:\n // 1. Uncontrolled: it's internal (this.state)\n // We will call this.setState to update that state\n // 2. Controlled: it's external (this.props)\n // We will call this.props.onStateChange to update that state\n //\n // In addition, we'll call this.props.onChange if the\n // selectedItem is changed.\n internalSetState(stateToSet, cb) {\n let isItemSelected, onChangeArg\n\n const onStateChangeArg = {}\n const isStateToSetFunction = typeof stateToSet === 'function'\n\n // we want to call `onInputValueChange` before the `setState` call\n // so someone controlling the `inputValue` state gets notified of\n // the input change as soon as possible. This avoids issues with\n // preserving the cursor position.\n // See https://github.com/paypal/downshift/issues/217 for more info.\n if (!isStateToSetFunction && stateToSet.hasOwnProperty('inputValue')) {\n this.props.onInputValueChange(stateToSet.inputValue, {\n ...this.getStateAndHelpers(),\n ...stateToSet,\n })\n }\n return this.setState(\n state => {\n state = this.getState(state)\n stateToSet = isStateToSetFunction ? stateToSet(state) : stateToSet\n\n // Your own function that could modify the state that will be set.\n stateToSet = this.props.stateReducer(state, stateToSet)\n\n // checks if an item is selected, regardless of if it's different from\n // what was selected before\n // used to determine if onSelect and onChange callbacks should be called\n isItemSelected = stateToSet.hasOwnProperty('selectedItem')\n // this keeps track of the object we want to call with setState\n const nextState = {}\n // this is just used to tell whether the state changed\n const nextFullState = {}\n // we need to call on change if the outside world is controlling any of our state\n // and we're trying to update that state. OR if the selection has changed and we're\n // trying to update the selection\n if (isItemSelected && stateToSet.selectedItem !== state.selectedItem) {\n onChangeArg = stateToSet.selectedItem\n }\n stateToSet.type = stateToSet.type || Downshift.stateChangeTypes.unknown\n\n Object.keys(stateToSet).forEach(key => {\n // onStateChangeArg should only have the state that is\n // actually changing\n if (state[key] !== stateToSet[key]) {\n onStateChangeArg[key] = stateToSet[key]\n }\n // the type is useful for the onStateChangeArg\n // but we don't actually want to set it in internal state.\n // this is an undocumented feature for now... Not all internalSetState\n // calls support it and I'm not certain we want them to yet.\n // But it enables users controlling the isOpen state to know when\n // the isOpen state changes due to mouseup events which is quite handy.\n if (key === 'type') {\n return\n }\n nextFullState[key] = stateToSet[key]\n // if it's coming from props, then we don't care to set it internally\n if (!this.isControlledProp(key)) {\n nextState[key] = stateToSet[key]\n }\n })\n\n // if stateToSet is a function, then we weren't able to call onInputValueChange\n // earlier, so we'll call it now that we know what the inputValue state will be.\n if (isStateToSetFunction && stateToSet.hasOwnProperty('inputValue')) {\n this.props.onInputValueChange(stateToSet.inputValue, {\n ...this.getStateAndHelpers(),\n ...stateToSet,\n })\n }\n\n return nextState\n },\n () => {\n // call the provided callback if it's a callback\n cbToCb(cb)()\n\n // only call the onStateChange and onChange callbacks if\n // we have relevant information to pass them.\n const hasMoreStateThanType = Object.keys(onStateChangeArg).length > 1\n if (hasMoreStateThanType) {\n this.props.onStateChange(onStateChangeArg, this.getStateAndHelpers())\n }\n\n if (isItemSelected) {\n this.props.onSelect(\n stateToSet.selectedItem,\n this.getStateAndHelpers(),\n )\n }\n\n if (onChangeArg !== undefined) {\n this.props.onChange(onChangeArg, this.getStateAndHelpers())\n }\n // this is currently undocumented and therefore subject to change\n // We'll try to not break it, but just be warned.\n this.props.onUserAction(onStateChangeArg, this.getStateAndHelpers())\n },\n )\n }\n\n getStateAndHelpers() {\n const {highlightedIndex, inputValue, selectedItem, isOpen} = this.getState()\n const {itemToString} = this.props\n const {id} = this\n const {\n getRootProps,\n getButtonProps,\n getLabelProps,\n getInputProps,\n getItemProps,\n openMenu,\n closeMenu,\n toggleMenu,\n selectItem,\n selectItemAtIndex,\n selectHighlightedItem,\n setHighlightedIndex,\n clearSelection,\n clearItems,\n reset,\n setItemCount,\n unsetItemCount,\n } = this\n return {\n // prop getters\n getRootProps,\n getButtonProps,\n getLabelProps,\n getInputProps,\n getItemProps,\n\n // actions\n reset,\n openMenu,\n closeMenu,\n toggleMenu,\n selectItem,\n selectItemAtIndex,\n selectHighlightedItem,\n setHighlightedIndex,\n clearSelection,\n clearItems,\n setItemCount,\n unsetItemCount,\n\n //props\n itemToString,\n\n //derived\n id,\n\n // state\n highlightedIndex,\n inputValue,\n isOpen,\n selectedItem,\n }\n }\n\n //////////////////////////// ROOT\n\n rootRef = node => (this._rootNode = node)\n\n getRootProps = (\n {refKey = 'ref', ...rest} = {},\n {suppressRefError = false} = {},\n ) => {\n // this is used in the render to know whether the user has called getRootProps.\n // It uses that to know whether to apply the props automatically\n this.getRootProps.called = true\n this.getRootProps.refKey = refKey\n this.getRootProps.suppressRefError = suppressRefError\n return {\n [refKey]: this.rootRef,\n ...rest,\n }\n }\n\n //\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ ROOT\n\n keyDownHandlers = {\n ArrowDown(event) {\n event.preventDefault()\n const amount = event.shiftKey ? 5 : 1\n this.moveHighlightedIndex(amount, {\n type: Downshift.stateChangeTypes.keyDownArrowDown,\n })\n },\n\n ArrowUp(event) {\n event.preventDefault()\n const amount = event.shiftKey ? -5 : -1\n this.moveHighlightedIndex(amount, {\n type: Downshift.stateChangeTypes.keyDownArrowUp,\n })\n },\n\n Enter(event) {\n if (this.getState().isOpen) {\n event.preventDefault()\n this.selectHighlightedItem({\n type: Downshift.stateChangeTypes.keyDownEnter,\n })\n }\n },\n\n Escape(event) {\n event.preventDefault()\n this.reset({type: Downshift.stateChangeTypes.keyDownEscape})\n },\n }\n\n //////////////////////////// BUTTON\n\n buttonKeyDownHandlers = {\n ...this.keyDownHandlers,\n\n ' '(event) {\n event.preventDefault()\n this.toggleMenu({type: Downshift.stateChangeTypes.keyDownSpaceButton})\n },\n }\n\n getButtonProps = ({onClick, onKeyDown, onBlur, ...rest} = {}) => {\n const {isOpen} = this.getState()\n const enabledEventHandlers = preval`module.exports = process.env.BUILD_REACT_NATIVE === 'true'`\n ? /* istanbul ignore next (react-native) */\n {\n onPress: composeEventHandlers(onClick, this.button_handleClick),\n }\n : {\n onClick: composeEventHandlers(onClick, this.button_handleClick),\n onKeyDown: composeEventHandlers(onKeyDown, this.button_handleKeyDown),\n onBlur: composeEventHandlers(onBlur, this.button_handleBlur),\n }\n const eventHandlers = rest.disabled ? {} : enabledEventHandlers\n return {\n type: 'button',\n role: 'button',\n 'aria-label': isOpen ? 'close menu' : 'open menu',\n 'aria-expanded': isOpen,\n 'aria-haspopup': true,\n ...eventHandlers,\n ...rest,\n }\n }\n\n button_handleKeyDown = event => {\n if (this.buttonKeyDownHandlers[event.key]) {\n this.buttonKeyDownHandlers[event.key].call(this, event)\n }\n }\n\n button_handleClick = event => {\n event.preventDefault()\n // handle odd case for Safari and Firefox which\n // don't give the button the focus properly.\n /* istanbul ignore if (can't reasonably test this) */\n if (\n this.props.environment.document.activeElement ===\n this.props.environment.document.body\n ) {\n event.target.focus()\n }\n this.toggleMenu({type: Downshift.stateChangeTypes.clickButton})\n }\n\n button_handleBlur = () => {\n if (!this.isMouseDown) {\n this.reset({type: Downshift.stateChangeTypes.blurButton})\n }\n }\n\n //\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ BUTTON\n\n /////////////////////////////// LABEL\n\n getLabelProps = (props = {}) => {\n this.getLabelProps.called = true\n if (\n this.getInputProps.called &&\n props.htmlFor &&\n props.htmlFor !== this.inputId\n ) {\n throw new Error(\n `downshift: You provided the htmlFor of \"${\n props.htmlFor\n }\" for your label, but the id of your input is \"${\n this.inputId\n }\". You must either remove the id from your input or set the htmlFor of the label equal to the input id.`,\n )\n }\n this.inputId = firstDefined(this.inputId, props.htmlFor, `${this.id}-input`)\n return {\n ...props,\n htmlFor: this.inputId,\n }\n }\n\n //\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ LABEL\n\n /////////////////////////////// INPUT\n\n getInputProps = ({onKeyDown, onBlur, onChange, onInput, ...rest} = {}) => {\n this.getInputProps.called = true\n if (this.getLabelProps.called && rest.id && rest.id !== this.inputId) {\n throw new Error(\n `downshift: You provided the id of \"${\n rest.id\n }\" for your input, but the htmlFor of your label is \"${\n this.inputId\n }\". You must either remove the id from your input or set the htmlFor of the label equal to the input id.`,\n )\n }\n this.inputId = firstDefined(this.inputId, rest.id, `${this.id}-input`)\n let onChangeKey\n /* istanbul ignore next (preact) */\n if (preval`module.exports = process.env.BUILD_PREACT === 'true'`) {\n onChangeKey = 'onInput'\n /* istanbul ignore next (react-native) */\n } else if (\n preval`module.exports = process.env.BUILD_REACT_NATIVE === 'true'`\n ) {\n onChangeKey = 'onChangeText'\n } else {\n onChangeKey = 'onChange'\n }\n const {inputValue, isOpen, highlightedIndex} = this.getState()\n const eventHandlers = rest.disabled\n ? {}\n : {\n [onChangeKey]: composeEventHandlers(\n onChange,\n onInput,\n this.input_handleChange,\n ),\n onKeyDown: composeEventHandlers(onKeyDown, this.input_handleKeyDown),\n onBlur: composeEventHandlers(onBlur, this.input_handleBlur),\n }\n return {\n role: 'combobox',\n 'aria-autocomplete': 'list',\n 'aria-expanded': isOpen,\n 'aria-activedescendant':\n isOpen && typeof highlightedIndex === 'number' && highlightedIndex >= 0\n ? this.getItemId(highlightedIndex)\n : null,\n autoComplete: 'off',\n value: inputValue,\n ...eventHandlers,\n ...rest,\n id: this.inputId,\n }\n }\n\n input_handleKeyDown = event => {\n if (event.key && this.keyDownHandlers[event.key]) {\n this.keyDownHandlers[event.key].call(this, event)\n }\n }\n\n input_handleChange = event => {\n this.internalSetState({\n type: Downshift.stateChangeTypes.changeInput,\n isOpen: true,\n inputValue: preval`module.exports = process.env.BUILD_REACT_NATIVE === 'true'`\n ? /* istanbul ignore next (react-native) */ event\n : event.target.value,\n })\n }\n\n input_handleBlur = () => {\n if (!this.isMouseDown) {\n this.reset({type: Downshift.stateChangeTypes.blurInput})\n }\n }\n\n //\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ INPUT\n\n /////////////////////////////// ITEM\n getItemId(index) {\n return `${this.id}-item-${index}`\n }\n\n getItemProps = ({\n onMouseMove,\n onMouseDown,\n onClick,\n index,\n item = requiredProp('getItemProps', 'item'),\n ...rest\n } = {}) => {\n if (index === undefined) {\n this.items.push(item)\n index = this.items.indexOf(item)\n } else {\n this.items[index] = item\n }\n\n const onSelectKey = preval`module.exports = process.env.BUILD_REACT_NATIVE === 'true'`\n ? /* istanbul ignore next (react-native) */ 'onPress'\n : 'onClick'\n return {\n id: this.getItemId(index),\n // onMouseMove is used over onMouseEnter here. onMouseMove\n // is only triggered on actual mouse movement while onMouseEnter\n // can fire on DOM changes, interrupting keyboard navigation\n onMouseMove: composeEventHandlers(onMouseMove, () => {\n if (index === this.getState().highlightedIndex) {\n return\n }\n this.setHighlightedIndex(index, {\n type: Downshift.stateChangeTypes.itemMouseEnter,\n })\n\n // We never want to manually scroll when changing state based\n // on `onMouseMove` because we will be moving the element out\n // from under the user which is currently scrolling/moving the\n // cursor\n this.avoidScrolling = true\n setTimeout(() => (this.avoidScrolling = false), 250)\n }),\n onMouseDown: composeEventHandlers(onMouseDown, event => {\n // This prevents the activeElement from being changed\n // to the item so it can remain with the current activeElement\n // which is a more common use case.\n event.preventDefault()\n }),\n [onSelectKey]: composeEventHandlers(onClick, () => {\n this.selectItemAtIndex(index, {\n type: Downshift.stateChangeTypes.clickItem,\n })\n }),\n ...rest,\n }\n }\n //\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ ITEM\n\n clearItems = () => {\n this.items = []\n }\n\n reset = (otherStateToSet = {}, cb) => {\n otherStateToSet = pickState(otherStateToSet)\n this.internalSetState(\n ({selectedItem}) => ({\n isOpen: false,\n highlightedIndex: this.props.defaultHighlightedIndex,\n inputValue: this.props.itemToString(selectedItem),\n ...otherStateToSet,\n }),\n cbToCb(cb),\n )\n }\n\n toggleMenu = (otherStateToSet = {}, cb) => {\n otherStateToSet = pickState(otherStateToSet)\n this.internalSetState(\n ({isOpen}) => {\n return {isOpen: !isOpen, ...otherStateToSet}\n },\n () => {\n const {isOpen} = this.getState()\n if (isOpen) {\n this.highlightDefaultIndex()\n }\n cbToCb(cb)()\n },\n )\n }\n\n openMenu = cb => {\n this.internalSetState({isOpen: true}, cbToCb(cb))\n }\n\n closeMenu = cb => {\n this.internalSetState({isOpen: false}, cbToCb(cb))\n }\n\n updateStatus = debounce(() => {\n if (!this._isMounted) {\n return\n }\n const state = this.getState()\n const item = this.items[state.highlightedIndex]\n const resultCount = this.getItemCount()\n const status = this.props.getA11yStatusMessage({\n itemToString: this.props.itemToString,\n previousResultCount: this.previousResultCount,\n resultCount,\n highlightedItem: item,\n ...state,\n })\n this.previousResultCount = resultCount\n /* istanbul ignore else (react-native) */\n if (preval`module.exports = process.env.BUILD_REACT_NATIVE !== 'true'`) {\n setA11yStatus(status)\n }\n }, 200)\n\n componentDidMount() {\n // the _isMounted property is because we have `updateStatus` in a `debounce`\n // and we don't want to update the status if the component has been umounted\n this._isMounted = true\n /* istanbul ignore if (react-native) */\n if (preval`module.exports = process.env.BUILD_REACT_NATIVE === 'true'`) {\n this.cleanup = () => {\n this._isMounted = false\n }\n } else {\n // this.isMouseDown helps us track whether the mouse is currently held down.\n // This is useful when the user clicks on an item in the list, but holds the mouse\n // down long enough for the list to disappear (because the blur event fires on the input)\n // this.isMouseDown is used in the blur handler on the input to determine whether the blur event should\n // trigger hiding the menu.\n const onMouseDown = () => {\n this.isMouseDown = true\n }\n const onMouseUp = event => {\n const {document} = this.props.environment\n this.isMouseDown = false\n if (\n (event.target === this._rootNode ||\n !this._rootNode.contains(event.target)) &&\n this.getState().isOpen &&\n (!this.inputId || document.activeElement.id !== this.inputId)\n ) {\n this.reset({type: Downshift.stateChangeTypes.mouseUp}, () =>\n this.props.onOuterClick(this.getStateAndHelpers()),\n )\n }\n }\n this.props.environment.addEventListener('mousedown', onMouseDown)\n this.props.environment.addEventListener('mouseup', onMouseUp)\n\n this.cleanup = () => {\n this._isMounted = false\n this.props.environment.removeEventListener('mousedown', onMouseDown)\n this.props.environment.removeEventListener('mouseup', onMouseUp)\n }\n }\n }\n\n componentDidUpdate(prevProps, prevState) {\n if (\n this.isControlledProp('selectedItem') &&\n this.props.selectedItemChanged(\n prevProps.selectedItem,\n this.props.selectedItem,\n )\n ) {\n this.internalSetState({\n type: Downshift.stateChangeTypes.controlledPropUpdatedSelectedItem,\n inputValue: this.props.itemToString(this.props.selectedItem),\n })\n }\n\n const current =\n this.props.highlightedIndex === undefined ? this.state : this.props\n const prev =\n prevProps.highlightedIndex === undefined ? prevState : prevProps\n\n if (\n current.highlightedIndex !== prev.highlightedIndex &&\n !this.avoidScrolling\n ) {\n this.scrollHighlightedItemIntoView()\n }\n\n this.updateStatus()\n }\n\n componentWillUnmount() {\n this.cleanup() // avoids memory leak\n }\n\n // eslint-disable-next-line complexity\n render() {\n const children = unwrapArray(this.props.render || this.props.children, noop)\n // because the items are rerendered every time we call the children\n // we clear this out each render and\n this.clearItems()\n // we reset this so we know whether the user calls getRootProps during\n // this render. If they do then we don't need to do anything,\n // if they don't then we need to clone the element they return and\n // apply the props for them.\n this.getRootProps.called = false\n this.getRootProps.refKey = undefined\n this.getRootProps.suppressRefError = undefined\n // we do something similar for getLabelProps\n this.getLabelProps.called = false\n // and something similar for getInputProps\n this.getInputProps.called = false\n const element = unwrapArray(children(this.getStateAndHelpers()))\n if (!element) {\n return null\n }\n if (this.getRootProps.called) {\n if (!this.getRootProps.suppressRefError) {\n validateGetRootPropsCalledCorrectly(element, this.getRootProps)\n }\n return element\n } else if (isDOMElement(element)) {\n // they didn't apply the root props, but we can clone\n // this and apply the props ourselves\n return React.cloneElement(\n element,\n this.getRootProps(getElementProps(element)),\n )\n } else {\n // they didn't apply the root props, but they need to\n // otherwise we can't query around the autocomplete\n throw new Error(\n 'downshift: If you return a non-DOM element, you must use apply the getRootProps function',\n )\n }\n }\n}\n\nexport default Downshift\n\nfunction validateGetRootPropsCalledCorrectly(element, {refKey}) {\n const refKeySpecified = refKey !== 'ref'\n const isComposite = !isDOMElement(element)\n if (isComposite && !refKeySpecified) {\n throw new Error(\n 'downshift: You returned a non-DOM element. You must specify a refKey in getRootProps',\n )\n } else if (!isComposite && refKeySpecified) {\n throw new Error(\n `downshift: You returned a DOM element. You should not specify a refKey in getRootProps. You specified \"${refKey}\"`,\n )\n }\n if (!getElementProps(element)[refKey]) {\n throw new Error(\n `downshift: You must apply the ref prop \"${refKey}\" from getRootProps onto your root element.`,\n )\n }\n}\n","import Downshift from './downshift'\nimport {resetIdCounter} from './utils'\n\n/*\n * Fix importing in typescript after rollup compilation\n * https://github.com/rollup/rollup/issues/1156\n * https://github.com/Microsoft/TypeScript/issues/13017#issuecomment-268657860\n */\nDownshift.default = Downshift\nDownshift.resetIdCounter = resetIdCounter\n\nexport default Downshift\n"],"names":["statusDiv","document","getElementById","statuses","setStatus","status","isSameAsLast","length","div","createElement","setAttribute","assign","style","body","appendChild","getStatusDiv","lastChild","removeChild","firstChild","filter","Boolean","forEach","statusItem","index","display","childDiv","textContent","idCounter","cbToCb","cb","noop","getClosestScrollParent","findParent","finder","node","rootNode","parentNode","scrollTop","documentElement","bind","scrollHeight","clientHeight","composeEventHandlers","fns","event","args","some","fn","preventDownshiftDefault","defaultPrevented","firstDefined","find","a","unwrapArray","arg","defaultValue","Array","isArray","isDOMElement","element","nodeName","type","getElementProps","props","attributes","stateKeys","pickState","state","result","hasOwnProperty","k","Downshift","_Component","_this","getState","defaultHighlightedIndex","defaultIsOpen","defaultInputValue","defaultSelectedItem","selectedItem","inputValue","itemToString","id","String","stateToMerge","this","Object","keys","reduce","key","_this2","isControlledProp","undefined","getItemCount","itemCount","items","internalSetState","stateToSet","isItemSelected","onChangeArg","onStateChangeArg","isStateToSetFunction","onInputValueChange","getStateAndHelpers","setState","_this3","stateReducer","nextState","nextFullState","stateChangeTypes","unknown","onStateChange","onSelect","onChange","onUserAction","highlightedIndex","isOpen","getRootProps","getButtonProps","getLabelProps","getInputProps","getItemProps","openMenu","closeMenu","toggleMenu","selectItem","selectItemAtIndex","selectHighlightedItem","setHighlightedIndex","clearSelection","clearItems","reset","setItemCount","unsetItemCount","getItemId","componentDidMount","_isMounted","onMouseDown","isMouseDown","onMouseUp","_this4","environment","target","_rootNode","contains","inputId","activeElement","mouseUp","onOuterClick","addEventListener","cleanup","removeEventListener","componentDidUpdate","prevProps","prevState","selectedItemChanged","controlledPropUpdatedSelectedItem","current","prev","avoidScrolling","scrollHighlightedItemIntoView","updateStatus","componentWillUnmount","render","children","called","refKey","suppressRefError","refKeySpecified","isComposite","Error","React","cloneElement","Component","defaultProps","highlightedItem","resultCount","previousResultCount","i","prevItem","item","window","time","timeoutId","input","_this5","count","getItemNodeFromIndex","otherStateToSet","scrollParent","scrollParentStyles","getComputedStyle","scrollParentRect","getBoundingClientRect","scrollParentBorderTopWidth","parseInt","borderTopWidth","bordersWidth","borderBottomWidth","scrollParentTop","top","nodeRect","bottom","nodeTop","height","openAndHighlightDefaultIndex","highlightDefaultIndex","moveHighlightedIndex","amount","changeHighlightedIndex","moveAmount","itemsLastIndex","baseIndex","newIndex","breakingChanges","resetInputOnSelection","itemIndex","rootRef","rest","keyDownHandlers","preventDefault","shiftKey","keyDownArrowDown","keyDownArrowUp","keyDownEnter","keyDownEscape","buttonKeyDownHandlers","keyDownSpaceButton","onClick","onKeyDown","onBlur","enabledEventHandlers","button_handleClick","button_handleKeyDown","button_handleBlur","eventHandlers","disabled","call","focus","clickButton","blurButton","htmlFor","onInput","input_handleChange","input_handleKeyDown","input_handleBlur","changeInput","value","blurInput","onMouseMove","fnName","propName","requiredProp","push","indexOf","itemMouseEnter","clickItem","getA11yStatusMessage","setTimeout","default","resetIdCounter"],"mappings":"qVACA,IAAIA,EACkB,oBAAbC,SACH,KACAA,SAASC,eAAe,uBAE1BC,KAEJ,SAASC,EAAUC,OACXC,EAAeH,EAASA,EAASI,OAAS,KAAOF,IACnDC,YACaH,GAAUE,KAEbA,WAERG,EAsBR,cACMR,SACKA,WAEGC,SAASQ,cAAc,QACzBC,aAAa,KAAM,yBACnBA,aAAa,OAAQ,YACrBA,aAAa,YAAa,eAC1BA,aAAa,gBAAiB,yBACjCC,OAAOX,EAAUY,cACd,SACF,uBACE,aACA,gBACE,iBACD,aACC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F,0BAEAjL,aAKb6F,SAAW,cACJ1B,kBAAkBoB,QAAQ,GAAOxF,EAAOC,UAG/C8F,UAAY,cACL3B,kBAAkBoB,QAAQ,GAAQxF,EAAOC,UAGhDoI,cD/pBgBlH,EC+pBQ,cACjB0I,EAAKjD,gBAGJrE,EAAQsH,EAAK/G,WACb0G,EAAOK,EAAK1F,MAAM5B,EAAMgD,kBACxB6D,EAAcS,EAAK5F,eACnBxF,EAASoL,EAAK1H,MAAMkM,qCACVxE,EAAK1H,MAAMkB,iCACJwG,EAAKR,kDAETG,GACdjH,MAEA8G,oBAAsBD,IAGX3K,KDhrBEiL,ECkrBjB,IDjrBCC,SAEJ,sCAAoB1I,yCACd0I,gBACWA,KAEH2E,WAAW,aACT,oBACNrN,IACLyI,aEvHP/G,EAAU4L,QAAU5L,GACV6L,eF6JV,aACc"}
1
+ {"version":3,"file":"downshift.umd.min.js","sources":["../src/set-a11y-status.js","../src/utils.js","../src/downshift.js","../src/index.js"],"sourcesContent":["// istanbul ignore next\nlet statusDiv =\n typeof document === 'undefined'\n ? null\n : document.getElementById('a11y-status-message')\n\nlet statuses = []\n\nfunction setStatus(status) {\n const isSameAsLast = statuses[statuses.length - 1] === status\n if (isSameAsLast) {\n statuses = [...statuses, status]\n } else {\n statuses = [status]\n }\n const div = getStatusDiv()\n\n // Remove previous children\n while (div.lastChild) {\n div.removeChild(div.firstChild)\n }\n\n statuses.filter(Boolean).forEach((statusItem, index) => {\n div.appendChild(getStatusChildDiv(statusItem, index))\n })\n}\n\nfunction getStatusChildDiv(status, index) {\n const display = index === statuses.length - 1 ? 'block' : 'none'\n\n const childDiv = document.createElement('div')\n childDiv.style.display = display\n childDiv.textContent = status\n\n return childDiv\n}\n\nfunction getStatusDiv() {\n if (statusDiv) {\n return statusDiv\n }\n statusDiv = document.createElement('div')\n statusDiv.setAttribute('id', 'a11y-status-message')\n statusDiv.setAttribute('role', 'status')\n statusDiv.setAttribute('aria-live', 'assertive')\n statusDiv.setAttribute('aria-relevant', 'additions text')\n Object.assign(statusDiv.style, {\n border: '0',\n clip: 'rect(0 0 0 0)',\n height: '1px',\n margin: '-1px',\n overflow: 'hidden',\n padding: '0',\n position: 'absolute',\n width: '1px',\n })\n document.body.appendChild(statusDiv)\n return statusDiv\n}\n\nexport default setStatus\n","let idCounter = 0\n\n/**\n * Accepts a parameter and returns it if it's a function\n * or a noop function if it's not. This allows us to\n * accept a callback, but not worry about it if it's not\n * passed.\n * @param {Function} cb the callback\n * @return {Function} a function\n */\nfunction cbToCb(cb) {\n return typeof cb === 'function' ? cb : noop\n}\nfunction noop() {}\n\nfunction findParent(finder, node, rootNode) {\n if (node !== null && node !== rootNode.parentNode) {\n if (finder(node)) {\n if (node === document.body && node.scrollTop === 0) {\n // in chrome body.scrollTop always return 0\n return document.documentElement\n }\n return node\n } else {\n return findParent(finder, node.parentNode, rootNode)\n }\n } else {\n return null\n }\n}\n\n/**\n * Get the closest element that scrolls\n * @param {HTMLElement} node - the child element to start searching for scroll parent at\n * @param {HTMLElement} rootNode - the root element of the component\n * @return {HTMLElement} the closest parentNode that scrolls\n */\nconst getClosestScrollParent = findParent.bind(\n null,\n node => node.scrollHeight > node.clientHeight,\n)\n\n/**\n * Scroll node into view if necessary\n * @param {HTMLElement} node - the element that should scroll into view\n * @param {HTMLElement} rootNode - the root element of the component\n * @param {Boolean} alignToTop - align element to the top of the visible area of the scrollable ancestor\n */\n// eslint-disable-next-line complexity\nfunction scrollIntoView(node, rootNode) {\n const scrollParent = getClosestScrollParent(node, rootNode)\n if (scrollParent === null) {\n return\n }\n const scrollParentStyles = getComputedStyle(scrollParent)\n const scrollParentRect = scrollParent.getBoundingClientRect()\n const scrollParentBorderTopWidth = parseInt(\n scrollParentStyles.borderTopWidth,\n 10,\n )\n const scrollParentBorderBottomWidth = parseInt(\n scrollParentStyles.borderBottomWidth,\n 10,\n )\n const bordersWidth =\n scrollParentBorderTopWidth + scrollParentBorderBottomWidth\n const scrollParentTop = scrollParentRect.top + scrollParentBorderTopWidth\n const nodeRect = node.getBoundingClientRect()\n\n if (nodeRect.top < 0 && scrollParentRect.top < 0) {\n scrollParent.scrollTop += nodeRect.top\n return\n }\n\n if (nodeRect.top < 0) {\n // the item is above the viewport and the parent is not above the viewport\n scrollParent.scrollTop += nodeRect.top - scrollParentTop\n return\n }\n\n if (nodeRect.top > 0 && scrollParentRect.top < 0) {\n if (\n scrollParentRect.bottom > 0 &&\n nodeRect.bottom + bordersWidth > scrollParentRect.bottom\n ) {\n // the item is below scrollable area\n scrollParent.scrollTop +=\n nodeRect.bottom - scrollParentRect.bottom + bordersWidth\n }\n // item and parent top are on different sides of view top border (do nothing)\n return\n }\n\n const nodeOffsetTop = nodeRect.top + scrollParent.scrollTop\n const nodeTop = nodeOffsetTop - scrollParentTop\n if (nodeTop < scrollParent.scrollTop) {\n // the item is above the scrollable area\n scrollParent.scrollTop = nodeTop\n } else if (\n nodeTop + nodeRect.height + bordersWidth >\n scrollParent.scrollTop + scrollParentRect.height\n ) {\n // the item is below the scrollable area\n scrollParent.scrollTop =\n nodeTop + nodeRect.height - scrollParentRect.height + bordersWidth\n }\n // the item is within the scrollable area (do nothing)\n}\n\n/**\n * Simple debounce implementation. Will call the given\n * function once after the time given has passed since\n * it was last called.\n * @param {Function} fn the function to call after the time\n * @param {Number} time the time to wait\n * @return {Function} the debounced function\n */\nfunction debounce(fn, time) {\n let timeoutId\n return wrapper\n function wrapper(...args) {\n if (timeoutId) {\n clearTimeout(timeoutId)\n }\n timeoutId = setTimeout(() => {\n timeoutId = null\n fn(...args)\n }, time)\n }\n}\n\n/**\n * This is intended to be used to compose event handlers.\n * They are executed in order until one of them sets\n * `event.preventDownshiftDefault = true`.\n * @param {Function} fns the event handler functions\n * @return {Function} the event handler to add to an element\n */\nfunction composeEventHandlers(...fns) {\n return (event, ...args) =>\n fns.some(fn => {\n fn && fn(event, ...args)\n // TODO: remove everything after the || in the next breaking change\n return event.preventDownshiftDefault || event.defaultPrevented\n })\n}\n\n/**\n * This generates a unique ID for an instance of Downshift\n * @return {String} the unique ID\n */\nfunction generateId() {\n return String(idCounter++)\n}\n\n/**\n * This is only used in tests\n * @param {Number} num The number to set the idCounter to\n */\nfunction setIdCounter(num) {\n idCounter = num\n}\n\n/**\n * Resets idCounter to 0. Used for SSR.\n */\nfunction resetIdCounter() {\n idCounter = 0\n}\n\n/**\n * Returns the first argument that is not undefined\n * @param {...*} args the arguments\n * @return {*} the defined value\n */\nfunction firstDefined(...args) {\n return args.find(a => typeof a !== 'undefined')\n}\n\n// eslint-disable-next-line complexity\nfunction getA11yStatusMessage({\n isOpen,\n highlightedItem,\n selectedItem,\n resultCount,\n previousResultCount,\n itemToString,\n}) {\n if (!isOpen) {\n if (selectedItem) {\n return itemToString(selectedItem)\n } else {\n return ''\n }\n }\n const resultCountChanged = resultCount !== previousResultCount\n if (!resultCount) {\n return 'No results.'\n } else if (!highlightedItem || resultCountChanged) {\n return `${resultCount} ${\n resultCount === 1 ? 'result is' : 'results are'\n } available, use up and down arrow keys to navigate.`\n }\n return itemToString(highlightedItem)\n}\n\n/**\n * Takes an argument and if it's an array, returns the first item in the array\n * otherwise returns the argument\n * @param {*} arg the maybe-array\n * @param {*} defaultValue the value if arg is falsey not defined\n * @return {*} the arg or it's first item\n */\nfunction unwrapArray(arg, defaultValue) {\n arg = Array.isArray(arg) ? /* istanbul ignore next (preact) */ arg[0] : arg\n if (!arg && defaultValue) {\n return defaultValue\n } else {\n return arg\n }\n}\n\n/**\n * @param {Object} element (P)react element\n * @return {Boolean} whether it's a DOM element\n */\nfunction isDOMElement(element) {\n /* istanbul ignore if */\n if (element.nodeName) {\n // then this is preact\n return typeof element.nodeName === 'string'\n } else {\n // then we assume this is react\n return typeof element.type === 'string'\n }\n}\n\n/**\n * @param {Object} element (P)react element\n * @return {Object} the props\n */\nfunction getElementProps(element) {\n // props for react, attributes for preact\n return element.props || /* istanbul ignore next (preact) */ element.attributes\n}\n\n/**\n * Throws a helpful error message for required properties. Useful\n * to be used as a default in destructuring or object params.\n * @param {String} fnName the function name\n * @param {String} propName the prop name\n */\nfunction requiredProp(fnName, propName) {\n throw new Error(`The property \"${propName}\" is required in \"${fnName}\"`)\n}\n\nconst stateKeys = [\n 'highlightedIndex',\n 'inputValue',\n 'isOpen',\n 'selectedItem',\n 'type',\n]\n/**\n * @param {Object} state The state object\n * @return {Object} State that is relevant to downshift\n */\nfunction pickState(state = {}) {\n const result = {}\n stateKeys.forEach(k => {\n if (state.hasOwnProperty(k)) {\n result[k] = state[k]\n }\n })\n return result\n}\n\nexport {\n cbToCb,\n composeEventHandlers,\n debounce,\n scrollIntoView,\n findParent,\n generateId,\n firstDefined,\n getA11yStatusMessage,\n unwrapArray,\n isDOMElement,\n getElementProps,\n noop,\n requiredProp,\n setIdCounter,\n resetIdCounter,\n pickState,\n isPlainObject,\n}\n\n/**\n * Simple check if the value passed is object literal\n * @param {*} obj any things\n * @return {Boolean} whether it's object literal\n */\nfunction isPlainObject(obj) {\n return Object.prototype.toString.call(obj) === '[object Object]'\n}\n","/* eslint camelcase:0 */\n\nimport React, {Component} from 'react'\nimport PropTypes from 'prop-types'\nimport preval from 'preval.macro'\nimport setA11yStatus from './set-a11y-status'\nimport {\n cbToCb,\n composeEventHandlers,\n debounce,\n scrollIntoView,\n generateId,\n firstDefined,\n getA11yStatusMessage,\n unwrapArray,\n isDOMElement,\n getElementProps,\n noop,\n requiredProp,\n pickState,\n isPlainObject,\n} from './utils'\n\nclass Downshift extends Component {\n static propTypes = {\n children: PropTypes.func,\n render: PropTypes.func,\n defaultHighlightedIndex: PropTypes.number,\n defaultSelectedItem: PropTypes.any,\n defaultInputValue: PropTypes.string,\n defaultIsOpen: PropTypes.bool,\n getA11yStatusMessage: PropTypes.func,\n itemToString: PropTypes.func,\n onChange: PropTypes.func,\n onSelect: PropTypes.func,\n onStateChange: PropTypes.func,\n onInputValueChange: PropTypes.func,\n onUserAction: PropTypes.func,\n onOuterClick: PropTypes.func,\n selectedItemChanged: PropTypes.func,\n stateReducer: PropTypes.func,\n itemCount: PropTypes.number,\n id: PropTypes.string,\n environment: PropTypes.shape({\n addEventListener: PropTypes.func,\n removeEventListener: PropTypes.func,\n document: PropTypes.shape({\n getElementById: PropTypes.func,\n activeElement: PropTypes.any,\n body: PropTypes.any,\n }),\n }),\n // things we keep in state for uncontrolled components\n // but can accept as props for controlled components\n /* eslint-disable react/no-unused-prop-types */\n selectedItem: PropTypes.any,\n isOpen: PropTypes.bool,\n inputValue: PropTypes.string,\n highlightedIndex: PropTypes.number,\n breakingChanges: PropTypes.shape({\n resetInputOnSelection: PropTypes.bool,\n }),\n /* eslint-enable */\n }\n\n static defaultProps = {\n defaultHighlightedIndex: null,\n defaultSelectedItem: null,\n defaultInputValue: '',\n defaultIsOpen: false,\n getA11yStatusMessage,\n itemToString: i => {\n if (i == null) {\n return ''\n }\n if (process.env.NODE_ENV !== 'production' && isPlainObject(i)) {\n //eslint-disable-next-line no-console\n console.warn(\n 'downshift: An object was passed to the default implementation of `itemToString`. You should probably provide your own `itemToString` implementation. Please refer to the `itemToString` API documentation.',\n 'The object that was passed:',\n i,\n )\n }\n return String(i)\n },\n onStateChange: () => {},\n onInputValueChange: () => {},\n onUserAction: () => {},\n onChange: () => {},\n onSelect: () => {},\n onOuterClick: () => {},\n selectedItemChanged: (prevItem, item) => prevItem !== item,\n environment:\n typeof window === 'undefined' /* istanbul ignore next (ssr) */\n ? {}\n : window,\n stateReducer: (state, stateToSet) => stateToSet,\n breakingChanges: {},\n }\n\n static stateChangeTypes = {\n unknown: '__autocomplete_unknown__',\n mouseUp: '__autocomplete_mouseup__',\n itemMouseEnter: '__autocomplete_item_mouseenter__',\n keyDownArrowUp: '__autocomplete_keydown_arrow_up__',\n keyDownArrowDown: '__autocomplete_keydown_arrow_down__',\n keyDownEscape: '__autocomplete_keydown_escape__',\n keyDownEnter: '__autocomplete_keydown_enter__',\n clickItem: '__autocomplete_click_item__',\n blurInput: '__autocomplete_blur_input__',\n changeInput: '__autocomplete_change_input__',\n keyDownSpaceButton: '__autocomplete_keydown_space_button__',\n clickButton: '__autocomplete_click_button__',\n blurButton: '__autocomplete_blur_button__',\n controlledPropUpdatedSelectedItem:\n '__autocomplete_controlled_prop_updated_selected_item__',\n }\n\n constructor(...args) {\n super(...args)\n const state = this.getState({\n highlightedIndex: this.props.defaultHighlightedIndex,\n isOpen: this.props.defaultIsOpen,\n inputValue: this.props.defaultInputValue,\n selectedItem: this.props.defaultSelectedItem,\n })\n if (state.selectedItem) {\n state.inputValue = this.props.itemToString(state.selectedItem)\n }\n this.state = state\n this.id = this.props.id || `downshift-${generateId()}`\n }\n\n input = null\n items = []\n // itemCount can be changed asynchronously\n // from within downshift (so it can't come from a prop)\n // this is why we store it as an instance and use\n // getItemCount rather than just use items.length\n // (to support windowing + async)\n itemCount = null\n previousResultCount = 0\n\n /**\n * Gets the state based on internal state or props\n * If a state value is passed via props, then that\n * is the value given, otherwise it's retrieved from\n * stateToMerge\n *\n * This will perform a shallow merge of the given state object\n * with the state coming from props\n * (for the controlled component scenario)\n * This is used in state updater functions so they're referencing\n * the right state regardless of where it comes from.\n *\n * @param {Object} stateToMerge defaults to this.state\n * @return {Object} the state\n */\n getState(stateToMerge = this.state) {\n return Object.keys(stateToMerge).reduce((state, key) => {\n state[key] = this.isControlledProp(key)\n ? this.props[key]\n : stateToMerge[key]\n return state\n }, {})\n }\n\n /**\n * This determines whether a prop is a \"controlled prop\" meaning it is\n * state which is controlled by the outside of this component rather\n * than within this component.\n * @param {String} key the key to check\n * @return {Boolean} whether it is a controlled controlled prop\n */\n isControlledProp(key) {\n return this.props[key] !== undefined\n }\n\n getItemCount() {\n // things read better this way. They're in priority order:\n // 1. `this.itemCount`\n // 2. `this.props.itemCount`\n // 3. `this.items.length`\n /* eslint-disable no-negated-condition */\n if (this.itemCount != null) {\n return this.itemCount\n } else if (this.props.itemCount !== undefined) {\n return this.props.itemCount\n } else {\n return this.items.length\n }\n /* eslint-enable no-negated-condition */\n }\n\n setItemCount = count => (this.itemCount = count)\n unsetItemCount = () => (this.itemCount = null)\n\n getItemNodeFromIndex = index => {\n return this.props.environment.document.getElementById(this.getItemId(index))\n }\n\n setHighlightedIndex = (\n highlightedIndex = this.props.defaultHighlightedIndex,\n otherStateToSet = {},\n ) => {\n otherStateToSet = pickState(otherStateToSet)\n this.internalSetState({highlightedIndex, ...otherStateToSet})\n }\n\n scrollHighlightedItemIntoView = () => {\n /* istanbul ignore else (react-native) */\n if (preval`module.exports = process.env.BUILD_REACT_NATIVE !== 'true'`) {\n const node = this.getItemNodeFromIndex(this.getState().highlightedIndex)\n const rootNode = this._rootNode\n scrollIntoView(node, rootNode)\n }\n }\n\n openAndHighlightDefaultIndex = (otherStateToSet = {}) => {\n this.setHighlightedIndex(undefined, {isOpen: true, ...otherStateToSet})\n }\n\n highlightDefaultIndex = (otherStateToSet = {}) => {\n this.setHighlightedIndex(undefined, otherStateToSet)\n }\n\n moveHighlightedIndex = (amount, otherStateToSet) => {\n if (this.getState().isOpen) {\n this.changeHighlightedIndex(amount, otherStateToSet)\n } else {\n this.openAndHighlightDefaultIndex(otherStateToSet)\n }\n }\n\n // eslint-disable-next-line complexity\n changeHighlightedIndex = (moveAmount, otherStateToSet) => {\n const itemsLastIndex = this.getItemCount() - 1\n if (itemsLastIndex < 0) {\n return\n }\n const {highlightedIndex} = this.getState()\n let baseIndex = highlightedIndex\n if (baseIndex === null) {\n baseIndex = moveAmount > 0 ? -1 : itemsLastIndex + 1\n }\n let newIndex = baseIndex + moveAmount\n if (newIndex < 0) {\n newIndex = itemsLastIndex\n } else if (newIndex > itemsLastIndex) {\n newIndex = 0\n }\n this.setHighlightedIndex(newIndex, otherStateToSet)\n }\n\n clearSelection = cb => {\n this.internalSetState(\n {\n selectedItem: null,\n inputValue: '',\n isOpen: false,\n },\n cb,\n )\n }\n\n selectItem = (item, otherStateToSet, cb) => {\n otherStateToSet = pickState(otherStateToSet)\n this.internalSetState(\n {\n isOpen: false,\n highlightedIndex: this.props.defaultHighlightedIndex,\n selectedItem: item,\n inputValue:\n this.isControlledProp('selectedItem') &&\n this.props.breakingChanges.resetInputOnSelection\n ? this.props.defaultInputValue\n : this.props.itemToString(item),\n ...otherStateToSet,\n },\n cb,\n )\n }\n\n selectItemAtIndex = (itemIndex, otherStateToSet, cb) => {\n const item = this.items[itemIndex]\n if (item == null) {\n return\n }\n this.selectItem(item, otherStateToSet, cb)\n }\n\n selectHighlightedItem = (otherStateToSet, cb) => {\n return this.selectItemAtIndex(\n this.getState().highlightedIndex,\n otherStateToSet,\n cb,\n )\n }\n\n // any piece of our state can live in two places:\n // 1. Uncontrolled: it's internal (this.state)\n // We will call this.setState to update that state\n // 2. Controlled: it's external (this.props)\n // We will call this.props.onStateChange to update that state\n //\n // In addition, we'll call this.props.onChange if the\n // selectedItem is changed.\n internalSetState(stateToSet, cb) {\n let isItemSelected, onChangeArg\n\n const onStateChangeArg = {}\n const isStateToSetFunction = typeof stateToSet === 'function'\n\n // we want to call `onInputValueChange` before the `setState` call\n // so someone controlling the `inputValue` state gets notified of\n // the input change as soon as possible. This avoids issues with\n // preserving the cursor position.\n // See https://github.com/paypal/downshift/issues/217 for more info.\n if (!isStateToSetFunction && stateToSet.hasOwnProperty('inputValue')) {\n this.props.onInputValueChange(stateToSet.inputValue, {\n ...this.getStateAndHelpers(),\n ...stateToSet,\n })\n }\n return this.setState(\n state => {\n state = this.getState(state)\n stateToSet = isStateToSetFunction ? stateToSet(state) : stateToSet\n\n // Your own function that could modify the state that will be set.\n stateToSet = this.props.stateReducer(state, stateToSet)\n\n // checks if an item is selected, regardless of if it's different from\n // what was selected before\n // used to determine if onSelect and onChange callbacks should be called\n isItemSelected = stateToSet.hasOwnProperty('selectedItem')\n // this keeps track of the object we want to call with setState\n const nextState = {}\n // this is just used to tell whether the state changed\n const nextFullState = {}\n // we need to call on change if the outside world is controlling any of our state\n // and we're trying to update that state. OR if the selection has changed and we're\n // trying to update the selection\n if (isItemSelected && stateToSet.selectedItem !== state.selectedItem) {\n onChangeArg = stateToSet.selectedItem\n }\n stateToSet.type = stateToSet.type || Downshift.stateChangeTypes.unknown\n\n Object.keys(stateToSet).forEach(key => {\n // onStateChangeArg should only have the state that is\n // actually changing\n if (state[key] !== stateToSet[key]) {\n onStateChangeArg[key] = stateToSet[key]\n }\n // the type is useful for the onStateChangeArg\n // but we don't actually want to set it in internal state.\n // this is an undocumented feature for now... Not all internalSetState\n // calls support it and I'm not certain we want them to yet.\n // But it enables users controlling the isOpen state to know when\n // the isOpen state changes due to mouseup events which is quite handy.\n if (key === 'type') {\n return\n }\n nextFullState[key] = stateToSet[key]\n // if it's coming from props, then we don't care to set it internally\n if (!this.isControlledProp(key)) {\n nextState[key] = stateToSet[key]\n }\n })\n\n // if stateToSet is a function, then we weren't able to call onInputValueChange\n // earlier, so we'll call it now that we know what the inputValue state will be.\n if (isStateToSetFunction && stateToSet.hasOwnProperty('inputValue')) {\n this.props.onInputValueChange(stateToSet.inputValue, {\n ...this.getStateAndHelpers(),\n ...stateToSet,\n })\n }\n\n return nextState\n },\n () => {\n // call the provided callback if it's a callback\n cbToCb(cb)()\n\n // only call the onStateChange and onChange callbacks if\n // we have relevant information to pass them.\n const hasMoreStateThanType = Object.keys(onStateChangeArg).length > 1\n if (hasMoreStateThanType) {\n this.props.onStateChange(onStateChangeArg, this.getStateAndHelpers())\n }\n\n if (isItemSelected) {\n this.props.onSelect(\n stateToSet.selectedItem,\n this.getStateAndHelpers(),\n )\n }\n\n if (onChangeArg !== undefined) {\n this.props.onChange(onChangeArg, this.getStateAndHelpers())\n }\n // this is currently undocumented and therefore subject to change\n // We'll try to not break it, but just be warned.\n this.props.onUserAction(onStateChangeArg, this.getStateAndHelpers())\n },\n )\n }\n\n getStateAndHelpers() {\n const {highlightedIndex, inputValue, selectedItem, isOpen} = this.getState()\n const {itemToString} = this.props\n const {id} = this\n const {\n getRootProps,\n getButtonProps,\n getLabelProps,\n getInputProps,\n getItemProps,\n openMenu,\n closeMenu,\n toggleMenu,\n selectItem,\n selectItemAtIndex,\n selectHighlightedItem,\n setHighlightedIndex,\n clearSelection,\n clearItems,\n reset,\n setItemCount,\n unsetItemCount,\n } = this\n return {\n // prop getters\n getRootProps,\n getButtonProps,\n getLabelProps,\n getInputProps,\n getItemProps,\n\n // actions\n reset,\n openMenu,\n closeMenu,\n toggleMenu,\n selectItem,\n selectItemAtIndex,\n selectHighlightedItem,\n setHighlightedIndex,\n clearSelection,\n clearItems,\n setItemCount,\n unsetItemCount,\n\n //props\n itemToString,\n\n //derived\n id,\n\n // state\n highlightedIndex,\n inputValue,\n isOpen,\n selectedItem,\n }\n }\n\n //////////////////////////// ROOT\n\n rootRef = node => (this._rootNode = node)\n\n getRootProps = (\n {refKey = 'ref', ...rest} = {},\n {suppressRefError = false} = {},\n ) => {\n // this is used in the render to know whether the user has called getRootProps.\n // It uses that to know whether to apply the props automatically\n this.getRootProps.called = true\n this.getRootProps.refKey = refKey\n this.getRootProps.suppressRefError = suppressRefError\n return {\n [refKey]: this.rootRef,\n ...rest,\n }\n }\n\n //\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ ROOT\n\n keyDownHandlers = {\n ArrowDown(event) {\n event.preventDefault()\n const amount = event.shiftKey ? 5 : 1\n this.moveHighlightedIndex(amount, {\n type: Downshift.stateChangeTypes.keyDownArrowDown,\n })\n },\n\n ArrowUp(event) {\n event.preventDefault()\n const amount = event.shiftKey ? -5 : -1\n this.moveHighlightedIndex(amount, {\n type: Downshift.stateChangeTypes.keyDownArrowUp,\n })\n },\n\n Enter(event) {\n if (this.getState().isOpen) {\n event.preventDefault()\n this.selectHighlightedItem({\n type: Downshift.stateChangeTypes.keyDownEnter,\n })\n }\n },\n\n Escape(event) {\n event.preventDefault()\n this.reset({type: Downshift.stateChangeTypes.keyDownEscape})\n },\n }\n\n //////////////////////////// BUTTON\n\n buttonKeyDownHandlers = {\n ...this.keyDownHandlers,\n\n ' '(event) {\n event.preventDefault()\n this.toggleMenu({type: Downshift.stateChangeTypes.keyDownSpaceButton})\n },\n }\n\n getButtonProps = ({onClick, onKeyDown, onBlur, ...rest} = {}) => {\n const {isOpen} = this.getState()\n const enabledEventHandlers = preval`module.exports = process.env.BUILD_REACT_NATIVE === 'true'`\n ? /* istanbul ignore next (react-native) */\n {\n onPress: composeEventHandlers(onClick, this.button_handleClick),\n }\n : {\n onClick: composeEventHandlers(onClick, this.button_handleClick),\n onKeyDown: composeEventHandlers(onKeyDown, this.button_handleKeyDown),\n onBlur: composeEventHandlers(onBlur, this.button_handleBlur),\n }\n const eventHandlers = rest.disabled ? {} : enabledEventHandlers\n return {\n type: 'button',\n role: 'button',\n 'aria-label': isOpen ? 'close menu' : 'open menu',\n 'aria-expanded': isOpen,\n 'aria-haspopup': true,\n ...eventHandlers,\n ...rest,\n }\n }\n\n button_handleKeyDown = event => {\n if (this.buttonKeyDownHandlers[event.key]) {\n this.buttonKeyDownHandlers[event.key].call(this, event)\n }\n }\n\n button_handleClick = event => {\n event.preventDefault()\n // handle odd case for Safari and Firefox which\n // don't give the button the focus properly.\n /* istanbul ignore if (can't reasonably test this) */\n if (\n this.props.environment.document.activeElement ===\n this.props.environment.document.body\n ) {\n event.target.focus()\n }\n this.toggleMenu({type: Downshift.stateChangeTypes.clickButton})\n }\n\n button_handleBlur = () => {\n if (!this.isMouseDown) {\n this.reset({type: Downshift.stateChangeTypes.blurButton})\n }\n }\n\n //\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ BUTTON\n\n /////////////////////////////// LABEL\n\n getLabelProps = (props = {}) => {\n this.getLabelProps.called = true\n if (\n this.getInputProps.called &&\n props.htmlFor &&\n props.htmlFor !== this.inputId\n ) {\n throw new Error(\n `downshift: You provided the htmlFor of \"${\n props.htmlFor\n }\" for your label, but the id of your input is \"${\n this.inputId\n }\". You must either remove the id from your input or set the htmlFor of the label equal to the input id.`,\n )\n }\n this.inputId = firstDefined(this.inputId, props.htmlFor, `${this.id}-input`)\n return {\n ...props,\n htmlFor: this.inputId,\n }\n }\n\n //\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ LABEL\n\n /////////////////////////////// INPUT\n\n getInputProps = ({onKeyDown, onBlur, onChange, onInput, ...rest} = {}) => {\n this.getInputProps.called = true\n if (this.getLabelProps.called && rest.id && rest.id !== this.inputId) {\n throw new Error(\n `downshift: You provided the id of \"${\n rest.id\n }\" for your input, but the htmlFor of your label is \"${\n this.inputId\n }\". You must either remove the id from your input or set the htmlFor of the label equal to the input id.`,\n )\n }\n this.inputId = firstDefined(this.inputId, rest.id, `${this.id}-input`)\n let onChangeKey\n /* istanbul ignore next (preact) */\n if (preval`module.exports = process.env.BUILD_PREACT === 'true'`) {\n onChangeKey = 'onInput'\n /* istanbul ignore next (react-native) */\n } else if (\n preval`module.exports = process.env.BUILD_REACT_NATIVE === 'true'`\n ) {\n onChangeKey = 'onChangeText'\n } else {\n onChangeKey = 'onChange'\n }\n const {inputValue, isOpen, highlightedIndex} = this.getState()\n const eventHandlers = rest.disabled\n ? {}\n : {\n [onChangeKey]: composeEventHandlers(\n onChange,\n onInput,\n this.input_handleChange,\n ),\n onKeyDown: composeEventHandlers(onKeyDown, this.input_handleKeyDown),\n onBlur: composeEventHandlers(onBlur, this.input_handleBlur),\n }\n return {\n role: 'combobox',\n 'aria-autocomplete': 'list',\n 'aria-expanded': isOpen,\n 'aria-activedescendant':\n isOpen && typeof highlightedIndex === 'number' && highlightedIndex >= 0\n ? this.getItemId(highlightedIndex)\n : null,\n autoComplete: 'off',\n value: inputValue,\n ...eventHandlers,\n ...rest,\n id: this.inputId,\n }\n }\n\n input_handleKeyDown = event => {\n if (event.key && this.keyDownHandlers[event.key]) {\n this.keyDownHandlers[event.key].call(this, event)\n }\n }\n\n input_handleChange = event => {\n this.internalSetState({\n type: Downshift.stateChangeTypes.changeInput,\n isOpen: true,\n inputValue: preval`module.exports = process.env.BUILD_REACT_NATIVE === 'true'`\n ? /* istanbul ignore next (react-native) */ event\n : event.target.value,\n })\n }\n\n input_handleBlur = () => {\n if (!this.isMouseDown) {\n this.reset({type: Downshift.stateChangeTypes.blurInput})\n }\n }\n\n //\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ INPUT\n\n /////////////////////////////// ITEM\n getItemId(index) {\n return `${this.id}-item-${index}`\n }\n\n getItemProps = ({\n onMouseMove,\n onMouseDown,\n onClick,\n index,\n item = requiredProp('getItemProps', 'item'),\n ...rest\n } = {}) => {\n if (index === undefined) {\n this.items.push(item)\n index = this.items.indexOf(item)\n } else {\n this.items[index] = item\n }\n\n const onSelectKey = preval`module.exports = process.env.BUILD_REACT_NATIVE === 'true'`\n ? /* istanbul ignore next (react-native) */ 'onPress'\n : 'onClick'\n\n const enabledEventHandlers = {\n // onMouseMove is used over onMouseEnter here. onMouseMove\n // is only triggered on actual mouse movement while onMouseEnter\n // can fire on DOM changes, interrupting keyboard navigation\n onMouseMove: composeEventHandlers(onMouseMove, () => {\n if (index === this.getState().highlightedIndex) {\n return\n }\n this.setHighlightedIndex(index, {\n type: Downshift.stateChangeTypes.itemMouseEnter,\n })\n\n // We never want to manually scroll when changing state based\n // on `onMouseMove` because we will be moving the element out\n // from under the user which is currently scrolling/moving the\n // cursor\n this.avoidScrolling = true\n setTimeout(() => (this.avoidScrolling = false), 250)\n }),\n onMouseDown: composeEventHandlers(onMouseDown, event => {\n // This prevents the activeElement from being changed\n // to the item so it can remain with the current activeElement\n // which is a more common use case.\n event.preventDefault()\n }),\n [onSelectKey]: composeEventHandlers(onClick, () => {\n this.selectItemAtIndex(index, {\n type: Downshift.stateChangeTypes.clickItem,\n })\n }),\n }\n\n const eventHandlers = rest.disabled ? {} : enabledEventHandlers\n\n return {\n id: this.getItemId(index),\n ...eventHandlers,\n ...rest,\n }\n }\n //\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ ITEM\n\n clearItems = () => {\n this.items = []\n }\n\n reset = (otherStateToSet = {}, cb) => {\n otherStateToSet = pickState(otherStateToSet)\n this.internalSetState(\n ({selectedItem}) => ({\n isOpen: false,\n highlightedIndex: this.props.defaultHighlightedIndex,\n inputValue: this.props.itemToString(selectedItem),\n ...otherStateToSet,\n }),\n cbToCb(cb),\n )\n }\n\n toggleMenu = (otherStateToSet = {}, cb) => {\n otherStateToSet = pickState(otherStateToSet)\n this.internalSetState(\n ({isOpen}) => {\n return {isOpen: !isOpen, ...otherStateToSet}\n },\n () => {\n const {isOpen} = this.getState()\n if (isOpen) {\n this.highlightDefaultIndex()\n }\n cbToCb(cb)()\n },\n )\n }\n\n openMenu = cb => {\n this.internalSetState({isOpen: true}, cbToCb(cb))\n }\n\n closeMenu = cb => {\n this.internalSetState({isOpen: false}, cbToCb(cb))\n }\n\n updateStatus = debounce(() => {\n if (!this._isMounted) {\n return\n }\n const state = this.getState()\n const item = this.items[state.highlightedIndex]\n const resultCount = this.getItemCount()\n const status = this.props.getA11yStatusMessage({\n itemToString: this.props.itemToString,\n previousResultCount: this.previousResultCount,\n resultCount,\n highlightedItem: item,\n ...state,\n })\n this.previousResultCount = resultCount\n /* istanbul ignore else (react-native) */\n if (preval`module.exports = process.env.BUILD_REACT_NATIVE !== 'true'`) {\n setA11yStatus(status)\n }\n }, 200)\n\n componentDidMount() {\n // the _isMounted property is because we have `updateStatus` in a `debounce`\n // and we don't want to update the status if the component has been umounted\n this._isMounted = true\n /* istanbul ignore if (react-native) */\n if (preval`module.exports = process.env.BUILD_REACT_NATIVE === 'true'`) {\n this.cleanup = () => {\n this._isMounted = false\n }\n } else {\n // this.isMouseDown helps us track whether the mouse is currently held down.\n // This is useful when the user clicks on an item in the list, but holds the mouse\n // down long enough for the list to disappear (because the blur event fires on the input)\n // this.isMouseDown is used in the blur handler on the input to determine whether the blur event should\n // trigger hiding the menu.\n const onMouseDown = () => {\n this.isMouseDown = true\n }\n const onMouseUp = event => {\n const {document} = this.props.environment\n this.isMouseDown = false\n if (\n (event.target === this._rootNode ||\n !this._rootNode.contains(event.target)) &&\n this.getState().isOpen &&\n (!this.inputId || document.activeElement.id !== this.inputId)\n ) {\n this.reset({type: Downshift.stateChangeTypes.mouseUp}, () =>\n this.props.onOuterClick(this.getStateAndHelpers()),\n )\n }\n }\n this.props.environment.addEventListener('mousedown', onMouseDown)\n this.props.environment.addEventListener('mouseup', onMouseUp)\n\n this.cleanup = () => {\n this._isMounted = false\n this.props.environment.removeEventListener('mousedown', onMouseDown)\n this.props.environment.removeEventListener('mouseup', onMouseUp)\n }\n }\n }\n\n componentDidUpdate(prevProps, prevState) {\n if (\n this.isControlledProp('selectedItem') &&\n this.props.selectedItemChanged(\n prevProps.selectedItem,\n this.props.selectedItem,\n )\n ) {\n this.internalSetState({\n type: Downshift.stateChangeTypes.controlledPropUpdatedSelectedItem,\n inputValue: this.props.itemToString(this.props.selectedItem),\n })\n }\n\n const current =\n this.props.highlightedIndex === undefined ? this.state : this.props\n const prev =\n prevProps.highlightedIndex === undefined ? prevState : prevProps\n\n if (\n current.highlightedIndex !== prev.highlightedIndex &&\n !this.avoidScrolling\n ) {\n this.scrollHighlightedItemIntoView()\n }\n\n this.updateStatus()\n }\n\n componentWillUnmount() {\n this.cleanup() // avoids memory leak\n }\n\n // eslint-disable-next-line complexity\n render() {\n const children = unwrapArray(this.props.render || this.props.children, noop)\n // because the items are rerendered every time we call the children\n // we clear this out each render and\n this.clearItems()\n // we reset this so we know whether the user calls getRootProps during\n // this render. If they do then we don't need to do anything,\n // if they don't then we need to clone the element they return and\n // apply the props for them.\n this.getRootProps.called = false\n this.getRootProps.refKey = undefined\n this.getRootProps.suppressRefError = undefined\n // we do something similar for getLabelProps\n this.getLabelProps.called = false\n // and something similar for getInputProps\n this.getInputProps.called = false\n const element = unwrapArray(children(this.getStateAndHelpers()))\n if (!element) {\n return null\n }\n if (this.getRootProps.called) {\n if (!this.getRootProps.suppressRefError) {\n validateGetRootPropsCalledCorrectly(element, this.getRootProps)\n }\n return element\n } else if (isDOMElement(element)) {\n // they didn't apply the root props, but we can clone\n // this and apply the props ourselves\n return React.cloneElement(\n element,\n this.getRootProps(getElementProps(element)),\n )\n } else {\n // they didn't apply the root props, but they need to\n // otherwise we can't query around the autocomplete\n throw new Error(\n 'downshift: If you return a non-DOM element, you must use apply the getRootProps function',\n )\n }\n }\n}\n\nexport default Downshift\n\nfunction validateGetRootPropsCalledCorrectly(element, {refKey}) {\n const refKeySpecified = refKey !== 'ref'\n const isComposite = !isDOMElement(element)\n if (isComposite && !refKeySpecified) {\n throw new Error(\n 'downshift: You returned a non-DOM element. You must specify a refKey in getRootProps',\n )\n } else if (!isComposite && refKeySpecified) {\n throw new Error(\n `downshift: You returned a DOM element. You should not specify a refKey in getRootProps. You specified \"${refKey}\"`,\n )\n }\n if (!getElementProps(element)[refKey]) {\n throw new Error(\n `downshift: You must apply the ref prop \"${refKey}\" from getRootProps onto your root element.`,\n )\n }\n}\n","import Downshift from './downshift'\nimport {resetIdCounter} from './utils'\n\n/*\n * Fix importing in typescript after rollup compilation\n * https://github.com/rollup/rollup/issues/1156\n * https://github.com/Microsoft/TypeScript/issues/13017#issuecomment-268657860\n */\nDownshift.default = Downshift\nDownshift.resetIdCounter = resetIdCounter\n\nexport default Downshift\n"],"names":["statusDiv","document","getElementById","statuses","setStatus","status","isSameAsLast","length","div","createElement","setAttribute","assign","style","body","appendChild","getStatusDiv","lastChild","removeChild","firstChild","filter","Boolean","forEach","statusItem","index","display","childDiv","textContent","idCounter","cbToCb","cb","noop","getClosestScrollParent","findParent","finder","node","rootNode","parentNode","scrollTop","documentElement","bind","scrollHeight","clientHeight","composeEventHandlers","fns","event","args","some","fn","preventDownshiftDefault","defaultPrevented","firstDefined","find","a","unwrapArray","arg","defaultValue","Array","isArray","isDOMElement","element","nodeName","type","getElementProps","props","attributes","stateKeys","pickState","state","result","hasOwnProperty","k","Downshift","_Component","_this","getState","defaultHighlightedIndex","defaultIsOpen","defaultInputValue","defaultSelectedItem","selectedItem","inputValue","itemToString","id","String","stateToMerge","this","Object","keys","reduce","key","_this2","isControlledProp","undefined","getItemCount","itemCount","items","internalSetState","stateToSet","isItemSelected","onChangeArg","onStateChangeArg","isStateToSetFunction","onInputValueChange","getStateAndHelpers","setState","_this3","stateReducer","nextState","nextFullState","stateChangeTypes","unknown","onStateChange","onSelect","onChange","onUserAction","highlightedIndex","isOpen","getRootProps","getButtonProps","getLabelProps","getInputProps","getItemProps","openMenu","closeMenu","toggleMenu","selectItem","selectItemAtIndex","selectHighlightedItem","setHighlightedIndex","clearSelection","clearItems","reset","setItemCount","unsetItemCount","getItemId","componentDidMount","_isMounted","onMouseDown","isMouseDown","onMouseUp","_this4","environment","target","_rootNode","contains","inputId","activeElement","mouseUp","onOuterClick","addEventListener","cleanup","removeEventListener","componentDidUpdate","prevProps","prevState","selectedItemChanged","controlledPropUpdatedSelectedItem","current","prev","avoidScrolling","scrollHighlightedItemIntoView","updateStatus","componentWillUnmount","render","children","called","refKey","suppressRefError","refKeySpecified","isComposite","Error","React","cloneElement","Component","defaultProps","highlightedItem","resultCount","previousResultCount","i","prevItem","item","window","time","timeoutId","input","_this5","count","getItemNodeFromIndex","otherStateToSet","scrollParent","scrollParentStyles","getComputedStyle","scrollParentRect","getBoundingClientRect","scrollParentBorderTopWidth","parseInt","borderTopWidth","bordersWidth","borderBottomWidth","scrollParentTop","top","nodeRect","bottom","nodeTop","height","openAndHighlightDefaultIndex","highlightDefaultIndex","moveHighlightedIndex","amount","changeHighlightedIndex","moveAmount","itemsLastIndex","baseIndex","newIndex","breakingChanges","resetInputOnSelection","itemIndex","rootRef","rest","keyDownHandlers","preventDefault","shiftKey","keyDownArrowDown","keyDownArrowUp","keyDownEnter","keyDownEscape","buttonKeyDownHandlers","keyDownSpaceButton","onClick","onKeyDown","onBlur","enabledEventHandlers","button_handleClick","button_handleKeyDown","button_handleBlur","eventHandlers","disabled","call","focus","clickButton","blurButton","htmlFor","onInput","input_handleChange","input_handleKeyDown","input_handleBlur","changeInput","value","blurInput","onMouseMove","fnName","propName","requiredProp","push","indexOf","itemMouseEnter","clickItem","getA11yStatusMessage","setTimeout","default","resetIdCounter"],"mappings":"qVACA,IAAIA,EACkB,oBAAbC,SACH,KACAA,SAASC,eAAe,uBAE1BC,KAEJ,SAASC,EAAUC,OACXC,EAAeH,EAASA,EAASI,OAAS,KAAOF,IACnDC,YACaH,GAAUE,KAEbA,WAERG,EAsBR,cACMR,SACKA,WAEGC,SAASQ,cAAc,QACzBC,aAAa,KAAM,yBACnBA,aAAa,OAAQ,YACrBA,aAAa,YAAa,eAC1BA,aAAa,gBAAiB,yBACjCC,OAAOX,EAAUY,cACd,SACF,uBACE,aACA,gBACE,iBACD,aACC,iBACH,iBAEAC,KAAKC,YAAYd,GACnBA,EA1CKe,GAGLP,EAAIQ,aACLC,YAAYT,EAAIU,cAGbC,OAAOC,SAASC,QAAQ,SAACC,EAAYC,GAKhD,IAA2BlB,EACnBmB,EAEAC,IAPAX,aAImBT,EAJWiB,EAK9BE,EAL0CD,IAKtBpB,EAASI,OAAS,EAAI,QAAU,QAEpDkB,EAAWxB,SAASQ,cAAc,QAC/BG,MAAMY,QAAUA,IAChBE,YAAcrB,EAEhBoB,MClCT,IAAIE,EAAY,EAUhB,SAASC,EAAOC,SACO,mBAAPA,EAAoBA,EAAKC,EAEzC,SAASA,KAwBT,IAAMC,EAtBN,SAASC,EAAWC,EAAQC,EAAMC,UACnB,OAATD,GAAiBA,IAASC,EAASC,WACjCH,EAAOC,GACLA,IAASjC,SAASY,MAA2B,IAAnBqB,EAAKG,UAE1BpC,SAASqC,gBAEXJ,EAEAF,EAAWC,EAAQC,EAAKE,WAAYD,GAGtC,MAU+BI,KACxC,KACA,mBAAQL,EAAKM,aAAeN,EAAKO,eAmGnC,SAASC,+BAAwBC,gDACxB,SAACC,8BAAUC,0DAChBF,EAAIG,KAAK,sBACDC,gBAAGH,UAAUC,IAEZD,E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B,GAAQ,oBAErCrH,EAAqB+F,EAAa,cAIvCmF,qBAvBJ,QAyBWlL,EAAqB0L,EAAS,aACtCtG,kBAAkBvG,QACfgD,EAAUsC,iBAAiBmJ,iBAKjCrB,EAAgBjB,EAAKkB,YAAgBL,eAGrC9C,EAAKnD,UAAU/G,IAChBoN,EACAjB,SAKPxF,WAAa,aACNnC,eAGPoC,MAAQ,eAACyD,4DAAsB/J,iBACXqC,EAAU0H,KACvB5F,iBACH,gBAAEjB,IAAAA,+BACQ,mBACU0G,EAAK1H,MAAMY,mCACjB8G,EAAK1H,MAAMkB,aAAaF,IACjC6G,IAELhK,EAAOC,UAIX+F,WAAa,eAACgE,4DAAsB/J,iBAChBqC,EAAU0H,KACvB5F,iBACH,gBAAEoB,IAAAA,iBACQA,QAASA,GAAWwE,IAE9B,WACmBH,EAAK/G,WAAf0C,UAEA0F,0BAEAjL,aAKb6F,SAAW,cACJ1B,kBAAkBoB,QAAQ,GAAOxF,EAAOC,UAG/C8F,UAAY,cACL3B,kBAAkBoB,QAAQ,GAAQxF,EAAOC,UAGhDoI,cDtqBgBlH,ECsqBQ,cACjB0I,EAAKjD,gBAGJrE,EAAQsH,EAAK/G,WACb0G,EAAOK,EAAK1F,MAAM5B,EAAMgD,kBACxB6D,EAAcS,EAAK5F,eACnBxF,EAASoL,EAAK1H,MAAMkM,qCACVxE,EAAK1H,MAAMkB,iCACJwG,EAAKR,kDAETG,GACdjH,MAEA8G,oBAAsBD,IAGX3K,KDvrBEiL,ECyrBjB,IDxrBCC,SAEJ,sCAAoB1I,yCACd0I,gBACWA,KAEH2E,WAAW,aACT,oBACNrN,IACLyI,aEvHP/G,EAAU4L,QAAU5L,GACV6L,eF6JV,aACc"}
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"downshift","version":"1.29.1","description":"A set of primitives to build simple, flexible, WAI-ARIA compliant React autocomplete components","main":"dist/downshift.cjs.js","jsnext:main":"dist/downshift.esm.js","react-native":"dist/downshift.native.cjs.js","module":"dist/downshift.esm.js","typings":"typings/index.d.ts","scripts":{"add-contributor":"kcd-scripts contributors add","build":"npm run build:web --silent && npm run build:native --silent -- --no-clean","build:web":"kcd-scripts build --bundle --p-react","build:native":"cross-env BUILD_REACT_NATIVE=true BUILD_FILENAME_SUFFIX=.native kcd-scripts build --bundle cjs","lint":"kcd-scripts lint","test":"kcd-scripts test","test:cover":"kcd-scripts test --coverage","test:ssr":"kcd-scripts test --config other/ssr/jest.config.js --no-watch","test:update":"npm run test:cover -s -- --updateSnapshot","test:ts":"tsc --noEmit -p ./tsconfig.json","test:build":"kcd-scripts test --config other/misc-tests/jest.config.js --no-watch","test:cypress:dev":"npm-run-all --parallel --race storybook cy:open","pretest:cypress":"npm run storybook:build --silent","test:cypress":"npm-run-all --parallel --race storybook:serve cy:run","cy:run":"cypress run","cy:open":"cypress open","build-and-test":"npm run build -s && npm run test:build -s","storybook":"start-storybook -p 6006 -c stories","storybook:build":"build-storybook -c stories","storybook:install":"cd stories && npm install","storybook:serve":"serve ./storybook-static -p 6006","setup":"npm install && npm run storybook:install -s && npm run storybook:build -s && npm run validate","validate":"kcd-scripts validate lint,build-and-test,test:cover,test:ts,test:ssr,test:cypress","precommit":"kcd-scripts precommit"},"files":["dist","typings","preact"],"keywords":["enhanced input","react","autocomplete","autosuggest","typeahead","dropdown","select","combobox","omnibox","accessibility","WAI-ARIA","multiselect","multiple selection"],"author":"Kent C. Dodds <kent@doddsfamily.us> (http://kentcdodds.com/)","license":"MIT","peerDependencies":{"prop-types":">=15","react":">=15"},"devDependencies":{"@storybook/react":"^3.3.14","cross-env":"^5.1.3","cypress":"^2.0.3","enzyme":"^3.3.0","enzyme-adapter-react-16":"^1.1.1","enzyme-to-json":"^3.3.1","eslint-plugin-cypress":"^2.0.1","jest-serializer-html":"^5.0.0","kcd-scripts":"^0.35.2","npm-run-all":"^4.1.2","preact":"^8.2.6","preact-render-to-string":"^3.7.0","preval.macro":"^1.0.2","prop-types":"^15.6.0","react":"^16.2.0","react-dom":"^16.2.0","react-test-renderer":"^16.2.0","serve":"^6.4.11","typescript":"^2.7.2"},"eslintConfig":{"extends":"./node_modules/kcd-scripts/eslint.js","rules":{"max-lines":"off","no-eq-null":"off","eqeqeq":"off","react/jsx-indent":"off","complexity":["error",12]}},"eslintIgnore":["node_modules","coverage","dist","storybook-static","typings"],"repository":{"type":"git","url":"https://github.com/paypal/downshift.git"},"bugs":{"url":"https://github.com/paypal/downshift/issues"},"homepage":"https://github.com/paypal/downshift#readme","dependencies":{}}
1
+ {"name":"downshift","version":"1.30.0","description":"A set of primitives to build simple, flexible, WAI-ARIA compliant React autocomplete components","main":"dist/downshift.cjs.js","jsnext:main":"dist/downshift.esm.js","react-native":"dist/downshift.native.cjs.js","module":"dist/downshift.esm.js","typings":"typings/index.d.ts","scripts":{"add-contributor":"kcd-scripts contributors add","build":"npm run build:web --silent && npm run build:native --silent -- --no-clean","build:web":"kcd-scripts build --bundle --p-react","build:native":"cross-env BUILD_REACT_NATIVE=true BUILD_FILENAME_SUFFIX=.native kcd-scripts build --bundle cjs","lint":"kcd-scripts lint","test":"kcd-scripts test","test:cover":"kcd-scripts test --coverage","test:ssr":"kcd-scripts test --config other/ssr/jest.config.js --no-watch","test:update":"npm run test:cover -s -- --updateSnapshot","test:ts":"tsc --noEmit -p ./tsconfig.json","test:build":"jest --projects other/misc-tests other/react-native","test:cypress:dev":"npm-run-all --parallel --race storybook cy:open","pretest:cypress":"npm run storybook:build --silent","test:cypress":"npm-run-all --parallel --race storybook:serve cy:run","cy:run":"cypress run","cy:open":"cypress open","build-and-test":"npm run build -s && npm run test:build -s","storybook":"start-storybook -p 6006 -c stories","storybook:build":"build-storybook -c stories","storybook:install":"cd stories && npm install","storybook:serve":"serve ./storybook-static -p 6006","setup":"npm install && npm run storybook:install -s && npm run storybook:build -s && npm run validate","validate":"kcd-scripts validate lint,build-and-test,test:cover,test:ts,test:ssr,test:cypress","precommit":"kcd-scripts precommit"},"files":["dist","typings","preact"],"keywords":["enhanced input","react","autocomplete","autosuggest","typeahead","dropdown","select","combobox","omnibox","accessibility","WAI-ARIA","multiselect","multiple selection"],"author":"Kent C. Dodds <kent@doddsfamily.us> (http://kentcdodds.com/)","license":"MIT","peerDependencies":{"prop-types":">=15","react":">=15"},"devDependencies":{"@storybook/react":"^3.3.14","babel-jest":"^22.2.0","babel-preset-env":"^1.6.1","babel-preset-react-native":"^4.0.0","cross-env":"^5.1.3","cypress":"^2.0.3","enzyme":"^3.3.0","enzyme-adapter-react-16":"^1.1.1","enzyme-to-json":"^3.3.1","eslint-plugin-cypress":"^2.0.1","jest-serializer-html":"^5.0.0","kcd-scripts":"^0.35.2","npm-run-all":"^4.1.2","preact":"^8.2.6","preact-render-to-string":"^3.7.0","preval.macro":"^1.0.2","prop-types":"^15.6.0","react":"^16.2.0","react-dom":"^16.2.0","react-native":"^0.53.0","react-test-renderer":"^16.2.0","serve":"^6.4.11","typescript":"^2.7.2"},"eslintConfig":{"extends":"./node_modules/kcd-scripts/eslint.js","rules":{"max-lines":"off","no-eq-null":"off","eqeqeq":"off","react/jsx-indent":"off","complexity":["error",12]}},"eslintIgnore":["node_modules","coverage","dist","storybook-static","typings"],"repository":{"type":"git","url":"https://github.com/paypal/downshift.git"},"bugs":{"url":"https://github.com/paypal/downshift/issues"},"homepage":"https://github.com/paypal/downshift#readme","dependencies":{}}
@@ -1131,7 +1131,7 @@ var _initialiseProps = function () {
1131
1131
  };
1132
1132
 
1133
1133
  this.getItemProps = function () {
1134
- var _babelHelpers$extends2;
1134
+ var _enabledEventHandlers;
1135
1135
 
1136
1136
  var _ref7 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1137
1137
 
@@ -1151,8 +1151,8 @@ var _initialiseProps = function () {
1151
1151
  }
1152
1152
 
1153
1153
  var onSelectKey = 'onClick';
1154
- return _extends((_babelHelpers$extends2 = {
1155
- id: _this5.getItemId(index),
1154
+
1155
+ var enabledEventHandlers = (_enabledEventHandlers = {
1156
1156
  // onMouseMove is used over onMouseEnter here. onMouseMove
1157
1157
  // is only triggered on actual mouse movement while onMouseEnter
1158
1158
  // can fire on DOM changes, interrupting keyboard navigation
@@ -1179,11 +1179,17 @@ var _initialiseProps = function () {
1179
1179
  // which is a more common use case.
1180
1180
  event.preventDefault();
1181
1181
  })
1182
- }, _babelHelpers$extends2[onSelectKey] = composeEventHandlers(onClick, function () {
1182
+ }, _enabledEventHandlers[onSelectKey] = composeEventHandlers(onClick, function () {
1183
1183
  _this5.selectItemAtIndex(index, {
1184
1184
  type: Downshift$1.stateChangeTypes.clickItem
1185
1185
  });
1186
- }), _babelHelpers$extends2), rest);
1186
+ }), _enabledEventHandlers);
1187
+
1188
+ var eventHandlers = rest.disabled ? {} : enabledEventHandlers;
1189
+
1190
+ return _extends({
1191
+ id: _this5.getItemId(index)
1192
+ }, eventHandlers, rest);
1187
1193
  };
1188
1194
 
1189
1195
  this.clearItems = function () {
@@ -1126,7 +1126,7 @@ var _initialiseProps = function () {
1126
1126
  };
1127
1127
 
1128
1128
  this.getItemProps = function () {
1129
- var _babelHelpers$extends2;
1129
+ var _enabledEventHandlers;
1130
1130
 
1131
1131
  var _ref7 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1132
1132
 
@@ -1146,8 +1146,8 @@ var _initialiseProps = function () {
1146
1146
  }
1147
1147
 
1148
1148
  var onSelectKey = 'onClick';
1149
- return _extends((_babelHelpers$extends2 = {
1150
- id: _this5.getItemId(index),
1149
+
1150
+ var enabledEventHandlers = (_enabledEventHandlers = {
1151
1151
  // onMouseMove is used over onMouseEnter here. onMouseMove
1152
1152
  // is only triggered on actual mouse movement while onMouseEnter
1153
1153
  // can fire on DOM changes, interrupting keyboard navigation
@@ -1174,11 +1174,17 @@ var _initialiseProps = function () {
1174
1174
  // which is a more common use case.
1175
1175
  event.preventDefault();
1176
1176
  })
1177
- }, _babelHelpers$extends2[onSelectKey] = composeEventHandlers(onClick, function () {
1177
+ }, _enabledEventHandlers[onSelectKey] = composeEventHandlers(onClick, function () {
1178
1178
  _this5.selectItemAtIndex(index, {
1179
1179
  type: Downshift$1.stateChangeTypes.clickItem
1180
1180
  });
1181
- }), _babelHelpers$extends2), rest);
1181
+ }), _enabledEventHandlers);
1182
+
1183
+ var eventHandlers = rest.disabled ? {} : enabledEventHandlers;
1184
+
1185
+ return _extends({
1186
+ id: _this5.getItemId(index)
1187
+ }, eventHandlers, rest);
1182
1188
  };
1183
1189
 
1184
1190
  this.clearItems = function () {
@@ -1132,7 +1132,7 @@ var _initialiseProps = function () {
1132
1132
  };
1133
1133
 
1134
1134
  this.getItemProps = function () {
1135
- var _babelHelpers$extends2;
1135
+ var _enabledEventHandlers;
1136
1136
 
1137
1137
  var _ref7 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1138
1138
 
@@ -1152,8 +1152,8 @@ var _initialiseProps = function () {
1152
1152
  }
1153
1153
 
1154
1154
  var onSelectKey = 'onClick';
1155
- return _extends((_babelHelpers$extends2 = {
1156
- id: _this5.getItemId(index),
1155
+
1156
+ var enabledEventHandlers = (_enabledEventHandlers = {
1157
1157
  // onMouseMove is used over onMouseEnter here. onMouseMove
1158
1158
  // is only triggered on actual mouse movement while onMouseEnter
1159
1159
  // can fire on DOM changes, interrupting keyboard navigation
@@ -1180,11 +1180,17 @@ var _initialiseProps = function () {
1180
1180
  // which is a more common use case.
1181
1181
  event.preventDefault();
1182
1182
  })
1183
- }, _babelHelpers$extends2[onSelectKey] = composeEventHandlers(onClick, function () {
1183
+ }, _enabledEventHandlers[onSelectKey] = composeEventHandlers(onClick, function () {
1184
1184
  _this5.selectItemAtIndex(index, {
1185
1185
  type: Downshift$1.stateChangeTypes.clickItem
1186
1186
  });
1187
- }), _babelHelpers$extends2), rest);
1187
+ }), _enabledEventHandlers);
1188
+
1189
+ var eventHandlers = rest.disabled ? {} : enabledEventHandlers;
1190
+
1191
+ return _extends({
1192
+ id: _this5.getItemId(index)
1193
+ }, eventHandlers, rest);
1188
1194
  };
1189
1195
 
1190
1196
  this.clearItems = function () {