downshift 6.1.2-alpha.0 → 6.1.4

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.
Files changed (36) hide show
  1. package/README.md +4 -1
  2. package/dist/downshift.cjs.js +139 -118
  3. package/dist/downshift.esm.js +140 -120
  4. package/dist/downshift.native.cjs.js +137 -116
  5. package/dist/downshift.umd.js +786 -936
  6. package/dist/downshift.umd.js.map +1 -1
  7. package/dist/downshift.umd.min.js +2 -28
  8. package/dist/downshift.umd.min.js.map +1 -1
  9. package/dist/src/hooks/reducer.d.ts +1 -0
  10. package/dist/src/hooks/useSelect/__tests__/utils.test.d.ts +1 -0
  11. package/dist/src/hooks/useSelect/reducer.d.ts +1 -0
  12. package/dist/src/hooks/useSelect/stateChangeTypes.d.ts +23 -0
  13. package/dist/src/hooks/useSelect/types.d.ts +7 -0
  14. package/dist/src/hooks/useSelect/utils.d.ts +23 -0
  15. package/dist/src/hooks/utils.d.ts +112 -0
  16. package/dist/src/is.macro.d.ts +2 -0
  17. package/dist/src/productionEnum.macro.d.ts +2 -0
  18. package/dist/src/set-a11y-status.d.ts +6 -0
  19. package/dist/src/types.d.ts +10 -0
  20. package/dist/src/utils.d.ts +156 -0
  21. package/dist/{basic.test.d.ts → test/basic.test.d.ts} +0 -0
  22. package/dist/{custom.test.d.ts → test/custom.test.d.ts} +0 -0
  23. package/dist/test/setup.d.ts +1 -0
  24. package/package.json +49 -36
  25. package/preact/dist/downshift.cjs.js +140 -118
  26. package/preact/dist/downshift.esm.js +141 -120
  27. package/preact/dist/downshift.umd.js +337 -437
  28. package/preact/dist/downshift.umd.js.map +1 -1
  29. package/preact/dist/downshift.umd.min.js +2 -11
  30. package/preact/dist/downshift.umd.min.js.map +1 -1
  31. package/typings/index.d.ts +4 -13
  32. package/dist/downshift.cjs.d.ts +0 -1
  33. package/dist/downshift.esm.d.ts +0 -1
  34. package/dist/downshift.native.cjs.d.ts +0 -1
  35. package/dist/downshift.umd.d.ts +0 -1
  36. package/dist/downshift.umd.min.d.ts +0 -1
package/README.md CHANGED
@@ -32,7 +32,7 @@ autocomplete, combobox or select dropdown components.</p>
32
32
 
33
33
  You need an autocomplete, a combobox or a select experience in your application
34
34
  and you want it to be accessible. You also want it to be simple and flexible to
35
- account for your use cases. Finally, it should follow the ARIA design pattern
35
+ account for your use cases. Finally, it should follow the [ARIA][aria] design pattern
36
36
  for a [combobox][combobox-aria] or a [select][select-aria], depending on your
37
37
  use case.
38
38
 
@@ -1403,6 +1403,7 @@ Thanks goes to these people ([emoji key][emojis]):
1403
1403
  <td align="center"><a href="https://github.com/fcrezza"><img src="https://avatars2.githubusercontent.com/u/48123020?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Anang Fachreza</b></sub></a><br /><a href="https://github.com/downshift-js/downshift/commits?author=fcrezza" title="Documentation">📖</a> <a href="#example-fcrezza" title="Examples">💡</a></td>
1404
1404
  <td align="center"><a href="http://nickdeom.com"><img src="https://avatars2.githubusercontent.com/u/56491159?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Nick Deom</b></sub></a><br /><a href="https://github.com/downshift-js/downshift/commits?author=ndeom" title="Code">💻</a> <a href="https://github.com/downshift-js/downshift/issues?q=author%3Andeom" title="Bug reports">🐛</a></td>
1405
1405
  <td align="center"><a href="https://github.com/clementgarbay"><img src="https://avatars3.githubusercontent.com/u/12433625?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Clément Garbay</b></sub></a><br /><a href="https://github.com/downshift-js/downshift/commits?author=clementgarbay" title="Code">💻</a></td>
1406
+ <td align="center"><a href="https://github.com/KaiminHuang"><img src="https://avatars.githubusercontent.com/u/5600404?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Kaimin Huang</b></sub></a><br /><a href="https://github.com/downshift-js/downshift/commits?author=KaiminHuang" title="Code">💻</a> <a href="https://github.com/downshift-js/downshift/issues?q=author%3AKaiminHuang" title="Bug reports">🐛</a></td>
1406
1407
  </tr>
1407
1408
  </table>
1408
1409
 
@@ -1480,6 +1481,8 @@ MIT
1480
1481
  [multiple-selection-readme]:
1481
1482
  https://github.com/downshift-js/downshift/tree/master/src/hooks/useMultipleSelection
1482
1483
  [bundle-phobia-link]: https://bundlephobia.com/result?p=downshift@3.4.8
1484
+ [aria]:
1485
+ https://www.w3.org/TR/wai-aria-practices/
1483
1486
  [combobox-aria]:
1484
1487
  https://www.w3.org/TR/wai-aria-practices/examples/combobox/aria1.1pattern/listbox-combo.html
1485
1488
  [select-aria]:
@@ -63,12 +63,14 @@ function scrollIntoView(node, menuNode) {
63
63
  /**
64
64
  * @param {HTMLElement} parent the parent node
65
65
  * @param {HTMLElement} child the child node
66
+ * @param {Window} environment The window context where downshift renders.
66
67
  * @return {Boolean} whether the parent is the child or the child is in the parent
67
68
  */
68
69
 
69
70
 
70
71
  function isOrContainsNode(parent, child, environment) {
71
- return parent === child || child instanceof environment.Node && parent.contains && parent.contains(child);
72
+ var result = parent === child || child instanceof environment.Node && parent.contains && parent.contains(child);
73
+ return result;
72
74
  }
73
75
  /**
74
76
  * Simple debounce implementation. Will call the given
@@ -416,7 +418,7 @@ function getNextNonDisabledIndex(moveAmount, baseIndex, itemCount, getItemNodeFr
416
418
  *
417
419
  * @param {EventTarget} target Target to check.
418
420
  * @param {HTMLElement[]} downshiftElements The elements that form downshift (list, toggle button etc).
419
- * @param {Environment} environment The environment.
421
+ * @param {Window} environment The window context where downshift renders.
420
422
  * @param {boolean} checkActiveElement Whether to also check activeElement.
421
423
  *
422
424
  * @returns {boolean} Whether or not the target is within downshift elements.
@@ -546,6 +548,12 @@ var stateChangeTypes$3 = /*#__PURE__*/Object.freeze({
546
548
  touchEnd: touchEnd
547
549
  });
548
550
 
551
+ var _excluded$4 = ["refKey", "ref"],
552
+ _excluded2$3 = ["onClick", "onPress", "onKeyDown", "onKeyUp", "onBlur"],
553
+ _excluded3$2 = ["onKeyDown", "onBlur", "onChange", "onInput", "onChangeText"],
554
+ _excluded4$1 = ["refKey", "ref"],
555
+ _excluded5$1 = ["onMouseMove", "onMouseDown", "onClick", "onPress", "index", "item"];
556
+
549
557
  var Downshift = /*#__PURE__*/function () {
550
558
  var Downshift = /*#__PURE__*/function (_Component) {
551
559
  _inheritsLoose__default['default'](Downshift, _Component);
@@ -665,6 +673,8 @@ var Downshift = /*#__PURE__*/function () {
665
673
  isItemSelected = newStateToSet.hasOwnProperty('selectedItem'); // this keeps track of the object we want to call with setState
666
674
 
667
675
  var nextState = {}; // this is just used to tell whether the state changed
676
+
677
+ var nextFullState = {}; // we need to call on change if the outside world is controlling any of our state
668
678
  // and we're trying to update that state. OR if the selection has changed and we're
669
679
  // trying to update the selection
670
680
 
@@ -690,7 +700,7 @@ var Downshift = /*#__PURE__*/function () {
690
700
  return;
691
701
  }
692
702
 
693
- newStateToSet[key]; // if it's coming from props, then we don't care to set it internally
703
+ nextFullState[key] = newStateToSet[key]; // if it's coming from props, then we don't care to set it internally
694
704
 
695
705
  if (!isControlledProp(_this.props, key)) {
696
706
  nextState[key] = newStateToSet[key];
@@ -739,7 +749,7 @@ var Downshift = /*#__PURE__*/function () {
739
749
  _ref$refKey = _ref.refKey,
740
750
  refKey = _ref$refKey === void 0 ? 'ref' : _ref$refKey,
741
751
  ref = _ref.ref,
742
- rest = _objectWithoutPropertiesLoose__default['default'](_ref, ["refKey", "ref"]);
752
+ rest = _objectWithoutPropertiesLoose__default['default'](_ref, _excluded$4);
743
753
 
744
754
  var _ref2 = _temp2 === void 0 ? {} : _temp2,
745
755
  _ref2$suppressRefErro = _ref2.suppressRefError,
@@ -923,7 +933,7 @@ var Downshift = /*#__PURE__*/function () {
923
933
  var onKeyDown = _ref3.onKeyDown,
924
934
  onKeyUp = _ref3.onKeyUp,
925
935
  onBlur = _ref3.onBlur,
926
- rest = _objectWithoutPropertiesLoose__default['default'](_ref3, ["onClick", "onPress", "onKeyDown", "onKeyUp", "onBlur"]);
936
+ rest = _objectWithoutPropertiesLoose__default['default'](_ref3, _excluded2$3);
927
937
 
928
938
  var _this$getState5 = _this.getState(),
929
939
  isOpen = _this$getState5.isOpen;
@@ -991,10 +1001,10 @@ var Downshift = /*#__PURE__*/function () {
991
1001
  _this.internalSetTimeout(function () {
992
1002
  if (!_this.isMouseDown && (_this.props.environment.document.activeElement == null || _this.props.environment.document.activeElement.id !== _this.inputId) && _this.props.environment.document.activeElement !== blurTarget // Do nothing if we refocus the same element again (to solve issue in Safari on iOS)
993
1003
  ) {
994
- _this.reset({
995
- type: blurButton
996
- });
997
- }
1004
+ _this.reset({
1005
+ type: blurButton
1006
+ });
1007
+ }
998
1008
  });
999
1009
  };
1000
1010
 
@@ -1012,7 +1022,7 @@ var Downshift = /*#__PURE__*/function () {
1012
1022
  onChange = _ref4.onChange,
1013
1023
  onInput = _ref4.onInput;
1014
1024
  _ref4.onChangeText;
1015
- var rest = _objectWithoutPropertiesLoose__default['default'](_ref4, ["onKeyDown", "onBlur", "onChange", "onInput", "onChangeText"]);
1025
+ var rest = _objectWithoutPropertiesLoose__default['default'](_ref4, _excluded3$2);
1016
1026
 
1017
1027
  var onChangeKey;
1018
1028
  var eventHandlers = {};
@@ -1087,7 +1097,7 @@ var Downshift = /*#__PURE__*/function () {
1087
1097
  _ref5$refKey = _ref5.refKey,
1088
1098
  refKey = _ref5$refKey === void 0 ? 'ref' : _ref5$refKey,
1089
1099
  ref = _ref5.ref,
1090
- props = _objectWithoutPropertiesLoose__default['default'](_ref5, ["refKey", "ref"]);
1100
+ props = _objectWithoutPropertiesLoose__default['default'](_ref5, _excluded4$1);
1091
1101
 
1092
1102
  var _ref6 = _temp6 === void 0 ? {} : _temp6,
1093
1103
  _ref6$suppressRefErro = _ref6.suppressRefError,
@@ -1112,7 +1122,7 @@ var Downshift = /*#__PURE__*/function () {
1112
1122
  item = _ref7$item === void 0 ? process.env.NODE_ENV === 'production' ?
1113
1123
  /* istanbul ignore next */
1114
1124
  undefined : requiredProp('getItemProps', 'item') : _ref7$item,
1115
- rest = _objectWithoutPropertiesLoose__default['default'](_ref7, ["onMouseMove", "onMouseDown", "onClick", "onPress", "index", "item"]);
1125
+ rest = _objectWithoutPropertiesLoose__default['default'](_ref7, _excluded5$1);
1116
1126
 
1117
1127
  if (index === undefined) {
1118
1128
  _this.items.push(item);
@@ -1438,7 +1448,7 @@ var Downshift = /*#__PURE__*/function () {
1438
1448
  _this7.isMouseDown = false; // if the target element or the activeElement is within a downshift node
1439
1449
  // then we don't want to reset downshift
1440
1450
 
1441
- var contextWithinDownshift = targetWithinDownshift(event.target, [_this7._rootNode, _this7._menuNode], _this7.props.environment.document);
1451
+ var contextWithinDownshift = targetWithinDownshift(event.target, [_this7._rootNode, _this7._menuNode], _this7.props.environment);
1442
1452
 
1443
1453
  if (!contextWithinDownshift && _this7.getState().isOpen) {
1444
1454
  _this7.reset({
@@ -1464,7 +1474,7 @@ var Downshift = /*#__PURE__*/function () {
1464
1474
  };
1465
1475
 
1466
1476
  var onTouchEnd = function onTouchEnd(event) {
1467
- var contextWithinDownshift = targetWithinDownshift(event.target, [_this7._rootNode, _this7._menuNode], _this7.props.environment.document, false);
1477
+ var contextWithinDownshift = targetWithinDownshift(event.target, [_this7._rootNode, _this7._menuNode], _this7.props.environment, false);
1468
1478
 
1469
1479
  if (!_this7.isTouchMove && !contextWithinDownshift && _this7.getState().isOpen) {
1470
1480
  _this7.reset({
@@ -1620,9 +1630,9 @@ var Downshift = /*#__PURE__*/function () {
1620
1630
  selectedItemChanged: function selectedItemChanged(prevItem, item) {
1621
1631
  return prevItem !== item;
1622
1632
  },
1623
- environment: typeof window === 'undefined'
1633
+ environment:
1624
1634
  /* istanbul ignore next (ssr) */
1625
- ? {} : window,
1635
+ typeof window === 'undefined' ? {} : window,
1626
1636
  stateReducer: function stateReducer(state, stateToSet) {
1627
1637
  return stateToSet;
1628
1638
  },
@@ -1679,6 +1689,7 @@ process.env.NODE_ENV !== "production" ? Downshift.propTypes = {
1679
1689
  /* eslint-enable react/no-unused-prop-types */
1680
1690
 
1681
1691
  } : void 0;
1692
+ var Downshift$1 = Downshift;
1682
1693
 
1683
1694
  function validateGetMenuPropsCalledCorrectly(node, _ref12) {
1684
1695
  var refKey = _ref12.refKey;
@@ -1708,6 +1719,7 @@ function validateGetRootPropsCalledCorrectly(element, _ref13) {
1708
1719
  }
1709
1720
  }
1710
1721
 
1722
+ var _excluded$3 = ["isInitialMount", "highlightedIndex", "items", "environment"];
1711
1723
  var dropdownDefaultStateValues = {
1712
1724
  highlightedIndex: -1,
1713
1725
  isOpen: false,
@@ -1905,9 +1917,9 @@ var defaultProps$3 = {
1905
1917
  getA11ySelectionMessage: getA11ySelectionMessage,
1906
1918
  scrollIntoView: scrollIntoView,
1907
1919
  circularNavigation: false,
1908
- environment: typeof window === 'undefined'
1920
+ environment:
1909
1921
  /* istanbul ignore next (ssr) */
1910
- ? {} : window
1922
+ typeof window === 'undefined' ? {} : window
1911
1923
  };
1912
1924
 
1913
1925
  function getDefaultValue$1(props, propKey, defaultStateValues) {
@@ -2033,7 +2045,7 @@ function useMouseAndTouchTracker(isOpen, downshiftElementRefs, environment, hand
2033
2045
  var onTouchEnd = function onTouchEnd(event) {
2034
2046
  if (isOpen && !mouseAndTouchTrackersRef.current.isTouchMove && !targetWithinDownshift(event.target, downshiftElementRefs.map(function (ref) {
2035
2047
  return ref.current;
2036
- }), environment.document, false)) {
2048
+ }), environment, false)) {
2037
2049
  handleBlur();
2038
2050
  }
2039
2051
  };
@@ -2121,11 +2133,11 @@ function useA11yMessageSetter(getA11yMessage, dependencyArray, _ref2) {
2121
2133
  highlightedIndex = _ref2.highlightedIndex,
2122
2134
  items = _ref2.items,
2123
2135
  environment = _ref2.environment,
2124
- rest = _objectWithoutPropertiesLoose__default['default'](_ref2, ["isInitialMount", "highlightedIndex", "items", "environment"]);
2136
+ rest = _objectWithoutPropertiesLoose__default['default'](_ref2, _excluded$3);
2125
2137
 
2126
2138
  // Sets a11y status message on changes in state.
2127
2139
  react.useEffect(function () {
2128
- if (isInitialMount) {
2140
+ if (isInitialMount || false) {
2129
2141
  return;
2130
2142
  }
2131
2143
 
@@ -2256,58 +2268,57 @@ function downshiftCommonReducer(state, action, stateChangeTypes) {
2256
2268
  }
2257
2269
  /* eslint-enable complexity */
2258
2270
 
2259
- function getItemIndexByCharacterKey(keysSoFar, highlightedIndex, items, itemToString, getItemNodeFromIndex) {
2260
- var lowerCasedKeysSoFar = keysSoFar.toLowerCase();
2261
-
2262
- for (var index = 0; index < items.length; index++) {
2263
- var offsetIndex = (index + highlightedIndex + 1) % items.length;
2264
-
2265
- if (itemToString(items[offsetIndex]).toLowerCase().startsWith(lowerCasedKeysSoFar)) {
2266
- var element = getItemNodeFromIndex(offsetIndex);
2267
-
2268
- if (!(element && element.hasAttribute('disabled'))) {
2269
- return offsetIndex;
2270
- }
2271
+ function getItemIndexByCharacterKey({ keysSoFar, highlightedIndex, items, itemToString, getItemNodeFromIndex, }) {
2272
+ const lowerCasedKeysSoFar = keysSoFar.toLowerCase();
2273
+ for (let index = 0; index < items.length; index++) {
2274
+ const offsetIndex = (index + highlightedIndex + 1) % items.length;
2275
+ const item = items[offsetIndex];
2276
+ if (item !== undefined &&
2277
+ itemToString(item)
2278
+ .toLowerCase()
2279
+ .startsWith(lowerCasedKeysSoFar)) {
2280
+ const element = getItemNodeFromIndex(offsetIndex);
2281
+ if (!element?.hasAttribute('disabled')) {
2282
+ return offsetIndex;
2283
+ }
2284
+ }
2271
2285
  }
2272
- }
2273
-
2274
- return highlightedIndex;
2286
+ return highlightedIndex;
2275
2287
  }
2276
-
2277
- var propTypes$2 = {
2278
- items: PropTypes__default['default'].array.isRequired,
2279
- itemToString: PropTypes__default['default'].func,
2280
- getA11yStatusMessage: PropTypes__default['default'].func,
2281
- getA11ySelectionMessage: PropTypes__default['default'].func,
2282
- circularNavigation: PropTypes__default['default'].bool,
2283
- highlightedIndex: PropTypes__default['default'].number,
2284
- defaultHighlightedIndex: PropTypes__default['default'].number,
2285
- initialHighlightedIndex: PropTypes__default['default'].number,
2286
- isOpen: PropTypes__default['default'].bool,
2287
- defaultIsOpen: PropTypes__default['default'].bool,
2288
- initialIsOpen: PropTypes__default['default'].bool,
2289
- selectedItem: PropTypes__default['default'].any,
2290
- initialSelectedItem: PropTypes__default['default'].any,
2291
- defaultSelectedItem: PropTypes__default['default'].any,
2292
- id: PropTypes__default['default'].string,
2293
- labelId: PropTypes__default['default'].string,
2294
- menuId: PropTypes__default['default'].string,
2295
- getItemId: PropTypes__default['default'].func,
2296
- toggleButtonId: PropTypes__default['default'].string,
2297
- stateReducer: PropTypes__default['default'].func,
2298
- onSelectedItemChange: PropTypes__default['default'].func,
2299
- onHighlightedIndexChange: PropTypes__default['default'].func,
2300
- onStateChange: PropTypes__default['default'].func,
2301
- onIsOpenChange: PropTypes__default['default'].func,
2302
- environment: PropTypes__default['default'].shape({
2303
- addEventListener: PropTypes__default['default'].func,
2304
- removeEventListener: PropTypes__default['default'].func,
2305
- document: PropTypes__default['default'].shape({
2306
- getElementById: PropTypes__default['default'].func,
2307
- activeElement: PropTypes__default['default'].any,
2308
- body: PropTypes__default['default'].any
2309
- })
2310
- })
2288
+ const propTypes$2 = {
2289
+ items: PropTypes__default['default'].array.isRequired,
2290
+ itemToString: PropTypes__default['default'].func,
2291
+ getA11yStatusMessage: PropTypes__default['default'].func,
2292
+ getA11ySelectionMessage: PropTypes__default['default'].func,
2293
+ circularNavigation: PropTypes__default['default'].bool,
2294
+ highlightedIndex: PropTypes__default['default'].number,
2295
+ defaultHighlightedIndex: PropTypes__default['default'].number,
2296
+ initialHighlightedIndex: PropTypes__default['default'].number,
2297
+ isOpen: PropTypes__default['default'].bool,
2298
+ defaultIsOpen: PropTypes__default['default'].bool,
2299
+ initialIsOpen: PropTypes__default['default'].bool,
2300
+ selectedItem: PropTypes__default['default'].any,
2301
+ initialSelectedItem: PropTypes__default['default'].any,
2302
+ defaultSelectedItem: PropTypes__default['default'].any,
2303
+ id: PropTypes__default['default'].string,
2304
+ labelId: PropTypes__default['default'].string,
2305
+ menuId: PropTypes__default['default'].string,
2306
+ getItemId: PropTypes__default['default'].func,
2307
+ toggleButtonId: PropTypes__default['default'].string,
2308
+ stateReducer: PropTypes__default['default'].func,
2309
+ onSelectedItemChange: PropTypes__default['default'].func,
2310
+ onHighlightedIndexChange: PropTypes__default['default'].func,
2311
+ onStateChange: PropTypes__default['default'].func,
2312
+ onIsOpenChange: PropTypes__default['default'].func,
2313
+ environment: PropTypes__default['default'].shape({
2314
+ addEventListener: PropTypes__default['default'].func,
2315
+ removeEventListener: PropTypes__default['default'].func,
2316
+ document: PropTypes__default['default'].shape({
2317
+ getElementById: PropTypes__default['default'].func,
2318
+ activeElement: PropTypes__default['default'].any,
2319
+ body: PropTypes__default['default'].any,
2320
+ }),
2321
+ }),
2311
2322
  };
2312
2323
  /**
2313
2324
  * Default implementation for status message. Only added when menu is open.
@@ -2317,39 +2328,29 @@ var propTypes$2 = {
2317
2328
  * @param {Object} param the downshift state and other relevant properties
2318
2329
  * @return {String} the a11y status message
2319
2330
  */
2320
-
2321
- function getA11yStatusMessage(_ref) {
2322
- var isOpen = _ref.isOpen,
2323
- resultCount = _ref.resultCount,
2324
- previousResultCount = _ref.previousResultCount;
2325
-
2326
- if (!isOpen) {
2331
+ function getA11yStatusMessage({ isOpen, resultCount, previousResultCount, }) {
2332
+ if (!isOpen) {
2333
+ return '';
2334
+ }
2335
+ if (!resultCount) {
2336
+ return 'No results are available.';
2337
+ }
2338
+ if (resultCount !== previousResultCount) {
2339
+ return `${resultCount} result${resultCount === 1 ? ' is' : 's are'} available, use up and down arrow keys to navigate. Press Enter or Space Bar keys to select.`;
2340
+ }
2327
2341
  return '';
2328
- }
2329
-
2330
- if (!resultCount) {
2331
- return 'No results are available.';
2332
- }
2333
-
2334
- if (resultCount !== previousResultCount) {
2335
- return resultCount + " result" + (resultCount === 1 ? ' is' : 's are') + " available, use up and down arrow keys to navigate. Press Enter or Space Bar keys to select.";
2336
- }
2337
-
2338
- return '';
2339
2342
  }
2340
-
2341
- var defaultProps$2 = _extends__default['default']({}, defaultProps$3, {
2342
- getA11yStatusMessage: getA11yStatusMessage
2343
- }); // eslint-disable-next-line import/no-mutable-exports
2344
-
2345
-
2346
- var validatePropTypes$2 = noop;
2343
+ const defaultProps$2 = {
2344
+ ...defaultProps$3,
2345
+ getA11yStatusMessage,
2346
+ };
2347
+ // eslint-disable-next-line import/no-mutable-exports
2348
+ let validatePropTypes$2 = noop;
2347
2349
  /* istanbul ignore next */
2348
-
2349
2350
  if (process.env.NODE_ENV !== 'production') {
2350
- validatePropTypes$2 = function validatePropTypes(options, caller) {
2351
- PropTypes__default['default'].checkPropTypes(propTypes$2, options, 'prop', caller.name);
2352
- };
2351
+ validatePropTypes$2 = (options, caller) => {
2352
+ PropTypes__default['default'].checkPropTypes(propTypes$2, options, 'prop', caller.name);
2353
+ };
2353
2354
  }
2354
2355
 
2355
2356
  var MenuKeyDownArrowDown = process.env.NODE_ENV !== "production" ? '__menu_keydown_arrow_down__' : 0;
@@ -2424,7 +2425,13 @@ function downshiftSelectReducer(state, action) {
2424
2425
  {
2425
2426
  var lowercasedKey = action.key;
2426
2427
  var inputValue = "" + state.inputValue + lowercasedKey;
2427
- var itemIndex = getItemIndexByCharacterKey(inputValue, state.selectedItem ? props.items.indexOf(state.selectedItem) : -1, props.items, props.itemToString, action.getItemNodeFromIndex);
2428
+ var itemIndex = getItemIndexByCharacterKey({
2429
+ keysSoFar: inputValue,
2430
+ highlightedIndex: state.selectedItem ? props.items.indexOf(state.selectedItem) : -1,
2431
+ items: props.items,
2432
+ itemToString: props.itemToString,
2433
+ getItemNodeFromIndex: action.getItemNodeFromIndex
2434
+ });
2428
2435
  changes = _extends__default['default']({
2429
2436
  inputValue: inputValue
2430
2437
  }, itemIndex >= 0 && {
@@ -2489,7 +2496,13 @@ function downshiftSelectReducer(state, action) {
2489
2496
 
2490
2497
  var _inputValue = "" + state.inputValue + _lowercasedKey;
2491
2498
 
2492
- var highlightedIndex = getItemIndexByCharacterKey(_inputValue, state.highlightedIndex, props.items, props.itemToString, action.getItemNodeFromIndex);
2499
+ var highlightedIndex = getItemIndexByCharacterKey({
2500
+ keysSoFar: _inputValue,
2501
+ highlightedIndex: state.highlightedIndex,
2502
+ items: props.items,
2503
+ itemToString: props.itemToString,
2504
+ getItemNodeFromIndex: action.getItemNodeFromIndex
2505
+ });
2493
2506
  changes = _extends__default['default']({
2494
2507
  inputValue: _inputValue
2495
2508
  }, highlightedIndex >= 0 && {
@@ -2524,6 +2537,9 @@ function downshiftSelectReducer(state, action) {
2524
2537
  }
2525
2538
  /* eslint-enable complexity */
2526
2539
 
2540
+ var _excluded$2 = ["onMouseLeave", "refKey", "onKeyDown", "onBlur", "ref"],
2541
+ _excluded2$2 = ["onClick", "onKeyDown", "refKey", "ref"],
2542
+ _excluded3$1 = ["item", "index", "onMouseMove", "onClick", "refKey", "ref"];
2527
2543
  useSelect.stateChangeTypes = stateChangeTypes$2;
2528
2544
 
2529
2545
  function useSelect(userProps) {
@@ -2814,7 +2830,7 @@ function useSelect(userProps) {
2814
2830
  onKeyDown = _ref.onKeyDown,
2815
2831
  onBlur = _ref.onBlur,
2816
2832
  ref = _ref.ref,
2817
- rest = _objectWithoutPropertiesLoose__default['default'](_ref, ["onMouseLeave", "refKey", "onKeyDown", "onBlur", "ref"]);
2833
+ rest = _objectWithoutPropertiesLoose__default['default'](_ref, _excluded$2);
2818
2834
 
2819
2835
  var _ref2 = _temp2 === void 0 ? {} : _temp2,
2820
2836
  _ref2$suppressRefErro = _ref2.suppressRefError,
@@ -2879,7 +2895,7 @@ function useSelect(userProps) {
2879
2895
  _ref3$refKey = _ref3.refKey,
2880
2896
  refKey = _ref3$refKey === void 0 ? 'ref' : _ref3$refKey,
2881
2897
  ref = _ref3.ref,
2882
- rest = _objectWithoutPropertiesLoose__default['default'](_ref3, ["onClick", "onKeyDown", "refKey", "ref"]);
2898
+ rest = _objectWithoutPropertiesLoose__default['default'](_ref3, _excluded2$2);
2883
2899
 
2884
2900
  var _ref4 = _temp4 === void 0 ? {} : _temp4,
2885
2901
  _ref4$suppressRefErro = _ref4.suppressRefError,
@@ -2928,7 +2944,7 @@ function useSelect(userProps) {
2928
2944
  _ref5$refKey = _ref5.refKey,
2929
2945
  refKey = _ref5$refKey === void 0 ? 'ref' : _ref5$refKey,
2930
2946
  ref = _ref5.ref,
2931
- rest = _objectWithoutPropertiesLoose__default['default'](_ref5, ["item", "index", "onMouseMove", "onClick", "refKey", "ref"]);
2947
+ rest = _objectWithoutPropertiesLoose__default['default'](_ref5, _excluded3$1);
2932
2948
 
2933
2949
  var _latest$current = latest.current,
2934
2950
  latestState = _latest$current.state,
@@ -3264,6 +3280,11 @@ function downshiftUseComboboxReducer(state, action) {
3264
3280
  }
3265
3281
  /* eslint-enable complexity */
3266
3282
 
3283
+ var _excluded$1 = ["onMouseLeave", "refKey", "ref"],
3284
+ _excluded2$1 = ["item", "index", "refKey", "ref", "onMouseMove", "onClick", "onPress"],
3285
+ _excluded3 = ["onClick", "onPress", "refKey", "ref"],
3286
+ _excluded4 = ["onKeyDown", "onChange", "onInput", "onBlur", "onChangeText", "refKey", "ref"],
3287
+ _excluded5 = ["refKey", "ref"];
3267
3288
  useCombobox.stateChangeTypes = stateChangeTypes$1;
3268
3289
 
3269
3290
  function useCombobox(userProps) {
@@ -3434,8 +3455,8 @@ function useCombobox(userProps) {
3434
3455
 
3435
3456
  if (!latestState.isOpen || latestState.highlightedIndex < 0 || event.which === 229 // if IME composing, wait for next Enter keydown event.
3436
3457
  ) {
3437
- return;
3438
- }
3458
+ return;
3459
+ }
3439
3460
 
3440
3461
  event.preventDefault();
3441
3462
  dispatch({
@@ -3460,7 +3481,7 @@ function useCombobox(userProps) {
3460
3481
  _ref$refKey = _ref.refKey,
3461
3482
  refKey = _ref$refKey === void 0 ? 'ref' : _ref$refKey,
3462
3483
  ref = _ref.ref,
3463
- rest = _objectWithoutPropertiesLoose__default['default'](_ref, ["onMouseLeave", "refKey", "ref"]);
3484
+ rest = _objectWithoutPropertiesLoose__default['default'](_ref, _excluded$1);
3464
3485
 
3465
3486
  var _ref2 = _temp2 === void 0 ? {} : _temp2,
3466
3487
  _ref2$suppressRefErro = _ref2.suppressRefError,
@@ -3487,7 +3508,7 @@ function useCombobox(userProps) {
3487
3508
  onMouseMove = _ref3.onMouseMove,
3488
3509
  onClick = _ref3.onClick;
3489
3510
  _ref3.onPress;
3490
- var rest = _objectWithoutPropertiesLoose__default['default'](_ref3, ["item", "index", "refKey", "ref", "onMouseMove", "onClick", "onPress"]);
3511
+ var rest = _objectWithoutPropertiesLoose__default['default'](_ref3, _excluded2$1);
3491
3512
 
3492
3513
  var _latest$current = latest.current,
3493
3514
  latestProps = _latest$current.props,
@@ -3541,7 +3562,7 @@ function useCombobox(userProps) {
3541
3562
  var _ref5$refKey = _ref5.refKey,
3542
3563
  refKey = _ref5$refKey === void 0 ? 'ref' : _ref5$refKey,
3543
3564
  ref = _ref5.ref,
3544
- rest = _objectWithoutPropertiesLoose__default['default'](_ref5, ["onClick", "onPress", "refKey", "ref"]);
3565
+ rest = _objectWithoutPropertiesLoose__default['default'](_ref5, _excluded3);
3545
3566
 
3546
3567
  var toggleButtonHandleClick = function toggleButtonHandleClick() {
3547
3568
  dispatch({
@@ -3571,7 +3592,7 @@ function useCombobox(userProps) {
3571
3592
  var _ref6$refKey = _ref6.refKey,
3572
3593
  refKey = _ref6$refKey === void 0 ? 'ref' : _ref6$refKey,
3573
3594
  ref = _ref6.ref,
3574
- rest = _objectWithoutPropertiesLoose__default['default'](_ref6, ["onKeyDown", "onChange", "onInput", "onBlur", "onChangeText", "refKey", "ref"]);
3595
+ rest = _objectWithoutPropertiesLoose__default['default'](_ref6, _excluded4);
3575
3596
 
3576
3597
  var _ref7 = _temp6 === void 0 ? {} : _temp6,
3577
3598
  _ref7$suppressRefErro = _ref7.suppressRefError,
@@ -3635,7 +3656,7 @@ function useCombobox(userProps) {
3635
3656
  _ref8$refKey = _ref8.refKey,
3636
3657
  refKey = _ref8$refKey === void 0 ? 'ref' : _ref8$refKey,
3637
3658
  ref = _ref8.ref,
3638
- rest = _objectWithoutPropertiesLoose__default['default'](_ref8, ["refKey", "ref"]);
3659
+ rest = _objectWithoutPropertiesLoose__default['default'](_ref8, _excluded5);
3639
3660
 
3640
3661
  var _ref9 = _temp8 === void 0 ? {} : _temp8,
3641
3662
  _ref9$suppressRefErro = _ref9.suppressRefError,
@@ -3775,9 +3796,7 @@ function isKeyDownOperationPermitted(event) {
3775
3796
  var element = event.target;
3776
3797
 
3777
3798
  if (element instanceof HTMLInputElement && // if element is a text input
3778
- element.value !== '' && ( // and we have text in it
3779
- // and cursor is either not at the start or is currently highlighting text.
3780
- element.selectionStart !== 0 || element.selectionEnd !== 0)) {
3799
+ element.value !== '' && (element.selectionStart !== 0 || element.selectionEnd !== 0)) {
3781
3800
  return false;
3782
3801
  }
3783
3802
 
@@ -3994,6 +4013,8 @@ function downshiftMultipleSelectionReducer(state, action) {
3994
4013
  return _extends__default['default']({}, state, changes);
3995
4014
  }
3996
4015
 
4016
+ var _excluded = ["refKey", "ref", "onClick", "onKeyDown", "selectedItem", "index"],
4017
+ _excluded2 = ["refKey", "ref", "onKeyDown", "onClick", "preventKeyAction"];
3997
4018
  useMultipleSelection.stateChangeTypes = stateChangeTypes;
3998
4019
 
3999
4020
  function useMultipleSelection(userProps) {
@@ -4123,7 +4144,7 @@ function useMultipleSelection(userProps) {
4123
4144
  onKeyDown = _ref3.onKeyDown,
4124
4145
  selectedItem = _ref3.selectedItem,
4125
4146
  index = _ref3.index,
4126
- rest = _objectWithoutPropertiesLoose__default['default'](_ref3, ["refKey", "ref", "onClick", "onKeyDown", "selectedItem", "index"]);
4147
+ rest = _objectWithoutPropertiesLoose__default['default'](_ref3, _excluded);
4127
4148
 
4128
4149
  var latestState = latest.current.state;
4129
4150
  var itemIndex = getItemIndex(index, selectedItem, latestState.selectedItems);
@@ -4164,7 +4185,7 @@ function useMultipleSelection(userProps) {
4164
4185
  onClick = _ref4.onClick,
4165
4186
  _ref4$preventKeyActio = _ref4.preventKeyAction,
4166
4187
  preventKeyAction = _ref4$preventKeyActio === void 0 ? false : _ref4$preventKeyActio,
4167
- rest = _objectWithoutPropertiesLoose__default['default'](_ref4, ["refKey", "ref", "onKeyDown", "onClick", "preventKeyAction"]);
4188
+ rest = _objectWithoutPropertiesLoose__default['default'](_ref4, _excluded2);
4168
4189
 
4169
4190
  var _ref5 = _temp3 === void 0 ? {} : _temp3,
4170
4191
  _ref5$suppressRefErro = _ref5.suppressRefError,
@@ -4238,7 +4259,7 @@ function useMultipleSelection(userProps) {
4238
4259
  };
4239
4260
  }
4240
4261
 
4241
- exports.default = Downshift;
4262
+ exports['default'] = Downshift$1;
4242
4263
  exports.resetIdCounter = resetIdCounter;
4243
4264
  exports.useCombobox = useCombobox;
4244
4265
  exports.useMultipleSelection = useMultipleSelection;