downshift 3.1.1 β†’ 3.1.5

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.
package/README.md CHANGED
@@ -19,7 +19,7 @@ autocomplete/dropdown/select/combobox components</p>
19
19
  [![downloads][downloads-badge]][npmcharts] [![version][version-badge]][package]
20
20
  [![MIT License][license-badge]][license]
21
21
 
22
- [![All Contributors](https://img.shields.io/badge/all_contributors-100-orange.svg?style=flat-square)](#contributors)
22
+ [![All Contributors](https://img.shields.io/badge/all_contributors-102-orange.svg?style=flat-square)](#contributors)
23
23
  [![PRs Welcome][prs-badge]][prs] [![Chat][chat-badge]][chat]
24
24
  [![Code of Conduct][coc-badge]][coc]
25
25
  [![Join the community on Spectrum][spectrum-badge]][spectrum]
@@ -603,7 +603,9 @@ function). However, if you're rendering a composite component (custom component)
603
603
  as the root element, then you'll need to call `getRootProps` and apply that to
604
604
  your root element (downshift will throw an error otherwise).
605
605
 
606
- Required properties:
606
+ There are no required properties for this method.
607
+
608
+ Optional properties:
607
609
 
608
610
  - `refKey`: if you're rendering a composite component, that component will need
609
611
  to accept a prop which it forwards to the root DOM element. Commonly, folks
@@ -1076,7 +1078,7 @@ Thanks goes to these people ([emoji key][emojis]):
1076
1078
  | [<img src="https://avatars3.githubusercontent.com/u/5456216?v=4" width="100px;"/><br /><sub><b>Cameron Edwards</b></sub>](http://cameronpedwards.com)<br />[πŸ’»](https://github.com/paypal/downshift/commits?author=cameronprattedwards "Code") [⚠️](https://github.com/paypal/downshift/commits?author=cameronprattedwards "Tests") | [<img src="https://avatars2.githubusercontent.com/u/179534?v=4" width="100px;"/><br /><sub><b>stereobooster</b></sub>](https://github.com/stereobooster)<br />[πŸ’»](https://github.com/paypal/downshift/commits?author=stereobooster "Code") [⚠️](https://github.com/paypal/downshift/commits?author=stereobooster "Tests") | [<img src="https://avatars0.githubusercontent.com/u/934879?v=4" width="100px;"/><br /><sub><b>Trevor Pierce</b></sub>](https://github.com/1Copenut)<br />[πŸ‘€](#review-1Copenut "Reviewed Pull Requests") | [<img src="https://avatars1.githubusercontent.com/u/1334982?v=4" width="100px;"/><br /><sub><b>Xuefei Li</b></sub>](http://xuefei-frank.com)<br />[πŸ’»](https://github.com/paypal/downshift/commits?author=franklixuefei "Code") | [<img src="https://avatars0.githubusercontent.com/u/7252803?v=4" width="100px;"/><br /><sub><b>Alfred Ringstad</b></sub>](https://hyperlab.se)<br />[πŸ’»](https://github.com/paypal/downshift/commits?author=alfredringstad "Code") | [<img src="https://avatars0.githubusercontent.com/u/6895497?v=4" width="100px;"/><br /><sub><b>D[oa]vid Weisz</b></sub>](https://github.com/dovidweisz)<br />[πŸ’»](https://github.com/paypal/downshift/commits?author=dovidweisz "Code") | [<img src="https://avatars0.githubusercontent.com/u/19773?v=4" width="100px;"/><br /><sub><b>Royston Shufflebotham</b></sub>](https://github.com/RoystonS)<br />[πŸ›](https://github.com/paypal/downshift/issues?q=author%3ARoystonS "Bug reports") [πŸ’»](https://github.com/paypal/downshift/commits?author=RoystonS "Code") |
1077
1079
  | [<img src="https://avatars3.githubusercontent.com/u/6643991?v=4" width="100px;"/><br /><sub><b>MichaΓ«l De Boey</b></sub>](http://michaeldeboey.be)<br />[πŸ’»](https://github.com/paypal/downshift/commits?author=MichaelDeBoey "Code") | [<img src="https://avatars3.githubusercontent.com/u/4412771?v=4" width="100px;"/><br /><sub><b>Henry</b></sub>](https://github.com/EricHenry)<br />[πŸ’»](https://github.com/paypal/downshift/commits?author=EricHenry "Code") | [<img src="https://avatars3.githubusercontent.com/u/2180127?v=4" width="100px;"/><br /><sub><b>Andrew Walton</b></sub>](http://www.greenarrow.me)<br />[πŸ›](https://github.com/paypal/downshift/issues?q=author%3Agreen-arrow "Bug reports") [πŸ’»](https://github.com/paypal/downshift/commits?author=green-arrow "Code") [⚠️](https://github.com/paypal/downshift/commits?author=green-arrow "Tests") | [<img src="https://avatars0.githubusercontent.com/u/13774309?v=4" width="100px;"/><br /><sub><b>Arthur Denner</b></sub>](https://github.com/arthurdenner)<br />[πŸ’»](https://github.com/paypal/downshift/commits?author=arthurdenner "Code") | [<img src="https://avatars2.githubusercontent.com/u/81981?v=4" width="100px;"/><br /><sub><b>Cody Olsen</b></sub>](http://twitter.com/stipsan)<br />[πŸ’»](https://github.com/paypal/downshift/commits?author=stipsan "Code") | [<img src="https://avatars0.githubusercontent.com/u/5084492?v=4" width="100px;"/><br /><sub><b>Thomas Ladd</b></sub>](https://github.com/TLadd)<br />[πŸ’»](https://github.com/paypal/downshift/commits?author=TLadd "Code") | [<img src="https://avatars3.githubusercontent.com/u/34634369?v=4" width="100px;"/><br /><sub><b>lixualinta</b></sub>](https://github.com/lixualinta)<br />[πŸ’»](https://github.com/paypal/downshift/commits?author=lixualinta "Code") |
1078
1080
  | [<img src="https://avatars2.githubusercontent.com/u/2118956?v=4" width="100px;"/><br /><sub><b>Jacob Cofman</b></sub>](https://twitter.com/JCofman)<br />[πŸ’»](https://github.com/paypal/downshift/commits?author=JCofman "Code") | [<img src="https://avatars3.githubusercontent.com/u/19275184?v=4" width="100px;"/><br /><sub><b>Joshua Freedman</b></sub>](https://github.com/jf248)<br />[πŸ’»](https://github.com/paypal/downshift/commits?author=jf248 "Code") | [<img src="https://avatars1.githubusercontent.com/u/24494020?v=4" width="100px;"/><br /><sub><b>Amy</b></sub>](https://github.com/AmyScript)<br />[πŸ’‘](#example-AmyScript "Examples") | [<img src="https://avatars1.githubusercontent.com/u/9063669?v=4" width="100px;"/><br /><sub><b>Rogin Farrer</b></sub>](http://twitter.com/roginfarrer)<br />[πŸ’»](https://github.com/paypal/downshift/commits?author=roginfarrer "Code") | [<img src="https://avatars3.githubusercontent.com/u/871583" width="100px;"/><br /><sub><b>Dmitrii Kanatnikov</b></sub>](https://github.com/rifler)<br />[πŸ’»](https://github.com/paypal/downshift/commits?author=rifler "Code") | [<img src="https://avatars2.githubusercontent.com/u/346300?v=4" width="100px;"/><br /><sub><b>Dallon Feldner</b></sub>](https://github.com/dallonf)<br />[πŸ›](https://github.com/paypal/downshift/issues?q=author%3Adallonf "Bug reports") [πŸ’»](https://github.com/paypal/downshift/commits?author=dallonf "Code") | [<img src="https://avatars2.githubusercontent.com/u/10165959?v=4" width="100px;"/><br /><sub><b>Samuel Fuller Thomas</b></sub>](https://samuelfullerthomas.com)<br />[πŸ’»](https://github.com/paypal/downshift/commits?author=samuelfullerthomas "Code") |
1079
- | [<img src="https://avatars1.githubusercontent.com/u/2430381?v=4" width="100px;"/><br /><sub><b>Ryan Castner</b></sub>](http://audiolion.github.io)<br />[πŸ’»](https://github.com/paypal/downshift/commits?author=audiolion "Code") | [<img src="https://avatars2.githubusercontent.com/u/11275392?v=4" width="100px;"/><br /><sub><b>Silviu Alexandru Avram</b></sub>](https://github.com/silviuavram)<br />[πŸ›](https://github.com/paypal/downshift/issues?q=author%3Asilviuavram "Bug reports") [πŸ’»](https://github.com/paypal/downshift/commits?author=silviuavram "Code") [⚠️](https://github.com/paypal/downshift/commits?author=silviuavram "Tests") |
1081
+ | [<img src="https://avatars1.githubusercontent.com/u/2430381?v=4" width="100px;"/><br /><sub><b>Ryan Castner</b></sub>](http://audiolion.github.io)<br />[πŸ’»](https://github.com/paypal/downshift/commits?author=audiolion "Code") | [<img src="https://avatars2.githubusercontent.com/u/11275392?v=4" width="100px;"/><br /><sub><b>Silviu Alexandru Avram</b></sub>](https://github.com/silviuavram)<br />[πŸ›](https://github.com/paypal/downshift/issues?q=author%3Asilviuavram "Bug reports") [πŸ’»](https://github.com/paypal/downshift/commits?author=silviuavram "Code") [⚠️](https://github.com/paypal/downshift/commits?author=silviuavram "Tests") | [<img src="https://avatars1.githubusercontent.com/u/15676655?v=4" width="100px;"/><br /><sub><b>Anton Volkov</b></sub>](https://github.com/akronb)<br />[πŸ’»](https://github.com/paypal/downshift/commits?author=akronb "Code") [⚠️](https://github.com/paypal/downshift/commits?author=akronb "Tests") | [<img src="https://avatars3.githubusercontent.com/u/513363?v=4" width="100px;"/><br /><sub><b>Keegan Street</b></sub>](http://keegan.st)<br />[πŸ›](https://github.com/paypal/downshift/issues?q=author%3Akeeganstreet "Bug reports") [πŸ’»](https://github.com/paypal/downshift/commits?author=keeganstreet "Code") |
1080
1082
 
1081
1083
  <!-- ALL-CONTRIBUTORS-LIST:END -->
1082
1084
 
@@ -12,6 +12,7 @@ var _assertThisInitialized = _interopDefault(require('@babel/runtime/helpers/ass
12
12
  var React = require('react');
13
13
  var React__default = _interopDefault(React);
14
14
  var PropTypes = _interopDefault(require('prop-types'));
15
+ var reactIs = require('react-is');
15
16
 
16
17
  // istanbul ignore next
17
18
  var statusDiv = typeof document === 'undefined' ? null : document.getElementById('a11y-status-message');
@@ -97,7 +98,7 @@ var keyDownSpaceButton = process.env.NODE_ENV !== "production" ? '__autocomplete
97
98
  var clickButton = process.env.NODE_ENV !== "production" ? '__autocomplete_click_button__' : 11;
98
99
  var blurButton = process.env.NODE_ENV !== "production" ? '__autocomplete_blur_button__' : 12;
99
100
  var controlledPropUpdatedSelectedItem = process.env.NODE_ENV !== "production" ? '__autocomplete_controlled_prop_updated_selected_item__' : 13;
100
- var touchStart = process.env.NODE_ENV !== "production" ? '__autocomplete_touchstart__' : 14;
101
+ var touchEnd = process.env.NODE_ENV !== "production" ? '__autocomplete_touchend__' : 14;
101
102
 
102
103
  var stateChangeTypes = /*#__PURE__*/Object.freeze({
103
104
  unknown: unknown,
@@ -114,7 +115,7 @@ var stateChangeTypes = /*#__PURE__*/Object.freeze({
114
115
  clickButton: clickButton,
115
116
  blurButton: blurButton,
116
117
  controlledPropUpdatedSelectedItem: controlledPropUpdatedSelectedItem,
117
- touchStart: touchStart
118
+ touchEnd: touchEnd
118
119
  });
119
120
 
120
121
  var idCounter = 0;
@@ -1278,14 +1279,25 @@ function (_Component) {
1278
1279
  }; // Touching an element in iOS gives focus and hover states, but touching out of
1279
1280
  // the element will remove hover, and persist the focus state, resulting in the
1280
1281
  // blur event not being triggered.
1282
+ // this.isTouchMove helps us track whether the user is tapping or swiping on a touch screen.
1283
+ // If the user taps outside of Downshift, the component should be reset,
1284
+ // but not if the user is swiping
1281
1285
 
1282
1286
 
1283
- var onTouchStart = function (event) {
1287
+ var onTouchStart = function () {
1288
+ _this4.isTouchMove = false;
1289
+ };
1290
+
1291
+ var onTouchMove = function () {
1292
+ _this4.isTouchMove = true;
1293
+ };
1294
+
1295
+ var onTouchEnd = function (event) {
1284
1296
  var contextWithinDownshift = targetWithinDownshift(event.target, false);
1285
1297
 
1286
- if (!contextWithinDownshift && _this4.getState().isOpen) {
1298
+ if (!_this4.isTouchMove && !contextWithinDownshift && _this4.getState().isOpen) {
1287
1299
  _this4.reset({
1288
- type: touchStart
1300
+ type: touchEnd
1289
1301
  }, function () {
1290
1302
  return _this4.props.onOuterClick(_this4.getStateAndHelpers());
1291
1303
  });
@@ -1295,6 +1307,8 @@ function (_Component) {
1295
1307
  this.props.environment.addEventListener('mousedown', onMouseDown);
1296
1308
  this.props.environment.addEventListener('mouseup', onMouseUp);
1297
1309
  this.props.environment.addEventListener('touchstart', onTouchStart);
1310
+ this.props.environment.addEventListener('touchmove', onTouchMove);
1311
+ this.props.environment.addEventListener('touchend', onTouchEnd);
1298
1312
 
1299
1313
  this.cleanup = function () {
1300
1314
  _this4.internalClearTimeouts();
@@ -1306,6 +1320,10 @@ function (_Component) {
1306
1320
  _this4.props.environment.removeEventListener('mouseup', onMouseUp);
1307
1321
 
1308
1322
  _this4.props.environment.removeEventListener('touchstart', onTouchStart);
1323
+
1324
+ _this4.props.environment.removeEventListener('touchmove', onTouchMove);
1325
+
1326
+ _this4.props.environment.removeEventListener('touchend', onTouchEnd);
1309
1327
  };
1310
1328
  }
1311
1329
  };
@@ -1494,7 +1512,7 @@ function validateGetRootPropsCalledCorrectly(element, _ref11) {
1494
1512
  var refKeySpecified = refKey !== 'ref';
1495
1513
  var isComposite = !isDOMElement(element);
1496
1514
 
1497
- if (isComposite && !refKeySpecified) {
1515
+ if (isComposite && !refKeySpecified && !reactIs.isForwardRef(element)) {
1498
1516
  // eslint-disable-next-line no-console
1499
1517
  console.error('downshift: You returned a non-DOM element. You must specify a refKey in getRootProps');
1500
1518
  } else if (!isComposite && refKeySpecified) {
@@ -1502,7 +1520,7 @@ function validateGetRootPropsCalledCorrectly(element, _ref11) {
1502
1520
  console.error("downshift: You returned a DOM element. You should not specify a refKey in getRootProps. You specified \"" + refKey + "\"");
1503
1521
  }
1504
1522
 
1505
- if (!getElementProps(element)[refKey]) {
1523
+ if (!reactIs.isForwardRef(element) && !getElementProps(element)[refKey]) {
1506
1524
  // eslint-disable-next-line no-console
1507
1525
  console.error("downshift: You must apply the ref prop \"" + refKey + "\" from getRootProps onto your root element.");
1508
1526
  }
@@ -5,6 +5,7 @@ import _inheritsLoose from '@babel/runtime/helpers/esm/inheritsLoose';
5
5
  import _assertThisInitialized from '@babel/runtime/helpers/esm/assertThisInitialized';
6
6
  import React, { Component } from 'react';
7
7
  import PropTypes from 'prop-types';
8
+ import { isForwardRef } from 'react-is';
8
9
 
9
10
  // istanbul ignore next
10
11
  var statusDiv = typeof document === 'undefined' ? null : document.getElementById('a11y-status-message');
@@ -90,7 +91,7 @@ var keyDownSpaceButton = process.env.NODE_ENV !== "production" ? '__autocomplete
90
91
  var clickButton = process.env.NODE_ENV !== "production" ? '__autocomplete_click_button__' : 11;
91
92
  var blurButton = process.env.NODE_ENV !== "production" ? '__autocomplete_blur_button__' : 12;
92
93
  var controlledPropUpdatedSelectedItem = process.env.NODE_ENV !== "production" ? '__autocomplete_controlled_prop_updated_selected_item__' : 13;
93
- var touchStart = process.env.NODE_ENV !== "production" ? '__autocomplete_touchstart__' : 14;
94
+ var touchEnd = process.env.NODE_ENV !== "production" ? '__autocomplete_touchend__' : 14;
94
95
 
95
96
  var stateChangeTypes = /*#__PURE__*/Object.freeze({
96
97
  unknown: unknown,
@@ -107,7 +108,7 @@ var stateChangeTypes = /*#__PURE__*/Object.freeze({
107
108
  clickButton: clickButton,
108
109
  blurButton: blurButton,
109
110
  controlledPropUpdatedSelectedItem: controlledPropUpdatedSelectedItem,
110
- touchStart: touchStart
111
+ touchEnd: touchEnd
111
112
  });
112
113
 
113
114
  var idCounter = 0;
@@ -1271,14 +1272,25 @@ function (_Component) {
1271
1272
  }; // Touching an element in iOS gives focus and hover states, but touching out of
1272
1273
  // the element will remove hover, and persist the focus state, resulting in the
1273
1274
  // blur event not being triggered.
1275
+ // this.isTouchMove helps us track whether the user is tapping or swiping on a touch screen.
1276
+ // If the user taps outside of Downshift, the component should be reset,
1277
+ // but not if the user is swiping
1274
1278
 
1275
1279
 
1276
- var onTouchStart = function (event) {
1280
+ var onTouchStart = function () {
1281
+ _this4.isTouchMove = false;
1282
+ };
1283
+
1284
+ var onTouchMove = function () {
1285
+ _this4.isTouchMove = true;
1286
+ };
1287
+
1288
+ var onTouchEnd = function (event) {
1277
1289
  var contextWithinDownshift = targetWithinDownshift(event.target, false);
1278
1290
 
1279
- if (!contextWithinDownshift && _this4.getState().isOpen) {
1291
+ if (!_this4.isTouchMove && !contextWithinDownshift && _this4.getState().isOpen) {
1280
1292
  _this4.reset({
1281
- type: touchStart
1293
+ type: touchEnd
1282
1294
  }, function () {
1283
1295
  return _this4.props.onOuterClick(_this4.getStateAndHelpers());
1284
1296
  });
@@ -1288,6 +1300,8 @@ function (_Component) {
1288
1300
  this.props.environment.addEventListener('mousedown', onMouseDown);
1289
1301
  this.props.environment.addEventListener('mouseup', onMouseUp);
1290
1302
  this.props.environment.addEventListener('touchstart', onTouchStart);
1303
+ this.props.environment.addEventListener('touchmove', onTouchMove);
1304
+ this.props.environment.addEventListener('touchend', onTouchEnd);
1291
1305
 
1292
1306
  this.cleanup = function () {
1293
1307
  _this4.internalClearTimeouts();
@@ -1299,6 +1313,10 @@ function (_Component) {
1299
1313
  _this4.props.environment.removeEventListener('mouseup', onMouseUp);
1300
1314
 
1301
1315
  _this4.props.environment.removeEventListener('touchstart', onTouchStart);
1316
+
1317
+ _this4.props.environment.removeEventListener('touchmove', onTouchMove);
1318
+
1319
+ _this4.props.environment.removeEventListener('touchend', onTouchEnd);
1302
1320
  };
1303
1321
  }
1304
1322
  };
@@ -1487,7 +1505,7 @@ function validateGetRootPropsCalledCorrectly(element, _ref11) {
1487
1505
  var refKeySpecified = refKey !== 'ref';
1488
1506
  var isComposite = !isDOMElement(element);
1489
1507
 
1490
- if (isComposite && !refKeySpecified) {
1508
+ if (isComposite && !refKeySpecified && !isForwardRef(element)) {
1491
1509
  // eslint-disable-next-line no-console
1492
1510
  console.error('downshift: You returned a non-DOM element. You must specify a refKey in getRootProps');
1493
1511
  } else if (!isComposite && refKeySpecified) {
@@ -1495,7 +1513,7 @@ function validateGetRootPropsCalledCorrectly(element, _ref11) {
1495
1513
  console.error("downshift: You returned a DOM element. You should not specify a refKey in getRootProps. You specified \"" + refKey + "\"");
1496
1514
  }
1497
1515
 
1498
- if (!getElementProps(element)[refKey]) {
1516
+ if (!isForwardRef(element) && !getElementProps(element)[refKey]) {
1499
1517
  // eslint-disable-next-line no-console
1500
1518
  console.error("downshift: You must apply the ref prop \"" + refKey + "\" from getRootProps onto your root element.");
1501
1519
  }
@@ -12,6 +12,7 @@ var _assertThisInitialized = _interopDefault(require('@babel/runtime/helpers/ass
12
12
  var React = require('react');
13
13
  var React__default = _interopDefault(React);
14
14
  var PropTypes = _interopDefault(require('prop-types'));
15
+ var reactIs = require('react-is');
15
16
 
16
17
  // istanbul ignore next
17
18
  var statusDiv = typeof document === 'undefined' ? null : document.getElementById('a11y-status-message');
@@ -97,7 +98,7 @@ var keyDownSpaceButton = process.env.NODE_ENV !== "production" ? '__autocomplete
97
98
  var clickButton = process.env.NODE_ENV !== "production" ? '__autocomplete_click_button__' : 11;
98
99
  var blurButton = process.env.NODE_ENV !== "production" ? '__autocomplete_blur_button__' : 12;
99
100
  var controlledPropUpdatedSelectedItem = process.env.NODE_ENV !== "production" ? '__autocomplete_controlled_prop_updated_selected_item__' : 13;
100
- var touchStart = process.env.NODE_ENV !== "production" ? '__autocomplete_touchstart__' : 14;
101
+ var touchEnd = process.env.NODE_ENV !== "production" ? '__autocomplete_touchend__' : 14;
101
102
 
102
103
  var stateChangeTypes = /*#__PURE__*/Object.freeze({
103
104
  unknown: unknown,
@@ -114,7 +115,7 @@ var stateChangeTypes = /*#__PURE__*/Object.freeze({
114
115
  clickButton: clickButton,
115
116
  blurButton: blurButton,
116
117
  controlledPropUpdatedSelectedItem: controlledPropUpdatedSelectedItem,
117
- touchStart: touchStart
118
+ touchEnd: touchEnd
118
119
  });
119
120
 
120
121
  var idCounter = 0;
@@ -1225,6 +1226,12 @@ function (_Component) {
1225
1226
  var _this4 = this;
1226
1227
 
1227
1228
  /* istanbul ignore if (react-native) */
1229
+ if (process.env.NODE_ENV !== 'production' && !true && this.getMenuProps.called && !this.getMenuProps.suppressRefError) {
1230
+ validateGetMenuPropsCalledCorrectly(this._menuNode, this.getMenuProps);
1231
+ }
1232
+ /* istanbul ignore if (react-native) */
1233
+
1234
+
1228
1235
  this.cleanup = function () {
1229
1236
  _this4.internalClearTimeouts();
1230
1237
  };
@@ -1394,12 +1401,21 @@ process.env.NODE_ENV !== "production" ? Downshift.propTypes = {
1394
1401
 
1395
1402
  } : void 0;
1396
1403
 
1404
+ function validateGetMenuPropsCalledCorrectly(node, _ref10) {
1405
+ var refKey = _ref10.refKey;
1406
+
1407
+ if (!node) {
1408
+ // eslint-disable-next-line no-console
1409
+ console.error("downshift: The ref prop \"" + refKey + "\" from getMenuProps was not applied correctly on your menu element.");
1410
+ }
1411
+ }
1412
+
1397
1413
  function validateGetRootPropsCalledCorrectly(element, _ref11) {
1398
1414
  var refKey = _ref11.refKey;
1399
1415
  var refKeySpecified = refKey !== 'ref';
1400
1416
  var isComposite = !isDOMElement(element);
1401
1417
 
1402
- if (isComposite && !refKeySpecified) {
1418
+ if (isComposite && !refKeySpecified && !reactIs.isForwardRef(element)) {
1403
1419
  // eslint-disable-next-line no-console
1404
1420
  console.error('downshift: You returned a non-DOM element. You must specify a refKey in getRootProps');
1405
1421
  } else if (!isComposite && refKeySpecified) {
@@ -1407,7 +1423,7 @@ function validateGetRootPropsCalledCorrectly(element, _ref11) {
1407
1423
  console.error("downshift: You returned a DOM element. You should not specify a refKey in getRootProps. You specified \"" + refKey + "\"");
1408
1424
  }
1409
1425
 
1410
- if (!getElementProps(element)[refKey]) {
1426
+ if (!reactIs.isForwardRef(element) && !getElementProps(element)[refKey]) {
1411
1427
  // eslint-disable-next-line no-console
1412
1428
  console.error("downshift: You must apply the ref prop \"" + refKey + "\" from getRootProps onto your root element.");
1413
1429
  }
@@ -53,6 +53,10 @@
53
53
  return self;
54
54
  }
55
55
 
56
+ function unwrapExports (x) {
57
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x.default : x;
58
+ }
59
+
56
60
  function createCommonjsModule(fn, module) {
57
61
  return module = { exports: {} }, fn(module, module.exports), module.exports;
58
62
  }
@@ -809,6 +813,269 @@
809
813
  }
810
814
  });
811
815
 
816
+ var reactIs_production_min = createCommonjsModule(function (module, exports) {
817
+ Object.defineProperty(exports,"__esModule",{value:!0});
818
+ var b="function"===typeof Symbol&&Symbol.for,c=b?Symbol.for("react.element"):60103,d=b?Symbol.for("react.portal"):60106,e=b?Symbol.for("react.fragment"):60107,f=b?Symbol.for("react.strict_mode"):60108,g=b?Symbol.for("react.profiler"):60114,h=b?Symbol.for("react.provider"):60109,k=b?Symbol.for("react.context"):60110,l=b?Symbol.for("react.async_mode"):60111,m=b?Symbol.for("react.concurrent_mode"):60111,n=b?Symbol.for("react.forward_ref"):60112,p=b?Symbol.for("react.suspense"):60113,r=b?Symbol.for("react.memo"):
819
+ 60115,t=b?Symbol.for("react.lazy"):60116;function u(a){if("object"===typeof a&&null!==a){var q=a.$$typeof;switch(q){case c:switch(a=a.type,a){case l:case m:case e:case g:case f:return a;default:switch(a=a&&a.$$typeof,a){case k:case n:case h:return a;default:return q}}case d:return q}}}function v(a){return u(a)===m}exports.typeOf=u;exports.AsyncMode=l;exports.ConcurrentMode=m;exports.ContextConsumer=k;exports.ContextProvider=h;exports.Element=c;exports.ForwardRef=n;exports.Fragment=e;
820
+ exports.Profiler=g;exports.Portal=d;exports.StrictMode=f;exports.isValidElementType=function(a){return "string"===typeof a||"function"===typeof a||a===e||a===m||a===g||a===f||a===p||"object"===typeof a&&null!==a&&(a.$$typeof===t||a.$$typeof===r||a.$$typeof===h||a.$$typeof===k||a.$$typeof===n)};exports.isAsyncMode=function(a){return v(a)||u(a)===l};exports.isConcurrentMode=v;exports.isContextConsumer=function(a){return u(a)===k};exports.isContextProvider=function(a){return u(a)===h};
821
+ exports.isElement=function(a){return "object"===typeof a&&null!==a&&a.$$typeof===c};exports.isForwardRef=function(a){return u(a)===n};exports.isFragment=function(a){return u(a)===e};exports.isProfiler=function(a){return u(a)===g};exports.isPortal=function(a){return u(a)===d};exports.isStrictMode=function(a){return u(a)===f};
822
+ });
823
+
824
+ unwrapExports(reactIs_production_min);
825
+ var reactIs_production_min_1 = reactIs_production_min.typeOf;
826
+ var reactIs_production_min_2 = reactIs_production_min.AsyncMode;
827
+ var reactIs_production_min_3 = reactIs_production_min.ConcurrentMode;
828
+ var reactIs_production_min_4 = reactIs_production_min.ContextConsumer;
829
+ var reactIs_production_min_5 = reactIs_production_min.ContextProvider;
830
+ var reactIs_production_min_6 = reactIs_production_min.Element;
831
+ var reactIs_production_min_7 = reactIs_production_min.ForwardRef;
832
+ var reactIs_production_min_8 = reactIs_production_min.Fragment;
833
+ var reactIs_production_min_9 = reactIs_production_min.Profiler;
834
+ var reactIs_production_min_10 = reactIs_production_min.Portal;
835
+ var reactIs_production_min_11 = reactIs_production_min.StrictMode;
836
+ var reactIs_production_min_12 = reactIs_production_min.isValidElementType;
837
+ var reactIs_production_min_13 = reactIs_production_min.isAsyncMode;
838
+ var reactIs_production_min_14 = reactIs_production_min.isConcurrentMode;
839
+ var reactIs_production_min_15 = reactIs_production_min.isContextConsumer;
840
+ var reactIs_production_min_16 = reactIs_production_min.isContextProvider;
841
+ var reactIs_production_min_17 = reactIs_production_min.isElement;
842
+ var reactIs_production_min_18 = reactIs_production_min.isForwardRef;
843
+ var reactIs_production_min_19 = reactIs_production_min.isFragment;
844
+ var reactIs_production_min_20 = reactIs_production_min.isProfiler;
845
+ var reactIs_production_min_21 = reactIs_production_min.isPortal;
846
+ var reactIs_production_min_22 = reactIs_production_min.isStrictMode;
847
+
848
+ var reactIs_development = createCommonjsModule(function (module, exports) {
849
+
850
+
851
+
852
+ {
853
+ (function() {
854
+
855
+ Object.defineProperty(exports, '__esModule', { value: true });
856
+
857
+ // The Symbol used to tag the ReactElement-like types. If there is no native Symbol
858
+ // nor polyfill, then a plain number is used for performance.
859
+ var hasSymbol = typeof Symbol === 'function' && Symbol.for;
860
+
861
+ var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
862
+ var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
863
+ var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
864
+ var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
865
+ var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
866
+ var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
867
+ var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace;
868
+ var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for('react.async_mode') : 0xeacf;
869
+ var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
870
+ var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
871
+ var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
872
+ var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
873
+ var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
874
+
875
+ function isValidElementType(type) {
876
+ return typeof type === 'string' || typeof type === 'function' ||
877
+ // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill.
878
+ type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || typeof type === 'object' && type !== null && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE);
879
+ }
880
+
881
+ /**
882
+ * Forked from fbjs/warning:
883
+ * https://github.com/facebook/fbjs/blob/e66ba20ad5be433eb54423f2b097d829324d9de6/packages/fbjs/src/__forks__/warning.js
884
+ *
885
+ * Only change is we use console.warn instead of console.error,
886
+ * and do nothing when 'console' is not supported.
887
+ * This really simplifies the code.
888
+ * ---
889
+ * Similar to invariant but only logs a warning if the condition is not met.
890
+ * This can be used to log issues in development environments in critical
891
+ * paths. Removing the logging code for production environments will keep the
892
+ * same logic and follow the same code paths.
893
+ */
894
+
895
+ var lowPriorityWarning = function () {};
896
+
897
+ {
898
+ var printWarning = function (format) {
899
+ for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
900
+ args[_key - 1] = arguments[_key];
901
+ }
902
+
903
+ var argIndex = 0;
904
+ var message = 'Warning: ' + format.replace(/%s/g, function () {
905
+ return args[argIndex++];
906
+ });
907
+ if (typeof console !== 'undefined') {
908
+ console.warn(message);
909
+ }
910
+ try {
911
+ // --- Welcome to debugging React ---
912
+ // This error was thrown as a convenience so that you can use this stack
913
+ // to find the callsite that caused this warning to fire.
914
+ throw new Error(message);
915
+ } catch (x) {}
916
+ };
917
+
918
+ lowPriorityWarning = function (condition, format) {
919
+ if (format === undefined) {
920
+ throw new Error('`lowPriorityWarning(condition, format, ...args)` requires a warning ' + 'message argument');
921
+ }
922
+ if (!condition) {
923
+ for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
924
+ args[_key2 - 2] = arguments[_key2];
925
+ }
926
+
927
+ printWarning.apply(undefined, [format].concat(args));
928
+ }
929
+ };
930
+ }
931
+
932
+ var lowPriorityWarning$1 = lowPriorityWarning;
933
+
934
+ function typeOf(object) {
935
+ if (typeof object === 'object' && object !== null) {
936
+ var $$typeof = object.$$typeof;
937
+
938
+ switch ($$typeof) {
939
+ case REACT_ELEMENT_TYPE:
940
+ var type = object.type;
941
+
942
+ switch (type) {
943
+ case REACT_ASYNC_MODE_TYPE:
944
+ case REACT_CONCURRENT_MODE_TYPE:
945
+ case REACT_FRAGMENT_TYPE:
946
+ case REACT_PROFILER_TYPE:
947
+ case REACT_STRICT_MODE_TYPE:
948
+ return type;
949
+ default:
950
+ var $$typeofType = type && type.$$typeof;
951
+
952
+ switch ($$typeofType) {
953
+ case REACT_CONTEXT_TYPE:
954
+ case REACT_FORWARD_REF_TYPE:
955
+ case REACT_PROVIDER_TYPE:
956
+ return $$typeofType;
957
+ default:
958
+ return $$typeof;
959
+ }
960
+ }
961
+ case REACT_PORTAL_TYPE:
962
+ return $$typeof;
963
+ }
964
+ }
965
+
966
+ return undefined;
967
+ }
968
+
969
+ // AsyncMode is deprecated along with isAsyncMode
970
+ var AsyncMode = REACT_ASYNC_MODE_TYPE;
971
+ var ConcurrentMode = REACT_CONCURRENT_MODE_TYPE;
972
+ var ContextConsumer = REACT_CONTEXT_TYPE;
973
+ var ContextProvider = REACT_PROVIDER_TYPE;
974
+ var Element = REACT_ELEMENT_TYPE;
975
+ var ForwardRef = REACT_FORWARD_REF_TYPE;
976
+ var Fragment = REACT_FRAGMENT_TYPE;
977
+ var Profiler = REACT_PROFILER_TYPE;
978
+ var Portal = REACT_PORTAL_TYPE;
979
+ var StrictMode = REACT_STRICT_MODE_TYPE;
980
+
981
+ var hasWarnedAboutDeprecatedIsAsyncMode = false;
982
+
983
+ // AsyncMode should be deprecated
984
+ function isAsyncMode(object) {
985
+ {
986
+ if (!hasWarnedAboutDeprecatedIsAsyncMode) {
987
+ hasWarnedAboutDeprecatedIsAsyncMode = true;
988
+ lowPriorityWarning$1(false, 'The ReactIs.isAsyncMode() alias has been deprecated, ' + 'and will be removed in React 17+. Update your code to use ' + 'ReactIs.isConcurrentMode() instead. It has the exact same API.');
989
+ }
990
+ }
991
+ return isConcurrentMode(object) || typeOf(object) === REACT_ASYNC_MODE_TYPE;
992
+ }
993
+ function isConcurrentMode(object) {
994
+ return typeOf(object) === REACT_CONCURRENT_MODE_TYPE;
995
+ }
996
+ function isContextConsumer(object) {
997
+ return typeOf(object) === REACT_CONTEXT_TYPE;
998
+ }
999
+ function isContextProvider(object) {
1000
+ return typeOf(object) === REACT_PROVIDER_TYPE;
1001
+ }
1002
+ function isElement(object) {
1003
+ return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
1004
+ }
1005
+ function isForwardRef(object) {
1006
+ return typeOf(object) === REACT_FORWARD_REF_TYPE;
1007
+ }
1008
+ function isFragment(object) {
1009
+ return typeOf(object) === REACT_FRAGMENT_TYPE;
1010
+ }
1011
+ function isProfiler(object) {
1012
+ return typeOf(object) === REACT_PROFILER_TYPE;
1013
+ }
1014
+ function isPortal(object) {
1015
+ return typeOf(object) === REACT_PORTAL_TYPE;
1016
+ }
1017
+ function isStrictMode(object) {
1018
+ return typeOf(object) === REACT_STRICT_MODE_TYPE;
1019
+ }
1020
+
1021
+ exports.typeOf = typeOf;
1022
+ exports.AsyncMode = AsyncMode;
1023
+ exports.ConcurrentMode = ConcurrentMode;
1024
+ exports.ContextConsumer = ContextConsumer;
1025
+ exports.ContextProvider = ContextProvider;
1026
+ exports.Element = Element;
1027
+ exports.ForwardRef = ForwardRef;
1028
+ exports.Fragment = Fragment;
1029
+ exports.Profiler = Profiler;
1030
+ exports.Portal = Portal;
1031
+ exports.StrictMode = StrictMode;
1032
+ exports.isValidElementType = isValidElementType;
1033
+ exports.isAsyncMode = isAsyncMode;
1034
+ exports.isConcurrentMode = isConcurrentMode;
1035
+ exports.isContextConsumer = isContextConsumer;
1036
+ exports.isContextProvider = isContextProvider;
1037
+ exports.isElement = isElement;
1038
+ exports.isForwardRef = isForwardRef;
1039
+ exports.isFragment = isFragment;
1040
+ exports.isProfiler = isProfiler;
1041
+ exports.isPortal = isPortal;
1042
+ exports.isStrictMode = isStrictMode;
1043
+ })();
1044
+ }
1045
+ });
1046
+
1047
+ unwrapExports(reactIs_development);
1048
+ var reactIs_development_1 = reactIs_development.typeOf;
1049
+ var reactIs_development_2 = reactIs_development.AsyncMode;
1050
+ var reactIs_development_3 = reactIs_development.ConcurrentMode;
1051
+ var reactIs_development_4 = reactIs_development.ContextConsumer;
1052
+ var reactIs_development_5 = reactIs_development.ContextProvider;
1053
+ var reactIs_development_6 = reactIs_development.Element;
1054
+ var reactIs_development_7 = reactIs_development.ForwardRef;
1055
+ var reactIs_development_8 = reactIs_development.Fragment;
1056
+ var reactIs_development_9 = reactIs_development.Profiler;
1057
+ var reactIs_development_10 = reactIs_development.Portal;
1058
+ var reactIs_development_11 = reactIs_development.StrictMode;
1059
+ var reactIs_development_12 = reactIs_development.isValidElementType;
1060
+ var reactIs_development_13 = reactIs_development.isAsyncMode;
1061
+ var reactIs_development_14 = reactIs_development.isConcurrentMode;
1062
+ var reactIs_development_15 = reactIs_development.isContextConsumer;
1063
+ var reactIs_development_16 = reactIs_development.isContextProvider;
1064
+ var reactIs_development_17 = reactIs_development.isElement;
1065
+ var reactIs_development_18 = reactIs_development.isForwardRef;
1066
+ var reactIs_development_19 = reactIs_development.isFragment;
1067
+ var reactIs_development_20 = reactIs_development.isProfiler;
1068
+ var reactIs_development_21 = reactIs_development.isPortal;
1069
+ var reactIs_development_22 = reactIs_development.isStrictMode;
1070
+
1071
+ var reactIs = createCommonjsModule(function (module) {
1072
+
1073
+ {
1074
+ module.exports = reactIs_development;
1075
+ }
1076
+ });
1077
+ var reactIs_1 = reactIs.isForwardRef;
1078
+
812
1079
  // istanbul ignore next
813
1080
  var statusDiv = typeof document === 'undefined' ? null : document.getElementById('a11y-status-message');
814
1081
  var statuses = [];
@@ -893,7 +1160,7 @@
893
1160
  var clickButton = '__autocomplete_click_button__';
894
1161
  var blurButton = '__autocomplete_blur_button__';
895
1162
  var controlledPropUpdatedSelectedItem = '__autocomplete_controlled_prop_updated_selected_item__';
896
- var touchStart = '__autocomplete_touchstart__';
1163
+ var touchEnd = '__autocomplete_touchend__';
897
1164
 
898
1165
  var stateChangeTypes = /*#__PURE__*/Object.freeze({
899
1166
  unknown: unknown,
@@ -910,7 +1177,7 @@
910
1177
  clickButton: clickButton,
911
1178
  blurButton: blurButton,
912
1179
  controlledPropUpdatedSelectedItem: controlledPropUpdatedSelectedItem,
913
- touchStart: touchStart
1180
+ touchEnd: touchEnd
914
1181
  });
915
1182
 
916
1183
  function isElement(el) {
@@ -2242,14 +2509,25 @@
2242
2509
  }; // Touching an element in iOS gives focus and hover states, but touching out of
2243
2510
  // the element will remove hover, and persist the focus state, resulting in the
2244
2511
  // blur event not being triggered.
2512
+ // this.isTouchMove helps us track whether the user is tapping or swiping on a touch screen.
2513
+ // If the user taps outside of Downshift, the component should be reset,
2514
+ // but not if the user is swiping
2245
2515
 
2246
2516
 
2247
- var onTouchStart = function (event) {
2517
+ var onTouchStart = function () {
2518
+ _this4.isTouchMove = false;
2519
+ };
2520
+
2521
+ var onTouchMove = function () {
2522
+ _this4.isTouchMove = true;
2523
+ };
2524
+
2525
+ var onTouchEnd = function (event) {
2248
2526
  var contextWithinDownshift = targetWithinDownshift(event.target, false);
2249
2527
 
2250
- if (!contextWithinDownshift && _this4.getState().isOpen) {
2528
+ if (!_this4.isTouchMove && !contextWithinDownshift && _this4.getState().isOpen) {
2251
2529
  _this4.reset({
2252
- type: touchStart
2530
+ type: touchEnd
2253
2531
  }, function () {
2254
2532
  return _this4.props.onOuterClick(_this4.getStateAndHelpers());
2255
2533
  });
@@ -2259,6 +2537,8 @@
2259
2537
  this.props.environment.addEventListener('mousedown', onMouseDown);
2260
2538
  this.props.environment.addEventListener('mouseup', onMouseUp);
2261
2539
  this.props.environment.addEventListener('touchstart', onTouchStart);
2540
+ this.props.environment.addEventListener('touchmove', onTouchMove);
2541
+ this.props.environment.addEventListener('touchend', onTouchEnd);
2262
2542
 
2263
2543
  this.cleanup = function () {
2264
2544
  _this4.internalClearTimeouts();
@@ -2270,6 +2550,10 @@
2270
2550
  _this4.props.environment.removeEventListener('mouseup', onMouseUp);
2271
2551
 
2272
2552
  _this4.props.environment.removeEventListener('touchstart', onTouchStart);
2553
+
2554
+ _this4.props.environment.removeEventListener('touchmove', onTouchMove);
2555
+
2556
+ _this4.props.environment.removeEventListener('touchend', onTouchEnd);
2273
2557
  };
2274
2558
  }
2275
2559
  };
@@ -2451,7 +2735,7 @@
2451
2735
  var refKeySpecified = refKey !== 'ref';
2452
2736
  var isComposite = !isDOMElement(element);
2453
2737
 
2454
- if (isComposite && !refKeySpecified) {
2738
+ if (isComposite && !refKeySpecified && !reactIs_1(element)) {
2455
2739
  // eslint-disable-next-line no-console
2456
2740
  console.error('downshift: You returned a non-DOM element. You must specify a refKey in getRootProps');
2457
2741
  } else if (!isComposite && refKeySpecified) {
@@ -2459,7 +2743,7 @@
2459
2743
  console.error("downshift: You returned a DOM element. You should not specify a refKey in getRootProps. You specified \"" + refKey + "\"");
2460
2744
  }
2461
2745
 
2462
- if (!getElementProps(element)[refKey]) {
2746
+ if (!reactIs_1(element) && !getElementProps(element)[refKey]) {
2463
2747
  // eslint-disable-next-line no-console
2464
2748
  console.error("downshift: You must apply the ref prop \"" + refKey + "\" from getRootProps onto your root element.");
2465
2749
  }