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
@@ -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
  _ref3.onKeyDown;
924
934
  _ref3.onKeyUp;
925
935
  _ref3.onBlur;
926
- var rest = _objectWithoutPropertiesLoose__default['default'](_ref3, ["onClick", "onPress", "onKeyDown", "onKeyUp", "onBlur"]);
936
+ var rest = _objectWithoutPropertiesLoose__default['default'](_ref3, _excluded2$3);
927
937
 
928
938
  var _this$getState5 = _this.getState(),
929
939
  isOpen = _this$getState5.isOpen;
@@ -982,10 +992,10 @@ var Downshift = /*#__PURE__*/function () {
982
992
  _this.internalSetTimeout(function () {
983
993
  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)
984
994
  ) {
985
- _this.reset({
986
- type: blurButton
987
- });
988
- }
995
+ _this.reset({
996
+ type: blurButton
997
+ });
998
+ }
989
999
  });
990
1000
  };
991
1001
 
@@ -1003,7 +1013,7 @@ var Downshift = /*#__PURE__*/function () {
1003
1013
  onChange = _ref4.onChange,
1004
1014
  onInput = _ref4.onInput,
1005
1015
  onChangeText = _ref4.onChangeText,
1006
- rest = _objectWithoutPropertiesLoose__default['default'](_ref4, ["onKeyDown", "onBlur", "onChange", "onInput", "onChangeText"]);
1016
+ rest = _objectWithoutPropertiesLoose__default['default'](_ref4, _excluded3$2);
1007
1017
 
1008
1018
  var onChangeKey;
1009
1019
  var eventHandlers = {};
@@ -1095,7 +1105,7 @@ var Downshift = /*#__PURE__*/function () {
1095
1105
  _ref5$refKey = _ref5.refKey,
1096
1106
  refKey = _ref5$refKey === void 0 ? 'ref' : _ref5$refKey,
1097
1107
  ref = _ref5.ref,
1098
- props = _objectWithoutPropertiesLoose__default['default'](_ref5, ["refKey", "ref"]);
1108
+ props = _objectWithoutPropertiesLoose__default['default'](_ref5, _excluded4$1);
1099
1109
 
1100
1110
  var _ref6 = _temp6 === void 0 ? {} : _temp6,
1101
1111
  _ref6$suppressRefErro = _ref6.suppressRefError,
@@ -1120,7 +1130,7 @@ var Downshift = /*#__PURE__*/function () {
1120
1130
  item = _ref7$item === void 0 ? process.env.NODE_ENV === 'production' ?
1121
1131
  /* istanbul ignore next */
1122
1132
  undefined : requiredProp('getItemProps', 'item') : _ref7$item,
1123
- rest = _objectWithoutPropertiesLoose__default['default'](_ref7, ["onMouseMove", "onMouseDown", "onClick", "onPress", "index", "item"]);
1133
+ rest = _objectWithoutPropertiesLoose__default['default'](_ref7, _excluded5$1);
1124
1134
 
1125
1135
  if (index === undefined) {
1126
1136
  _this.items.push(item);
@@ -1549,9 +1559,9 @@ var Downshift = /*#__PURE__*/function () {
1549
1559
  selectedItemChanged: function selectedItemChanged(prevItem, item) {
1550
1560
  return prevItem !== item;
1551
1561
  },
1552
- environment: typeof window === 'undefined'
1562
+ environment:
1553
1563
  /* istanbul ignore next (ssr) */
1554
- ? {} : window,
1564
+ typeof window === 'undefined' ? {} : window,
1555
1565
  stateReducer: function stateReducer(state, stateToSet) {
1556
1566
  return stateToSet;
1557
1567
  },
@@ -1608,6 +1618,7 @@ process.env.NODE_ENV !== "production" ? Downshift.propTypes = {
1608
1618
  /* eslint-enable react/no-unused-prop-types */
1609
1619
 
1610
1620
  } : void 0;
1621
+ var Downshift$1 = Downshift;
1611
1622
 
1612
1623
  function validateGetMenuPropsCalledCorrectly(node, _ref12) {
1613
1624
  var refKey = _ref12.refKey;
@@ -1637,6 +1648,7 @@ function validateGetRootPropsCalledCorrectly(element, _ref13) {
1637
1648
  }
1638
1649
  }
1639
1650
 
1651
+ var _excluded$3 = ["isInitialMount", "highlightedIndex", "items", "environment"];
1640
1652
  var dropdownDefaultStateValues = {
1641
1653
  highlightedIndex: -1,
1642
1654
  isOpen: false,
@@ -1834,9 +1846,9 @@ var defaultProps$3 = {
1834
1846
  getA11ySelectionMessage: getA11ySelectionMessage,
1835
1847
  scrollIntoView: scrollIntoView,
1836
1848
  circularNavigation: false,
1837
- environment: typeof window === 'undefined'
1849
+ environment:
1838
1850
  /* istanbul ignore next (ssr) */
1839
- ? {} : window
1851
+ typeof window === 'undefined' ? {} : window
1840
1852
  };
1841
1853
 
1842
1854
  function getDefaultValue$1(props, propKey, defaultStateValues) {
@@ -1962,7 +1974,7 @@ function useMouseAndTouchTracker(isOpen, downshiftElementRefs, environment, hand
1962
1974
  var onTouchEnd = function onTouchEnd(event) {
1963
1975
  if (isOpen && !mouseAndTouchTrackersRef.current.isTouchMove && !targetWithinDownshift(event.target, downshiftElementRefs.map(function (ref) {
1964
1976
  return ref.current;
1965
- }), environment.document, false)) {
1977
+ }), environment, false)) {
1966
1978
  handleBlur();
1967
1979
  }
1968
1980
  };
@@ -2050,11 +2062,11 @@ function useA11yMessageSetter(getA11yMessage, dependencyArray, _ref2) {
2050
2062
  highlightedIndex = _ref2.highlightedIndex,
2051
2063
  items = _ref2.items,
2052
2064
  environment = _ref2.environment,
2053
- rest = _objectWithoutPropertiesLoose__default['default'](_ref2, ["isInitialMount", "highlightedIndex", "items", "environment"]);
2065
+ rest = _objectWithoutPropertiesLoose__default['default'](_ref2, _excluded$3);
2054
2066
 
2055
2067
  // Sets a11y status message on changes in state.
2056
2068
  react.useEffect(function () {
2057
- if (isInitialMount) {
2069
+ if (isInitialMount || true) {
2058
2070
  return;
2059
2071
  }
2060
2072
 
@@ -2185,58 +2197,57 @@ function downshiftCommonReducer(state, action, stateChangeTypes) {
2185
2197
  }
2186
2198
  /* eslint-enable complexity */
2187
2199
 
2188
- function getItemIndexByCharacterKey(keysSoFar, highlightedIndex, items, itemToString, getItemNodeFromIndex) {
2189
- var lowerCasedKeysSoFar = keysSoFar.toLowerCase();
2190
-
2191
- for (var index = 0; index < items.length; index++) {
2192
- var offsetIndex = (index + highlightedIndex + 1) % items.length;
2193
-
2194
- if (itemToString(items[offsetIndex]).toLowerCase().startsWith(lowerCasedKeysSoFar)) {
2195
- var element = getItemNodeFromIndex(offsetIndex);
2196
-
2197
- if (!(element && element.hasAttribute('disabled'))) {
2198
- return offsetIndex;
2199
- }
2200
+ function getItemIndexByCharacterKey({ keysSoFar, highlightedIndex, items, itemToString, getItemNodeFromIndex, }) {
2201
+ const lowerCasedKeysSoFar = keysSoFar.toLowerCase();
2202
+ for (let index = 0; index < items.length; index++) {
2203
+ const offsetIndex = (index + highlightedIndex + 1) % items.length;
2204
+ const item = items[offsetIndex];
2205
+ if (item !== undefined &&
2206
+ itemToString(item)
2207
+ .toLowerCase()
2208
+ .startsWith(lowerCasedKeysSoFar)) {
2209
+ const element = getItemNodeFromIndex(offsetIndex);
2210
+ if (!element?.hasAttribute('disabled')) {
2211
+ return offsetIndex;
2212
+ }
2213
+ }
2200
2214
  }
2201
- }
2202
-
2203
- return highlightedIndex;
2215
+ return highlightedIndex;
2204
2216
  }
2205
-
2206
- var propTypes$2 = {
2207
- items: PropTypes__default['default'].array.isRequired,
2208
- itemToString: PropTypes__default['default'].func,
2209
- getA11yStatusMessage: PropTypes__default['default'].func,
2210
- getA11ySelectionMessage: PropTypes__default['default'].func,
2211
- circularNavigation: PropTypes__default['default'].bool,
2212
- highlightedIndex: PropTypes__default['default'].number,
2213
- defaultHighlightedIndex: PropTypes__default['default'].number,
2214
- initialHighlightedIndex: PropTypes__default['default'].number,
2215
- isOpen: PropTypes__default['default'].bool,
2216
- defaultIsOpen: PropTypes__default['default'].bool,
2217
- initialIsOpen: PropTypes__default['default'].bool,
2218
- selectedItem: PropTypes__default['default'].any,
2219
- initialSelectedItem: PropTypes__default['default'].any,
2220
- defaultSelectedItem: PropTypes__default['default'].any,
2221
- id: PropTypes__default['default'].string,
2222
- labelId: PropTypes__default['default'].string,
2223
- menuId: PropTypes__default['default'].string,
2224
- getItemId: PropTypes__default['default'].func,
2225
- toggleButtonId: PropTypes__default['default'].string,
2226
- stateReducer: PropTypes__default['default'].func,
2227
- onSelectedItemChange: PropTypes__default['default'].func,
2228
- onHighlightedIndexChange: PropTypes__default['default'].func,
2229
- onStateChange: PropTypes__default['default'].func,
2230
- onIsOpenChange: PropTypes__default['default'].func,
2231
- environment: PropTypes__default['default'].shape({
2232
- addEventListener: PropTypes__default['default'].func,
2233
- removeEventListener: PropTypes__default['default'].func,
2234
- document: PropTypes__default['default'].shape({
2235
- getElementById: PropTypes__default['default'].func,
2236
- activeElement: PropTypes__default['default'].any,
2237
- body: PropTypes__default['default'].any
2238
- })
2239
- })
2217
+ const propTypes$2 = {
2218
+ items: PropTypes__default['default'].array.isRequired,
2219
+ itemToString: PropTypes__default['default'].func,
2220
+ getA11yStatusMessage: PropTypes__default['default'].func,
2221
+ getA11ySelectionMessage: PropTypes__default['default'].func,
2222
+ circularNavigation: PropTypes__default['default'].bool,
2223
+ highlightedIndex: PropTypes__default['default'].number,
2224
+ defaultHighlightedIndex: PropTypes__default['default'].number,
2225
+ initialHighlightedIndex: PropTypes__default['default'].number,
2226
+ isOpen: PropTypes__default['default'].bool,
2227
+ defaultIsOpen: PropTypes__default['default'].bool,
2228
+ initialIsOpen: PropTypes__default['default'].bool,
2229
+ selectedItem: PropTypes__default['default'].any,
2230
+ initialSelectedItem: PropTypes__default['default'].any,
2231
+ defaultSelectedItem: PropTypes__default['default'].any,
2232
+ id: PropTypes__default['default'].string,
2233
+ labelId: PropTypes__default['default'].string,
2234
+ menuId: PropTypes__default['default'].string,
2235
+ getItemId: PropTypes__default['default'].func,
2236
+ toggleButtonId: PropTypes__default['default'].string,
2237
+ stateReducer: PropTypes__default['default'].func,
2238
+ onSelectedItemChange: PropTypes__default['default'].func,
2239
+ onHighlightedIndexChange: PropTypes__default['default'].func,
2240
+ onStateChange: PropTypes__default['default'].func,
2241
+ onIsOpenChange: PropTypes__default['default'].func,
2242
+ environment: PropTypes__default['default'].shape({
2243
+ addEventListener: PropTypes__default['default'].func,
2244
+ removeEventListener: PropTypes__default['default'].func,
2245
+ document: PropTypes__default['default'].shape({
2246
+ getElementById: PropTypes__default['default'].func,
2247
+ activeElement: PropTypes__default['default'].any,
2248
+ body: PropTypes__default['default'].any,
2249
+ }),
2250
+ }),
2240
2251
  };
2241
2252
  /**
2242
2253
  * Default implementation for status message. Only added when menu is open.
@@ -2246,39 +2257,29 @@ var propTypes$2 = {
2246
2257
  * @param {Object} param the downshift state and other relevant properties
2247
2258
  * @return {String} the a11y status message
2248
2259
  */
2249
-
2250
- function getA11yStatusMessage(_ref) {
2251
- var isOpen = _ref.isOpen,
2252
- resultCount = _ref.resultCount,
2253
- previousResultCount = _ref.previousResultCount;
2254
-
2255
- if (!isOpen) {
2260
+ function getA11yStatusMessage({ isOpen, resultCount, previousResultCount, }) {
2261
+ if (!isOpen) {
2262
+ return '';
2263
+ }
2264
+ if (!resultCount) {
2265
+ return 'No results are available.';
2266
+ }
2267
+ if (resultCount !== previousResultCount) {
2268
+ 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.`;
2269
+ }
2256
2270
  return '';
2257
- }
2258
-
2259
- if (!resultCount) {
2260
- return 'No results are available.';
2261
- }
2262
-
2263
- if (resultCount !== previousResultCount) {
2264
- 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.";
2265
- }
2266
-
2267
- return '';
2268
2271
  }
2269
-
2270
- var defaultProps$2 = _extends__default['default']({}, defaultProps$3, {
2271
- getA11yStatusMessage: getA11yStatusMessage
2272
- }); // eslint-disable-next-line import/no-mutable-exports
2273
-
2274
-
2275
- var validatePropTypes$2 = noop;
2272
+ const defaultProps$2 = {
2273
+ ...defaultProps$3,
2274
+ getA11yStatusMessage,
2275
+ };
2276
+ // eslint-disable-next-line import/no-mutable-exports
2277
+ let validatePropTypes$2 = noop;
2276
2278
  /* istanbul ignore next */
2277
-
2278
2279
  if (process.env.NODE_ENV !== 'production') {
2279
- validatePropTypes$2 = function validatePropTypes(options, caller) {
2280
- PropTypes__default['default'].checkPropTypes(propTypes$2, options, 'prop', caller.name);
2281
- };
2280
+ validatePropTypes$2 = (options, caller) => {
2281
+ PropTypes__default['default'].checkPropTypes(propTypes$2, options, 'prop', caller.name);
2282
+ };
2282
2283
  }
2283
2284
 
2284
2285
  var MenuKeyDownArrowDown = process.env.NODE_ENV !== "production" ? '__menu_keydown_arrow_down__' : 0;
@@ -2353,7 +2354,13 @@ function downshiftSelectReducer(state, action) {
2353
2354
  {
2354
2355
  var lowercasedKey = action.key;
2355
2356
  var inputValue = "" + state.inputValue + lowercasedKey;
2356
- var itemIndex = getItemIndexByCharacterKey(inputValue, state.selectedItem ? props.items.indexOf(state.selectedItem) : -1, props.items, props.itemToString, action.getItemNodeFromIndex);
2357
+ var itemIndex = getItemIndexByCharacterKey({
2358
+ keysSoFar: inputValue,
2359
+ highlightedIndex: state.selectedItem ? props.items.indexOf(state.selectedItem) : -1,
2360
+ items: props.items,
2361
+ itemToString: props.itemToString,
2362
+ getItemNodeFromIndex: action.getItemNodeFromIndex
2363
+ });
2357
2364
  changes = _extends__default['default']({
2358
2365
  inputValue: inputValue
2359
2366
  }, itemIndex >= 0 && {
@@ -2418,7 +2425,13 @@ function downshiftSelectReducer(state, action) {
2418
2425
 
2419
2426
  var _inputValue = "" + state.inputValue + _lowercasedKey;
2420
2427
 
2421
- var highlightedIndex = getItemIndexByCharacterKey(_inputValue, state.highlightedIndex, props.items, props.itemToString, action.getItemNodeFromIndex);
2428
+ var highlightedIndex = getItemIndexByCharacterKey({
2429
+ keysSoFar: _inputValue,
2430
+ highlightedIndex: state.highlightedIndex,
2431
+ items: props.items,
2432
+ itemToString: props.itemToString,
2433
+ getItemNodeFromIndex: action.getItemNodeFromIndex
2434
+ });
2422
2435
  changes = _extends__default['default']({
2423
2436
  inputValue: _inputValue
2424
2437
  }, highlightedIndex >= 0 && {
@@ -2453,6 +2466,9 @@ function downshiftSelectReducer(state, action) {
2453
2466
  }
2454
2467
  /* eslint-enable complexity */
2455
2468
 
2469
+ var _excluded$2 = ["onMouseLeave", "refKey", "onKeyDown", "onBlur", "ref"],
2470
+ _excluded2$2 = ["onClick", "onKeyDown", "refKey", "ref"],
2471
+ _excluded3$1 = ["item", "index", "onMouseMove", "onClick", "refKey", "ref"];
2456
2472
  useSelect.stateChangeTypes = stateChangeTypes$2;
2457
2473
 
2458
2474
  function useSelect(userProps) {
@@ -2743,7 +2759,7 @@ function useSelect(userProps) {
2743
2759
  onKeyDown = _ref.onKeyDown,
2744
2760
  onBlur = _ref.onBlur,
2745
2761
  ref = _ref.ref,
2746
- rest = _objectWithoutPropertiesLoose__default['default'](_ref, ["onMouseLeave", "refKey", "onKeyDown", "onBlur", "ref"]);
2762
+ rest = _objectWithoutPropertiesLoose__default['default'](_ref, _excluded$2);
2747
2763
 
2748
2764
  var _ref2 = _temp2 === void 0 ? {} : _temp2,
2749
2765
  _ref2$suppressRefErro = _ref2.suppressRefError,
@@ -2808,7 +2824,7 @@ function useSelect(userProps) {
2808
2824
  _ref3$refKey = _ref3.refKey,
2809
2825
  refKey = _ref3$refKey === void 0 ? 'ref' : _ref3$refKey,
2810
2826
  ref = _ref3.ref,
2811
- rest = _objectWithoutPropertiesLoose__default['default'](_ref3, ["onClick", "onKeyDown", "refKey", "ref"]);
2827
+ rest = _objectWithoutPropertiesLoose__default['default'](_ref3, _excluded2$2);
2812
2828
 
2813
2829
  var _ref4 = _temp4 === void 0 ? {} : _temp4,
2814
2830
  _ref4$suppressRefErro = _ref4.suppressRefError,
@@ -2857,7 +2873,7 @@ function useSelect(userProps) {
2857
2873
  _ref5$refKey = _ref5.refKey,
2858
2874
  refKey = _ref5$refKey === void 0 ? 'ref' : _ref5$refKey,
2859
2875
  ref = _ref5.ref,
2860
- rest = _objectWithoutPropertiesLoose__default['default'](_ref5, ["item", "index", "onMouseMove", "onClick", "refKey", "ref"]);
2876
+ rest = _objectWithoutPropertiesLoose__default['default'](_ref5, _excluded3$1);
2861
2877
 
2862
2878
  var _latest$current = latest.current,
2863
2879
  latestState = _latest$current.state,
@@ -3193,6 +3209,11 @@ function downshiftUseComboboxReducer(state, action) {
3193
3209
  }
3194
3210
  /* eslint-enable complexity */
3195
3211
 
3212
+ var _excluded$1 = ["onMouseLeave", "refKey", "ref"],
3213
+ _excluded2$1 = ["item", "index", "refKey", "ref", "onMouseMove", "onClick", "onPress"],
3214
+ _excluded3 = ["onClick", "onPress", "refKey", "ref"],
3215
+ _excluded4 = ["onKeyDown", "onChange", "onInput", "onBlur", "onChangeText", "refKey", "ref"],
3216
+ _excluded5 = ["refKey", "ref"];
3196
3217
  useCombobox.stateChangeTypes = stateChangeTypes$1;
3197
3218
 
3198
3219
  function useCombobox(userProps) {
@@ -3363,8 +3384,8 @@ function useCombobox(userProps) {
3363
3384
 
3364
3385
  if (!latestState.isOpen || latestState.highlightedIndex < 0 || event.which === 229 // if IME composing, wait for next Enter keydown event.
3365
3386
  ) {
3366
- return;
3367
- }
3387
+ return;
3388
+ }
3368
3389
 
3369
3390
  event.preventDefault();
3370
3391
  dispatch({
@@ -3389,7 +3410,7 @@ function useCombobox(userProps) {
3389
3410
  _ref$refKey = _ref.refKey,
3390
3411
  refKey = _ref$refKey === void 0 ? 'ref' : _ref$refKey,
3391
3412
  ref = _ref.ref,
3392
- rest = _objectWithoutPropertiesLoose__default['default'](_ref, ["onMouseLeave", "refKey", "ref"]);
3413
+ rest = _objectWithoutPropertiesLoose__default['default'](_ref, _excluded$1);
3393
3414
 
3394
3415
  var _ref2 = _temp2 === void 0 ? {} : _temp2,
3395
3416
  _ref2$suppressRefErro = _ref2.suppressRefError,
@@ -3416,7 +3437,7 @@ function useCombobox(userProps) {
3416
3437
  onMouseMove = _ref3.onMouseMove;
3417
3438
  _ref3.onClick;
3418
3439
  var onPress = _ref3.onPress,
3419
- rest = _objectWithoutPropertiesLoose__default['default'](_ref3, ["item", "index", "refKey", "ref", "onMouseMove", "onClick", "onPress"]);
3440
+ rest = _objectWithoutPropertiesLoose__default['default'](_ref3, _excluded2$1);
3420
3441
 
3421
3442
  var _latest$current = latest.current,
3422
3443
  latestProps = _latest$current.props,
@@ -3472,7 +3493,7 @@ function useCombobox(userProps) {
3472
3493
  _ref5$refKey = _ref5.refKey,
3473
3494
  refKey = _ref5$refKey === void 0 ? 'ref' : _ref5$refKey,
3474
3495
  ref = _ref5.ref,
3475
- rest = _objectWithoutPropertiesLoose__default['default'](_ref5, ["onClick", "onPress", "refKey", "ref"]);
3496
+ rest = _objectWithoutPropertiesLoose__default['default'](_ref5, _excluded3);
3476
3497
 
3477
3498
  var toggleButtonHandleClick = function toggleButtonHandleClick() {
3478
3499
  dispatch({
@@ -3503,7 +3524,7 @@ function useCombobox(userProps) {
3503
3524
  _ref6$refKey = _ref6.refKey,
3504
3525
  refKey = _ref6$refKey === void 0 ? 'ref' : _ref6$refKey,
3505
3526
  ref = _ref6.ref,
3506
- rest = _objectWithoutPropertiesLoose__default['default'](_ref6, ["onKeyDown", "onChange", "onInput", "onBlur", "onChangeText", "refKey", "ref"]);
3527
+ rest = _objectWithoutPropertiesLoose__default['default'](_ref6, _excluded4);
3507
3528
 
3508
3529
  var _ref7 = _temp6 === void 0 ? {} : _temp6,
3509
3530
  _ref7$suppressRefErro = _ref7.suppressRefError,
@@ -3581,7 +3602,7 @@ function useCombobox(userProps) {
3581
3602
  _ref8$refKey = _ref8.refKey,
3582
3603
  refKey = _ref8$refKey === void 0 ? 'ref' : _ref8$refKey,
3583
3604
  ref = _ref8.ref,
3584
- rest = _objectWithoutPropertiesLoose__default['default'](_ref8, ["refKey", "ref"]);
3605
+ rest = _objectWithoutPropertiesLoose__default['default'](_ref8, _excluded5);
3585
3606
 
3586
3607
  var _ref9 = _temp8 === void 0 ? {} : _temp8,
3587
3608
  _ref9$suppressRefErro = _ref9.suppressRefError,
@@ -3721,9 +3742,7 @@ function isKeyDownOperationPermitted(event) {
3721
3742
  var element = event.target;
3722
3743
 
3723
3744
  if (element instanceof HTMLInputElement && // if element is a text input
3724
- element.value !== '' && ( // and we have text in it
3725
- // and cursor is either not at the start or is currently highlighting text.
3726
- element.selectionStart !== 0 || element.selectionEnd !== 0)) {
3745
+ element.value !== '' && (element.selectionStart !== 0 || element.selectionEnd !== 0)) {
3727
3746
  return false;
3728
3747
  }
3729
3748
 
@@ -3940,6 +3959,8 @@ function downshiftMultipleSelectionReducer(state, action) {
3940
3959
  return _extends__default['default']({}, state, changes);
3941
3960
  }
3942
3961
 
3962
+ var _excluded = ["refKey", "ref", "onClick", "onKeyDown", "selectedItem", "index"],
3963
+ _excluded2 = ["refKey", "ref", "onKeyDown", "onClick", "preventKeyAction"];
3943
3964
  useMultipleSelection.stateChangeTypes = stateChangeTypes;
3944
3965
 
3945
3966
  function useMultipleSelection(userProps) {
@@ -4069,7 +4090,7 @@ function useMultipleSelection(userProps) {
4069
4090
  onKeyDown = _ref3.onKeyDown,
4070
4091
  selectedItem = _ref3.selectedItem,
4071
4092
  index = _ref3.index,
4072
- rest = _objectWithoutPropertiesLoose__default['default'](_ref3, ["refKey", "ref", "onClick", "onKeyDown", "selectedItem", "index"]);
4093
+ rest = _objectWithoutPropertiesLoose__default['default'](_ref3, _excluded);
4073
4094
 
4074
4095
  var latestState = latest.current.state;
4075
4096
  var itemIndex = getItemIndex(index, selectedItem, latestState.selectedItems);
@@ -4110,7 +4131,7 @@ function useMultipleSelection(userProps) {
4110
4131
  onClick = _ref4.onClick,
4111
4132
  _ref4$preventKeyActio = _ref4.preventKeyAction,
4112
4133
  preventKeyAction = _ref4$preventKeyActio === void 0 ? false : _ref4$preventKeyActio,
4113
- rest = _objectWithoutPropertiesLoose__default['default'](_ref4, ["refKey", "ref", "onKeyDown", "onClick", "preventKeyAction"]);
4134
+ rest = _objectWithoutPropertiesLoose__default['default'](_ref4, _excluded2);
4114
4135
 
4115
4136
  var _ref5 = _temp3 === void 0 ? {} : _temp3,
4116
4137
  _ref5$suppressRefErro = _ref5.suppressRefError,
@@ -4184,7 +4205,7 @@ function useMultipleSelection(userProps) {
4184
4205
  };
4185
4206
  }
4186
4207
 
4187
- exports.default = Downshift;
4208
+ exports['default'] = Downshift$1;
4188
4209
  exports.resetIdCounter = resetIdCounter;
4189
4210
  exports.useCombobox = useCombobox;
4190
4211
  exports.useMultipleSelection = useMultipleSelection;