downshift 7.1.1 → 7.1.2

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.
@@ -4,6 +4,55 @@
4
4
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Downshift = {}, global.React));
5
5
  })(this, (function (exports, react) { 'use strict';
6
6
 
7
+ function _objectWithoutPropertiesLoose(source, excluded) {
8
+ if (source == null) return {};
9
+ var target = {};
10
+ var sourceKeys = Object.keys(source);
11
+ var key, i;
12
+ for (i = 0; i < sourceKeys.length; i++) {
13
+ key = sourceKeys[i];
14
+ if (excluded.indexOf(key) >= 0) continue;
15
+ target[key] = source[key];
16
+ }
17
+ return target;
18
+ }
19
+
20
+ function _extends() {
21
+ _extends = Object.assign ? Object.assign.bind() : function (target) {
22
+ for (var i = 1; i < arguments.length; i++) {
23
+ var source = arguments[i];
24
+ for (var key in source) {
25
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
26
+ target[key] = source[key];
27
+ }
28
+ }
29
+ }
30
+ return target;
31
+ };
32
+ return _extends.apply(this, arguments);
33
+ }
34
+
35
+ function _assertThisInitialized(self) {
36
+ if (self === void 0) {
37
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
38
+ }
39
+ return self;
40
+ }
41
+
42
+ function _setPrototypeOf(o, p) {
43
+ _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
44
+ o.__proto__ = p;
45
+ return o;
46
+ };
47
+ return _setPrototypeOf(o, p);
48
+ }
49
+
50
+ function _inheritsLoose(subClass, superClass) {
51
+ subClass.prototype = Object.create(superClass.prototype);
52
+ subClass.prototype.constructor = subClass;
53
+ _setPrototypeOf(subClass, superClass);
54
+ }
55
+
7
56
  var propTypes$3 = {exports: {}};
8
57
 
9
58
  var reactIs$1 = {exports: {}};
@@ -1265,7 +1314,7 @@
1265
1314
 
1266
1315
  function t(t){return "object"==typeof t&&null!=t&&1===t.nodeType}function e(t,e){return (!e||"hidden"!==t)&&"visible"!==t&&"clip"!==t}function n(t,n){if(t.clientHeight<t.scrollHeight||t.clientWidth<t.scrollWidth){var r=getComputedStyle(t,null);return e(r.overflowY,n)||e(r.overflowX,n)||function(t){var e=function(t){if(!t.ownerDocument||!t.ownerDocument.defaultView)return null;try{return t.ownerDocument.defaultView.frameElement}catch(t){return null}}(t);return !!e&&(e.clientHeight<t.scrollHeight||e.clientWidth<t.scrollWidth)}(t)}return !1}function r(t,e,n,r,i,o,l,d){return o<t&&l>e||o>t&&l<e?0:o<=t&&d<=n||l>=e&&d>=n?o-t-r:l>e&&d<n||o<t&&d>n?l-e+i:0}var i=function(e,i){var o=window,l=i.scrollMode,d=i.block,f=i.inline,h=i.boundary,u=i.skipOverflowHiddenElements,s="function"==typeof h?h:function(t){return t!==h};if(!t(e))throw new TypeError("Invalid target");for(var a,c,g=document.scrollingElement||document.documentElement,p=[],m=e;t(m)&&s(m);){if((m=null==(c=(a=m).parentElement)?a.getRootNode().host||null:c)===g){p.push(m);break}null!=m&&m===document.body&&n(m)&&!n(document.documentElement)||null!=m&&n(m,u)&&p.push(m);}for(var w=o.visualViewport?o.visualViewport.width:innerWidth,v=o.visualViewport?o.visualViewport.height:innerHeight,W=window.scrollX||pageXOffset,H=window.scrollY||pageYOffset,b=e.getBoundingClientRect(),y=b.height,E=b.width,M=b.top,V=b.right,x=b.bottom,I=b.left,C="start"===d||"nearest"===d?M:"end"===d?x:M+y/2,R="center"===f?I+E/2:"end"===f?V:I,T=[],k=0;k<p.length;k++){var B=p[k],D=B.getBoundingClientRect(),O=D.height,X=D.width,Y=D.top,L=D.right,S=D.bottom,j=D.left;if("if-needed"===l&&M>=0&&I>=0&&x<=v&&V<=w&&M>=Y&&x<=S&&I>=j&&V<=L)return T;var N=getComputedStyle(B),q=parseInt(N.borderLeftWidth,10),z=parseInt(N.borderTopWidth,10),A=parseInt(N.borderRightWidth,10),F=parseInt(N.borderBottomWidth,10),G=0,J=0,K="offsetWidth"in B?B.offsetWidth-B.clientWidth-q-A:0,P="offsetHeight"in B?B.offsetHeight-B.clientHeight-z-F:0,Q="offsetWidth"in B?0===B.offsetWidth?0:X/B.offsetWidth:0,U="offsetHeight"in B?0===B.offsetHeight?0:O/B.offsetHeight:0;if(g===B)G="start"===d?C:"end"===d?C-v:"nearest"===d?r(H,H+v,v,z,F,H+C,H+C+y,y):C-v/2,J="start"===f?R:"center"===f?R-w/2:"end"===f?R-w:r(W,W+w,w,q,A,W+R,W+R+E,E),G=Math.max(0,G+H),J=Math.max(0,J+W);else {G="start"===d?C-Y-z:"end"===d?C-S+F+P:"nearest"===d?r(Y,S,O,z,F+P,C,C+y,y):C-(Y+O/2)+P/2,J="start"===f?R-j-q:"center"===f?R-(j+X/2)+K/2:"end"===f?R-L+A+K:r(j,L,X,q,A+K,R,R+E,E);var Z=B.scrollLeft,$=B.scrollTop;C+=$-(G=Math.max(0,Math.min($+G/U,B.scrollHeight-O/U+P))),R+=Z-(J=Math.max(0,Math.min(Z+J/Q,B.scrollWidth-X/Q+K)));}T.push({el:B,top:G,left:J});}return T};
1267
1316
 
1268
- let idCounter = 0;
1317
+ var idCounter = 0;
1269
1318
 
1270
1319
  /**
1271
1320
  * Accepts a parameter and returns it if it's a function
@@ -1289,17 +1338,15 @@
1289
1338
  if (!node) {
1290
1339
  return;
1291
1340
  }
1292
- const actions = i(node, {
1341
+ var actions = i(node, {
1293
1342
  boundary: menuNode,
1294
1343
  block: 'nearest',
1295
1344
  scrollMode: 'if-needed'
1296
1345
  });
1297
- actions.forEach(_ref => {
1298
- let {
1299
- el,
1300
- top,
1301
- left
1302
- } = _ref;
1346
+ actions.forEach(function (_ref) {
1347
+ var el = _ref.el,
1348
+ top = _ref.top,
1349
+ left = _ref.left;
1303
1350
  el.scrollTop = top;
1304
1351
  el.scrollLeft = left;
1305
1352
  });
@@ -1312,7 +1359,7 @@
1312
1359
  * @return {Boolean} whether the parent is the child or the child is in the parent
1313
1360
  */
1314
1361
  function isOrContainsNode(parent, child, environment) {
1315
- const result = parent === child || child instanceof environment.Node && parent.contains && parent.contains(child);
1362
+ var result = parent === child || child instanceof environment.Node && parent.contains && parent.contains(child);
1316
1363
  return result;
1317
1364
  }
1318
1365
 
@@ -1325,7 +1372,7 @@
1325
1372
  * @return {Function} the debounced function
1326
1373
  */
1327
1374
  function debounce(fn, time) {
1328
- let timeoutId;
1375
+ var timeoutId;
1329
1376
  function cancel() {
1330
1377
  if (timeoutId) {
1331
1378
  clearTimeout(timeoutId);
@@ -1336,9 +1383,9 @@
1336
1383
  args[_key] = arguments[_key];
1337
1384
  }
1338
1385
  cancel();
1339
- timeoutId = setTimeout(() => {
1386
+ timeoutId = setTimeout(function () {
1340
1387
  timeoutId = null;
1341
- fn(...args);
1388
+ fn.apply(void 0, args);
1342
1389
  }, time);
1343
1390
  }
1344
1391
  wrapper.cancel = cancel;
@@ -1360,9 +1407,9 @@
1360
1407
  for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
1361
1408
  args[_key3 - 1] = arguments[_key3];
1362
1409
  }
1363
- return fns.some(fn => {
1410
+ return fns.some(function (fn) {
1364
1411
  if (fn) {
1365
- fn(event, ...args);
1412
+ fn.apply(void 0, [event].concat(args));
1366
1413
  }
1367
1414
  return event.preventDownshiftDefault || event.hasOwnProperty('nativeEvent') && event.nativeEvent.preventDownshiftDefault;
1368
1415
  });
@@ -1372,8 +1419,8 @@
1372
1419
  for (var _len4 = arguments.length, refs = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
1373
1420
  refs[_key4] = arguments[_key4];
1374
1421
  }
1375
- return node => {
1376
- refs.forEach(ref => {
1422
+ return function (node) {
1423
+ refs.forEach(function (ref) {
1377
1424
  if (typeof ref === 'function') {
1378
1425
  ref(node);
1379
1426
  } else if (ref) {
@@ -1407,11 +1454,9 @@
1407
1454
  * @return {String} the a11y status message
1408
1455
  */
1409
1456
  function getA11yStatusMessage$1(_ref2) {
1410
- let {
1411
- isOpen,
1412
- resultCount,
1413
- previousResultCount
1414
- } = _ref2;
1457
+ var isOpen = _ref2.isOpen,
1458
+ resultCount = _ref2.resultCount,
1459
+ previousResultCount = _ref2.previousResultCount;
1415
1460
  if (!isOpen) {
1416
1461
  return '';
1417
1462
  }
@@ -1419,7 +1464,7 @@
1419
1464
  return 'No results are available.';
1420
1465
  }
1421
1466
  if (resultCount !== previousResultCount) {
1422
- return `${resultCount} result${resultCount === 1 ? ' is' : 's are'} available, use up and down arrow keys to navigate. Press Enter key to select.`;
1467
+ return resultCount + " result" + (resultCount === 1 ? ' is' : 's are') + " available, use up and down arrow keys to navigate. Press Enter key to select.";
1423
1468
  }
1424
1469
  return '';
1425
1470
  }
@@ -1466,9 +1511,9 @@
1466
1511
  */
1467
1512
  function requiredProp(fnName, propName) {
1468
1513
  // eslint-disable-next-line no-console
1469
- console.error(`The property "${propName}" is required in "${fnName}"`);
1514
+ console.error("The property \"" + propName + "\" is required in \"" + fnName + "\"");
1470
1515
  }
1471
- const stateKeys = ['highlightedIndex', 'inputValue', 'isOpen', 'selectedItem', 'type'];
1516
+ var stateKeys = ['highlightedIndex', 'inputValue', 'isOpen', 'selectedItem', 'type'];
1472
1517
  /**
1473
1518
  * @param {Object} state the state object
1474
1519
  * @return {Object} state that is relevant to downshift
@@ -1477,8 +1522,8 @@
1477
1522
  if (state === void 0) {
1478
1523
  state = {};
1479
1524
  }
1480
- const result = {};
1481
- stateKeys.forEach(k => {
1525
+ var result = {};
1526
+ stateKeys.forEach(function (k) {
1482
1527
  if (state.hasOwnProperty(k)) {
1483
1528
  result[k] = state[k];
1484
1529
  }
@@ -1498,7 +1543,7 @@
1498
1543
  * @returns {Object} The merged controlled state.
1499
1544
  */
1500
1545
  function getState(state, props) {
1501
- return Object.keys(state).reduce((prevState, key) => {
1546
+ return Object.keys(state).reduce(function (prevState, key) {
1502
1547
  prevState[key] = isControlledProp(props, key) ? props[key] : state[key];
1503
1548
  return prevState;
1504
1549
  }, {});
@@ -1523,13 +1568,11 @@
1523
1568
  * @return {String} keyboard key
1524
1569
  */
1525
1570
  function normalizeArrowKey(event) {
1526
- const {
1527
- key,
1528
- keyCode
1529
- } = event;
1571
+ var key = event.key,
1572
+ keyCode = event.keyCode;
1530
1573
  /* istanbul ignore next (ie) */
1531
1574
  if (keyCode >= 37 && keyCode <= 40 && key.indexOf('Arrow') !== 0) {
1532
- return `Arrow${key}`;
1575
+ return "Arrow" + key;
1533
1576
  }
1534
1577
  return key;
1535
1578
  }
@@ -1561,17 +1604,17 @@
1561
1604
  if (itemCount === 0) {
1562
1605
  return -1;
1563
1606
  }
1564
- const itemsLastIndex = itemCount - 1;
1607
+ var itemsLastIndex = itemCount - 1;
1565
1608
  if (typeof baseIndex !== 'number' || baseIndex < 0 || baseIndex >= itemCount) {
1566
1609
  baseIndex = moveAmount > 0 ? -1 : itemsLastIndex + 1;
1567
1610
  }
1568
- let newIndex = baseIndex + moveAmount;
1611
+ var newIndex = baseIndex + moveAmount;
1569
1612
  if (newIndex < 0) {
1570
1613
  newIndex = circular ? itemsLastIndex : 0;
1571
1614
  } else if (newIndex > itemsLastIndex) {
1572
1615
  newIndex = circular ? 0 : itemsLastIndex;
1573
1616
  }
1574
- const nonDisabledNewIndex = getNextNonDisabledIndex(moveAmount, newIndex, itemCount, getItemNodeFromIndex, circular);
1617
+ var nonDisabledNewIndex = getNextNonDisabledIndex(moveAmount, newIndex, itemCount, getItemNodeFromIndex, circular);
1575
1618
  if (nonDisabledNewIndex === -1) {
1576
1619
  return baseIndex >= itemCount ? -1 : baseIndex;
1577
1620
  }
@@ -1589,20 +1632,20 @@
1589
1632
  * @returns {number} The new index. Returns baseIndex if item is not disabled. Returns next non-disabled item otherwise. If no non-disabled found it will return -1.
1590
1633
  */
1591
1634
  function getNextNonDisabledIndex(moveAmount, baseIndex, itemCount, getItemNodeFromIndex, circular) {
1592
- const currentElementNode = getItemNodeFromIndex(baseIndex);
1635
+ var currentElementNode = getItemNodeFromIndex(baseIndex);
1593
1636
  if (!currentElementNode || !currentElementNode.hasAttribute('disabled')) {
1594
1637
  return baseIndex;
1595
1638
  }
1596
1639
  if (moveAmount > 0) {
1597
- for (let index = baseIndex + 1; index < itemCount; index++) {
1640
+ for (var index = baseIndex + 1; index < itemCount; index++) {
1598
1641
  if (!getItemNodeFromIndex(index).hasAttribute('disabled')) {
1599
1642
  return index;
1600
1643
  }
1601
1644
  }
1602
1645
  } else {
1603
- for (let index = baseIndex - 1; index >= 0; index--) {
1604
- if (!getItemNodeFromIndex(index).hasAttribute('disabled')) {
1605
- return index;
1646
+ for (var _index = baseIndex - 1; _index >= 0; _index--) {
1647
+ if (!getItemNodeFromIndex(_index).hasAttribute('disabled')) {
1648
+ return _index;
1606
1649
  }
1607
1650
  }
1608
1651
  }
@@ -1626,28 +1669,30 @@
1626
1669
  if (checkActiveElement === void 0) {
1627
1670
  checkActiveElement = true;
1628
1671
  }
1629
- return downshiftElements.some(contextNode => contextNode && (isOrContainsNode(contextNode, target, environment) || checkActiveElement && isOrContainsNode(contextNode, environment.document.activeElement, environment)));
1672
+ return downshiftElements.some(function (contextNode) {
1673
+ return contextNode && (isOrContainsNode(contextNode, target, environment) || checkActiveElement && isOrContainsNode(contextNode, environment.document.activeElement, environment));
1674
+ });
1630
1675
  }
1631
1676
 
1632
1677
  // eslint-disable-next-line import/no-mutable-exports
1633
- let validateControlledUnchanged = noop;
1678
+ var validateControlledUnchanged = noop;
1634
1679
  /* istanbul ignore next */
1635
1680
  {
1636
- validateControlledUnchanged = (state, prevProps, nextProps) => {
1637
- const warningDescription = `This prop should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled Downshift element for the lifetime of the component. More info: https://github.com/downshift-js/downshift#control-props`;
1638
- Object.keys(state).forEach(propKey => {
1681
+ validateControlledUnchanged = function validateControlledUnchanged(state, prevProps, nextProps) {
1682
+ var warningDescription = "This prop should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled Downshift element for the lifetime of the component. More info: https://github.com/downshift-js/downshift#control-props";
1683
+ Object.keys(state).forEach(function (propKey) {
1639
1684
  if (prevProps[propKey] !== undefined && nextProps[propKey] === undefined) {
1640
1685
  // eslint-disable-next-line no-console
1641
- console.error(`downshift: A component has changed the controlled prop "${propKey}" to be uncontrolled. ${warningDescription}`);
1686
+ console.error("downshift: A component has changed the controlled prop \"" + propKey + "\" to be uncontrolled. " + warningDescription);
1642
1687
  } else if (prevProps[propKey] === undefined && nextProps[propKey] !== undefined) {
1643
1688
  // eslint-disable-next-line no-console
1644
- console.error(`downshift: A component has changed the uncontrolled prop "${propKey}" to be controlled. ${warningDescription}`);
1689
+ console.error("downshift: A component has changed the uncontrolled prop \"" + propKey + "\" to be controlled. " + warningDescription);
1645
1690
  }
1646
1691
  });
1647
1692
  };
1648
1693
  }
1649
1694
 
1650
- const cleanupStatus = debounce(documentProp => {
1695
+ var cleanupStatus = debounce(function (documentProp) {
1651
1696
  getStatusDiv(documentProp).textContent = '';
1652
1697
  }, 500);
1653
1698
 
@@ -1656,7 +1701,7 @@
1656
1701
  * @param {Object} documentProp document passed by the user.
1657
1702
  */
1658
1703
  function setStatus(status, documentProp) {
1659
- const div = getStatusDiv(documentProp);
1704
+ var div = getStatusDiv(documentProp);
1660
1705
  if (!status) {
1661
1706
  return;
1662
1707
  }
@@ -1673,7 +1718,7 @@
1673
1718
  if (documentProp === void 0) {
1674
1719
  documentProp = document;
1675
1720
  }
1676
- let statusDiv = documentProp.getElementById('a11y-status-message');
1721
+ var statusDiv = documentProp.getElementById('a11y-status-message');
1677
1722
  if (statusDiv) {
1678
1723
  return statusDiv;
1679
1724
  }
@@ -1696,23 +1741,23 @@
1696
1741
  return statusDiv;
1697
1742
  }
1698
1743
 
1699
- const unknown = '__autocomplete_unknown__' ;
1700
- const mouseUp = '__autocomplete_mouseup__' ;
1701
- const itemMouseEnter = '__autocomplete_item_mouseenter__' ;
1702
- const keyDownArrowUp = '__autocomplete_keydown_arrow_up__' ;
1703
- const keyDownArrowDown = '__autocomplete_keydown_arrow_down__' ;
1704
- const keyDownEscape = '__autocomplete_keydown_escape__' ;
1705
- const keyDownEnter = '__autocomplete_keydown_enter__' ;
1706
- const keyDownHome = '__autocomplete_keydown_home__' ;
1707
- const keyDownEnd = '__autocomplete_keydown_end__' ;
1708
- const clickItem = '__autocomplete_click_item__' ;
1709
- const blurInput = '__autocomplete_blur_input__' ;
1710
- const changeInput = '__autocomplete_change_input__' ;
1711
- const keyDownSpaceButton = '__autocomplete_keydown_space_button__' ;
1712
- const clickButton = '__autocomplete_click_button__' ;
1713
- const blurButton = '__autocomplete_blur_button__' ;
1714
- const controlledPropUpdatedSelectedItem = '__autocomplete_controlled_prop_updated_selected_item__' ;
1715
- const touchEnd = '__autocomplete_touchend__' ;
1744
+ var unknown = '__autocomplete_unknown__' ;
1745
+ var mouseUp = '__autocomplete_mouseup__' ;
1746
+ var itemMouseEnter = '__autocomplete_item_mouseenter__' ;
1747
+ var keyDownArrowUp = '__autocomplete_keydown_arrow_up__' ;
1748
+ var keyDownArrowDown = '__autocomplete_keydown_arrow_down__' ;
1749
+ var keyDownEscape = '__autocomplete_keydown_escape__' ;
1750
+ var keyDownEnter = '__autocomplete_keydown_enter__' ;
1751
+ var keyDownHome = '__autocomplete_keydown_home__' ;
1752
+ var keyDownEnd = '__autocomplete_keydown_end__' ;
1753
+ var clickItem = '__autocomplete_click_item__' ;
1754
+ var blurInput = '__autocomplete_blur_input__' ;
1755
+ var changeInput = '__autocomplete_change_input__' ;
1756
+ var keyDownSpaceButton = '__autocomplete_keydown_space_button__' ;
1757
+ var clickButton = '__autocomplete_click_button__' ;
1758
+ var blurButton = '__autocomplete_blur_button__' ;
1759
+ var controlledPropUpdatedSelectedItem = '__autocomplete_controlled_prop_updated_selected_item__' ;
1760
+ var touchEnd = '__autocomplete_touchend__' ;
1716
1761
 
1717
1762
  var stateChangeTypes$3 = /*#__PURE__*/Object.freeze({
1718
1763
  __proto__: null,
@@ -1735,37 +1780,48 @@
1735
1780
  touchEnd: touchEnd
1736
1781
  });
1737
1782
 
1738
- /* eslint camelcase:0 */
1739
- const Downshift = /*#__PURE__*/(() => {
1740
- class Downshift extends react.Component {
1741
- constructor(_props) {
1783
+ var _excluded$4 = ["refKey", "ref"],
1784
+ _excluded2$3 = ["onClick", "onPress", "onKeyDown", "onKeyUp", "onBlur"],
1785
+ _excluded3$2 = ["onKeyDown", "onBlur", "onChange", "onInput", "onChangeText"],
1786
+ _excluded4$1 = ["refKey", "ref"],
1787
+ _excluded5 = ["onMouseMove", "onMouseDown", "onClick", "onPress", "index", "item"];
1788
+ var Downshift = /*#__PURE__*/function () {
1789
+ var Downshift = /*#__PURE__*/function (_Component) {
1790
+ _inheritsLoose(Downshift, _Component);
1791
+ function Downshift(_props) {
1742
1792
  var _this;
1743
- super(_props);
1744
- _this = this;
1745
- this.id = this.props.id || `downshift-${generateId()}`;
1746
- this.menuId = this.props.menuId || `${this.id}-menu`;
1747
- this.labelId = this.props.labelId || `${this.id}-label`;
1748
- this.inputId = this.props.inputId || `${this.id}-input`;
1749
- this.getItemId = this.props.getItemId || (index => `${this.id}-item-${index}`);
1750
- this.input = null;
1751
- this.items = [];
1752
- this.itemCount = null;
1753
- this.previousResultCount = 0;
1754
- this.timeoutIds = [];
1755
- this.internalSetTimeout = (fn, time) => {
1756
- const id = setTimeout(() => {
1757
- this.timeoutIds = this.timeoutIds.filter(i => i !== id);
1793
+ _this = _Component.call(this, _props) || this;
1794
+ // fancy destructuring + defaults + aliases
1795
+ // this basically says each value of state should either be set to
1796
+ // the initial value or the default value if the initial value is not provided
1797
+ _this.id = _this.props.id || "downshift-" + generateId();
1798
+ _this.menuId = _this.props.menuId || _this.id + "-menu";
1799
+ _this.labelId = _this.props.labelId || _this.id + "-label";
1800
+ _this.inputId = _this.props.inputId || _this.id + "-input";
1801
+ _this.getItemId = _this.props.getItemId || function (index) {
1802
+ return _this.id + "-item-" + index;
1803
+ };
1804
+ _this.input = null;
1805
+ _this.items = [];
1806
+ _this.itemCount = null;
1807
+ _this.previousResultCount = 0;
1808
+ _this.timeoutIds = [];
1809
+ _this.internalSetTimeout = function (fn, time) {
1810
+ var id = setTimeout(function () {
1811
+ _this.timeoutIds = _this.timeoutIds.filter(function (i) {
1812
+ return i !== id;
1813
+ });
1758
1814
  fn();
1759
1815
  }, time);
1760
- this.timeoutIds.push(id);
1816
+ _this.timeoutIds.push(id);
1761
1817
  };
1762
- this.setItemCount = count => {
1763
- this.itemCount = count;
1818
+ _this.setItemCount = function (count) {
1819
+ _this.itemCount = count;
1764
1820
  };
1765
- this.unsetItemCount = () => {
1766
- this.itemCount = null;
1821
+ _this.unsetItemCount = function () {
1822
+ _this.itemCount = null;
1767
1823
  };
1768
- this.setHighlightedIndex = function (highlightedIndex, otherStateToSet) {
1824
+ _this.setHighlightedIndex = function (highlightedIndex, otherStateToSet) {
1769
1825
  if (highlightedIndex === void 0) {
1770
1826
  highlightedIndex = _this.props.defaultHighlightedIndex;
1771
1827
  }
@@ -1773,43 +1829,41 @@
1773
1829
  otherStateToSet = {};
1774
1830
  }
1775
1831
  otherStateToSet = pickState(otherStateToSet);
1776
- _this.internalSetState({
1777
- highlightedIndex,
1778
- ...otherStateToSet
1779
- });
1832
+ _this.internalSetState(_extends({
1833
+ highlightedIndex: highlightedIndex
1834
+ }, otherStateToSet));
1780
1835
  };
1781
- this.clearSelection = cb => {
1782
- this.internalSetState({
1836
+ _this.clearSelection = function (cb) {
1837
+ _this.internalSetState({
1783
1838
  selectedItem: null,
1784
1839
  inputValue: '',
1785
- highlightedIndex: this.props.defaultHighlightedIndex,
1786
- isOpen: this.props.defaultIsOpen
1840
+ highlightedIndex: _this.props.defaultHighlightedIndex,
1841
+ isOpen: _this.props.defaultIsOpen
1787
1842
  }, cb);
1788
1843
  };
1789
- this.selectItem = (item, otherStateToSet, cb) => {
1844
+ _this.selectItem = function (item, otherStateToSet, cb) {
1790
1845
  otherStateToSet = pickState(otherStateToSet);
1791
- this.internalSetState({
1792
- isOpen: this.props.defaultIsOpen,
1793
- highlightedIndex: this.props.defaultHighlightedIndex,
1846
+ _this.internalSetState(_extends({
1847
+ isOpen: _this.props.defaultIsOpen,
1848
+ highlightedIndex: _this.props.defaultHighlightedIndex,
1794
1849
  selectedItem: item,
1795
- inputValue: this.props.itemToString(item),
1796
- ...otherStateToSet
1797
- }, cb);
1850
+ inputValue: _this.props.itemToString(item)
1851
+ }, otherStateToSet), cb);
1798
1852
  };
1799
- this.selectItemAtIndex = (itemIndex, otherStateToSet, cb) => {
1800
- const item = this.items[itemIndex];
1853
+ _this.selectItemAtIndex = function (itemIndex, otherStateToSet, cb) {
1854
+ var item = _this.items[itemIndex];
1801
1855
  if (item == null) {
1802
1856
  return;
1803
1857
  }
1804
- this.selectItem(item, otherStateToSet, cb);
1858
+ _this.selectItem(item, otherStateToSet, cb);
1805
1859
  };
1806
- this.selectHighlightedItem = (otherStateToSet, cb) => {
1807
- return this.selectItemAtIndex(this.getState().highlightedIndex, otherStateToSet, cb);
1860
+ _this.selectHighlightedItem = function (otherStateToSet, cb) {
1861
+ return _this.selectItemAtIndex(_this.getState().highlightedIndex, otherStateToSet, cb);
1808
1862
  };
1809
- this.internalSetState = (stateToSet, cb) => {
1810
- let isItemSelected, onChangeArg;
1811
- const onStateChangeArg = {};
1812
- const isStateToSetFunction = typeof stateToSet === 'function';
1863
+ _this.internalSetState = function (stateToSet, cb) {
1864
+ var isItemSelected, onChangeArg;
1865
+ var onStateChangeArg = {};
1866
+ var isStateToSetFunction = typeof stateToSet === 'function';
1813
1867
 
1814
1868
  // we want to call `onInputValueChange` before the `setState` call
1815
1869
  // so someone controlling the `inputValue` state gets notified of
@@ -1817,24 +1871,21 @@
1817
1871
  // preserving the cursor position.
1818
1872
  // See https://github.com/downshift-js/downshift/issues/217 for more info.
1819
1873
  if (!isStateToSetFunction && stateToSet.hasOwnProperty('inputValue')) {
1820
- this.props.onInputValueChange(stateToSet.inputValue, {
1821
- ...this.getStateAndHelpers(),
1822
- ...stateToSet
1823
- });
1874
+ _this.props.onInputValueChange(stateToSet.inputValue, _extends({}, _this.getStateAndHelpers(), stateToSet));
1824
1875
  }
1825
- return this.setState(state => {
1826
- state = this.getState(state);
1827
- let newStateToSet = isStateToSetFunction ? stateToSet(state) : stateToSet;
1876
+ return _this.setState(function (state) {
1877
+ state = _this.getState(state);
1878
+ var newStateToSet = isStateToSetFunction ? stateToSet(state) : stateToSet;
1828
1879
 
1829
1880
  // Your own function that could modify the state that will be set.
1830
- newStateToSet = this.props.stateReducer(state, newStateToSet);
1881
+ newStateToSet = _this.props.stateReducer(state, newStateToSet);
1831
1882
 
1832
1883
  // checks if an item is selected, regardless of if it's different from
1833
1884
  // what was selected before
1834
1885
  // used to determine if onSelect and onChange callbacks should be called
1835
1886
  isItemSelected = newStateToSet.hasOwnProperty('selectedItem');
1836
1887
  // this keeps track of the object we want to call with setState
1837
- const nextState = {};
1888
+ var nextState = {};
1838
1889
  // we need to call on change if the outside world is controlling any of our state
1839
1890
  // and we're trying to update that state. OR if the selection has changed and we're
1840
1891
  // trying to update the selection
@@ -1842,7 +1893,7 @@
1842
1893
  onChangeArg = newStateToSet.selectedItem;
1843
1894
  }
1844
1895
  newStateToSet.type = newStateToSet.type || unknown;
1845
- Object.keys(newStateToSet).forEach(key => {
1896
+ Object.keys(newStateToSet).forEach(function (key) {
1846
1897
  // onStateChangeArg should only have the state that is
1847
1898
  // actually changing
1848
1899
  if (state[key] !== newStateToSet[key]) {
@@ -1859,7 +1910,7 @@
1859
1910
  }
1860
1911
  newStateToSet[key];
1861
1912
  // if it's coming from props, then we don't care to set it internally
1862
- if (!isControlledProp(this.props, key)) {
1913
+ if (!isControlledProp(_this.props, key)) {
1863
1914
  nextState[key] = newStateToSet[key];
1864
1915
  }
1865
1916
  });
@@ -1867,66 +1918,58 @@
1867
1918
  // if stateToSet is a function, then we weren't able to call onInputValueChange
1868
1919
  // earlier, so we'll call it now that we know what the inputValue state will be.
1869
1920
  if (isStateToSetFunction && newStateToSet.hasOwnProperty('inputValue')) {
1870
- this.props.onInputValueChange(newStateToSet.inputValue, {
1871
- ...this.getStateAndHelpers(),
1872
- ...newStateToSet
1873
- });
1921
+ _this.props.onInputValueChange(newStateToSet.inputValue, _extends({}, _this.getStateAndHelpers(), newStateToSet));
1874
1922
  }
1875
1923
  return nextState;
1876
- }, () => {
1924
+ }, function () {
1877
1925
  // call the provided callback if it's a function
1878
1926
  cbToCb(cb)();
1879
1927
 
1880
1928
  // only call the onStateChange and onChange callbacks if
1881
1929
  // we have relevant information to pass them.
1882
- const hasMoreStateThanType = Object.keys(onStateChangeArg).length > 1;
1930
+ var hasMoreStateThanType = Object.keys(onStateChangeArg).length > 1;
1883
1931
  if (hasMoreStateThanType) {
1884
- this.props.onStateChange(onStateChangeArg, this.getStateAndHelpers());
1932
+ _this.props.onStateChange(onStateChangeArg, _this.getStateAndHelpers());
1885
1933
  }
1886
1934
  if (isItemSelected) {
1887
- this.props.onSelect(stateToSet.selectedItem, this.getStateAndHelpers());
1935
+ _this.props.onSelect(stateToSet.selectedItem, _this.getStateAndHelpers());
1888
1936
  }
1889
1937
  if (onChangeArg !== undefined) {
1890
- this.props.onChange(onChangeArg, this.getStateAndHelpers());
1938
+ _this.props.onChange(onChangeArg, _this.getStateAndHelpers());
1891
1939
  }
1892
1940
  // this is currently undocumented and therefore subject to change
1893
1941
  // We'll try to not break it, but just be warned.
1894
- this.props.onUserAction(onStateChangeArg, this.getStateAndHelpers());
1942
+ _this.props.onUserAction(onStateChangeArg, _this.getStateAndHelpers());
1895
1943
  });
1896
1944
  };
1897
- this.rootRef = node => this._rootNode = node;
1898
- this.getRootProps = function (_temp, _temp2) {
1899
- let {
1900
- refKey = 'ref',
1901
- ref,
1902
- ...rest
1903
- } = _temp === void 0 ? {} : _temp;
1904
- let {
1905
- suppressRefError = false
1906
- } = _temp2 === void 0 ? {} : _temp2;
1945
+ _this.rootRef = function (node) {
1946
+ return _this._rootNode = node;
1947
+ };
1948
+ _this.getRootProps = function (_temp, _temp2) {
1949
+ var _extends2;
1950
+ var _ref = _temp === void 0 ? {} : _temp,
1951
+ _ref$refKey = _ref.refKey,
1952
+ refKey = _ref$refKey === void 0 ? 'ref' : _ref$refKey,
1953
+ ref = _ref.ref,
1954
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$4);
1955
+ var _ref2 = _temp2 === void 0 ? {} : _temp2,
1956
+ _ref2$suppressRefErro = _ref2.suppressRefError,
1957
+ suppressRefError = _ref2$suppressRefErro === void 0 ? false : _ref2$suppressRefErro;
1907
1958
  // this is used in the render to know whether the user has called getRootProps.
1908
1959
  // It uses that to know whether to apply the props automatically
1909
1960
  _this.getRootProps.called = true;
1910
1961
  _this.getRootProps.refKey = refKey;
1911
1962
  _this.getRootProps.suppressRefError = suppressRefError;
1912
- const {
1913
- isOpen
1914
- } = _this.getState();
1915
- return {
1916
- [refKey]: handleRefs(ref, _this.rootRef),
1917
- role: 'combobox',
1918
- 'aria-expanded': isOpen,
1919
- 'aria-haspopup': 'listbox',
1920
- 'aria-owns': isOpen ? _this.menuId : null,
1921
- 'aria-labelledby': _this.labelId,
1922
- ...rest
1923
- };
1963
+ var _this$getState = _this.getState(),
1964
+ isOpen = _this$getState.isOpen;
1965
+ return _extends((_extends2 = {}, _extends2[refKey] = handleRefs(ref, _this.rootRef), _extends2.role = 'combobox', _extends2['aria-expanded'] = isOpen, _extends2['aria-haspopup'] = 'listbox', _extends2['aria-owns'] = isOpen ? _this.menuId : null, _extends2['aria-labelledby'] = _this.labelId, _extends2), rest);
1924
1966
  };
1925
- this.keyDownHandlers = {
1926
- ArrowDown(event) {
1967
+ _this.keyDownHandlers = {
1968
+ ArrowDown: function ArrowDown(event) {
1969
+ var _this2 = this;
1927
1970
  event.preventDefault();
1928
1971
  if (this.getState().isOpen) {
1929
- const amount = event.shiftKey ? 5 : 1;
1972
+ var amount = event.shiftKey ? 5 : 1;
1930
1973
  this.moveHighlightedIndex(amount, {
1931
1974
  type: keyDownArrowDown
1932
1975
  });
@@ -1934,24 +1977,26 @@
1934
1977
  this.internalSetState({
1935
1978
  isOpen: true,
1936
1979
  type: keyDownArrowDown
1937
- }, () => {
1938
- const itemCount = this.getItemCount();
1980
+ }, function () {
1981
+ var itemCount = _this2.getItemCount();
1939
1982
  if (itemCount > 0) {
1940
- const {
1941
- highlightedIndex
1942
- } = this.getState();
1943
- const nextHighlightedIndex = getNextWrappingIndex(1, highlightedIndex, itemCount, index => this.getItemNodeFromIndex(index));
1944
- this.setHighlightedIndex(nextHighlightedIndex, {
1983
+ var _this2$getState = _this2.getState(),
1984
+ highlightedIndex = _this2$getState.highlightedIndex;
1985
+ var nextHighlightedIndex = getNextWrappingIndex(1, highlightedIndex, itemCount, function (index) {
1986
+ return _this2.getItemNodeFromIndex(index);
1987
+ });
1988
+ _this2.setHighlightedIndex(nextHighlightedIndex, {
1945
1989
  type: keyDownArrowDown
1946
1990
  });
1947
1991
  }
1948
1992
  });
1949
1993
  }
1950
1994
  },
1951
- ArrowUp(event) {
1995
+ ArrowUp: function ArrowUp(event) {
1996
+ var _this3 = this;
1952
1997
  event.preventDefault();
1953
1998
  if (this.getState().isOpen) {
1954
- const amount = event.shiftKey ? -5 : -1;
1999
+ var amount = event.shiftKey ? -5 : -1;
1955
2000
  this.moveHighlightedIndex(amount, {
1956
2001
  type: keyDownArrowUp
1957
2002
  });
@@ -1959,32 +2004,32 @@
1959
2004
  this.internalSetState({
1960
2005
  isOpen: true,
1961
2006
  type: keyDownArrowUp
1962
- }, () => {
1963
- const itemCount = this.getItemCount();
2007
+ }, function () {
2008
+ var itemCount = _this3.getItemCount();
1964
2009
  if (itemCount > 0) {
1965
- const {
1966
- highlightedIndex
1967
- } = this.getState();
1968
- const nextHighlightedIndex = getNextWrappingIndex(-1, highlightedIndex, itemCount, index => this.getItemNodeFromIndex(index));
1969
- this.setHighlightedIndex(nextHighlightedIndex, {
2010
+ var _this3$getState = _this3.getState(),
2011
+ highlightedIndex = _this3$getState.highlightedIndex;
2012
+ var nextHighlightedIndex = getNextWrappingIndex(-1, highlightedIndex, itemCount, function (index) {
2013
+ return _this3.getItemNodeFromIndex(index);
2014
+ });
2015
+ _this3.setHighlightedIndex(nextHighlightedIndex, {
1970
2016
  type: keyDownArrowUp
1971
2017
  });
1972
2018
  }
1973
2019
  });
1974
2020
  }
1975
2021
  },
1976
- Enter(event) {
2022
+ Enter: function Enter(event) {
1977
2023
  if (event.which === 229) {
1978
2024
  return;
1979
2025
  }
1980
- const {
1981
- isOpen,
1982
- highlightedIndex
1983
- } = this.getState();
2026
+ var _this$getState2 = this.getState(),
2027
+ isOpen = _this$getState2.isOpen,
2028
+ highlightedIndex = _this$getState2.highlightedIndex;
1984
2029
  if (isOpen && highlightedIndex != null) {
1985
2030
  event.preventDefault();
1986
- const item = this.items[highlightedIndex];
1987
- const itemNode = this.getItemNodeFromIndex(highlightedIndex);
2031
+ var item = this.items[highlightedIndex];
2032
+ var itemNode = this.getItemNodeFromIndex(highlightedIndex);
1988
2033
  if (item == null || itemNode && itemNode.hasAttribute('disabled')) {
1989
2034
  return;
1990
2035
  }
@@ -1993,112 +2038,109 @@
1993
2038
  });
1994
2039
  }
1995
2040
  },
1996
- Escape(event) {
2041
+ Escape: function Escape(event) {
1997
2042
  event.preventDefault();
1998
- this.reset({
1999
- type: keyDownEscape,
2000
- ...(!this.state.isOpen && {
2001
- selectedItem: null,
2002
- inputValue: ''
2003
- })
2004
- });
2043
+ this.reset(_extends({
2044
+ type: keyDownEscape
2045
+ }, !this.state.isOpen && {
2046
+ selectedItem: null,
2047
+ inputValue: ''
2048
+ }));
2005
2049
  }
2006
2050
  };
2007
- this.buttonKeyDownHandlers = {
2008
- ...this.keyDownHandlers,
2009
- ' '(event) {
2051
+ _this.buttonKeyDownHandlers = _extends({}, _this.keyDownHandlers, {
2052
+ ' ': function _(event) {
2010
2053
  event.preventDefault();
2011
2054
  this.toggleMenu({
2012
2055
  type: keyDownSpaceButton
2013
2056
  });
2014
2057
  }
2015
- };
2016
- this.inputKeyDownHandlers = {
2017
- ...this.keyDownHandlers,
2018
- Home(event) {
2019
- const {
2020
- isOpen
2021
- } = this.getState();
2058
+ });
2059
+ _this.inputKeyDownHandlers = _extends({}, _this.keyDownHandlers, {
2060
+ Home: function Home(event) {
2061
+ var _this4 = this;
2062
+ var _this$getState3 = this.getState(),
2063
+ isOpen = _this$getState3.isOpen;
2022
2064
  if (!isOpen) {
2023
2065
  return;
2024
2066
  }
2025
2067
  event.preventDefault();
2026
- const itemCount = this.getItemCount();
2068
+ var itemCount = this.getItemCount();
2027
2069
  if (itemCount <= 0 || !isOpen) {
2028
2070
  return;
2029
2071
  }
2030
2072
 
2031
2073
  // get next non-disabled starting downwards from 0 if that's disabled.
2032
- const newHighlightedIndex = getNextNonDisabledIndex(1, 0, itemCount, index => this.getItemNodeFromIndex(index), false);
2074
+ var newHighlightedIndex = getNextNonDisabledIndex(1, 0, itemCount, function (index) {
2075
+ return _this4.getItemNodeFromIndex(index);
2076
+ }, false);
2033
2077
  this.setHighlightedIndex(newHighlightedIndex, {
2034
2078
  type: keyDownHome
2035
2079
  });
2036
2080
  },
2037
- End(event) {
2038
- const {
2039
- isOpen
2040
- } = this.getState();
2081
+ End: function End(event) {
2082
+ var _this5 = this;
2083
+ var _this$getState4 = this.getState(),
2084
+ isOpen = _this$getState4.isOpen;
2041
2085
  if (!isOpen) {
2042
2086
  return;
2043
2087
  }
2044
2088
  event.preventDefault();
2045
- const itemCount = this.getItemCount();
2089
+ var itemCount = this.getItemCount();
2046
2090
  if (itemCount <= 0 || !isOpen) {
2047
2091
  return;
2048
2092
  }
2049
2093
 
2050
2094
  // get next non-disabled starting upwards from last index if that's disabled.
2051
- const newHighlightedIndex = getNextNonDisabledIndex(-1, itemCount - 1, itemCount, index => this.getItemNodeFromIndex(index), false);
2095
+ var newHighlightedIndex = getNextNonDisabledIndex(-1, itemCount - 1, itemCount, function (index) {
2096
+ return _this5.getItemNodeFromIndex(index);
2097
+ }, false);
2052
2098
  this.setHighlightedIndex(newHighlightedIndex, {
2053
2099
  type: keyDownEnd
2054
2100
  });
2055
2101
  }
2056
- };
2057
- this.getToggleButtonProps = function (_temp3) {
2058
- let {
2059
- onClick,
2060
- onPress,
2061
- onKeyDown,
2062
- onKeyUp,
2063
- onBlur,
2064
- ...rest
2065
- } = _temp3 === void 0 ? {} : _temp3;
2066
- const {
2067
- isOpen
2068
- } = _this.getState();
2069
- const enabledEventHandlers = {
2102
+ });
2103
+ _this.getToggleButtonProps = function (_temp3) {
2104
+ var _ref3 = _temp3 === void 0 ? {} : _temp3,
2105
+ onClick = _ref3.onClick;
2106
+ _ref3.onPress;
2107
+ var onKeyDown = _ref3.onKeyDown,
2108
+ onKeyUp = _ref3.onKeyUp,
2109
+ onBlur = _ref3.onBlur,
2110
+ rest = _objectWithoutPropertiesLoose(_ref3, _excluded2$3);
2111
+ var _this$getState5 = _this.getState(),
2112
+ isOpen = _this$getState5.isOpen;
2113
+ var enabledEventHandlers = {
2070
2114
  onClick: callAllEventHandlers(onClick, _this.buttonHandleClick),
2071
2115
  onKeyDown: callAllEventHandlers(onKeyDown, _this.buttonHandleKeyDown),
2072
2116
  onKeyUp: callAllEventHandlers(onKeyUp, _this.buttonHandleKeyUp),
2073
2117
  onBlur: callAllEventHandlers(onBlur, _this.buttonHandleBlur)
2074
2118
  };
2075
- const eventHandlers = rest.disabled ? {} : enabledEventHandlers;
2076
- return {
2119
+ var eventHandlers = rest.disabled ? {} : enabledEventHandlers;
2120
+ return _extends({
2077
2121
  type: 'button',
2078
2122
  role: 'button',
2079
2123
  'aria-label': isOpen ? 'close menu' : 'open menu',
2080
2124
  'aria-haspopup': true,
2081
- 'data-toggle': true,
2082
- ...eventHandlers,
2083
- ...rest
2084
- };
2125
+ 'data-toggle': true
2126
+ }, eventHandlers, rest);
2085
2127
  };
2086
- this.buttonHandleKeyUp = event => {
2128
+ _this.buttonHandleKeyUp = function (event) {
2087
2129
  // Prevent click event from emitting in Firefox
2088
2130
  event.preventDefault();
2089
2131
  };
2090
- this.buttonHandleKeyDown = event => {
2091
- const key = normalizeArrowKey(event);
2092
- if (this.buttonKeyDownHandlers[key]) {
2093
- this.buttonKeyDownHandlers[key].call(this, event);
2132
+ _this.buttonHandleKeyDown = function (event) {
2133
+ var key = normalizeArrowKey(event);
2134
+ if (_this.buttonKeyDownHandlers[key]) {
2135
+ _this.buttonKeyDownHandlers[key].call(_assertThisInitialized(_this), event);
2094
2136
  }
2095
2137
  };
2096
- this.buttonHandleClick = event => {
2138
+ _this.buttonHandleClick = function (event) {
2097
2139
  event.preventDefault();
2098
2140
  // handle odd case for Safari and Firefox which
2099
2141
  // don't give the button the focus properly.
2100
2142
  /* istanbul ignore if (can't reasonably test this) */
2101
- if (this.props.environment.document.activeElement === this.props.environment.document.body) {
2143
+ if (_this.props.environment.document.activeElement === _this.props.environment.document.body) {
2102
2144
  event.target.focus();
2103
2145
  }
2104
2146
  // to simplify testing components that use downshift, we'll not wrap this in a setTimeout
@@ -2106,59 +2148,55 @@
2106
2148
  // when building for production and should therefore have no impact on production code.
2107
2149
  {
2108
2150
  // Ensure that toggle of menu occurs after the potential blur event in iOS
2109
- this.internalSetTimeout(() => this.toggleMenu({
2110
- type: clickButton
2111
- }));
2151
+ _this.internalSetTimeout(function () {
2152
+ return _this.toggleMenu({
2153
+ type: clickButton
2154
+ });
2155
+ });
2112
2156
  }
2113
2157
  };
2114
- this.buttonHandleBlur = event => {
2115
- const blurTarget = event.target; // Save blur target for comparison with activeElement later
2158
+ _this.buttonHandleBlur = function (event) {
2159
+ var blurTarget = event.target; // Save blur target for comparison with activeElement later
2116
2160
  // Need setTimeout, so that when the user presses Tab, the activeElement is the next focused element, not body element
2117
- this.internalSetTimeout(() => {
2118
- 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)
2161
+ _this.internalSetTimeout(function () {
2162
+ 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)
2119
2163
  ) {
2120
- this.reset({
2164
+ _this.reset({
2121
2165
  type: blurButton
2122
2166
  });
2123
2167
  }
2124
2168
  });
2125
2169
  };
2126
- this.getLabelProps = props => {
2127
- return {
2128
- htmlFor: this.inputId,
2129
- id: this.labelId,
2130
- ...props
2131
- };
2170
+ _this.getLabelProps = function (props) {
2171
+ return _extends({
2172
+ htmlFor: _this.inputId,
2173
+ id: _this.labelId
2174
+ }, props);
2132
2175
  };
2133
- this.getInputProps = function (_temp4) {
2134
- let {
2135
- onKeyDown,
2136
- onBlur,
2137
- onChange,
2138
- onInput,
2139
- onChangeText,
2140
- ...rest
2141
- } = _temp4 === void 0 ? {} : _temp4;
2142
- let onChangeKey;
2143
- let eventHandlers = {};
2176
+ _this.getInputProps = function (_temp4) {
2177
+ var _ref4 = _temp4 === void 0 ? {} : _temp4,
2178
+ onKeyDown = _ref4.onKeyDown,
2179
+ onBlur = _ref4.onBlur,
2180
+ onChange = _ref4.onChange,
2181
+ onInput = _ref4.onInput;
2182
+ _ref4.onChangeText;
2183
+ var rest = _objectWithoutPropertiesLoose(_ref4, _excluded3$2);
2184
+ var onChangeKey;
2185
+ var eventHandlers = {};
2144
2186
 
2145
2187
  /* istanbul ignore next (preact) */
2146
2188
  {
2147
2189
  onChangeKey = 'onChange';
2148
2190
  }
2149
- const {
2150
- inputValue,
2151
- isOpen,
2152
- highlightedIndex
2153
- } = _this.getState();
2191
+ var _this$getState6 = _this.getState(),
2192
+ inputValue = _this$getState6.inputValue,
2193
+ isOpen = _this$getState6.isOpen,
2194
+ highlightedIndex = _this$getState6.highlightedIndex;
2154
2195
  if (!rest.disabled) {
2155
- eventHandlers = {
2156
- [onChangeKey]: callAllEventHandlers(onChange, onInput, _this.inputHandleChange),
2157
- onKeyDown: callAllEventHandlers(onKeyDown, _this.inputHandleKeyDown),
2158
- onBlur: callAllEventHandlers(onBlur, _this.inputHandleBlur)
2159
- };
2196
+ var _eventHandlers;
2197
+ eventHandlers = (_eventHandlers = {}, _eventHandlers[onChangeKey] = callAllEventHandlers(onChange, onInput, _this.inputHandleChange), _eventHandlers.onKeyDown = callAllEventHandlers(onKeyDown, _this.inputHandleKeyDown), _eventHandlers.onBlur = callAllEventHandlers(onBlur, _this.inputHandleBlur), _eventHandlers);
2160
2198
  }
2161
- return {
2199
+ return _extends({
2162
2200
  'aria-autocomplete': 'list',
2163
2201
  'aria-activedescendant': isOpen && typeof highlightedIndex === 'number' && highlightedIndex >= 0 ? _this.getItemId(highlightedIndex) : null,
2164
2202
  'aria-controls': isOpen ? _this.menuId : null,
@@ -2167,82 +2205,76 @@
2167
2205
  // revert back since autocomplete="nope" is ignored on latest Chrome and Opera
2168
2206
  autoComplete: 'off',
2169
2207
  value: inputValue,
2170
- id: _this.inputId,
2171
- ...eventHandlers,
2172
- ...rest
2173
- };
2208
+ id: _this.inputId
2209
+ }, eventHandlers, rest);
2174
2210
  };
2175
- this.inputHandleKeyDown = event => {
2176
- const key = normalizeArrowKey(event);
2177
- if (key && this.inputKeyDownHandlers[key]) {
2178
- this.inputKeyDownHandlers[key].call(this, event);
2211
+ _this.inputHandleKeyDown = function (event) {
2212
+ var key = normalizeArrowKey(event);
2213
+ if (key && _this.inputKeyDownHandlers[key]) {
2214
+ _this.inputKeyDownHandlers[key].call(_assertThisInitialized(_this), event);
2179
2215
  }
2180
2216
  };
2181
- this.inputHandleChange = event => {
2182
- this.internalSetState({
2217
+ _this.inputHandleChange = function (event) {
2218
+ _this.internalSetState({
2183
2219
  type: changeInput,
2184
2220
  isOpen: true,
2185
2221
  inputValue: event.target.value,
2186
- highlightedIndex: this.props.defaultHighlightedIndex
2222
+ highlightedIndex: _this.props.defaultHighlightedIndex
2187
2223
  });
2188
2224
  };
2189
- this.inputHandleBlur = () => {
2225
+ _this.inputHandleBlur = function () {
2190
2226
  // Need setTimeout, so that when the user presses Tab, the activeElement is the next focused element, not the body element
2191
- this.internalSetTimeout(() => {
2192
- const downshiftButtonIsActive = this.props.environment.document && !!this.props.environment.document.activeElement && !!this.props.environment.document.activeElement.dataset && this.props.environment.document.activeElement.dataset.toggle && this._rootNode && this._rootNode.contains(this.props.environment.document.activeElement);
2193
- if (!this.isMouseDown && !downshiftButtonIsActive) {
2194
- this.reset({
2227
+ _this.internalSetTimeout(function () {
2228
+ var downshiftButtonIsActive = _this.props.environment.document && !!_this.props.environment.document.activeElement && !!_this.props.environment.document.activeElement.dataset && _this.props.environment.document.activeElement.dataset.toggle && _this._rootNode && _this._rootNode.contains(_this.props.environment.document.activeElement);
2229
+ if (!_this.isMouseDown && !downshiftButtonIsActive) {
2230
+ _this.reset({
2195
2231
  type: blurInput
2196
2232
  });
2197
2233
  }
2198
2234
  });
2199
2235
  };
2200
- this.menuRef = node => {
2201
- this._menuNode = node;
2236
+ _this.menuRef = function (node) {
2237
+ _this._menuNode = node;
2202
2238
  };
2203
- this.getMenuProps = function (_temp5, _temp6) {
2204
- let {
2205
- refKey = 'ref',
2206
- ref,
2207
- ...props
2208
- } = _temp5 === void 0 ? {} : _temp5;
2209
- let {
2210
- suppressRefError = false
2211
- } = _temp6 === void 0 ? {} : _temp6;
2239
+ _this.getMenuProps = function (_temp5, _temp6) {
2240
+ var _extends3;
2241
+ var _ref5 = _temp5 === void 0 ? {} : _temp5,
2242
+ _ref5$refKey = _ref5.refKey,
2243
+ refKey = _ref5$refKey === void 0 ? 'ref' : _ref5$refKey,
2244
+ ref = _ref5.ref,
2245
+ props = _objectWithoutPropertiesLoose(_ref5, _excluded4$1);
2246
+ var _ref6 = _temp6 === void 0 ? {} : _temp6,
2247
+ _ref6$suppressRefErro = _ref6.suppressRefError,
2248
+ suppressRefError = _ref6$suppressRefErro === void 0 ? false : _ref6$suppressRefErro;
2212
2249
  _this.getMenuProps.called = true;
2213
2250
  _this.getMenuProps.refKey = refKey;
2214
2251
  _this.getMenuProps.suppressRefError = suppressRefError;
2215
- return {
2216
- [refKey]: handleRefs(ref, _this.menuRef),
2217
- role: 'listbox',
2218
- 'aria-labelledby': props && props['aria-label'] ? null : _this.labelId,
2219
- id: _this.menuId,
2220
- ...props
2221
- };
2252
+ return _extends((_extends3 = {}, _extends3[refKey] = handleRefs(ref, _this.menuRef), _extends3.role = 'listbox', _extends3['aria-labelledby'] = props && props['aria-label'] ? null : _this.labelId, _extends3.id = _this.menuId, _extends3), props);
2222
2253
  };
2223
- this.getItemProps = function (_temp7) {
2224
- let {
2225
- onMouseMove,
2226
- onMouseDown,
2227
- onClick,
2228
- onPress,
2229
- index,
2230
- item = requiredProp('getItemProps', 'item'),
2231
- ...rest
2232
- } = _temp7 === void 0 ? {} : _temp7;
2254
+ _this.getItemProps = function (_temp7) {
2255
+ var _enabledEventHandlers;
2256
+ var _ref7 = _temp7 === void 0 ? {} : _temp7,
2257
+ onMouseMove = _ref7.onMouseMove,
2258
+ onMouseDown = _ref7.onMouseDown,
2259
+ onClick = _ref7.onClick;
2260
+ _ref7.onPress;
2261
+ var index = _ref7.index,
2262
+ _ref7$item = _ref7.item,
2263
+ item = _ref7$item === void 0 ? requiredProp('getItemProps', 'item') : _ref7$item,
2264
+ rest = _objectWithoutPropertiesLoose(_ref7, _excluded5);
2233
2265
  if (index === undefined) {
2234
2266
  _this.items.push(item);
2235
2267
  index = _this.items.indexOf(item);
2236
2268
  } else {
2237
2269
  _this.items[index] = item;
2238
2270
  }
2239
- const onSelectKey = 'onClick';
2240
- const customClickHandler = onClick;
2241
- const enabledEventHandlers = {
2271
+ var onSelectKey = 'onClick';
2272
+ var customClickHandler = onClick;
2273
+ var enabledEventHandlers = (_enabledEventHandlers = {
2242
2274
  // onMouseMove is used over onMouseEnter here. onMouseMove
2243
2275
  // is only triggered on actual mouse movement while onMouseEnter
2244
2276
  // can fire on DOM changes, interrupting keyboard navigation
2245
- onMouseMove: callAllEventHandlers(onMouseMove, () => {
2277
+ onMouseMove: callAllEventHandlers(onMouseMove, function () {
2246
2278
  if (index === _this.getState().highlightedIndex) {
2247
2279
  return;
2248
2280
  }
@@ -2255,75 +2287,66 @@
2255
2287
  // from under the user which is currently scrolling/moving the
2256
2288
  // cursor
2257
2289
  _this.avoidScrolling = true;
2258
- _this.internalSetTimeout(() => _this.avoidScrolling = false, 250);
2290
+ _this.internalSetTimeout(function () {
2291
+ return _this.avoidScrolling = false;
2292
+ }, 250);
2259
2293
  }),
2260
- onMouseDown: callAllEventHandlers(onMouseDown, event => {
2294
+ onMouseDown: callAllEventHandlers(onMouseDown, function (event) {
2261
2295
  // This prevents the activeElement from being changed
2262
2296
  // to the item so it can remain with the current activeElement
2263
2297
  // which is a more common use case.
2264
2298
  event.preventDefault();
2265
- }),
2266
- [onSelectKey]: callAllEventHandlers(customClickHandler, () => {
2267
- _this.selectItemAtIndex(index, {
2268
- type: clickItem
2269
- });
2270
2299
  })
2271
- };
2300
+ }, _enabledEventHandlers[onSelectKey] = callAllEventHandlers(customClickHandler, function () {
2301
+ _this.selectItemAtIndex(index, {
2302
+ type: clickItem
2303
+ });
2304
+ }), _enabledEventHandlers);
2272
2305
 
2273
2306
  // Passing down the onMouseDown handler to prevent redirect
2274
2307
  // of the activeElement if clicking on disabled items
2275
- const eventHandlers = rest.disabled ? {
2308
+ var eventHandlers = rest.disabled ? {
2276
2309
  onMouseDown: enabledEventHandlers.onMouseDown
2277
2310
  } : enabledEventHandlers;
2278
- return {
2311
+ return _extends({
2279
2312
  id: _this.getItemId(index),
2280
2313
  role: 'option',
2281
- 'aria-selected': _this.getState().highlightedIndex === index,
2282
- ...eventHandlers,
2283
- ...rest
2284
- };
2314
+ 'aria-selected': _this.getState().highlightedIndex === index
2315
+ }, eventHandlers, rest);
2285
2316
  };
2286
- this.clearItems = () => {
2287
- this.items = [];
2317
+ _this.clearItems = function () {
2318
+ _this.items = [];
2288
2319
  };
2289
- this.reset = function (otherStateToSet, cb) {
2320
+ _this.reset = function (otherStateToSet, cb) {
2290
2321
  if (otherStateToSet === void 0) {
2291
2322
  otherStateToSet = {};
2292
2323
  }
2293
2324
  otherStateToSet = pickState(otherStateToSet);
2294
- _this.internalSetState(_ref => {
2295
- let {
2296
- selectedItem
2297
- } = _ref;
2298
- return {
2325
+ _this.internalSetState(function (_ref8) {
2326
+ var selectedItem = _ref8.selectedItem;
2327
+ return _extends({
2299
2328
  isOpen: _this.props.defaultIsOpen,
2300
2329
  highlightedIndex: _this.props.defaultHighlightedIndex,
2301
- inputValue: _this.props.itemToString(selectedItem),
2302
- ...otherStateToSet
2303
- };
2330
+ inputValue: _this.props.itemToString(selectedItem)
2331
+ }, otherStateToSet);
2304
2332
  }, cb);
2305
2333
  };
2306
- this.toggleMenu = function (otherStateToSet, cb) {
2334
+ _this.toggleMenu = function (otherStateToSet, cb) {
2307
2335
  if (otherStateToSet === void 0) {
2308
2336
  otherStateToSet = {};
2309
2337
  }
2310
2338
  otherStateToSet = pickState(otherStateToSet);
2311
- _this.internalSetState(_ref2 => {
2312
- let {
2313
- isOpen
2314
- } = _ref2;
2315
- return {
2316
- isOpen: !isOpen,
2317
- ...(isOpen && {
2318
- highlightedIndex: _this.props.defaultHighlightedIndex
2319
- }),
2320
- ...otherStateToSet
2321
- };
2322
- }, () => {
2323
- const {
2324
- isOpen,
2325
- highlightedIndex
2326
- } = _this.getState();
2339
+ _this.internalSetState(function (_ref9) {
2340
+ var isOpen = _ref9.isOpen;
2341
+ return _extends({
2342
+ isOpen: !isOpen
2343
+ }, isOpen && {
2344
+ highlightedIndex: _this.props.defaultHighlightedIndex
2345
+ }, otherStateToSet);
2346
+ }, function () {
2347
+ var _this$getState7 = _this.getState(),
2348
+ isOpen = _this$getState7.isOpen,
2349
+ highlightedIndex = _this$getState7.highlightedIndex;
2327
2350
  if (isOpen) {
2328
2351
  if (_this.getItemCount() > 0 && typeof highlightedIndex === 'number') {
2329
2352
  _this.setHighlightedIndex(highlightedIndex, otherStateToSet);
@@ -2332,57 +2355,58 @@
2332
2355
  cbToCb(cb)();
2333
2356
  });
2334
2357
  };
2335
- this.openMenu = cb => {
2336
- this.internalSetState({
2358
+ _this.openMenu = function (cb) {
2359
+ _this.internalSetState({
2337
2360
  isOpen: true
2338
2361
  }, cb);
2339
2362
  };
2340
- this.closeMenu = cb => {
2341
- this.internalSetState({
2363
+ _this.closeMenu = function (cb) {
2364
+ _this.internalSetState({
2342
2365
  isOpen: false
2343
2366
  }, cb);
2344
2367
  };
2345
- this.updateStatus = debounce(() => {
2346
- const state = this.getState();
2347
- const item = this.items[state.highlightedIndex];
2348
- const resultCount = this.getItemCount();
2349
- const status = this.props.getA11yStatusMessage({
2350
- itemToString: this.props.itemToString,
2351
- previousResultCount: this.previousResultCount,
2352
- resultCount,
2353
- highlightedItem: item,
2354
- ...state
2355
- });
2356
- this.previousResultCount = resultCount;
2357
- setStatus(status, this.props.environment.document);
2368
+ _this.updateStatus = debounce(function () {
2369
+ var state = _this.getState();
2370
+ var item = _this.items[state.highlightedIndex];
2371
+ var resultCount = _this.getItemCount();
2372
+ var status = _this.props.getA11yStatusMessage(_extends({
2373
+ itemToString: _this.props.itemToString,
2374
+ previousResultCount: _this.previousResultCount,
2375
+ resultCount: resultCount,
2376
+ highlightedItem: item
2377
+ }, state));
2378
+ _this.previousResultCount = resultCount;
2379
+ setStatus(status, _this.props.environment.document);
2358
2380
  }, 200);
2359
- // fancy destructuring + defaults + aliases
2360
- // this basically says each value of state should either be set to
2361
- // the initial value or the default value if the initial value is not provided
2362
- const {
2363
- defaultHighlightedIndex,
2364
- initialHighlightedIndex: _highlightedIndex = defaultHighlightedIndex,
2365
- defaultIsOpen,
2366
- initialIsOpen: _isOpen = defaultIsOpen,
2367
- initialInputValue: _inputValue = '',
2368
- initialSelectedItem: _selectedItem = null
2369
- } = this.props;
2370
- const _state = this.getState({
2381
+ var _this$props = _this.props,
2382
+ defaultHighlightedIndex = _this$props.defaultHighlightedIndex,
2383
+ _this$props$initialHi = _this$props.initialHighlightedIndex,
2384
+ _highlightedIndex = _this$props$initialHi === void 0 ? defaultHighlightedIndex : _this$props$initialHi,
2385
+ defaultIsOpen = _this$props.defaultIsOpen,
2386
+ _this$props$initialIs = _this$props.initialIsOpen,
2387
+ _isOpen = _this$props$initialIs === void 0 ? defaultIsOpen : _this$props$initialIs,
2388
+ _this$props$initialIn = _this$props.initialInputValue,
2389
+ _inputValue = _this$props$initialIn === void 0 ? '' : _this$props$initialIn,
2390
+ _this$props$initialSe = _this$props.initialSelectedItem,
2391
+ _selectedItem = _this$props$initialSe === void 0 ? null : _this$props$initialSe;
2392
+ var _state = _this.getState({
2371
2393
  highlightedIndex: _highlightedIndex,
2372
2394
  isOpen: _isOpen,
2373
2395
  inputValue: _inputValue,
2374
2396
  selectedItem: _selectedItem
2375
2397
  });
2376
- if (_state.selectedItem != null && this.props.initialInputValue === undefined) {
2377
- _state.inputValue = this.props.itemToString(_state.selectedItem);
2398
+ if (_state.selectedItem != null && _this.props.initialInputValue === undefined) {
2399
+ _state.inputValue = _this.props.itemToString(_state.selectedItem);
2378
2400
  }
2379
- this.state = _state;
2401
+ _this.state = _state;
2402
+ return _this;
2380
2403
  }
2404
+ var _proto = Downshift.prototype;
2381
2405
  /**
2382
2406
  * Clear all running timeouts
2383
2407
  */
2384
- internalClearTimeouts() {
2385
- this.timeoutIds.forEach(id => {
2408
+ _proto.internalClearTimeouts = function internalClearTimeouts() {
2409
+ this.timeoutIds.forEach(function (id) {
2386
2410
  clearTimeout(id);
2387
2411
  });
2388
2412
  this.timeoutIds = [];
@@ -2396,117 +2420,113 @@
2396
2420
  *
2397
2421
  * @param {Object} stateToMerge defaults to this.state
2398
2422
  * @return {Object} the state
2399
- */
2400
- getState(stateToMerge) {
2423
+ */;
2424
+ _proto.getState = function getState$1(stateToMerge) {
2401
2425
  if (stateToMerge === void 0) {
2402
2426
  stateToMerge = this.state;
2403
2427
  }
2404
2428
  return getState(stateToMerge, this.props);
2405
- }
2406
- getItemCount() {
2429
+ };
2430
+ _proto.getItemCount = function getItemCount() {
2407
2431
  // things read better this way. They're in priority order:
2408
2432
  // 1. `this.itemCount`
2409
2433
  // 2. `this.props.itemCount`
2410
2434
  // 3. `this.items.length`
2411
- let itemCount = this.items.length;
2435
+ var itemCount = this.items.length;
2412
2436
  if (this.itemCount != null) {
2413
2437
  itemCount = this.itemCount;
2414
2438
  } else if (this.props.itemCount !== undefined) {
2415
2439
  itemCount = this.props.itemCount;
2416
2440
  }
2417
2441
  return itemCount;
2418
- }
2419
- getItemNodeFromIndex(index) {
2442
+ };
2443
+ _proto.getItemNodeFromIndex = function getItemNodeFromIndex(index) {
2420
2444
  return this.props.environment.document.getElementById(this.getItemId(index));
2421
- }
2422
- scrollHighlightedItemIntoView() {
2445
+ };
2446
+ _proto.scrollHighlightedItemIntoView = function scrollHighlightedItemIntoView() {
2423
2447
  /* istanbul ignore else (react-native) */
2424
2448
  {
2425
- const node = this.getItemNodeFromIndex(this.getState().highlightedIndex);
2449
+ var node = this.getItemNodeFromIndex(this.getState().highlightedIndex);
2426
2450
  this.props.scrollIntoView(node, this._menuNode);
2427
2451
  }
2428
- }
2429
- moveHighlightedIndex(amount, otherStateToSet) {
2430
- const itemCount = this.getItemCount();
2431
- const {
2432
- highlightedIndex
2433
- } = this.getState();
2452
+ };
2453
+ _proto.moveHighlightedIndex = function moveHighlightedIndex(amount, otherStateToSet) {
2454
+ var _this6 = this;
2455
+ var itemCount = this.getItemCount();
2456
+ var _this$getState8 = this.getState(),
2457
+ highlightedIndex = _this$getState8.highlightedIndex;
2434
2458
  if (itemCount > 0) {
2435
- const nextHighlightedIndex = getNextWrappingIndex(amount, highlightedIndex, itemCount, index => this.getItemNodeFromIndex(index));
2459
+ var nextHighlightedIndex = getNextWrappingIndex(amount, highlightedIndex, itemCount, function (index) {
2460
+ return _this6.getItemNodeFromIndex(index);
2461
+ });
2436
2462
  this.setHighlightedIndex(nextHighlightedIndex, otherStateToSet);
2437
2463
  }
2438
- }
2439
- getStateAndHelpers() {
2440
- const {
2441
- highlightedIndex,
2442
- inputValue,
2443
- selectedItem,
2444
- isOpen
2445
- } = this.getState();
2446
- const {
2447
- itemToString
2448
- } = this.props;
2449
- const {
2450
- id
2451
- } = this;
2452
- const {
2453
- getRootProps,
2454
- getToggleButtonProps,
2455
- getLabelProps,
2456
- getMenuProps,
2457
- getInputProps,
2458
- getItemProps,
2459
- openMenu,
2460
- closeMenu,
2461
- toggleMenu,
2462
- selectItem,
2463
- selectItemAtIndex,
2464
- selectHighlightedItem,
2465
- setHighlightedIndex,
2466
- clearSelection,
2467
- clearItems,
2468
- reset,
2469
- setItemCount,
2470
- unsetItemCount,
2471
- internalSetState: setState
2472
- } = this;
2464
+ };
2465
+ _proto.getStateAndHelpers = function getStateAndHelpers() {
2466
+ var _this$getState9 = this.getState(),
2467
+ highlightedIndex = _this$getState9.highlightedIndex,
2468
+ inputValue = _this$getState9.inputValue,
2469
+ selectedItem = _this$getState9.selectedItem,
2470
+ isOpen = _this$getState9.isOpen;
2471
+ var itemToString = this.props.itemToString;
2472
+ var id = this.id;
2473
+ var getRootProps = this.getRootProps,
2474
+ getToggleButtonProps = this.getToggleButtonProps,
2475
+ getLabelProps = this.getLabelProps,
2476
+ getMenuProps = this.getMenuProps,
2477
+ getInputProps = this.getInputProps,
2478
+ getItemProps = this.getItemProps,
2479
+ openMenu = this.openMenu,
2480
+ closeMenu = this.closeMenu,
2481
+ toggleMenu = this.toggleMenu,
2482
+ selectItem = this.selectItem,
2483
+ selectItemAtIndex = this.selectItemAtIndex,
2484
+ selectHighlightedItem = this.selectHighlightedItem,
2485
+ setHighlightedIndex = this.setHighlightedIndex,
2486
+ clearSelection = this.clearSelection,
2487
+ clearItems = this.clearItems,
2488
+ reset = this.reset,
2489
+ setItemCount = this.setItemCount,
2490
+ unsetItemCount = this.unsetItemCount,
2491
+ setState = this.internalSetState;
2473
2492
  return {
2474
2493
  // prop getters
2475
- getRootProps,
2476
- getToggleButtonProps,
2477
- getLabelProps,
2478
- getMenuProps,
2479
- getInputProps,
2480
- getItemProps,
2494
+ getRootProps: getRootProps,
2495
+ getToggleButtonProps: getToggleButtonProps,
2496
+ getLabelProps: getLabelProps,
2497
+ getMenuProps: getMenuProps,
2498
+ getInputProps: getInputProps,
2499
+ getItemProps: getItemProps,
2481
2500
  // actions
2482
- reset,
2483
- openMenu,
2484
- closeMenu,
2485
- toggleMenu,
2486
- selectItem,
2487
- selectItemAtIndex,
2488
- selectHighlightedItem,
2489
- setHighlightedIndex,
2490
- clearSelection,
2491
- clearItems,
2492
- setItemCount,
2493
- unsetItemCount,
2494
- setState,
2501
+ reset: reset,
2502
+ openMenu: openMenu,
2503
+ closeMenu: closeMenu,
2504
+ toggleMenu: toggleMenu,
2505
+ selectItem: selectItem,
2506
+ selectItemAtIndex: selectItemAtIndex,
2507
+ selectHighlightedItem: selectHighlightedItem,
2508
+ setHighlightedIndex: setHighlightedIndex,
2509
+ clearSelection: clearSelection,
2510
+ clearItems: clearItems,
2511
+ setItemCount: setItemCount,
2512
+ unsetItemCount: unsetItemCount,
2513
+ setState: setState,
2495
2514
  // props
2496
- itemToString,
2515
+ itemToString: itemToString,
2497
2516
  // derived
2498
- id,
2517
+ id: id,
2499
2518
  // state
2500
- highlightedIndex,
2501
- inputValue,
2502
- isOpen,
2503
- selectedItem
2519
+ highlightedIndex: highlightedIndex,
2520
+ inputValue: inputValue,
2521
+ isOpen: isOpen,
2522
+ selectedItem: selectedItem
2504
2523
  };
2505
2524
  }
2506
2525
 
2507
2526
  //////////////////////////// ROOT
2508
-
2509
- componentDidMount() {
2527
+ ;
2528
+ _proto.componentDidMount = function componentDidMount() {
2529
+ var _this7 = this;
2510
2530
  /* istanbul ignore if (react-native) */
2511
2531
  if (this.getMenuProps.called && !this.getMenuProps.suppressRefError) {
2512
2532
  validateGetMenuPropsCalledCorrectly(this._menuNode, this.getMenuProps);
@@ -2519,18 +2539,20 @@
2519
2539
  // down long enough for the list to disappear (because the blur event fires on the input)
2520
2540
  // this.isMouseDown is used in the blur handler on the input to determine whether the blur event should
2521
2541
  // trigger hiding the menu.
2522
- const onMouseDown = () => {
2523
- this.isMouseDown = true;
2542
+ var onMouseDown = function onMouseDown() {
2543
+ _this7.isMouseDown = true;
2524
2544
  };
2525
- const onMouseUp = event => {
2526
- this.isMouseDown = false;
2545
+ var onMouseUp = function onMouseUp(event) {
2546
+ _this7.isMouseDown = false;
2527
2547
  // if the target element or the activeElement is within a downshift node
2528
2548
  // then we don't want to reset downshift
2529
- const contextWithinDownshift = targetWithinDownshift(event.target, [this._rootNode, this._menuNode], this.props.environment);
2530
- if (!contextWithinDownshift && this.getState().isOpen) {
2531
- this.reset({
2549
+ var contextWithinDownshift = targetWithinDownshift(event.target, [_this7._rootNode, _this7._menuNode], _this7.props.environment);
2550
+ if (!contextWithinDownshift && _this7.getState().isOpen) {
2551
+ _this7.reset({
2532
2552
  type: mouseUp
2533
- }, () => this.props.onOuterClick(this.getStateAndHelpers()));
2553
+ }, function () {
2554
+ return _this7.props.onOuterClick(_this7.getStateAndHelpers());
2555
+ });
2534
2556
  }
2535
2557
  };
2536
2558
  // Touching an element in iOS gives focus and hover states, but touching out of
@@ -2539,31 +2561,31 @@
2539
2561
  // this.isTouchMove helps us track whether the user is tapping or swiping on a touch screen.
2540
2562
  // If the user taps outside of Downshift, the component should be reset,
2541
2563
  // but not if the user is swiping
2542
- const onTouchStart = () => {
2543
- this.isTouchMove = false;
2564
+ var onTouchStart = function onTouchStart() {
2565
+ _this7.isTouchMove = false;
2544
2566
  };
2545
- const onTouchMove = () => {
2546
- this.isTouchMove = true;
2567
+ var onTouchMove = function onTouchMove() {
2568
+ _this7.isTouchMove = true;
2547
2569
  };
2548
- const onTouchEnd = event => {
2549
- const contextWithinDownshift = targetWithinDownshift(event.target, [this._rootNode, this._menuNode], this.props.environment, false);
2550
- if (!this.isTouchMove && !contextWithinDownshift && this.getState().isOpen) {
2551
- this.reset({
2570
+ var onTouchEnd = function onTouchEnd(event) {
2571
+ var contextWithinDownshift = targetWithinDownshift(event.target, [_this7._rootNode, _this7._menuNode], _this7.props.environment, false);
2572
+ if (!_this7.isTouchMove && !contextWithinDownshift && _this7.getState().isOpen) {
2573
+ _this7.reset({
2552
2574
  type: touchEnd
2553
- }, () => this.props.onOuterClick(this.getStateAndHelpers()));
2575
+ }, function () {
2576
+ return _this7.props.onOuterClick(_this7.getStateAndHelpers());
2577
+ });
2554
2578
  }
2555
2579
  };
2556
- const {
2557
- environment
2558
- } = this.props;
2580
+ var environment = this.props.environment;
2559
2581
  environment.addEventListener('mousedown', onMouseDown);
2560
2582
  environment.addEventListener('mouseup', onMouseUp);
2561
2583
  environment.addEventListener('touchstart', onTouchStart);
2562
2584
  environment.addEventListener('touchmove', onTouchMove);
2563
2585
  environment.addEventListener('touchend', onTouchEnd);
2564
- this.cleanup = () => {
2565
- this.internalClearTimeouts();
2566
- this.updateStatus.cancel();
2586
+ this.cleanup = function () {
2587
+ _this7.internalClearTimeouts();
2588
+ _this7.updateStatus.cancel();
2567
2589
  environment.removeEventListener('mousedown', onMouseDown);
2568
2590
  environment.removeEventListener('mouseup', onMouseUp);
2569
2591
  environment.removeEventListener('touchstart', onTouchStart);
@@ -2571,19 +2593,17 @@
2571
2593
  environment.removeEventListener('touchend', onTouchEnd);
2572
2594
  };
2573
2595
  }
2574
- }
2575
- shouldScroll(prevState, prevProps) {
2576
- const {
2577
- highlightedIndex: currentHighlightedIndex
2578
- } = this.props.highlightedIndex === undefined ? this.getState() : this.props;
2579
- const {
2580
- highlightedIndex: prevHighlightedIndex
2581
- } = prevProps.highlightedIndex === undefined ? prevState : prevProps;
2582
- const scrollWhenOpen = currentHighlightedIndex && this.getState().isOpen && !prevState.isOpen;
2583
- const scrollWhenNavigating = currentHighlightedIndex !== prevHighlightedIndex;
2596
+ };
2597
+ _proto.shouldScroll = function shouldScroll(prevState, prevProps) {
2598
+ var _ref10 = this.props.highlightedIndex === undefined ? this.getState() : this.props,
2599
+ currentHighlightedIndex = _ref10.highlightedIndex;
2600
+ var _ref11 = prevProps.highlightedIndex === undefined ? prevState : prevProps,
2601
+ prevHighlightedIndex = _ref11.highlightedIndex;
2602
+ var scrollWhenOpen = currentHighlightedIndex && this.getState().isOpen && !prevState.isOpen;
2603
+ var scrollWhenNavigating = currentHighlightedIndex !== prevHighlightedIndex;
2584
2604
  return scrollWhenOpen || scrollWhenNavigating;
2585
- }
2586
- componentDidUpdate(prevProps, prevState) {
2605
+ };
2606
+ _proto.componentDidUpdate = function componentDidUpdate(prevProps, prevState) {
2587
2607
  {
2588
2608
  validateControlledUnchanged(this.state, prevProps, this.props);
2589
2609
  /* istanbul ignore if (react-native) */
@@ -2605,13 +2625,12 @@
2605
2625
  {
2606
2626
  this.updateStatus();
2607
2627
  }
2608
- }
2609
- componentWillUnmount() {
2628
+ };
2629
+ _proto.componentWillUnmount = function componentWillUnmount() {
2610
2630
  this.cleanup(); // avoids memory leak
2611
- }
2612
-
2613
- render() {
2614
- const children = unwrapArray(this.props.children, noop);
2631
+ };
2632
+ _proto.render = function render() {
2633
+ var children = unwrapArray(this.props.children, noop);
2615
2634
  // because the items are rerendered every time we call the children
2616
2635
  // we clear this out each render and it will be populated again as
2617
2636
  // getItemProps is called.
@@ -2631,7 +2650,7 @@
2631
2650
  this.getLabelProps.called = false;
2632
2651
  // and something similar for getInputProps
2633
2652
  this.getInputProps.called = false;
2634
- const element = unwrapArray(children(this.getStateAndHelpers()));
2653
+ var element = unwrapArray(children(this.getStateAndHelpers()));
2635
2654
  if (!element) {
2636
2655
  return null;
2637
2656
  }
@@ -2653,13 +2672,14 @@
2653
2672
 
2654
2673
  throw new Error('downshift: If you return a non-DOM element, you must apply the getRootProps function');
2655
2674
  }
2656
- }
2657
- }
2675
+ };
2676
+ return Downshift;
2677
+ }(react.Component);
2658
2678
  Downshift.defaultProps = {
2659
2679
  defaultHighlightedIndex: null,
2660
2680
  defaultIsOpen: false,
2661
2681
  getA11yStatusMessage: getA11yStatusMessage$1,
2662
- itemToString: i => {
2682
+ itemToString: function itemToString(i) {
2663
2683
  if (i == null) {
2664
2684
  return '';
2665
2685
  }
@@ -2675,16 +2695,20 @@
2675
2695
  onChange: noop,
2676
2696
  onSelect: noop,
2677
2697
  onOuterClick: noop,
2678
- selectedItemChanged: (prevItem, item) => prevItem !== item,
2698
+ selectedItemChanged: function selectedItemChanged(prevItem, item) {
2699
+ return prevItem !== item;
2700
+ },
2679
2701
  environment: /* istanbul ignore next (ssr) */
2680
2702
  typeof window === 'undefined' ? {} : window,
2681
- stateReducer: (state, stateToSet) => stateToSet,
2703
+ stateReducer: function stateReducer(state, stateToSet) {
2704
+ return stateToSet;
2705
+ },
2682
2706
  suppressRefError: false,
2683
- scrollIntoView
2707
+ scrollIntoView: scrollIntoView
2684
2708
  };
2685
2709
  Downshift.stateChangeTypes = stateChangeTypes$3;
2686
2710
  return Downshift;
2687
- })();
2711
+ }();
2688
2712
  Downshift.propTypes = {
2689
2713
  children: PropTypes.func,
2690
2714
  defaultHighlightedIndex: PropTypes.number,
@@ -2730,70 +2754,61 @@
2730
2754
  /* eslint-enable react/no-unused-prop-types */
2731
2755
  } ;
2732
2756
  var Downshift$1 = Downshift;
2733
- function validateGetMenuPropsCalledCorrectly(node, _ref3) {
2734
- let {
2735
- refKey
2736
- } = _ref3;
2757
+ function validateGetMenuPropsCalledCorrectly(node, _ref12) {
2758
+ var refKey = _ref12.refKey;
2737
2759
  if (!node) {
2738
2760
  // eslint-disable-next-line no-console
2739
- console.error(`downshift: The ref prop "${refKey}" from getMenuProps was not applied correctly on your menu element.`);
2761
+ console.error("downshift: The ref prop \"" + refKey + "\" from getMenuProps was not applied correctly on your menu element.");
2740
2762
  }
2741
2763
  }
2742
- function validateGetRootPropsCalledCorrectly(element, _ref4) {
2743
- let {
2744
- refKey
2745
- } = _ref4;
2746
- const refKeySpecified = refKey !== 'ref';
2747
- const isComposite = !isDOMElement(element);
2764
+ function validateGetRootPropsCalledCorrectly(element, _ref13) {
2765
+ var refKey = _ref13.refKey;
2766
+ var refKeySpecified = refKey !== 'ref';
2767
+ var isComposite = !isDOMElement(element);
2748
2768
  if (isComposite && !refKeySpecified && !reactIs.exports.isForwardRef(element)) {
2749
2769
  // eslint-disable-next-line no-console
2750
2770
  console.error('downshift: You returned a non-DOM element. You must specify a refKey in getRootProps');
2751
2771
  } else if (!isComposite && refKeySpecified) {
2752
2772
  // eslint-disable-next-line no-console
2753
- console.error(`downshift: You returned a DOM element. You should not specify a refKey in getRootProps. You specified "${refKey}"`);
2773
+ console.error("downshift: You returned a DOM element. You should not specify a refKey in getRootProps. You specified \"" + refKey + "\"");
2754
2774
  }
2755
2775
  if (!reactIs.exports.isForwardRef(element) && !getElementProps(element)[refKey]) {
2756
2776
  // eslint-disable-next-line no-console
2757
- console.error(`downshift: You must apply the ref prop "${refKey}" from getRootProps onto your root element.`);
2777
+ console.error("downshift: You must apply the ref prop \"" + refKey + "\" from getRootProps onto your root element.");
2758
2778
  }
2759
2779
  }
2760
2780
 
2761
- const dropdownDefaultStateValues = {
2781
+ var _excluded$3 = ["isInitialMount", "highlightedIndex", "items", "environment"];
2782
+ var dropdownDefaultStateValues = {
2762
2783
  highlightedIndex: -1,
2763
2784
  isOpen: false,
2764
2785
  selectedItem: null,
2765
2786
  inputValue: ''
2766
2787
  };
2767
2788
  function callOnChangeProps(action, state, newState) {
2768
- const {
2769
- props,
2770
- type
2771
- } = action;
2772
- const changes = {};
2773
- Object.keys(state).forEach(key => {
2789
+ var props = action.props,
2790
+ type = action.type;
2791
+ var changes = {};
2792
+ Object.keys(state).forEach(function (key) {
2774
2793
  invokeOnChangeHandler(key, action, state, newState);
2775
2794
  if (newState[key] !== state[key]) {
2776
2795
  changes[key] = newState[key];
2777
2796
  }
2778
2797
  });
2779
2798
  if (props.onStateChange && Object.keys(changes).length) {
2780
- props.onStateChange({
2781
- type,
2782
- ...changes
2783
- });
2799
+ props.onStateChange(_extends({
2800
+ type: type
2801
+ }, changes));
2784
2802
  }
2785
2803
  }
2786
2804
  function invokeOnChangeHandler(key, action, state, newState) {
2787
- const {
2788
- props,
2789
- type
2790
- } = action;
2791
- const handler = `on${capitalizeString(key)}Change`;
2805
+ var props = action.props,
2806
+ type = action.type;
2807
+ var handler = "on" + capitalizeString(key) + "Change";
2792
2808
  if (props[handler] && newState[key] !== undefined && newState[key] !== state[key]) {
2793
- props[handler]({
2794
- type,
2795
- ...newState
2796
- });
2809
+ props[handler](_extends({
2810
+ type: type
2811
+ }, newState));
2797
2812
  }
2798
2813
  }
2799
2814
 
@@ -2815,37 +2830,36 @@
2815
2830
  * @returns {string} The a11y message.
2816
2831
  */
2817
2832
  function getA11ySelectionMessage(selectionParameters) {
2818
- const {
2819
- selectedItem,
2820
- itemToString: itemToStringLocal
2821
- } = selectionParameters;
2822
- return selectedItem ? `${itemToStringLocal(selectedItem)} has been selected.` : '';
2833
+ var selectedItem = selectionParameters.selectedItem,
2834
+ itemToStringLocal = selectionParameters.itemToString;
2835
+ return selectedItem ? itemToStringLocal(selectedItem) + " has been selected." : '';
2823
2836
  }
2824
2837
 
2825
2838
  /**
2826
2839
  * Debounced call for updating the a11y message.
2827
2840
  */
2828
- const updateA11yStatus = debounce((getA11yMessage, document) => {
2841
+ var updateA11yStatus = debounce(function (getA11yMessage, document) {
2829
2842
  setStatus(getA11yMessage(), document);
2830
2843
  }, 200);
2831
2844
 
2832
2845
  // istanbul ignore next
2833
- const useIsomorphicLayoutEffect = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined' ? react.useLayoutEffect : react.useEffect;
2846
+ var useIsomorphicLayoutEffect = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined' ? react.useLayoutEffect : react.useEffect;
2834
2847
  function useElementIds(_ref) {
2835
- let {
2836
- id = `downshift-${generateId()}`,
2837
- labelId,
2838
- menuId,
2839
- getItemId,
2840
- toggleButtonId,
2841
- inputId
2842
- } = _ref;
2843
- const elementIdsRef = react.useRef({
2844
- labelId: labelId || `${id}-label`,
2845
- menuId: menuId || `${id}-menu`,
2846
- getItemId: getItemId || (index => `${id}-item-${index}`),
2847
- toggleButtonId: toggleButtonId || `${id}-toggle-button`,
2848
- inputId: inputId || `${id}-input`
2848
+ var _ref$id = _ref.id,
2849
+ id = _ref$id === void 0 ? "downshift-" + generateId() : _ref$id,
2850
+ labelId = _ref.labelId,
2851
+ menuId = _ref.menuId,
2852
+ getItemId = _ref.getItemId,
2853
+ toggleButtonId = _ref.toggleButtonId,
2854
+ inputId = _ref.inputId;
2855
+ var elementIdsRef = react.useRef({
2856
+ labelId: labelId || id + "-label",
2857
+ menuId: menuId || id + "-menu",
2858
+ getItemId: getItemId || function (index) {
2859
+ return id + "-item-" + index;
2860
+ },
2861
+ toggleButtonId: toggleButtonId || id + "-toggle-button",
2862
+ inputId: inputId || id + "-input"
2849
2863
  });
2850
2864
  return elementIdsRef.current;
2851
2865
  }
@@ -2865,10 +2879,10 @@
2865
2879
  return /^\S{1}$/.test(key);
2866
2880
  }
2867
2881
  function capitalizeString(string) {
2868
- return `${string.slice(0, 1).toUpperCase()}${string.slice(1)}`;
2882
+ return "" + string.slice(0, 1).toUpperCase() + string.slice(1);
2869
2883
  }
2870
2884
  function useLatestRef(val) {
2871
- const ref = react.useRef(val);
2885
+ var ref = react.useRef(val);
2872
2886
  // technically this is not "concurrent mode safe" because we're manipulating
2873
2887
  // the value during render (so it's not idempotent). However, the places this
2874
2888
  // hook is used is to support memoizing callbacks which will be called
@@ -2889,26 +2903,28 @@
2889
2903
  * @returns {Array} An array with the state and an action dispatcher.
2890
2904
  */
2891
2905
  function useEnhancedReducer(reducer, initialState, props) {
2892
- const prevStateRef = react.useRef();
2893
- const actionRef = react.useRef();
2894
- const enhancedReducer = react.useCallback((state, action) => {
2906
+ var prevStateRef = react.useRef();
2907
+ var actionRef = react.useRef();
2908
+ var enhancedReducer = react.useCallback(function (state, action) {
2895
2909
  actionRef.current = action;
2896
2910
  state = getState(state, action.props);
2897
- const changes = reducer(state, action);
2898
- const newState = action.props.stateReducer(state, {
2899
- ...action,
2900
- changes
2901
- });
2911
+ var changes = reducer(state, action);
2912
+ var newState = action.props.stateReducer(state, _extends({}, action, {
2913
+ changes: changes
2914
+ }));
2902
2915
  return newState;
2903
2916
  }, [reducer]);
2904
- const [state, dispatch] = react.useReducer(enhancedReducer, initialState);
2905
- const propsRef = useLatestRef(props);
2906
- const dispatchWithProps = react.useCallback(action => dispatch({
2907
- props: propsRef.current,
2908
- ...action
2909
- }), [propsRef]);
2910
- const action = actionRef.current;
2911
- react.useEffect(() => {
2917
+ var _useReducer = react.useReducer(enhancedReducer, initialState),
2918
+ state = _useReducer[0],
2919
+ dispatch = _useReducer[1];
2920
+ var propsRef = useLatestRef(props);
2921
+ var dispatchWithProps = react.useCallback(function (action) {
2922
+ return dispatch(_extends({
2923
+ props: propsRef.current
2924
+ }, action));
2925
+ }, [propsRef]);
2926
+ var action = actionRef.current;
2927
+ react.useEffect(function () {
2912
2928
  if (action && prevStateRef.current && prevStateRef.current !== state) {
2913
2929
  callOnChangeProps(action, getState(prevStateRef.current, action.props), state);
2914
2930
  }
@@ -2927,14 +2943,16 @@
2927
2943
  * @returns {Array} An array with the state and an action dispatcher.
2928
2944
  */
2929
2945
  function useControlledReducer$1(reducer, initialState, props) {
2930
- const [state, dispatch] = useEnhancedReducer(reducer, initialState, props);
2946
+ var _useEnhancedReducer = useEnhancedReducer(reducer, initialState, props),
2947
+ state = _useEnhancedReducer[0],
2948
+ dispatch = _useEnhancedReducer[1];
2931
2949
  return [getState(state, props), dispatch];
2932
2950
  }
2933
- const defaultProps$3 = {
2934
- itemToString,
2935
- stateReducer,
2936
- getA11ySelectionMessage,
2937
- scrollIntoView,
2951
+ var defaultProps$3 = {
2952
+ itemToString: itemToString,
2953
+ stateReducer: stateReducer,
2954
+ getA11ySelectionMessage: getA11ySelectionMessage,
2955
+ scrollIntoView: scrollIntoView,
2938
2956
  environment: /* istanbul ignore next (ssr) */
2939
2957
  typeof window === 'undefined' ? {} : window
2940
2958
  };
@@ -2942,7 +2960,7 @@
2942
2960
  if (defaultStateValues === void 0) {
2943
2961
  defaultStateValues = dropdownDefaultStateValues;
2944
2962
  }
2945
- const defaultValue = props[`default${capitalizeString(propKey)}`];
2963
+ var defaultValue = props["default" + capitalizeString(propKey)];
2946
2964
  if (defaultValue !== undefined) {
2947
2965
  return defaultValue;
2948
2966
  }
@@ -2952,38 +2970,34 @@
2952
2970
  if (defaultStateValues === void 0) {
2953
2971
  defaultStateValues = dropdownDefaultStateValues;
2954
2972
  }
2955
- const value = props[propKey];
2973
+ var value = props[propKey];
2956
2974
  if (value !== undefined) {
2957
2975
  return value;
2958
2976
  }
2959
- const initialValue = props[`initial${capitalizeString(propKey)}`];
2977
+ var initialValue = props["initial" + capitalizeString(propKey)];
2960
2978
  if (initialValue !== undefined) {
2961
2979
  return initialValue;
2962
2980
  }
2963
2981
  return getDefaultValue$1(props, propKey, defaultStateValues);
2964
2982
  }
2965
2983
  function getInitialState$2(props) {
2966
- const selectedItem = getInitialValue$1(props, 'selectedItem');
2967
- const isOpen = getInitialValue$1(props, 'isOpen');
2968
- const highlightedIndex = getInitialValue$1(props, 'highlightedIndex');
2969
- const inputValue = getInitialValue$1(props, 'inputValue');
2984
+ var selectedItem = getInitialValue$1(props, 'selectedItem');
2985
+ var isOpen = getInitialValue$1(props, 'isOpen');
2986
+ var highlightedIndex = getInitialValue$1(props, 'highlightedIndex');
2987
+ var inputValue = getInitialValue$1(props, 'inputValue');
2970
2988
  return {
2971
2989
  highlightedIndex: highlightedIndex < 0 && selectedItem && isOpen ? props.items.indexOf(selectedItem) : highlightedIndex,
2972
- isOpen,
2973
- selectedItem,
2974
- inputValue
2990
+ isOpen: isOpen,
2991
+ selectedItem: selectedItem,
2992
+ inputValue: inputValue
2975
2993
  };
2976
2994
  }
2977
2995
  function getHighlightedIndexOnOpen(props, state, offset) {
2978
- const {
2979
- items,
2980
- initialHighlightedIndex,
2981
- defaultHighlightedIndex
2982
- } = props;
2983
- const {
2984
- selectedItem,
2985
- highlightedIndex
2986
- } = state;
2996
+ var items = props.items,
2997
+ initialHighlightedIndex = props.initialHighlightedIndex,
2998
+ defaultHighlightedIndex = props.defaultHighlightedIndex;
2999
+ var selectedItem = state.selectedItem,
3000
+ highlightedIndex = state.highlightedIndex;
2987
3001
  if (items.length === 0) {
2988
3002
  return -1;
2989
3003
  }
@@ -3014,30 +3028,34 @@
3014
3028
  * @returns {Object} Ref containing whether mouseDown or touchMove event is happening
3015
3029
  */
3016
3030
  function useMouseAndTouchTracker(isOpen, downshiftElementRefs, environment, handleBlur) {
3017
- const mouseAndTouchTrackersRef = react.useRef({
3031
+ var mouseAndTouchTrackersRef = react.useRef({
3018
3032
  isMouseDown: false,
3019
3033
  isTouchMove: false
3020
3034
  });
3021
- react.useEffect(() => {
3035
+ react.useEffect(function () {
3022
3036
  // The same strategy for checking if a click occurred inside or outside downsift
3023
3037
  // as in downshift.js.
3024
- const onMouseDown = () => {
3038
+ var onMouseDown = function onMouseDown() {
3025
3039
  mouseAndTouchTrackersRef.current.isMouseDown = true;
3026
3040
  };
3027
- const onMouseUp = event => {
3041
+ var onMouseUp = function onMouseUp(event) {
3028
3042
  mouseAndTouchTrackersRef.current.isMouseDown = false;
3029
- if (isOpen && !targetWithinDownshift(event.target, downshiftElementRefs.map(ref => ref.current), environment)) {
3043
+ if (isOpen && !targetWithinDownshift(event.target, downshiftElementRefs.map(function (ref) {
3044
+ return ref.current;
3045
+ }), environment)) {
3030
3046
  handleBlur();
3031
3047
  }
3032
3048
  };
3033
- const onTouchStart = () => {
3049
+ var onTouchStart = function onTouchStart() {
3034
3050
  mouseAndTouchTrackersRef.current.isTouchMove = false;
3035
3051
  };
3036
- const onTouchMove = () => {
3052
+ var onTouchMove = function onTouchMove() {
3037
3053
  mouseAndTouchTrackersRef.current.isTouchMove = true;
3038
3054
  };
3039
- const onTouchEnd = event => {
3040
- if (isOpen && !mouseAndTouchTrackersRef.current.isTouchMove && !targetWithinDownshift(event.target, downshiftElementRefs.map(ref => ref.current), environment, false)) {
3055
+ var onTouchEnd = function onTouchEnd(event) {
3056
+ if (isOpen && !mouseAndTouchTrackersRef.current.isTouchMove && !targetWithinDownshift(event.target, downshiftElementRefs.map(function (ref) {
3057
+ return ref.current;
3058
+ }), environment, false)) {
3041
3059
  handleBlur();
3042
3060
  }
3043
3061
  };
@@ -3060,7 +3078,9 @@
3060
3078
 
3061
3079
  /* istanbul ignore next */
3062
3080
  // eslint-disable-next-line import/no-mutable-exports
3063
- let useGetterPropsCalledChecker = () => noop;
3081
+ var useGetterPropsCalledChecker = function useGetterPropsCalledChecker() {
3082
+ return noop;
3083
+ };
3064
3084
  /**
3065
3085
  * Custom hook that checks if getter props are called correctly.
3066
3086
  *
@@ -3069,82 +3089,77 @@
3069
3089
  */
3070
3090
  /* istanbul ignore next */
3071
3091
  {
3072
- useGetterPropsCalledChecker = function () {
3073
- const isInitialMountRef = react.useRef(true);
3092
+ useGetterPropsCalledChecker = function useGetterPropsCalledChecker() {
3093
+ var isInitialMountRef = react.useRef(true);
3074
3094
  for (var _len = arguments.length, propKeys = new Array(_len), _key = 0; _key < _len; _key++) {
3075
3095
  propKeys[_key] = arguments[_key];
3076
3096
  }
3077
- const getterPropsCalledRef = react.useRef(propKeys.reduce((acc, propKey) => {
3097
+ var getterPropsCalledRef = react.useRef(propKeys.reduce(function (acc, propKey) {
3078
3098
  acc[propKey] = {};
3079
3099
  return acc;
3080
3100
  }, {}));
3081
- react.useEffect(() => {
3082
- Object.keys(getterPropsCalledRef.current).forEach(propKey => {
3083
- const propCallInfo = getterPropsCalledRef.current[propKey];
3101
+ react.useEffect(function () {
3102
+ Object.keys(getterPropsCalledRef.current).forEach(function (propKey) {
3103
+ var propCallInfo = getterPropsCalledRef.current[propKey];
3084
3104
  if (isInitialMountRef.current) {
3085
3105
  if (!Object.keys(propCallInfo).length) {
3086
3106
  // eslint-disable-next-line no-console
3087
- console.error(`downshift: You forgot to call the ${propKey} getter function on your component / element.`);
3107
+ console.error("downshift: You forgot to call the " + propKey + " getter function on your component / element.");
3088
3108
  return;
3089
3109
  }
3090
3110
  }
3091
- const {
3092
- suppressRefError,
3093
- refKey,
3094
- elementRef
3095
- } = propCallInfo;
3111
+ var suppressRefError = propCallInfo.suppressRefError,
3112
+ refKey = propCallInfo.refKey,
3113
+ elementRef = propCallInfo.elementRef;
3096
3114
  if ((!elementRef || !elementRef.current) && !suppressRefError) {
3097
3115
  // eslint-disable-next-line no-console
3098
- console.error(`downshift: The ref prop "${refKey}" from ${propKey} was not applied correctly on your element.`);
3116
+ console.error("downshift: The ref prop \"" + refKey + "\" from " + propKey + " was not applied correctly on your element.");
3099
3117
  }
3100
3118
  });
3101
3119
  isInitialMountRef.current = false;
3102
3120
  });
3103
- const setGetterPropCallInfo = react.useCallback((propKey, suppressRefError, refKey, elementRef) => {
3121
+ var setGetterPropCallInfo = react.useCallback(function (propKey, suppressRefError, refKey, elementRef) {
3104
3122
  getterPropsCalledRef.current[propKey] = {
3105
- suppressRefError,
3106
- refKey,
3107
- elementRef
3123
+ suppressRefError: suppressRefError,
3124
+ refKey: refKey,
3125
+ elementRef: elementRef
3108
3126
  };
3109
3127
  }, []);
3110
3128
  return setGetterPropCallInfo;
3111
3129
  };
3112
3130
  }
3113
3131
  function useA11yMessageSetter(getA11yMessage, dependencyArray, _ref2) {
3114
- let {
3115
- isInitialMount,
3116
- highlightedIndex,
3117
- items,
3118
- environment,
3119
- ...rest
3120
- } = _ref2;
3132
+ var isInitialMount = _ref2.isInitialMount,
3133
+ highlightedIndex = _ref2.highlightedIndex,
3134
+ items = _ref2.items,
3135
+ environment = _ref2.environment,
3136
+ rest = _objectWithoutPropertiesLoose(_ref2, _excluded$3);
3121
3137
  // Sets a11y status message on changes in state.
3122
- react.useEffect(() => {
3138
+ react.useEffect(function () {
3123
3139
  if (isInitialMount || false) {
3124
3140
  return;
3125
3141
  }
3126
- updateA11yStatus(() => getA11yMessage({
3127
- highlightedIndex,
3128
- highlightedItem: items[highlightedIndex],
3129
- resultCount: items.length,
3130
- ...rest
3131
- }), environment.document);
3142
+ updateA11yStatus(function () {
3143
+ return getA11yMessage(_extends({
3144
+ highlightedIndex: highlightedIndex,
3145
+ highlightedItem: items[highlightedIndex],
3146
+ resultCount: items.length
3147
+ }, rest));
3148
+ }, environment.document);
3132
3149
  // eslint-disable-next-line react-hooks/exhaustive-deps
3133
3150
  }, dependencyArray);
3134
3151
  }
3135
3152
  function useScrollIntoView(_ref3) {
3136
- let {
3137
- highlightedIndex,
3138
- isOpen,
3139
- itemRefs,
3140
- getItemNodeFromIndex,
3141
- menuElement,
3142
- scrollIntoView: scrollIntoViewProp
3143
- } = _ref3;
3153
+ var highlightedIndex = _ref3.highlightedIndex,
3154
+ isOpen = _ref3.isOpen,
3155
+ itemRefs = _ref3.itemRefs,
3156
+ getItemNodeFromIndex = _ref3.getItemNodeFromIndex,
3157
+ menuElement = _ref3.menuElement,
3158
+ scrollIntoViewProp = _ref3.scrollIntoView;
3144
3159
  // used not to scroll on highlight by mouse.
3145
- const shouldScrollRef = react.useRef(true);
3160
+ var shouldScrollRef = react.useRef(true);
3146
3161
  // Scroll on highlighted item if change comes from keyboard.
3147
- useIsomorphicLayoutEffect(() => {
3162
+ useIsomorphicLayoutEffect(function () {
3148
3163
  if (highlightedIndex < 0 || !isOpen || !Object.keys(itemRefs.current).length) {
3149
3164
  return;
3150
3165
  }
@@ -3159,18 +3174,16 @@
3159
3174
  }
3160
3175
 
3161
3176
  // eslint-disable-next-line import/no-mutable-exports
3162
- let useControlPropsValidator = noop;
3177
+ var useControlPropsValidator = noop;
3163
3178
  /* istanbul ignore next */
3164
3179
  {
3165
- useControlPropsValidator = _ref4 => {
3166
- let {
3167
- isInitialMount,
3168
- props,
3169
- state
3170
- } = _ref4;
3180
+ useControlPropsValidator = function useControlPropsValidator(_ref4) {
3181
+ var isInitialMount = _ref4.isInitialMount,
3182
+ props = _ref4.props,
3183
+ state = _ref4.state;
3171
3184
  // used for checking when props are moving from controlled to uncontrolled.
3172
- const prevPropsRef = react.useRef(props);
3173
- react.useEffect(() => {
3185
+ var prevPropsRef = react.useRef(props);
3186
+ react.useEffect(function () {
3174
3187
  if (isInitialMount) {
3175
3188
  return;
3176
3189
  }
@@ -3181,11 +3194,9 @@
3181
3194
  }
3182
3195
 
3183
3196
  function downshiftCommonReducer(state, action, stateChangeTypes) {
3184
- const {
3185
- type,
3186
- props
3187
- } = action;
3188
- let changes;
3197
+ var type = action.type,
3198
+ props = action.props;
3199
+ var changes;
3189
3200
  switch (type) {
3190
3201
  case stateChangeTypes.ItemMouseMove:
3191
3202
  changes = {
@@ -3236,10 +3247,7 @@
3236
3247
  default:
3237
3248
  throw new Error('Reducer called without proper action type.');
3238
3249
  }
3239
- return {
3240
- ...state,
3241
- ...changes
3242
- };
3250
+ return _extends({}, state, changes);
3243
3251
  }
3244
3252
  /* eslint-enable complexity */
3245
3253
 
@@ -3351,28 +3359,28 @@
3351
3359
  };
3352
3360
  }
3353
3361
 
3354
- const ToggleButtonClick$1 = '__togglebutton_click__' ;
3355
- const ToggleButtonKeyDownArrowDown = '__togglebutton_keydown_arrow_down__' ;
3356
- const ToggleButtonKeyDownArrowUp = '__togglebutton_keydown_arrow_up__' ;
3357
- const ToggleButtonKeyDownCharacter = '__togglebutton_keydown_character__' ;
3358
- const ToggleButtonKeyDownEscape = '__togglebutton_keydown_escape__' ;
3359
- const ToggleButtonKeyDownHome = '__togglebutton_keydown_home__' ;
3360
- const ToggleButtonKeyDownEnd = '__togglebutton_keydown_end__' ;
3361
- const ToggleButtonKeyDownEnter = '__togglebutton_keydown_enter__' ;
3362
- const ToggleButtonKeyDownSpaceButton = '__togglebutton_keydown_space_button__' ;
3363
- const ToggleButtonKeyDownPageUp = '__togglebutton_keydown_page_up__' ;
3364
- const ToggleButtonKeyDownPageDown = '__togglebutton_keydown_page_down__' ;
3365
- const ToggleButtonBlur = '__togglebutton_blur__' ;
3366
- const MenuMouseLeave$1 = '__menu_mouse_leave__' ;
3367
- const ItemMouseMove$1 = '__item_mouse_move__' ;
3368
- const ItemClick$1 = '__item_click__' ;
3369
- const FunctionToggleMenu$1 = '__function_toggle_menu__' ;
3370
- const FunctionOpenMenu$1 = '__function_open_menu__' ;
3371
- const FunctionCloseMenu$1 = '__function_close_menu__' ;
3372
- const FunctionSetHighlightedIndex$1 = '__function_set_highlighted_index__' ;
3373
- const FunctionSelectItem$1 = '__function_select_item__' ;
3374
- const FunctionSetInputValue$1 = '__function_set_input_value__' ;
3375
- const FunctionReset$2 = '__function_reset__' ;
3362
+ var ToggleButtonClick$1 = '__togglebutton_click__' ;
3363
+ var ToggleButtonKeyDownArrowDown = '__togglebutton_keydown_arrow_down__' ;
3364
+ var ToggleButtonKeyDownArrowUp = '__togglebutton_keydown_arrow_up__' ;
3365
+ var ToggleButtonKeyDownCharacter = '__togglebutton_keydown_character__' ;
3366
+ var ToggleButtonKeyDownEscape = '__togglebutton_keydown_escape__' ;
3367
+ var ToggleButtonKeyDownHome = '__togglebutton_keydown_home__' ;
3368
+ var ToggleButtonKeyDownEnd = '__togglebutton_keydown_end__' ;
3369
+ var ToggleButtonKeyDownEnter = '__togglebutton_keydown_enter__' ;
3370
+ var ToggleButtonKeyDownSpaceButton = '__togglebutton_keydown_space_button__' ;
3371
+ var ToggleButtonKeyDownPageUp = '__togglebutton_keydown_page_up__' ;
3372
+ var ToggleButtonKeyDownPageDown = '__togglebutton_keydown_page_down__' ;
3373
+ var ToggleButtonBlur = '__togglebutton_blur__' ;
3374
+ var MenuMouseLeave$1 = '__menu_mouse_leave__' ;
3375
+ var ItemMouseMove$1 = '__item_mouse_move__' ;
3376
+ var ItemClick$1 = '__item_click__' ;
3377
+ var FunctionToggleMenu$1 = '__function_toggle_menu__' ;
3378
+ var FunctionOpenMenu$1 = '__function_open_menu__' ;
3379
+ var FunctionCloseMenu$1 = '__function_close_menu__' ;
3380
+ var FunctionSetHighlightedIndex$1 = '__function_set_highlighted_index__' ;
3381
+ var FunctionSelectItem$1 = '__function_select_item__' ;
3382
+ var FunctionSetInputValue$1 = '__function_set_input_value__' ;
3383
+ var FunctionReset$2 = '__function_reset__' ;
3376
3384
 
3377
3385
  var stateChangeTypes$2 = /*#__PURE__*/Object.freeze({
3378
3386
  __proto__: null,
@@ -3402,12 +3410,10 @@
3402
3410
 
3403
3411
  /* eslint-disable complexity */
3404
3412
  function downshiftSelectReducer(state, action) {
3405
- const {
3406
- type,
3407
- props,
3408
- altKey
3409
- } = action;
3410
- let changes;
3413
+ var type = action.type,
3414
+ props = action.props,
3415
+ altKey = action.altKey;
3416
+ var changes;
3411
3417
  switch (type) {
3412
3418
  case ItemClick$1:
3413
3419
  changes = {
@@ -3418,10 +3424,10 @@
3418
3424
  break;
3419
3425
  case ToggleButtonKeyDownCharacter:
3420
3426
  {
3421
- const lowercasedKey = action.key;
3422
- const inputValue = `${state.inputValue}${lowercasedKey}`;
3423
- const prevHighlightedIndex = !state.isOpen && state.selectedItem ? props.items.indexOf(state.selectedItem) : state.highlightedIndex;
3424
- const highlightedIndex = getItemIndexByCharacterKey({
3427
+ var lowercasedKey = action.key;
3428
+ var inputValue = "" + state.inputValue + lowercasedKey;
3429
+ var prevHighlightedIndex = !state.isOpen && state.selectedItem ? props.items.indexOf(state.selectedItem) : state.highlightedIndex;
3430
+ var highlightedIndex = getItemIndexByCharacterKey({
3425
3431
  keysSoFar: inputValue,
3426
3432
  highlightedIndex: prevHighlightedIndex,
3427
3433
  items: props.items,
@@ -3429,34 +3435,33 @@
3429
3435
  getItemNodeFromIndex: action.getItemNodeFromIndex
3430
3436
  });
3431
3437
  changes = {
3432
- inputValue,
3433
- highlightedIndex,
3438
+ inputValue: inputValue,
3439
+ highlightedIndex: highlightedIndex,
3434
3440
  isOpen: true
3435
3441
  };
3436
3442
  }
3437
3443
  break;
3438
3444
  case ToggleButtonKeyDownArrowDown:
3439
3445
  {
3440
- const highlightedIndex = state.isOpen ? getNextWrappingIndex(1, state.highlightedIndex, props.items.length, action.getItemNodeFromIndex, false) : altKey && state.selectedItem == null ? -1 : getHighlightedIndexOnOpen(props, state, 1);
3446
+ var _highlightedIndex = state.isOpen ? getNextWrappingIndex(1, state.highlightedIndex, props.items.length, action.getItemNodeFromIndex, false) : altKey && state.selectedItem == null ? -1 : getHighlightedIndexOnOpen(props, state, 1);
3441
3447
  changes = {
3442
- highlightedIndex,
3448
+ highlightedIndex: _highlightedIndex,
3443
3449
  isOpen: true
3444
3450
  };
3445
3451
  }
3446
3452
  break;
3447
3453
  case ToggleButtonKeyDownArrowUp:
3448
3454
  if (state.isOpen && altKey) {
3449
- changes = {
3455
+ changes = _extends({
3450
3456
  isOpen: getDefaultValue$1(props, 'isOpen'),
3451
- highlightedIndex: getDefaultValue$1(props, 'highlightedIndex'),
3452
- ...(state.highlightedIndex >= 0 && {
3453
- selectedItem: props.items[state.highlightedIndex]
3454
- })
3455
- };
3457
+ highlightedIndex: getDefaultValue$1(props, 'highlightedIndex')
3458
+ }, state.highlightedIndex >= 0 && {
3459
+ selectedItem: props.items[state.highlightedIndex]
3460
+ });
3456
3461
  } else {
3457
- const highlightedIndex = state.isOpen ? getNextWrappingIndex(-1, state.highlightedIndex, props.items.length, action.getItemNodeFromIndex, false) : getHighlightedIndexOnOpen(props, state, -1);
3462
+ var _highlightedIndex2 = state.isOpen ? getNextWrappingIndex(-1, state.highlightedIndex, props.items.length, action.getItemNodeFromIndex, false) : getHighlightedIndexOnOpen(props, state, -1);
3458
3463
  changes = {
3459
- highlightedIndex,
3464
+ highlightedIndex: _highlightedIndex2,
3460
3465
  isOpen: true
3461
3466
  };
3462
3467
  }
@@ -3464,13 +3469,12 @@
3464
3469
  // only triggered when menu is open.
3465
3470
  case ToggleButtonKeyDownEnter:
3466
3471
  case ToggleButtonKeyDownSpaceButton:
3467
- changes = {
3472
+ changes = _extends({
3468
3473
  isOpen: getDefaultValue$1(props, 'isOpen'),
3469
- highlightedIndex: getDefaultValue$1(props, 'highlightedIndex'),
3470
- ...(state.highlightedIndex >= 0 && {
3471
- selectedItem: props.items[state.highlightedIndex]
3472
- })
3473
- };
3474
+ highlightedIndex: getDefaultValue$1(props, 'highlightedIndex')
3475
+ }, state.highlightedIndex >= 0 && {
3476
+ selectedItem: props.items[state.highlightedIndex]
3477
+ });
3474
3478
  break;
3475
3479
  case ToggleButtonKeyDownHome:
3476
3480
  changes = {
@@ -3501,13 +3505,12 @@
3501
3505
  };
3502
3506
  break;
3503
3507
  case ToggleButtonBlur:
3504
- changes = {
3508
+ changes = _extends({
3505
3509
  isOpen: false,
3506
- highlightedIndex: -1,
3507
- ...(state.highlightedIndex >= 0 && {
3508
- selectedItem: props.items[state.highlightedIndex]
3509
- })
3510
- };
3510
+ highlightedIndex: -1
3511
+ }, state.highlightedIndex >= 0 && {
3512
+ selectedItem: props.items[state.highlightedIndex]
3513
+ });
3511
3514
  break;
3512
3515
  case FunctionSelectItem$1:
3513
3516
  changes = {
@@ -3517,13 +3520,13 @@
3517
3520
  default:
3518
3521
  return downshiftCommonReducer(state, action, stateChangeTypes$2);
3519
3522
  }
3520
- return {
3521
- ...state,
3522
- ...changes
3523
- };
3523
+ return _extends({}, state, changes);
3524
3524
  }
3525
3525
  /* eslint-enable complexity */
3526
3526
 
3527
+ var _excluded$2 = ["onMouseLeave", "refKey", "onKeyDown", "onBlur", "ref"],
3528
+ _excluded2$2 = ["onBlur", "onClick", "onKeyDown", "refKey", "ref"],
3529
+ _excluded3$1 = ["item", "index", "onMouseMove", "onClick", "refKey", "ref", "disabled"];
3527
3530
  useSelect.stateChangeTypes = stateChangeTypes$2;
3528
3531
  function useSelect(userProps) {
3529
3532
  if (userProps === void 0) {
@@ -3531,81 +3534,76 @@
3531
3534
  }
3532
3535
  validatePropTypes$2(userProps, useSelect);
3533
3536
  // Props defaults and destructuring.
3534
- const props = {
3535
- ...defaultProps$2,
3536
- ...userProps
3537
- };
3538
- const {
3539
- items,
3540
- scrollIntoView,
3541
- environment,
3542
- itemToString,
3543
- getA11ySelectionMessage,
3544
- getA11yStatusMessage
3545
- } = props;
3537
+ var props = _extends({}, defaultProps$2, userProps);
3538
+ var items = props.items,
3539
+ scrollIntoView = props.scrollIntoView,
3540
+ environment = props.environment,
3541
+ itemToString = props.itemToString,
3542
+ getA11ySelectionMessage = props.getA11ySelectionMessage,
3543
+ getA11yStatusMessage = props.getA11yStatusMessage;
3546
3544
  // Initial state depending on controlled props.
3547
- const initialState = getInitialState$2(props);
3548
- const [state, dispatch] = useControlledReducer$1(downshiftSelectReducer, initialState, props);
3549
- const {
3550
- isOpen,
3551
- highlightedIndex,
3552
- selectedItem,
3553
- inputValue
3554
- } = state;
3545
+ var initialState = getInitialState$2(props);
3546
+ var _useControlledReducer = useControlledReducer$1(downshiftSelectReducer, initialState, props),
3547
+ state = _useControlledReducer[0],
3548
+ dispatch = _useControlledReducer[1];
3549
+ var isOpen = state.isOpen,
3550
+ highlightedIndex = state.highlightedIndex,
3551
+ selectedItem = state.selectedItem,
3552
+ inputValue = state.inputValue;
3555
3553
 
3556
3554
  // Element efs.
3557
- const toggleButtonRef = react.useRef(null);
3558
- const menuRef = react.useRef(null);
3559
- const itemRefs = react.useRef({});
3555
+ var toggleButtonRef = react.useRef(null);
3556
+ var menuRef = react.useRef(null);
3557
+ var itemRefs = react.useRef({});
3560
3558
  // used to keep the inputValue clearTimeout object between renders.
3561
- const clearTimeoutRef = react.useRef(null);
3559
+ var clearTimeoutRef = react.useRef(null);
3562
3560
  // prevent id re-generation between renders.
3563
- const elementIds = useElementIds(props);
3561
+ var elementIds = useElementIds(props);
3564
3562
  // used to keep track of how many items we had on previous cycle.
3565
- const previousResultCountRef = react.useRef();
3566
- const isInitialMountRef = react.useRef(true);
3563
+ var previousResultCountRef = react.useRef();
3564
+ var isInitialMountRef = react.useRef(true);
3567
3565
  // utility callback to get item element.
3568
- const latest = useLatestRef({
3569
- state,
3570
- props
3566
+ var latest = useLatestRef({
3567
+ state: state,
3568
+ props: props
3571
3569
  });
3572
3570
 
3573
3571
  // Some utils.
3574
- const getItemNodeFromIndex = react.useCallback(index => itemRefs.current[elementIds.getItemId(index)], [elementIds]);
3572
+ var getItemNodeFromIndex = react.useCallback(function (index) {
3573
+ return itemRefs.current[elementIds.getItemId(index)];
3574
+ }, [elementIds]);
3575
3575
 
3576
3576
  // Effects.
3577
3577
  // Sets a11y status message on changes in state.
3578
- useA11yMessageSetter(getA11yStatusMessage, [isOpen, highlightedIndex, inputValue, items], {
3578
+ useA11yMessageSetter(getA11yStatusMessage, [isOpen, highlightedIndex, inputValue, items], _extends({
3579
3579
  isInitialMount: isInitialMountRef.current,
3580
3580
  previousResultCount: previousResultCountRef.current,
3581
- items,
3582
- environment,
3583
- itemToString,
3584
- ...state
3585
- });
3581
+ items: items,
3582
+ environment: environment,
3583
+ itemToString: itemToString
3584
+ }, state));
3586
3585
  // Sets a11y status message on changes in selectedItem.
3587
- useA11yMessageSetter(getA11ySelectionMessage, [selectedItem], {
3586
+ useA11yMessageSetter(getA11ySelectionMessage, [selectedItem], _extends({
3588
3587
  isInitialMount: isInitialMountRef.current,
3589
3588
  previousResultCount: previousResultCountRef.current,
3590
- items,
3591
- environment,
3592
- itemToString,
3593
- ...state
3594
- });
3589
+ items: items,
3590
+ environment: environment,
3591
+ itemToString: itemToString
3592
+ }, state));
3595
3593
  // Scroll on highlighted item if change comes from keyboard.
3596
- const shouldScrollRef = useScrollIntoView({
3594
+ var shouldScrollRef = useScrollIntoView({
3597
3595
  menuElement: menuRef.current,
3598
- highlightedIndex,
3599
- isOpen,
3600
- itemRefs,
3601
- scrollIntoView,
3602
- getItemNodeFromIndex
3596
+ highlightedIndex: highlightedIndex,
3597
+ isOpen: isOpen,
3598
+ itemRefs: itemRefs,
3599
+ scrollIntoView: scrollIntoView,
3600
+ getItemNodeFromIndex: getItemNodeFromIndex
3603
3601
  });
3604
3602
 
3605
3603
  // Sets cleanup for the keysSoFar callback, debounded after 500ms.
3606
- react.useEffect(() => {
3604
+ react.useEffect(function () {
3607
3605
  // init the clean function here as we need access to dispatch.
3608
- clearTimeoutRef.current = debounce(outerDispatch => {
3606
+ clearTimeoutRef.current = debounce(function (outerDispatch) {
3609
3607
  outerDispatch({
3610
3608
  type: FunctionSetInputValue$1,
3611
3609
  inputValue: ''
@@ -3613,13 +3611,13 @@
3613
3611
  }, 500);
3614
3612
 
3615
3613
  // Cancel any pending debounced calls on mount
3616
- return () => {
3614
+ return function () {
3617
3615
  clearTimeoutRef.current.cancel();
3618
3616
  };
3619
3617
  }, []);
3620
3618
 
3621
3619
  // Invokes the keysSoFar callback set up above.
3622
- react.useEffect(() => {
3620
+ react.useEffect(function () {
3623
3621
  if (!inputValue) {
3624
3622
  return;
3625
3623
  }
@@ -3627,249 +3625,234 @@
3627
3625
  }, [dispatch, inputValue]);
3628
3626
  useControlPropsValidator({
3629
3627
  isInitialMount: isInitialMountRef.current,
3630
- props,
3631
- state
3628
+ props: props,
3629
+ state: state
3632
3630
  });
3633
- react.useEffect(() => {
3631
+ react.useEffect(function () {
3634
3632
  if (isInitialMountRef.current) {
3635
3633
  return;
3636
3634
  }
3637
3635
  previousResultCountRef.current = items.length;
3638
3636
  });
3639
3637
  // Add mouse/touch events to document.
3640
- const mouseAndTouchTrackersRef = useMouseAndTouchTracker(isOpen, [menuRef, toggleButtonRef], environment, () => {
3638
+ var mouseAndTouchTrackersRef = useMouseAndTouchTracker(isOpen, [menuRef, toggleButtonRef], environment, function () {
3641
3639
  dispatch({
3642
3640
  type: ToggleButtonBlur
3643
3641
  });
3644
3642
  });
3645
- const setGetterPropCallInfo = useGetterPropsCalledChecker('getMenuProps', 'getToggleButtonProps');
3643
+ var setGetterPropCallInfo = useGetterPropsCalledChecker('getMenuProps', 'getToggleButtonProps');
3646
3644
  // Make initial ref false.
3647
- react.useEffect(() => {
3645
+ react.useEffect(function () {
3648
3646
  isInitialMountRef.current = false;
3649
- return () => {
3647
+ return function () {
3650
3648
  isInitialMountRef.current = true;
3651
3649
  };
3652
3650
  }, []);
3653
3651
  // Reset itemRefs on close.
3654
- react.useEffect(() => {
3652
+ react.useEffect(function () {
3655
3653
  if (!isOpen) {
3656
3654
  itemRefs.current = {};
3657
3655
  }
3658
3656
  }, [isOpen]);
3659
3657
 
3660
3658
  // Event handler functions.
3661
- const toggleButtonKeyDownHandlers = react.useMemo(() => ({
3662
- ArrowDown(event) {
3663
- event.preventDefault();
3664
- dispatch({
3665
- type: ToggleButtonKeyDownArrowDown,
3666
- getItemNodeFromIndex,
3667
- altKey: event.altKey
3668
- });
3669
- },
3670
- ArrowUp(event) {
3671
- event.preventDefault();
3672
- dispatch({
3673
- type: ToggleButtonKeyDownArrowUp,
3674
- getItemNodeFromIndex,
3675
- altKey: event.altKey
3676
- });
3677
- },
3678
- Home(event) {
3679
- event.preventDefault();
3680
- dispatch({
3681
- type: ToggleButtonKeyDownHome,
3682
- getItemNodeFromIndex
3683
- });
3684
- },
3685
- End(event) {
3686
- event.preventDefault();
3687
- dispatch({
3688
- type: ToggleButtonKeyDownEnd,
3689
- getItemNodeFromIndex
3690
- });
3691
- },
3692
- Escape() {
3693
- if (latest.current.state.isOpen) {
3694
- dispatch({
3695
- type: ToggleButtonKeyDownEscape
3696
- });
3697
- }
3698
- },
3699
- Enter(event) {
3700
- event.preventDefault();
3701
- dispatch({
3702
- type: latest.current.state.isOpen ? ToggleButtonKeyDownEnter : ToggleButtonClick$1
3703
- });
3704
- },
3705
- PageUp(event) {
3706
- if (latest.current.state.isOpen) {
3659
+ var toggleButtonKeyDownHandlers = react.useMemo(function () {
3660
+ return {
3661
+ ArrowDown: function ArrowDown(event) {
3707
3662
  event.preventDefault();
3708
3663
  dispatch({
3709
- type: ToggleButtonKeyDownPageUp,
3710
- getItemNodeFromIndex
3664
+ type: ToggleButtonKeyDownArrowDown,
3665
+ getItemNodeFromIndex: getItemNodeFromIndex,
3666
+ altKey: event.altKey
3711
3667
  });
3712
- }
3713
- },
3714
- PageDown(event) {
3715
- if (latest.current.state.isOpen) {
3668
+ },
3669
+ ArrowUp: function ArrowUp(event) {
3716
3670
  event.preventDefault();
3717
3671
  dispatch({
3718
- type: ToggleButtonKeyDownPageDown,
3719
- getItemNodeFromIndex
3672
+ type: ToggleButtonKeyDownArrowUp,
3673
+ getItemNodeFromIndex: getItemNodeFromIndex,
3674
+ altKey: event.altKey
3720
3675
  });
3721
- }
3722
- },
3723
- ' '(event) {
3724
- event.preventDefault();
3725
- const currentState = latest.current.state;
3726
- if (!currentState.isOpen) {
3676
+ },
3677
+ Home: function Home(event) {
3678
+ event.preventDefault();
3727
3679
  dispatch({
3728
- type: ToggleButtonClick$1
3680
+ type: ToggleButtonKeyDownHome,
3681
+ getItemNodeFromIndex: getItemNodeFromIndex
3729
3682
  });
3730
- return;
3731
- }
3732
- if (currentState.inputValue) {
3683
+ },
3684
+ End: function End(event) {
3685
+ event.preventDefault();
3733
3686
  dispatch({
3734
- type: ToggleButtonKeyDownCharacter,
3735
- key: ' ',
3736
- getItemNodeFromIndex
3687
+ type: ToggleButtonKeyDownEnd,
3688
+ getItemNodeFromIndex: getItemNodeFromIndex
3737
3689
  });
3738
- } else {
3690
+ },
3691
+ Escape: function Escape() {
3692
+ if (latest.current.state.isOpen) {
3693
+ dispatch({
3694
+ type: ToggleButtonKeyDownEscape
3695
+ });
3696
+ }
3697
+ },
3698
+ Enter: function Enter(event) {
3699
+ event.preventDefault();
3739
3700
  dispatch({
3740
- type: ToggleButtonKeyDownSpaceButton
3701
+ type: latest.current.state.isOpen ? ToggleButtonKeyDownEnter : ToggleButtonClick$1
3741
3702
  });
3703
+ },
3704
+ PageUp: function PageUp(event) {
3705
+ if (latest.current.state.isOpen) {
3706
+ event.preventDefault();
3707
+ dispatch({
3708
+ type: ToggleButtonKeyDownPageUp,
3709
+ getItemNodeFromIndex: getItemNodeFromIndex
3710
+ });
3711
+ }
3712
+ },
3713
+ PageDown: function PageDown(event) {
3714
+ if (latest.current.state.isOpen) {
3715
+ event.preventDefault();
3716
+ dispatch({
3717
+ type: ToggleButtonKeyDownPageDown,
3718
+ getItemNodeFromIndex: getItemNodeFromIndex
3719
+ });
3720
+ }
3721
+ },
3722
+ ' ': function _(event) {
3723
+ event.preventDefault();
3724
+ var currentState = latest.current.state;
3725
+ if (!currentState.isOpen) {
3726
+ dispatch({
3727
+ type: ToggleButtonClick$1
3728
+ });
3729
+ return;
3730
+ }
3731
+ if (currentState.inputValue) {
3732
+ dispatch({
3733
+ type: ToggleButtonKeyDownCharacter,
3734
+ key: ' ',
3735
+ getItemNodeFromIndex: getItemNodeFromIndex
3736
+ });
3737
+ } else {
3738
+ dispatch({
3739
+ type: ToggleButtonKeyDownSpaceButton
3740
+ });
3741
+ }
3742
3742
  }
3743
- }
3744
- }), [dispatch, getItemNodeFromIndex, latest]);
3743
+ };
3744
+ }, [dispatch, getItemNodeFromIndex, latest]);
3745
3745
 
3746
3746
  // Action functions.
3747
- const toggleMenu = react.useCallback(() => {
3747
+ var toggleMenu = react.useCallback(function () {
3748
3748
  dispatch({
3749
3749
  type: FunctionToggleMenu$1
3750
3750
  });
3751
3751
  }, [dispatch]);
3752
- const closeMenu = react.useCallback(() => {
3752
+ var closeMenu = react.useCallback(function () {
3753
3753
  dispatch({
3754
3754
  type: FunctionCloseMenu$1
3755
3755
  });
3756
3756
  }, [dispatch]);
3757
- const openMenu = react.useCallback(() => {
3757
+ var openMenu = react.useCallback(function () {
3758
3758
  dispatch({
3759
3759
  type: FunctionOpenMenu$1
3760
3760
  });
3761
3761
  }, [dispatch]);
3762
- const setHighlightedIndex = react.useCallback(newHighlightedIndex => {
3762
+ var setHighlightedIndex = react.useCallback(function (newHighlightedIndex) {
3763
3763
  dispatch({
3764
3764
  type: FunctionSetHighlightedIndex$1,
3765
3765
  highlightedIndex: newHighlightedIndex
3766
3766
  });
3767
3767
  }, [dispatch]);
3768
- const selectItem = react.useCallback(newSelectedItem => {
3768
+ var selectItem = react.useCallback(function (newSelectedItem) {
3769
3769
  dispatch({
3770
3770
  type: FunctionSelectItem$1,
3771
3771
  selectedItem: newSelectedItem
3772
3772
  });
3773
3773
  }, [dispatch]);
3774
- const reset = react.useCallback(() => {
3774
+ var reset = react.useCallback(function () {
3775
3775
  dispatch({
3776
3776
  type: FunctionReset$2
3777
3777
  });
3778
3778
  }, [dispatch]);
3779
- const setInputValue = react.useCallback(newInputValue => {
3779
+ var setInputValue = react.useCallback(function (newInputValue) {
3780
3780
  dispatch({
3781
3781
  type: FunctionSetInputValue$1,
3782
3782
  inputValue: newInputValue
3783
3783
  });
3784
3784
  }, [dispatch]);
3785
3785
  // Getter functions.
3786
- const getLabelProps = react.useCallback(labelProps => ({
3787
- id: elementIds.labelId,
3788
- htmlFor: elementIds.toggleButtonId,
3789
- ...labelProps
3790
- }), [elementIds]);
3791
- const getMenuProps = react.useCallback(function (_temp, _temp2) {
3792
- let {
3793
- onMouseLeave,
3794
- refKey = 'ref',
3795
- onKeyDown,
3796
- onBlur,
3797
- ref,
3798
- ...rest
3799
- } = _temp === void 0 ? {} : _temp;
3800
- let {
3801
- suppressRefError = false
3802
- } = _temp2 === void 0 ? {} : _temp2;
3803
- const menuHandleMouseLeave = () => {
3786
+ var getLabelProps = react.useCallback(function (labelProps) {
3787
+ return _extends({
3788
+ id: elementIds.labelId,
3789
+ htmlFor: elementIds.toggleButtonId
3790
+ }, labelProps);
3791
+ }, [elementIds]);
3792
+ var getMenuProps = react.useCallback(function (_temp, _temp2) {
3793
+ var _extends2;
3794
+ var _ref = _temp === void 0 ? {} : _temp,
3795
+ onMouseLeave = _ref.onMouseLeave,
3796
+ _ref$refKey = _ref.refKey,
3797
+ refKey = _ref$refKey === void 0 ? 'ref' : _ref$refKey;
3798
+ _ref.onKeyDown;
3799
+ _ref.onBlur;
3800
+ var ref = _ref.ref,
3801
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$2);
3802
+ var _ref2 = _temp2 === void 0 ? {} : _temp2,
3803
+ _ref2$suppressRefErro = _ref2.suppressRefError,
3804
+ suppressRefError = _ref2$suppressRefErro === void 0 ? false : _ref2$suppressRefErro;
3805
+ var menuHandleMouseLeave = function menuHandleMouseLeave() {
3804
3806
  dispatch({
3805
3807
  type: MenuMouseLeave$1
3806
3808
  });
3807
3809
  };
3808
3810
  setGetterPropCallInfo('getMenuProps', suppressRefError, refKey, menuRef);
3809
- return {
3810
- [refKey]: handleRefs(ref, menuNode => {
3811
- menuRef.current = menuNode;
3812
- }),
3813
- id: elementIds.menuId,
3814
- role: 'listbox',
3815
- 'aria-labelledby': elementIds.labelId,
3816
- tabIndex: -1,
3817
- onMouseLeave: callAllEventHandlers(onMouseLeave, menuHandleMouseLeave),
3818
- ...rest
3819
- };
3811
+ return _extends((_extends2 = {}, _extends2[refKey] = handleRefs(ref, function (menuNode) {
3812
+ menuRef.current = menuNode;
3813
+ }), _extends2.id = elementIds.menuId, _extends2.role = 'listbox', _extends2['aria-labelledby'] = elementIds.labelId, _extends2.tabIndex = -1, _extends2.onMouseLeave = callAllEventHandlers(onMouseLeave, menuHandleMouseLeave), _extends2), rest);
3820
3814
  }, [dispatch, setGetterPropCallInfo, elementIds]);
3821
- const getToggleButtonProps = react.useCallback(function (_temp3, _temp4) {
3822
- let {
3823
- onBlur,
3824
- onClick,
3825
- onKeyDown,
3826
- refKey = 'ref',
3827
- ref,
3828
- ...rest
3829
- } = _temp3 === void 0 ? {} : _temp3;
3830
- let {
3831
- suppressRefError = false
3832
- } = _temp4 === void 0 ? {} : _temp4;
3833
- const latestState = latest.current.state;
3834
- const toggleButtonHandleClick = () => {
3815
+ var getToggleButtonProps = react.useCallback(function (_temp3, _temp4) {
3816
+ var _extends3;
3817
+ var _ref3 = _temp3 === void 0 ? {} : _temp3,
3818
+ onBlur = _ref3.onBlur,
3819
+ onClick = _ref3.onClick,
3820
+ onKeyDown = _ref3.onKeyDown,
3821
+ _ref3$refKey = _ref3.refKey,
3822
+ refKey = _ref3$refKey === void 0 ? 'ref' : _ref3$refKey,
3823
+ ref = _ref3.ref,
3824
+ rest = _objectWithoutPropertiesLoose(_ref3, _excluded2$2);
3825
+ var _ref4 = _temp4 === void 0 ? {} : _temp4,
3826
+ _ref4$suppressRefErro = _ref4.suppressRefError,
3827
+ suppressRefError = _ref4$suppressRefErro === void 0 ? false : _ref4$suppressRefErro;
3828
+ var latestState = latest.current.state;
3829
+ var toggleButtonHandleClick = function toggleButtonHandleClick() {
3835
3830
  dispatch({
3836
3831
  type: ToggleButtonClick$1
3837
3832
  });
3838
3833
  };
3839
- const toggleButtonHandleBlur = () => {
3834
+ var toggleButtonHandleBlur = function toggleButtonHandleBlur() {
3840
3835
  if (latestState.isOpen && !mouseAndTouchTrackersRef.current.isMouseDown) {
3841
3836
  dispatch({
3842
3837
  type: ToggleButtonBlur
3843
3838
  });
3844
3839
  }
3845
3840
  };
3846
- const toggleButtonHandleKeyDown = event => {
3847
- const key = normalizeArrowKey(event);
3841
+ var toggleButtonHandleKeyDown = function toggleButtonHandleKeyDown(event) {
3842
+ var key = normalizeArrowKey(event);
3848
3843
  if (key && toggleButtonKeyDownHandlers[key]) {
3849
3844
  toggleButtonKeyDownHandlers[key](event);
3850
3845
  } else if (isAcceptedCharacterKey(key)) {
3851
3846
  dispatch({
3852
3847
  type: ToggleButtonKeyDownCharacter,
3853
- key,
3854
- getItemNodeFromIndex
3848
+ key: key,
3849
+ getItemNodeFromIndex: getItemNodeFromIndex
3855
3850
  });
3856
3851
  }
3857
3852
  };
3858
- const toggleProps = {
3859
- [refKey]: handleRefs(ref, toggleButtonNode => {
3860
- toggleButtonRef.current = toggleButtonNode;
3861
- }),
3862
- 'aria-activedescendant': latestState.isOpen && latestState.highlightedIndex > -1 ? elementIds.getItemId(latestState.highlightedIndex) : '',
3863
- 'aria-controls': elementIds.menuId,
3864
- 'aria-expanded': latest.current.state.isOpen,
3865
- 'aria-haspopup': 'listbox',
3866
- 'aria-labelledby': `${elementIds.labelId}`,
3867
- id: elementIds.toggleButtonId,
3868
- role: 'combobox',
3869
- tabIndex: 0,
3870
- onBlur: callAllEventHandlers(onBlur, toggleButtonHandleBlur),
3871
- ...rest
3872
- };
3853
+ var toggleProps = _extends((_extends3 = {}, _extends3[refKey] = handleRefs(ref, function (toggleButtonNode) {
3854
+ toggleButtonRef.current = toggleButtonNode;
3855
+ }), _extends3['aria-activedescendant'] = latestState.isOpen && latestState.highlightedIndex > -1 ? elementIds.getItemId(latestState.highlightedIndex) : '', _extends3['aria-controls'] = elementIds.menuId, _extends3['aria-expanded'] = latest.current.state.isOpen, _extends3['aria-haspopup'] = 'listbox', _extends3['aria-labelledby'] = "" + elementIds.labelId, _extends3.id = elementIds.toggleButtonId, _extends3.role = 'combobox', _extends3.tabIndex = 0, _extends3.onBlur = callAllEventHandlers(onBlur, toggleButtonHandleBlur), _extends3), rest);
3873
3856
  if (!rest.disabled) {
3874
3857
  toggleProps.onClick = callAllEventHandlers(onClick, toggleButtonHandleClick);
3875
3858
  toggleProps.onKeyDown = callAllEventHandlers(onKeyDown, toggleButtonHandleKeyDown);
@@ -3877,56 +3860,54 @@
3877
3860
  setGetterPropCallInfo('getToggleButtonProps', suppressRefError, refKey, toggleButtonRef);
3878
3861
  return toggleProps;
3879
3862
  }, [latest, elementIds, setGetterPropCallInfo, dispatch, mouseAndTouchTrackersRef, toggleButtonKeyDownHandlers, getItemNodeFromIndex]);
3880
- const getItemProps = react.useCallback(function (_temp5) {
3881
- let {
3882
- item: itemProp,
3883
- index: indexProp,
3884
- onMouseMove,
3885
- onClick,
3886
- refKey = 'ref',
3887
- ref,
3888
- disabled,
3889
- ...rest
3890
- } = _temp5 === void 0 ? {} : _temp5;
3891
- const {
3892
- state: latestState,
3893
- props: latestProps
3894
- } = latest.current;
3895
- const item = itemProp ?? items[indexProp];
3896
- const index = getItemIndex(indexProp, item, latestProps.items);
3897
- const itemHandleMouseMove = () => {
3863
+ var getItemProps = react.useCallback(function (_temp5) {
3864
+ var _extends4;
3865
+ var _ref5 = _temp5 === void 0 ? {} : _temp5,
3866
+ itemProp = _ref5.item,
3867
+ indexProp = _ref5.index,
3868
+ onMouseMove = _ref5.onMouseMove,
3869
+ onClick = _ref5.onClick,
3870
+ _ref5$refKey = _ref5.refKey,
3871
+ refKey = _ref5$refKey === void 0 ? 'ref' : _ref5$refKey,
3872
+ ref = _ref5.ref,
3873
+ disabled = _ref5.disabled,
3874
+ rest = _objectWithoutPropertiesLoose(_ref5, _excluded3$1);
3875
+ var _latest$current = latest.current,
3876
+ latestState = _latest$current.state,
3877
+ latestProps = _latest$current.props;
3878
+ var item = itemProp != null ? itemProp : items[indexProp];
3879
+ var index = getItemIndex(indexProp, item, latestProps.items);
3880
+ var itemHandleMouseMove = function itemHandleMouseMove() {
3898
3881
  if (index === latestState.highlightedIndex) {
3899
3882
  return;
3900
3883
  }
3901
3884
  shouldScrollRef.current = false;
3902
3885
  dispatch({
3903
3886
  type: ItemMouseMove$1,
3904
- index,
3905
- disabled
3887
+ index: index,
3888
+ disabled: disabled
3906
3889
  });
3907
3890
  };
3908
- const itemHandleClick = () => {
3891
+ var itemHandleClick = function itemHandleClick() {
3909
3892
  dispatch({
3910
3893
  type: ItemClick$1,
3911
- index
3894
+ index: index
3912
3895
  });
3913
3896
  };
3914
- const itemIndex = getItemIndex(index, item, latestProps.items);
3897
+ var itemIndex = getItemIndex(index, item, latestProps.items);
3915
3898
  if (itemIndex < 0) {
3916
3899
  throw new Error('Pass either item or item index in getItemProps!');
3917
3900
  }
3918
- const itemProps = {
3919
- disabled,
3901
+ var itemProps = _extends((_extends4 = {
3902
+ disabled: disabled,
3920
3903
  role: 'option',
3921
- 'aria-selected': `${item === selectedItem}`,
3922
- id: elementIds.getItemId(itemIndex),
3923
- [refKey]: handleRefs(ref, itemNode => {
3924
- if (itemNode) {
3925
- itemRefs.current[elementIds.getItemId(itemIndex)] = itemNode;
3926
- }
3927
- }),
3928
- ...rest
3929
- };
3904
+ 'aria-selected': "" + (item === selectedItem),
3905
+ id: elementIds.getItemId(itemIndex)
3906
+ }, _extends4[refKey] = handleRefs(ref, function (itemNode) {
3907
+ if (itemNode) {
3908
+ itemRefs.current[elementIds.getItemId(itemIndex)] = itemNode;
3909
+ }
3910
+ }), _extends4), rest);
3930
3911
  if (!disabled) {
3931
3912
  itemProps.onClick = callAllEventHandlers(onClick, itemHandleClick);
3932
3913
  }
@@ -3935,49 +3916,49 @@
3935
3916
  }, [latest, items, selectedItem, elementIds, shouldScrollRef, dispatch]);
3936
3917
  return {
3937
3918
  // prop getters.
3938
- getToggleButtonProps,
3939
- getLabelProps,
3940
- getMenuProps,
3941
- getItemProps,
3919
+ getToggleButtonProps: getToggleButtonProps,
3920
+ getLabelProps: getLabelProps,
3921
+ getMenuProps: getMenuProps,
3922
+ getItemProps: getItemProps,
3942
3923
  // actions.
3943
- toggleMenu,
3944
- openMenu,
3945
- closeMenu,
3946
- setHighlightedIndex,
3947
- selectItem,
3948
- reset,
3949
- setInputValue,
3924
+ toggleMenu: toggleMenu,
3925
+ openMenu: openMenu,
3926
+ closeMenu: closeMenu,
3927
+ setHighlightedIndex: setHighlightedIndex,
3928
+ selectItem: selectItem,
3929
+ reset: reset,
3930
+ setInputValue: setInputValue,
3950
3931
  // state.
3951
- highlightedIndex,
3952
- isOpen,
3953
- selectedItem,
3954
- inputValue
3932
+ highlightedIndex: highlightedIndex,
3933
+ isOpen: isOpen,
3934
+ selectedItem: selectedItem,
3935
+ inputValue: inputValue
3955
3936
  };
3956
3937
  }
3957
3938
 
3958
- const InputKeyDownArrowDown = '__input_keydown_arrow_down__' ;
3959
- const InputKeyDownArrowUp = '__input_keydown_arrow_up__' ;
3960
- const InputKeyDownEscape = '__input_keydown_escape__' ;
3961
- const InputKeyDownHome = '__input_keydown_home__' ;
3962
- const InputKeyDownEnd = '__input_keydown_end__' ;
3963
- const InputKeyDownPageUp = '__input_keydown_page_up__' ;
3964
- const InputKeyDownPageDown = '__input_keydown_page_down__' ;
3965
- const InputKeyDownEnter = '__input_keydown_enter__' ;
3966
- const InputChange = '__input_change__' ;
3967
- const InputBlur = '__input_blur__' ;
3968
- const InputFocus = '__input_focus__' ;
3969
- const MenuMouseLeave = '__menu_mouse_leave__' ;
3970
- const ItemMouseMove = '__item_mouse_move__' ;
3971
- const ItemClick = '__item_click__' ;
3972
- const ToggleButtonClick = '__togglebutton_click__' ;
3973
- const FunctionToggleMenu = '__function_toggle_menu__' ;
3974
- const FunctionOpenMenu = '__function_open_menu__' ;
3975
- const FunctionCloseMenu = '__function_close_menu__' ;
3976
- const FunctionSetHighlightedIndex = '__function_set_highlighted_index__' ;
3977
- const FunctionSelectItem = '__function_select_item__' ;
3978
- const FunctionSetInputValue = '__function_set_input_value__' ;
3979
- const FunctionReset$1 = '__function_reset__' ;
3980
- const ControlledPropUpdatedSelectedItem = '__controlled_prop_updated_selected_item__' ;
3939
+ var InputKeyDownArrowDown = '__input_keydown_arrow_down__' ;
3940
+ var InputKeyDownArrowUp = '__input_keydown_arrow_up__' ;
3941
+ var InputKeyDownEscape = '__input_keydown_escape__' ;
3942
+ var InputKeyDownHome = '__input_keydown_home__' ;
3943
+ var InputKeyDownEnd = '__input_keydown_end__' ;
3944
+ var InputKeyDownPageUp = '__input_keydown_page_up__' ;
3945
+ var InputKeyDownPageDown = '__input_keydown_page_down__' ;
3946
+ var InputKeyDownEnter = '__input_keydown_enter__' ;
3947
+ var InputChange = '__input_change__' ;
3948
+ var InputBlur = '__input_blur__' ;
3949
+ var InputFocus = '__input_focus__' ;
3950
+ var MenuMouseLeave = '__menu_mouse_leave__' ;
3951
+ var ItemMouseMove = '__item_mouse_move__' ;
3952
+ var ItemClick = '__item_click__' ;
3953
+ var ToggleButtonClick = '__togglebutton_click__' ;
3954
+ var FunctionToggleMenu = '__function_toggle_menu__' ;
3955
+ var FunctionOpenMenu = '__function_open_menu__' ;
3956
+ var FunctionCloseMenu = '__function_close_menu__' ;
3957
+ var FunctionSetHighlightedIndex = '__function_set_highlighted_index__' ;
3958
+ var FunctionSelectItem = '__function_select_item__' ;
3959
+ var FunctionSetInputValue = '__function_set_input_value__' ;
3960
+ var FunctionReset$1 = '__function_reset__' ;
3961
+ var ControlledPropUpdatedSelectedItem = '__controlled_prop_updated_selected_item__' ;
3981
3962
 
3982
3963
  var stateChangeTypes$1 = /*#__PURE__*/Object.freeze({
3983
3964
  __proto__: null,
@@ -4007,22 +3988,17 @@
4007
3988
  });
4008
3989
 
4009
3990
  function getInitialState$1(props) {
4010
- const initialState = getInitialState$2(props);
4011
- const {
4012
- selectedItem
4013
- } = initialState;
4014
- let {
4015
- inputValue
4016
- } = initialState;
3991
+ var initialState = getInitialState$2(props);
3992
+ var selectedItem = initialState.selectedItem;
3993
+ var inputValue = initialState.inputValue;
4017
3994
  if (inputValue === '' && selectedItem && props.defaultInputValue === undefined && props.initialInputValue === undefined && props.inputValue === undefined) {
4018
3995
  inputValue = props.itemToString(selectedItem);
4019
3996
  }
4020
- return {
4021
- ...initialState,
4022
- inputValue
4023
- };
3997
+ return _extends({}, initialState, {
3998
+ inputValue: inputValue
3999
+ });
4024
4000
  }
4025
- const propTypes$1 = {
4001
+ var propTypes$1 = {
4026
4002
  items: PropTypes.array.isRequired,
4027
4003
  itemToString: PropTypes.func,
4028
4004
  getA11yStatusMessage: PropTypes.func,
@@ -4075,11 +4051,13 @@
4075
4051
  * @returns {Array} An array with the state and an action dispatcher.
4076
4052
  */
4077
4053
  function useControlledReducer(reducer, initialState, props) {
4078
- const previousSelectedItemRef = react.useRef();
4079
- const [state, dispatch] = useEnhancedReducer(reducer, initialState, props);
4054
+ var previousSelectedItemRef = react.useRef();
4055
+ var _useEnhancedReducer = useEnhancedReducer(reducer, initialState, props),
4056
+ state = _useEnhancedReducer[0],
4057
+ dispatch = _useEnhancedReducer[1];
4080
4058
 
4081
4059
  // ToDo: if needed, make same approach as selectedItemChanged from Downshift.
4082
- react.useEffect(() => {
4060
+ react.useEffect(function () {
4083
4061
  if (isControlledProp(props, 'selectedItem')) {
4084
4062
  if (previousSelectedItemRef.current !== props.selectedItem) {
4085
4063
  dispatch({
@@ -4094,26 +4072,23 @@
4094
4072
  }
4095
4073
 
4096
4074
  // eslint-disable-next-line import/no-mutable-exports
4097
- let validatePropTypes$1 = noop;
4075
+ var validatePropTypes$1 = noop;
4098
4076
  /* istanbul ignore next */
4099
4077
  {
4100
- validatePropTypes$1 = (options, caller) => {
4078
+ validatePropTypes$1 = function validatePropTypes(options, caller) {
4101
4079
  PropTypes.checkPropTypes(propTypes$1, options, 'prop', caller.name);
4102
4080
  };
4103
4081
  }
4104
- const defaultProps$1 = {
4105
- ...defaultProps$3,
4082
+ var defaultProps$1 = _extends({}, defaultProps$3, {
4106
4083
  getA11yStatusMessage: getA11yStatusMessage$1
4107
- };
4084
+ });
4108
4085
 
4109
4086
  /* eslint-disable complexity */
4110
4087
  function downshiftUseComboboxReducer(state, action) {
4111
- const {
4112
- type,
4113
- props,
4114
- altKey
4115
- } = action;
4116
- let changes;
4088
+ var type = action.type,
4089
+ props = action.props,
4090
+ altKey = action.altKey;
4091
+ var changes;
4117
4092
  switch (type) {
4118
4093
  case ItemClick:
4119
4094
  changes = {
@@ -4138,14 +4113,13 @@
4138
4113
  case InputKeyDownArrowUp:
4139
4114
  if (state.isOpen) {
4140
4115
  if (altKey) {
4141
- changes = {
4116
+ changes = _extends({
4142
4117
  isOpen: getDefaultValue$1(props, 'isOpen'),
4143
- highlightedIndex: getDefaultValue$1(props, 'highlightedIndex'),
4144
- ...(state.highlightedIndex >= 0 && {
4145
- selectedItem: props.items[state.highlightedIndex],
4146
- inputValue: props.itemToString(props.items[state.highlightedIndex])
4147
- })
4148
- };
4118
+ highlightedIndex: getDefaultValue$1(props, 'highlightedIndex')
4119
+ }, state.highlightedIndex >= 0 && {
4120
+ selectedItem: props.items[state.highlightedIndex],
4121
+ inputValue: props.itemToString(props.items[state.highlightedIndex])
4122
+ });
4149
4123
  } else {
4150
4124
  changes = {
4151
4125
  highlightedIndex: getNextWrappingIndex(-1, state.highlightedIndex, props.items.length, action.getItemNodeFromIndex, true)
@@ -4159,24 +4133,22 @@
4159
4133
  }
4160
4134
  break;
4161
4135
  case InputKeyDownEnter:
4162
- changes = {
4136
+ changes = _extends({
4163
4137
  isOpen: getDefaultValue$1(props, 'isOpen'),
4164
- highlightedIndex: getDefaultValue$1(props, 'highlightedIndex'),
4165
- ...(state.highlightedIndex >= 0 && {
4166
- selectedItem: props.items[state.highlightedIndex],
4167
- inputValue: props.itemToString(props.items[state.highlightedIndex])
4168
- })
4169
- };
4138
+ highlightedIndex: getDefaultValue$1(props, 'highlightedIndex')
4139
+ }, state.highlightedIndex >= 0 && {
4140
+ selectedItem: props.items[state.highlightedIndex],
4141
+ inputValue: props.itemToString(props.items[state.highlightedIndex])
4142
+ });
4170
4143
  break;
4171
4144
  case InputKeyDownEscape:
4172
- changes = {
4145
+ changes = _extends({
4173
4146
  isOpen: false,
4174
- highlightedIndex: -1,
4175
- ...(!state.isOpen && {
4176
- selectedItem: null,
4177
- inputValue: ''
4178
- })
4179
- };
4147
+ highlightedIndex: -1
4148
+ }, !state.isOpen && {
4149
+ selectedItem: null,
4150
+ inputValue: ''
4151
+ });
4180
4152
  break;
4181
4153
  case InputKeyDownPageUp:
4182
4154
  changes = {
@@ -4199,14 +4171,13 @@
4199
4171
  };
4200
4172
  break;
4201
4173
  case InputBlur:
4202
- changes = {
4174
+ changes = _extends({
4203
4175
  isOpen: false,
4204
- highlightedIndex: -1,
4205
- ...(state.highlightedIndex >= 0 && action.selectItem && {
4206
- selectedItem: props.items[state.highlightedIndex],
4207
- inputValue: props.itemToString(props.items[state.highlightedIndex])
4208
- })
4209
- };
4176
+ highlightedIndex: -1
4177
+ }, state.highlightedIndex >= 0 && action.selectItem && {
4178
+ selectedItem: props.items[state.highlightedIndex],
4179
+ inputValue: props.itemToString(props.items[state.highlightedIndex])
4180
+ });
4210
4181
  break;
4211
4182
  case InputChange:
4212
4183
  changes = {
@@ -4235,14 +4206,14 @@
4235
4206
  default:
4236
4207
  return downshiftCommonReducer(state, action, stateChangeTypes$1);
4237
4208
  }
4238
- return {
4239
- ...state,
4240
- ...changes
4241
- };
4209
+ return _extends({}, state, changes);
4242
4210
  }
4243
4211
  /* eslint-enable complexity */
4244
4212
 
4245
- /* eslint-disable max-statements */
4213
+ var _excluded$1 = ["onMouseLeave", "refKey", "ref"],
4214
+ _excluded2$1 = ["item", "index", "refKey", "ref", "onMouseMove", "onMouseDown", "onClick", "onPress", "disabled"],
4215
+ _excluded3 = ["onClick", "onPress", "refKey", "ref"],
4216
+ _excluded4 = ["onKeyDown", "onChange", "onInput", "onFocus", "onBlur", "onChangeText", "refKey", "ref"];
4246
4217
  useCombobox.stateChangeTypes = stateChangeTypes$1;
4247
4218
  function useCombobox(userProps) {
4248
4219
  if (userProps === void 0) {
@@ -4250,349 +4221,327 @@
4250
4221
  }
4251
4222
  validatePropTypes$1(userProps, useCombobox);
4252
4223
  // Props defaults and destructuring.
4253
- const props = {
4254
- ...defaultProps$1,
4255
- ...userProps
4256
- };
4257
- const {
4258
- initialIsOpen,
4259
- defaultIsOpen,
4260
- items,
4261
- scrollIntoView,
4262
- environment,
4263
- getA11yStatusMessage,
4264
- getA11ySelectionMessage,
4265
- itemToString
4266
- } = props;
4224
+ var props = _extends({}, defaultProps$1, userProps);
4225
+ var initialIsOpen = props.initialIsOpen,
4226
+ defaultIsOpen = props.defaultIsOpen,
4227
+ items = props.items,
4228
+ scrollIntoView = props.scrollIntoView,
4229
+ environment = props.environment,
4230
+ getA11yStatusMessage = props.getA11yStatusMessage,
4231
+ getA11ySelectionMessage = props.getA11ySelectionMessage,
4232
+ itemToString = props.itemToString;
4267
4233
  // Initial state depending on controlled props.
4268
- const initialState = getInitialState$1(props);
4269
- const [state, dispatch] = useControlledReducer(downshiftUseComboboxReducer, initialState, props);
4270
- const {
4271
- isOpen,
4272
- highlightedIndex,
4273
- selectedItem,
4274
- inputValue
4275
- } = state;
4234
+ var initialState = getInitialState$1(props);
4235
+ var _useControlledReducer = useControlledReducer(downshiftUseComboboxReducer, initialState, props),
4236
+ state = _useControlledReducer[0],
4237
+ dispatch = _useControlledReducer[1];
4238
+ var isOpen = state.isOpen,
4239
+ highlightedIndex = state.highlightedIndex,
4240
+ selectedItem = state.selectedItem,
4241
+ inputValue = state.inputValue;
4276
4242
 
4277
4243
  // Element refs.
4278
- const menuRef = react.useRef(null);
4279
- const itemRefs = react.useRef({});
4280
- const inputRef = react.useRef(null);
4281
- const toggleButtonRef = react.useRef(null);
4282
- const isInitialMountRef = react.useRef(true);
4244
+ var menuRef = react.useRef(null);
4245
+ var itemRefs = react.useRef({});
4246
+ var inputRef = react.useRef(null);
4247
+ var toggleButtonRef = react.useRef(null);
4248
+ var isInitialMountRef = react.useRef(true);
4283
4249
  // prevent id re-generation between renders.
4284
- const elementIds = useElementIds(props);
4250
+ var elementIds = useElementIds(props);
4285
4251
  // used to keep track of how many items we had on previous cycle.
4286
- const previousResultCountRef = react.useRef();
4252
+ var previousResultCountRef = react.useRef();
4287
4253
  // utility callback to get item element.
4288
- const latest = useLatestRef({
4289
- state,
4290
- props
4254
+ var latest = useLatestRef({
4255
+ state: state,
4256
+ props: props
4291
4257
  });
4292
- const getItemNodeFromIndex = react.useCallback(index => itemRefs.current[elementIds.getItemId(index)], [elementIds]);
4258
+ var getItemNodeFromIndex = react.useCallback(function (index) {
4259
+ return itemRefs.current[elementIds.getItemId(index)];
4260
+ }, [elementIds]);
4293
4261
 
4294
4262
  // Effects.
4295
4263
  // Sets a11y status message on changes in state.
4296
- useA11yMessageSetter(getA11yStatusMessage, [isOpen, highlightedIndex, inputValue, items], {
4264
+ useA11yMessageSetter(getA11yStatusMessage, [isOpen, highlightedIndex, inputValue, items], _extends({
4297
4265
  isInitialMount: isInitialMountRef.current,
4298
4266
  previousResultCount: previousResultCountRef.current,
4299
- items,
4300
- environment,
4301
- itemToString,
4302
- ...state
4303
- });
4267
+ items: items,
4268
+ environment: environment,
4269
+ itemToString: itemToString
4270
+ }, state));
4304
4271
  // Sets a11y status message on changes in selectedItem.
4305
- useA11yMessageSetter(getA11ySelectionMessage, [selectedItem], {
4272
+ useA11yMessageSetter(getA11ySelectionMessage, [selectedItem], _extends({
4306
4273
  isInitialMount: isInitialMountRef.current,
4307
4274
  previousResultCount: previousResultCountRef.current,
4308
- items,
4309
- environment,
4310
- itemToString,
4311
- ...state
4312
- });
4275
+ items: items,
4276
+ environment: environment,
4277
+ itemToString: itemToString
4278
+ }, state));
4313
4279
  // Scroll on highlighted item if change comes from keyboard.
4314
- const shouldScrollRef = useScrollIntoView({
4280
+ var shouldScrollRef = useScrollIntoView({
4315
4281
  menuElement: menuRef.current,
4316
- highlightedIndex,
4317
- isOpen,
4318
- itemRefs,
4319
- scrollIntoView,
4320
- getItemNodeFromIndex
4282
+ highlightedIndex: highlightedIndex,
4283
+ isOpen: isOpen,
4284
+ itemRefs: itemRefs,
4285
+ scrollIntoView: scrollIntoView,
4286
+ getItemNodeFromIndex: getItemNodeFromIndex
4321
4287
  });
4322
4288
  useControlPropsValidator({
4323
4289
  isInitialMount: isInitialMountRef.current,
4324
- props,
4325
- state
4290
+ props: props,
4291
+ state: state
4326
4292
  });
4327
4293
  // Focus the input on first render if required.
4328
- react.useEffect(() => {
4329
- const focusOnOpen = initialIsOpen || defaultIsOpen || isOpen;
4294
+ react.useEffect(function () {
4295
+ var focusOnOpen = initialIsOpen || defaultIsOpen || isOpen;
4330
4296
  if (focusOnOpen && inputRef.current) {
4331
4297
  inputRef.current.focus();
4332
4298
  }
4333
4299
  // eslint-disable-next-line react-hooks/exhaustive-deps
4334
4300
  }, []);
4335
- react.useEffect(() => {
4301
+ react.useEffect(function () {
4336
4302
  if (isInitialMountRef.current) {
4337
4303
  return;
4338
4304
  }
4339
4305
  previousResultCountRef.current = items.length;
4340
4306
  });
4341
4307
  // Add mouse/touch events to document.
4342
- const mouseAndTouchTrackersRef = useMouseAndTouchTracker(isOpen, [inputRef, menuRef, toggleButtonRef], environment, () => {
4308
+ var mouseAndTouchTrackersRef = useMouseAndTouchTracker(isOpen, [inputRef, menuRef, toggleButtonRef], environment, function () {
4343
4309
  dispatch({
4344
4310
  type: InputBlur,
4345
4311
  selectItem: false
4346
4312
  });
4347
4313
  });
4348
- const setGetterPropCallInfo = useGetterPropsCalledChecker('getInputProps', 'getMenuProps');
4314
+ var setGetterPropCallInfo = useGetterPropsCalledChecker('getInputProps', 'getMenuProps');
4349
4315
  // Make initial ref false.
4350
- react.useEffect(() => {
4316
+ react.useEffect(function () {
4351
4317
  isInitialMountRef.current = false;
4352
- return () => {
4318
+ return function () {
4353
4319
  isInitialMountRef.current = true;
4354
4320
  };
4355
4321
  }, []);
4356
4322
  // Reset itemRefs on close.
4357
- react.useEffect(() => {
4323
+ react.useEffect(function () {
4358
4324
  if (!isOpen) {
4359
4325
  itemRefs.current = {};
4360
4326
  } else if (document.activeElement !== inputRef.current) {
4361
- inputRef?.current?.focus();
4327
+ var _inputRef$current;
4328
+ inputRef == null ? void 0 : (_inputRef$current = inputRef.current) == null ? void 0 : _inputRef$current.focus();
4362
4329
  }
4363
4330
  }, [isOpen]);
4364
4331
 
4365
4332
  /* Event handler functions */
4366
- const inputKeyDownHandlers = react.useMemo(() => ({
4367
- ArrowDown(event) {
4368
- event.preventDefault();
4369
- dispatch({
4370
- type: InputKeyDownArrowDown,
4371
- altKey: event.altKey,
4372
- getItemNodeFromIndex
4373
- });
4374
- },
4375
- ArrowUp(event) {
4376
- event.preventDefault();
4377
- dispatch({
4378
- type: InputKeyDownArrowUp,
4379
- altKey: event.altKey,
4380
- getItemNodeFromIndex
4381
- });
4382
- },
4383
- Home(event) {
4384
- if (!latest.current.state.isOpen) {
4385
- return;
4386
- }
4387
- event.preventDefault();
4388
- dispatch({
4389
- type: InputKeyDownHome,
4390
- getItemNodeFromIndex
4391
- });
4392
- },
4393
- End(event) {
4394
- if (!latest.current.state.isOpen) {
4395
- return;
4396
- }
4397
- event.preventDefault();
4398
- dispatch({
4399
- type: InputKeyDownEnd,
4400
- getItemNodeFromIndex
4401
- });
4402
- },
4403
- Escape(event) {
4404
- const latestState = latest.current.state;
4405
- if (latestState.isOpen || latestState.inputValue || latestState.selectedItem || latestState.highlightedIndex > -1) {
4333
+ var inputKeyDownHandlers = react.useMemo(function () {
4334
+ return {
4335
+ ArrowDown: function ArrowDown(event) {
4406
4336
  event.preventDefault();
4407
4337
  dispatch({
4408
- type: InputKeyDownEscape
4338
+ type: InputKeyDownArrowDown,
4339
+ altKey: event.altKey,
4340
+ getItemNodeFromIndex: getItemNodeFromIndex
4409
4341
  });
4410
- }
4411
- },
4412
- Enter(event) {
4413
- const latestState = latest.current.state;
4414
- // if closed or no highlighted index, do nothing.
4415
- if (!latestState.isOpen || event.which === 229 // if IME composing, wait for next Enter keydown event.
4416
- ) {
4417
- return;
4418
- }
4419
- event.preventDefault();
4420
- dispatch({
4421
- type: InputKeyDownEnter,
4422
- getItemNodeFromIndex
4423
- });
4424
- },
4425
- PageUp(event) {
4426
- if (latest.current.state.isOpen) {
4342
+ },
4343
+ ArrowUp: function ArrowUp(event) {
4427
4344
  event.preventDefault();
4428
4345
  dispatch({
4429
- type: InputKeyDownPageUp,
4430
- getItemNodeFromIndex
4346
+ type: InputKeyDownArrowUp,
4347
+ altKey: event.altKey,
4348
+ getItemNodeFromIndex: getItemNodeFromIndex
4431
4349
  });
4432
- }
4433
- },
4434
- PageDown(event) {
4435
- if (latest.current.state.isOpen) {
4350
+ },
4351
+ Home: function Home(event) {
4352
+ if (!latest.current.state.isOpen) {
4353
+ return;
4354
+ }
4355
+ event.preventDefault();
4356
+ dispatch({
4357
+ type: InputKeyDownHome,
4358
+ getItemNodeFromIndex: getItemNodeFromIndex
4359
+ });
4360
+ },
4361
+ End: function End(event) {
4362
+ if (!latest.current.state.isOpen) {
4363
+ return;
4364
+ }
4436
4365
  event.preventDefault();
4437
4366
  dispatch({
4438
- type: InputKeyDownPageDown,
4439
- getItemNodeFromIndex
4367
+ type: InputKeyDownEnd,
4368
+ getItemNodeFromIndex: getItemNodeFromIndex
4440
4369
  });
4370
+ },
4371
+ Escape: function Escape(event) {
4372
+ var latestState = latest.current.state;
4373
+ if (latestState.isOpen || latestState.inputValue || latestState.selectedItem || latestState.highlightedIndex > -1) {
4374
+ event.preventDefault();
4375
+ dispatch({
4376
+ type: InputKeyDownEscape
4377
+ });
4378
+ }
4379
+ },
4380
+ Enter: function Enter(event) {
4381
+ var latestState = latest.current.state;
4382
+ // if closed or no highlighted index, do nothing.
4383
+ if (!latestState.isOpen || event.which === 229 // if IME composing, wait for next Enter keydown event.
4384
+ ) {
4385
+ return;
4386
+ }
4387
+ event.preventDefault();
4388
+ dispatch({
4389
+ type: InputKeyDownEnter,
4390
+ getItemNodeFromIndex: getItemNodeFromIndex
4391
+ });
4392
+ },
4393
+ PageUp: function PageUp(event) {
4394
+ if (latest.current.state.isOpen) {
4395
+ event.preventDefault();
4396
+ dispatch({
4397
+ type: InputKeyDownPageUp,
4398
+ getItemNodeFromIndex: getItemNodeFromIndex
4399
+ });
4400
+ }
4401
+ },
4402
+ PageDown: function PageDown(event) {
4403
+ if (latest.current.state.isOpen) {
4404
+ event.preventDefault();
4405
+ dispatch({
4406
+ type: InputKeyDownPageDown,
4407
+ getItemNodeFromIndex: getItemNodeFromIndex
4408
+ });
4409
+ }
4441
4410
  }
4442
- }
4443
- }), [dispatch, latest, getItemNodeFromIndex]);
4411
+ };
4412
+ }, [dispatch, latest, getItemNodeFromIndex]);
4444
4413
 
4445
4414
  // Getter props.
4446
- const getLabelProps = react.useCallback(labelProps => ({
4447
- id: elementIds.labelId,
4448
- htmlFor: elementIds.inputId,
4449
- ...labelProps
4450
- }), [elementIds]);
4451
- const getMenuProps = react.useCallback(function (_temp, _temp2) {
4452
- let {
4453
- onMouseLeave,
4454
- refKey = 'ref',
4455
- ref,
4456
- ...rest
4457
- } = _temp === void 0 ? {} : _temp;
4458
- let {
4459
- suppressRefError = false
4460
- } = _temp2 === void 0 ? {} : _temp2;
4415
+ var getLabelProps = react.useCallback(function (labelProps) {
4416
+ return _extends({
4417
+ id: elementIds.labelId,
4418
+ htmlFor: elementIds.inputId
4419
+ }, labelProps);
4420
+ }, [elementIds]);
4421
+ var getMenuProps = react.useCallback(function (_temp, _temp2) {
4422
+ var _extends2;
4423
+ var _ref = _temp === void 0 ? {} : _temp,
4424
+ onMouseLeave = _ref.onMouseLeave,
4425
+ _ref$refKey = _ref.refKey,
4426
+ refKey = _ref$refKey === void 0 ? 'ref' : _ref$refKey,
4427
+ ref = _ref.ref,
4428
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$1);
4429
+ var _ref2 = _temp2 === void 0 ? {} : _temp2,
4430
+ _ref2$suppressRefErro = _ref2.suppressRefError,
4431
+ suppressRefError = _ref2$suppressRefErro === void 0 ? false : _ref2$suppressRefErro;
4461
4432
  setGetterPropCallInfo('getMenuProps', suppressRefError, refKey, menuRef);
4462
- return {
4463
- [refKey]: handleRefs(ref, menuNode => {
4464
- menuRef.current = menuNode;
4465
- }),
4466
- id: elementIds.menuId,
4467
- role: 'listbox',
4468
- 'aria-labelledby': elementIds.labelId,
4469
- onMouseLeave: callAllEventHandlers(onMouseLeave, () => {
4470
- dispatch({
4471
- type: MenuMouseLeave
4472
- });
4473
- }),
4474
- ...rest
4475
- };
4433
+ return _extends((_extends2 = {}, _extends2[refKey] = handleRefs(ref, function (menuNode) {
4434
+ menuRef.current = menuNode;
4435
+ }), _extends2.id = elementIds.menuId, _extends2.role = 'listbox', _extends2['aria-labelledby'] = elementIds.labelId, _extends2.onMouseLeave = callAllEventHandlers(onMouseLeave, function () {
4436
+ dispatch({
4437
+ type: MenuMouseLeave
4438
+ });
4439
+ }), _extends2), rest);
4476
4440
  }, [dispatch, setGetterPropCallInfo, elementIds]);
4477
- const getItemProps = react.useCallback(function (_temp3) {
4478
- let {
4479
- item,
4480
- index,
4481
- refKey = 'ref',
4482
- ref,
4483
- onMouseMove,
4484
- onMouseDown,
4485
- onClick,
4486
- onPress,
4487
- disabled,
4488
- ...rest
4489
- } = _temp3 === void 0 ? {} : _temp3;
4490
- const {
4491
- props: latestProps,
4492
- state: latestState
4493
- } = latest.current;
4494
- const itemIndex = getItemIndex(index, item, latestProps.items);
4441
+ var getItemProps = react.useCallback(function (_temp3) {
4442
+ var _extends3, _ref4;
4443
+ var _ref3 = _temp3 === void 0 ? {} : _temp3,
4444
+ item = _ref3.item,
4445
+ index = _ref3.index,
4446
+ _ref3$refKey = _ref3.refKey,
4447
+ refKey = _ref3$refKey === void 0 ? 'ref' : _ref3$refKey,
4448
+ ref = _ref3.ref,
4449
+ onMouseMove = _ref3.onMouseMove,
4450
+ onMouseDown = _ref3.onMouseDown,
4451
+ onClick = _ref3.onClick;
4452
+ _ref3.onPress;
4453
+ var disabled = _ref3.disabled,
4454
+ rest = _objectWithoutPropertiesLoose(_ref3, _excluded2$1);
4455
+ var _latest$current = latest.current,
4456
+ latestProps = _latest$current.props,
4457
+ latestState = _latest$current.state;
4458
+ var itemIndex = getItemIndex(index, item, latestProps.items);
4495
4459
  if (itemIndex < 0) {
4496
4460
  throw new Error('Pass either item or item index in getItemProps!');
4497
4461
  }
4498
- const onSelectKey = 'onClick';
4499
- const customClickHandler = onClick;
4500
- const itemHandleMouseMove = () => {
4462
+ var onSelectKey = 'onClick';
4463
+ var customClickHandler = onClick;
4464
+ var itemHandleMouseMove = function itemHandleMouseMove() {
4501
4465
  if (index === latestState.highlightedIndex) {
4502
4466
  return;
4503
4467
  }
4504
4468
  shouldScrollRef.current = false;
4505
4469
  dispatch({
4506
4470
  type: ItemMouseMove,
4507
- index,
4508
- disabled
4471
+ index: index,
4472
+ disabled: disabled
4509
4473
  });
4510
4474
  };
4511
- const itemHandleClick = () => {
4475
+ var itemHandleClick = function itemHandleClick() {
4512
4476
  dispatch({
4513
4477
  type: ItemClick,
4514
- index
4478
+ index: index
4515
4479
  });
4516
4480
  };
4517
- const itemHandleMouseDown = e => e.preventDefault();
4518
- return {
4519
- [refKey]: handleRefs(ref, itemNode => {
4520
- if (itemNode) {
4521
- itemRefs.current[elementIds.getItemId(itemIndex)] = itemNode;
4522
- }
4523
- }),
4524
- disabled,
4525
- role: 'option',
4526
- 'aria-selected': `${itemIndex === latestState.highlightedIndex}`,
4527
- id: elementIds.getItemId(itemIndex),
4528
- ...(!disabled && {
4529
- [onSelectKey]: callAllEventHandlers(customClickHandler, itemHandleClick)
4530
- }),
4531
- onMouseMove: callAllEventHandlers(onMouseMove, itemHandleMouseMove),
4532
- onMouseDown: callAllEventHandlers(onMouseDown, itemHandleMouseDown),
4533
- ...rest
4481
+ var itemHandleMouseDown = function itemHandleMouseDown(e) {
4482
+ return e.preventDefault();
4534
4483
  };
4484
+ return _extends((_extends3 = {}, _extends3[refKey] = handleRefs(ref, function (itemNode) {
4485
+ if (itemNode) {
4486
+ itemRefs.current[elementIds.getItemId(itemIndex)] = itemNode;
4487
+ }
4488
+ }), _extends3.disabled = disabled, _extends3.role = 'option', _extends3['aria-selected'] = "" + (itemIndex === latestState.highlightedIndex), _extends3.id = elementIds.getItemId(itemIndex), _extends3), !disabled && (_ref4 = {}, _ref4[onSelectKey] = callAllEventHandlers(customClickHandler, itemHandleClick), _ref4), {
4489
+ onMouseMove: callAllEventHandlers(onMouseMove, itemHandleMouseMove),
4490
+ onMouseDown: callAllEventHandlers(onMouseDown, itemHandleMouseDown)
4491
+ }, rest);
4535
4492
  }, [dispatch, latest, shouldScrollRef, elementIds]);
4536
- const getToggleButtonProps = react.useCallback(function (_temp4) {
4537
- let {
4538
- onClick,
4539
- onPress,
4540
- refKey = 'ref',
4541
- ref,
4542
- ...rest
4543
- } = _temp4 === void 0 ? {} : _temp4;
4544
- const latestState = latest.current.state;
4545
- const toggleButtonHandleClick = () => {
4493
+ var getToggleButtonProps = react.useCallback(function (_temp4) {
4494
+ var _extends4;
4495
+ var _ref5 = _temp4 === void 0 ? {} : _temp4,
4496
+ onClick = _ref5.onClick;
4497
+ _ref5.onPress;
4498
+ var _ref5$refKey = _ref5.refKey,
4499
+ refKey = _ref5$refKey === void 0 ? 'ref' : _ref5$refKey,
4500
+ ref = _ref5.ref,
4501
+ rest = _objectWithoutPropertiesLoose(_ref5, _excluded3);
4502
+ var latestState = latest.current.state;
4503
+ var toggleButtonHandleClick = function toggleButtonHandleClick() {
4546
4504
  dispatch({
4547
4505
  type: ToggleButtonClick
4548
4506
  });
4549
4507
  };
4550
- return {
4551
- [refKey]: handleRefs(ref, toggleButtonNode => {
4552
- toggleButtonRef.current = toggleButtonNode;
4553
- }),
4554
- 'aria-controls': elementIds.menuId,
4555
- 'aria-expanded': latestState.isOpen,
4556
- id: elementIds.toggleButtonId,
4557
- tabIndex: -1,
4558
- ...(!rest.disabled && {
4559
- ...({
4560
- onClick: callAllEventHandlers(onClick, toggleButtonHandleClick)
4561
- })
4562
- }),
4563
- ...rest
4564
- };
4508
+ return _extends((_extends4 = {}, _extends4[refKey] = handleRefs(ref, function (toggleButtonNode) {
4509
+ toggleButtonRef.current = toggleButtonNode;
4510
+ }), _extends4['aria-controls'] = elementIds.menuId, _extends4['aria-expanded'] = latestState.isOpen, _extends4.id = elementIds.toggleButtonId, _extends4.tabIndex = -1, _extends4), !rest.disabled && _extends({}, {
4511
+ onClick: callAllEventHandlers(onClick, toggleButtonHandleClick)
4512
+ }), rest);
4565
4513
  }, [dispatch, latest, elementIds]);
4566
- const getInputProps = react.useCallback(function (_temp5, _temp6) {
4567
- let {
4568
- onKeyDown,
4569
- onChange,
4570
- onInput,
4571
- onFocus,
4572
- onBlur,
4573
- onChangeText,
4574
- refKey = 'ref',
4575
- ref,
4576
- ...rest
4577
- } = _temp5 === void 0 ? {} : _temp5;
4578
- let {
4579
- suppressRefError = false
4580
- } = _temp6 === void 0 ? {} : _temp6;
4514
+ var getInputProps = react.useCallback(function (_temp5, _temp6) {
4515
+ var _extends5;
4516
+ var _ref6 = _temp5 === void 0 ? {} : _temp5,
4517
+ onKeyDown = _ref6.onKeyDown,
4518
+ onChange = _ref6.onChange,
4519
+ onInput = _ref6.onInput,
4520
+ onFocus = _ref6.onFocus,
4521
+ onBlur = _ref6.onBlur;
4522
+ _ref6.onChangeText;
4523
+ var _ref6$refKey = _ref6.refKey,
4524
+ refKey = _ref6$refKey === void 0 ? 'ref' : _ref6$refKey,
4525
+ ref = _ref6.ref,
4526
+ rest = _objectWithoutPropertiesLoose(_ref6, _excluded4);
4527
+ var _ref7 = _temp6 === void 0 ? {} : _temp6,
4528
+ _ref7$suppressRefErro = _ref7.suppressRefError,
4529
+ suppressRefError = _ref7$suppressRefErro === void 0 ? false : _ref7$suppressRefErro;
4581
4530
  setGetterPropCallInfo('getInputProps', suppressRefError, refKey, inputRef);
4582
- const latestState = latest.current.state;
4583
- const inputHandleKeyDown = event => {
4584
- const key = normalizeArrowKey(event);
4531
+ var latestState = latest.current.state;
4532
+ var inputHandleKeyDown = function inputHandleKeyDown(event) {
4533
+ var key = normalizeArrowKey(event);
4585
4534
  if (key && inputKeyDownHandlers[key]) {
4586
4535
  inputKeyDownHandlers[key](event);
4587
4536
  }
4588
4537
  };
4589
- const inputHandleChange = event => {
4538
+ var inputHandleChange = function inputHandleChange(event) {
4590
4539
  dispatch({
4591
4540
  type: InputChange,
4592
4541
  inputValue: event.target.value
4593
4542
  });
4594
4543
  };
4595
- const inputHandleBlur = () => {
4544
+ var inputHandleBlur = function inputHandleBlur() {
4596
4545
  /* istanbul ignore else */
4597
4546
  if (latestState.isOpen && !mouseAndTouchTrackersRef.current.isMouseDown) {
4598
4547
  dispatch({
@@ -4601,7 +4550,7 @@
4601
4550
  });
4602
4551
  }
4603
4552
  };
4604
- const inputHandleFocus = () => {
4553
+ var inputHandleFocus = function inputHandleFocus() {
4605
4554
  if (!latestState.isOpen) {
4606
4555
  dispatch({
4607
4556
  type: InputFocus
@@ -4610,99 +4559,80 @@
4610
4559
  };
4611
4560
 
4612
4561
  /* istanbul ignore next (preact) */
4613
- const onChangeKey = 'onChange';
4614
- let eventHandlers = {};
4562
+ var onChangeKey = 'onChange';
4563
+ var eventHandlers = {};
4615
4564
  if (!rest.disabled) {
4616
- eventHandlers = {
4617
- [onChangeKey]: callAllEventHandlers(onChange, onInput, inputHandleChange),
4618
- onKeyDown: callAllEventHandlers(onKeyDown, inputHandleKeyDown),
4619
- onBlur: callAllEventHandlers(onBlur, inputHandleBlur),
4620
- onFocus: callAllEventHandlers(onFocus, inputHandleFocus)
4621
- };
4565
+ var _eventHandlers;
4566
+ eventHandlers = (_eventHandlers = {}, _eventHandlers[onChangeKey] = callAllEventHandlers(onChange, onInput, inputHandleChange), _eventHandlers.onKeyDown = callAllEventHandlers(onKeyDown, inputHandleKeyDown), _eventHandlers.onBlur = callAllEventHandlers(onBlur, inputHandleBlur), _eventHandlers.onFocus = callAllEventHandlers(onFocus, inputHandleFocus), _eventHandlers);
4622
4567
  }
4623
- return {
4624
- [refKey]: handleRefs(ref, inputNode => {
4625
- inputRef.current = inputNode;
4626
- }),
4627
- 'aria-activedescendant': latestState.isOpen && latestState.highlightedIndex > -1 ? elementIds.getItemId(latestState.highlightedIndex) : '',
4628
- 'aria-autocomplete': 'list',
4629
- 'aria-controls': elementIds.menuId,
4630
- 'aria-expanded': latestState.isOpen,
4631
- 'aria-labelledby': elementIds.labelId,
4632
- // https://developer.mozilla.org/en-US/docs/Web/Security/Securing_your_site/Turning_off_form_autocompletion
4633
- // revert back since autocomplete="nope" is ignored on latest Chrome and Opera
4634
- autoComplete: 'off',
4635
- id: elementIds.inputId,
4636
- role: 'combobox',
4637
- value: latestState.inputValue,
4638
- ...eventHandlers,
4639
- ...rest
4640
- };
4568
+ return _extends((_extends5 = {}, _extends5[refKey] = handleRefs(ref, function (inputNode) {
4569
+ inputRef.current = inputNode;
4570
+ }), _extends5['aria-activedescendant'] = latestState.isOpen && latestState.highlightedIndex > -1 ? elementIds.getItemId(latestState.highlightedIndex) : '', _extends5['aria-autocomplete'] = 'list', _extends5['aria-controls'] = elementIds.menuId, _extends5['aria-expanded'] = latestState.isOpen, _extends5['aria-labelledby'] = elementIds.labelId, _extends5.autoComplete = 'off', _extends5.id = elementIds.inputId, _extends5.role = 'combobox', _extends5.value = latestState.inputValue, _extends5), eventHandlers, rest);
4641
4571
  }, [dispatch, inputKeyDownHandlers, latest, mouseAndTouchTrackersRef, setGetterPropCallInfo, elementIds]);
4642
4572
 
4643
4573
  // returns
4644
- const toggleMenu = react.useCallback(() => {
4574
+ var toggleMenu = react.useCallback(function () {
4645
4575
  dispatch({
4646
4576
  type: FunctionToggleMenu
4647
4577
  });
4648
4578
  }, [dispatch]);
4649
- const closeMenu = react.useCallback(() => {
4579
+ var closeMenu = react.useCallback(function () {
4650
4580
  dispatch({
4651
4581
  type: FunctionCloseMenu
4652
4582
  });
4653
4583
  }, [dispatch]);
4654
- const openMenu = react.useCallback(() => {
4584
+ var openMenu = react.useCallback(function () {
4655
4585
  dispatch({
4656
4586
  type: FunctionOpenMenu
4657
4587
  });
4658
4588
  }, [dispatch]);
4659
- const setHighlightedIndex = react.useCallback(newHighlightedIndex => {
4589
+ var setHighlightedIndex = react.useCallback(function (newHighlightedIndex) {
4660
4590
  dispatch({
4661
4591
  type: FunctionSetHighlightedIndex,
4662
4592
  highlightedIndex: newHighlightedIndex
4663
4593
  });
4664
4594
  }, [dispatch]);
4665
- const selectItem = react.useCallback(newSelectedItem => {
4595
+ var selectItem = react.useCallback(function (newSelectedItem) {
4666
4596
  dispatch({
4667
4597
  type: FunctionSelectItem,
4668
4598
  selectedItem: newSelectedItem
4669
4599
  });
4670
4600
  }, [dispatch]);
4671
- const setInputValue = react.useCallback(newInputValue => {
4601
+ var setInputValue = react.useCallback(function (newInputValue) {
4672
4602
  dispatch({
4673
4603
  type: FunctionSetInputValue,
4674
4604
  inputValue: newInputValue
4675
4605
  });
4676
4606
  }, [dispatch]);
4677
- const reset = react.useCallback(() => {
4607
+ var reset = react.useCallback(function () {
4678
4608
  dispatch({
4679
4609
  type: FunctionReset$1
4680
4610
  });
4681
4611
  }, [dispatch]);
4682
4612
  return {
4683
4613
  // prop getters.
4684
- getItemProps,
4685
- getLabelProps,
4686
- getMenuProps,
4687
- getInputProps,
4688
- getToggleButtonProps,
4614
+ getItemProps: getItemProps,
4615
+ getLabelProps: getLabelProps,
4616
+ getMenuProps: getMenuProps,
4617
+ getInputProps: getInputProps,
4618
+ getToggleButtonProps: getToggleButtonProps,
4689
4619
  // actions.
4690
- toggleMenu,
4691
- openMenu,
4692
- closeMenu,
4693
- setHighlightedIndex,
4694
- setInputValue,
4695
- selectItem,
4696
- reset,
4620
+ toggleMenu: toggleMenu,
4621
+ openMenu: openMenu,
4622
+ closeMenu: closeMenu,
4623
+ setHighlightedIndex: setHighlightedIndex,
4624
+ setInputValue: setInputValue,
4625
+ selectItem: selectItem,
4626
+ reset: reset,
4697
4627
  // state.
4698
- highlightedIndex,
4699
- isOpen,
4700
- selectedItem,
4701
- inputValue
4628
+ highlightedIndex: highlightedIndex,
4629
+ isOpen: isOpen,
4630
+ selectedItem: selectedItem,
4631
+ inputValue: inputValue
4702
4632
  };
4703
4633
  }
4704
4634
 
4705
- const defaultStateValues = {
4635
+ var defaultStateValues = {
4706
4636
  activeIndex: -1,
4707
4637
  selectedItems: []
4708
4638
  };
@@ -4740,11 +4670,11 @@
4740
4670
  * @returns {Object} The initial state.
4741
4671
  */
4742
4672
  function getInitialState(props) {
4743
- const activeIndex = getInitialValue(props, 'activeIndex');
4744
- const selectedItems = getInitialValue(props, 'selectedItems');
4673
+ var activeIndex = getInitialValue(props, 'activeIndex');
4674
+ var selectedItems = getInitialValue(props, 'selectedItems');
4745
4675
  return {
4746
- activeIndex,
4747
- selectedItems
4676
+ activeIndex: activeIndex,
4677
+ selectedItems: selectedItems
4748
4678
  };
4749
4679
  }
4750
4680
 
@@ -4761,7 +4691,7 @@
4761
4691
  if (event.shiftKey || event.metaKey || event.ctrlKey || event.altKey) {
4762
4692
  return false;
4763
4693
  }
4764
- const element = event.target;
4694
+ var element = event.target;
4765
4695
  if (element instanceof HTMLInputElement &&
4766
4696
  // if element is a text input
4767
4697
  element.value !== '' && (
@@ -4780,13 +4710,11 @@
4780
4710
  * @returns {string} The a11y message.
4781
4711
  */
4782
4712
  function getA11yRemovalMessage(selectionParameters) {
4783
- const {
4784
- removedSelectedItem,
4785
- itemToString: itemToStringLocal
4786
- } = selectionParameters;
4787
- return `${itemToStringLocal(removedSelectedItem)} has been removed.`;
4713
+ var removedSelectedItem = selectionParameters.removedSelectedItem,
4714
+ itemToStringLocal = selectionParameters.itemToString;
4715
+ return itemToStringLocal(removedSelectedItem) + " has been removed.";
4788
4716
  }
4789
- const propTypes = {
4717
+ var propTypes = {
4790
4718
  selectedItems: PropTypes.array,
4791
4719
  initialSelectedItems: PropTypes.array,
4792
4720
  defaultSelectedItems: PropTypes.array,
@@ -4810,37 +4738,37 @@
4810
4738
  })
4811
4739
  })
4812
4740
  };
4813
- const defaultProps = {
4741
+ var defaultProps = {
4814
4742
  itemToString: defaultProps$3.itemToString,
4815
4743
  stateReducer: defaultProps$3.stateReducer,
4816
4744
  environment: defaultProps$3.environment,
4817
- getA11yRemovalMessage,
4745
+ getA11yRemovalMessage: getA11yRemovalMessage,
4818
4746
  keyNavigationNext: 'ArrowRight',
4819
4747
  keyNavigationPrevious: 'ArrowLeft'
4820
4748
  };
4821
4749
 
4822
4750
  // eslint-disable-next-line import/no-mutable-exports
4823
- let validatePropTypes = noop;
4751
+ var validatePropTypes = noop;
4824
4752
  /* istanbul ignore next */
4825
4753
  {
4826
- validatePropTypes = (options, caller) => {
4754
+ validatePropTypes = function validatePropTypes(options, caller) {
4827
4755
  PropTypes.checkPropTypes(propTypes, options, 'prop', caller.name);
4828
4756
  };
4829
4757
  }
4830
4758
 
4831
- const SelectedItemClick = '__selected_item_click__' ;
4832
- const SelectedItemKeyDownDelete = '__selected_item_keydown_delete__' ;
4833
- const SelectedItemKeyDownBackspace = '__selected_item_keydown_backspace__' ;
4834
- const SelectedItemKeyDownNavigationNext = '__selected_item_keydown_navigation_next__' ;
4835
- const SelectedItemKeyDownNavigationPrevious = '__selected_item_keydown_navigation_previous__' ;
4836
- const DropdownKeyDownNavigationPrevious = '__dropdown_keydown_navigation_previous__' ;
4837
- const DropdownKeyDownBackspace = '__dropdown_keydown_backspace__' ;
4838
- const DropdownClick = '__dropdown_click__' ;
4839
- const FunctionAddSelectedItem = '__function_add_selected_item__' ;
4840
- const FunctionRemoveSelectedItem = '__function_remove_selected_item__' ;
4841
- const FunctionSetSelectedItems = '__function_set_selected_items__' ;
4842
- const FunctionSetActiveIndex = '__function_set_active_index__' ;
4843
- const FunctionReset = '__function_reset__' ;
4759
+ var SelectedItemClick = '__selected_item_click__' ;
4760
+ var SelectedItemKeyDownDelete = '__selected_item_keydown_delete__' ;
4761
+ var SelectedItemKeyDownBackspace = '__selected_item_keydown_backspace__' ;
4762
+ var SelectedItemKeyDownNavigationNext = '__selected_item_keydown_navigation_next__' ;
4763
+ var SelectedItemKeyDownNavigationPrevious = '__selected_item_keydown_navigation_previous__' ;
4764
+ var DropdownKeyDownNavigationPrevious = '__dropdown_keydown_navigation_previous__' ;
4765
+ var DropdownKeyDownBackspace = '__dropdown_keydown_backspace__' ;
4766
+ var DropdownClick = '__dropdown_click__' ;
4767
+ var FunctionAddSelectedItem = '__function_add_selected_item__' ;
4768
+ var FunctionRemoveSelectedItem = '__function_remove_selected_item__' ;
4769
+ var FunctionSetSelectedItems = '__function_set_selected_items__' ;
4770
+ var FunctionSetActiveIndex = '__function_set_active_index__' ;
4771
+ var FunctionReset = '__function_reset__' ;
4844
4772
 
4845
4773
  var stateChangeTypes = /*#__PURE__*/Object.freeze({
4846
4774
  __proto__: null,
@@ -4861,17 +4789,13 @@
4861
4789
 
4862
4790
  /* eslint-disable complexity */
4863
4791
  function downshiftMultipleSelectionReducer(state, action) {
4864
- const {
4865
- type,
4866
- index,
4867
- props,
4868
- selectedItem
4869
- } = action;
4870
- const {
4871
- activeIndex,
4872
- selectedItems
4873
- } = state;
4874
- let changes;
4792
+ var type = action.type,
4793
+ index = action.index,
4794
+ props = action.props,
4795
+ selectedItem = action.selectedItem;
4796
+ var activeIndex = state.activeIndex,
4797
+ selectedItems = state.selectedItems;
4798
+ var changes;
4875
4799
  switch (type) {
4876
4800
  case SelectedItemClick:
4877
4801
  changes = {
@@ -4894,18 +4818,17 @@
4894
4818
  if (activeIndex < 0) {
4895
4819
  break;
4896
4820
  }
4897
- let newActiveIndex = activeIndex;
4821
+ var newActiveIndex = activeIndex;
4898
4822
  if (selectedItems.length === 1) {
4899
4823
  newActiveIndex = -1;
4900
4824
  } else if (activeIndex === selectedItems.length - 1) {
4901
4825
  newActiveIndex = selectedItems.length - 2;
4902
4826
  }
4903
- changes = {
4904
- selectedItems: [...selectedItems.slice(0, activeIndex), ...selectedItems.slice(activeIndex + 1)],
4905
- ...{
4906
- activeIndex: newActiveIndex
4907
- }
4908
- };
4827
+ changes = _extends({
4828
+ selectedItems: [].concat(selectedItems.slice(0, activeIndex), selectedItems.slice(activeIndex + 1))
4829
+ }, {
4830
+ activeIndex: newActiveIndex
4831
+ });
4909
4832
  break;
4910
4833
  }
4911
4834
  case DropdownKeyDownNavigationPrevious:
@@ -4920,7 +4843,7 @@
4920
4843
  break;
4921
4844
  case FunctionAddSelectedItem:
4922
4845
  changes = {
4923
- selectedItems: [...selectedItems, selectedItem]
4846
+ selectedItems: [].concat(selectedItems, [selectedItem])
4924
4847
  };
4925
4848
  break;
4926
4849
  case DropdownClick:
@@ -4930,27 +4853,25 @@
4930
4853
  break;
4931
4854
  case FunctionRemoveSelectedItem:
4932
4855
  {
4933
- let newActiveIndex = activeIndex;
4934
- const selectedItemIndex = selectedItems.indexOf(selectedItem);
4856
+ var _newActiveIndex = activeIndex;
4857
+ var selectedItemIndex = selectedItems.indexOf(selectedItem);
4935
4858
  if (selectedItemIndex < 0) {
4936
4859
  break;
4937
4860
  }
4938
4861
  if (selectedItems.length === 1) {
4939
- newActiveIndex = -1;
4862
+ _newActiveIndex = -1;
4940
4863
  } else if (selectedItemIndex === selectedItems.length - 1) {
4941
- newActiveIndex = selectedItems.length - 2;
4864
+ _newActiveIndex = selectedItems.length - 2;
4942
4865
  }
4943
4866
  changes = {
4944
- selectedItems: [...selectedItems.slice(0, selectedItemIndex), ...selectedItems.slice(selectedItemIndex + 1)],
4945
- activeIndex: newActiveIndex
4867
+ selectedItems: [].concat(selectedItems.slice(0, selectedItemIndex), selectedItems.slice(selectedItemIndex + 1)),
4868
+ activeIndex: _newActiveIndex
4946
4869
  };
4947
4870
  break;
4948
4871
  }
4949
4872
  case FunctionSetSelectedItems:
4950
4873
  {
4951
- const {
4952
- selectedItems: newSelectedItems
4953
- } = action;
4874
+ var newSelectedItems = action.selectedItems;
4954
4875
  changes = {
4955
4876
  selectedItems: newSelectedItems
4956
4877
  };
@@ -4958,11 +4879,9 @@
4958
4879
  }
4959
4880
  case FunctionSetActiveIndex:
4960
4881
  {
4961
- const {
4962
- activeIndex: newActiveIndex
4963
- } = action;
4882
+ var _newActiveIndex2 = action.activeIndex;
4964
4883
  changes = {
4965
- activeIndex: newActiveIndex
4884
+ activeIndex: _newActiveIndex2
4966
4885
  };
4967
4886
  break;
4968
4887
  }
@@ -4975,12 +4894,11 @@
4975
4894
  default:
4976
4895
  throw new Error('Reducer called without proper action type.');
4977
4896
  }
4978
- return {
4979
- ...state,
4980
- ...changes
4981
- };
4897
+ return _extends({}, state, changes);
4982
4898
  }
4983
4899
 
4900
+ var _excluded = ["refKey", "ref", "onClick", "onKeyDown", "selectedItem", "index"],
4901
+ _excluded2 = ["refKey", "ref", "onKeyDown", "onClick", "preventKeyAction"];
4984
4902
  useMultipleSelection.stateChangeTypes = stateChangeTypes;
4985
4903
  function useMultipleSelection(userProps) {
4986
4904
  if (userProps === void 0) {
@@ -4988,49 +4906,46 @@
4988
4906
  }
4989
4907
  validatePropTypes(userProps, useMultipleSelection);
4990
4908
  // Props defaults and destructuring.
4991
- const props = {
4992
- ...defaultProps,
4993
- ...userProps
4994
- };
4995
- const {
4996
- getA11yRemovalMessage,
4997
- itemToString,
4998
- environment,
4999
- keyNavigationNext,
5000
- keyNavigationPrevious
5001
- } = props;
4909
+ var props = _extends({}, defaultProps, userProps);
4910
+ var getA11yRemovalMessage = props.getA11yRemovalMessage,
4911
+ itemToString = props.itemToString,
4912
+ environment = props.environment,
4913
+ keyNavigationNext = props.keyNavigationNext,
4914
+ keyNavigationPrevious = props.keyNavigationPrevious;
5002
4915
 
5003
4916
  // Reducer init.
5004
- const [state, dispatch] = useControlledReducer$1(downshiftMultipleSelectionReducer, getInitialState(props), props);
5005
- const {
5006
- activeIndex,
5007
- selectedItems
5008
- } = state;
4917
+ var _useControlledReducer = useControlledReducer$1(downshiftMultipleSelectionReducer, getInitialState(props), props),
4918
+ state = _useControlledReducer[0],
4919
+ dispatch = _useControlledReducer[1];
4920
+ var activeIndex = state.activeIndex,
4921
+ selectedItems = state.selectedItems;
5009
4922
 
5010
4923
  // Refs.
5011
- const isInitialMountRef = react.useRef(true);
5012
- const dropdownRef = react.useRef(null);
5013
- const previousSelectedItemsRef = react.useRef(selectedItems);
5014
- const selectedItemRefs = react.useRef();
4924
+ var isInitialMountRef = react.useRef(true);
4925
+ var dropdownRef = react.useRef(null);
4926
+ var previousSelectedItemsRef = react.useRef(selectedItems);
4927
+ var selectedItemRefs = react.useRef();
5015
4928
  selectedItemRefs.current = [];
5016
- const latest = useLatestRef({
5017
- state,
5018
- props
4929
+ var latest = useLatestRef({
4930
+ state: state,
4931
+ props: props
5019
4932
  });
5020
4933
 
5021
4934
  // Effects.
5022
4935
  /* Sets a11y status message on changes in selectedItem. */
5023
- react.useEffect(() => {
4936
+ react.useEffect(function () {
5024
4937
  if (isInitialMountRef.current) {
5025
4938
  return;
5026
4939
  }
5027
4940
  if (selectedItems.length < previousSelectedItemsRef.current.length) {
5028
- const removedSelectedItem = previousSelectedItemsRef.current.find(item => selectedItems.indexOf(item) < 0);
4941
+ var removedSelectedItem = previousSelectedItemsRef.current.find(function (item) {
4942
+ return selectedItems.indexOf(item) < 0;
4943
+ });
5029
4944
  setStatus(getA11yRemovalMessage({
5030
- itemToString,
4945
+ itemToString: itemToString,
5031
4946
  resultCount: selectedItems.length,
5032
- removedSelectedItem,
5033
- activeIndex,
4947
+ removedSelectedItem: removedSelectedItem,
4948
+ activeIndex: activeIndex,
5034
4949
  activeSelectedItem: selectedItems[activeIndex]
5035
4950
  }), environment.document);
5036
4951
  }
@@ -5039,7 +4954,7 @@
5039
4954
  // eslint-disable-next-line react-hooks/exhaustive-deps
5040
4955
  }, [selectedItems.length]);
5041
4956
  // Sets focus on active item.
5042
- react.useEffect(() => {
4957
+ react.useEffect(function () {
5043
4958
  if (isInitialMountRef.current) {
5044
4959
  return;
5045
4960
  }
@@ -5051,178 +4966,167 @@
5051
4966
  }, [activeIndex]);
5052
4967
  useControlPropsValidator({
5053
4968
  isInitialMount: isInitialMountRef.current,
5054
- props,
5055
- state
4969
+ props: props,
4970
+ state: state
5056
4971
  });
5057
- const setGetterPropCallInfo = useGetterPropsCalledChecker('getDropdownProps');
4972
+ var setGetterPropCallInfo = useGetterPropsCalledChecker('getDropdownProps');
5058
4973
  // Make initial ref false.
5059
- react.useEffect(() => {
4974
+ react.useEffect(function () {
5060
4975
  isInitialMountRef.current = false;
5061
- return () => {
4976
+ return function () {
5062
4977
  isInitialMountRef.current = true;
5063
4978
  };
5064
4979
  }, []);
5065
4980
 
5066
4981
  // Event handler functions.
5067
- const selectedItemKeyDownHandlers = react.useMemo(() => ({
5068
- [keyNavigationPrevious]() {
4982
+ var selectedItemKeyDownHandlers = react.useMemo(function () {
4983
+ var _ref;
4984
+ return _ref = {}, _ref[keyNavigationPrevious] = function () {
5069
4985
  dispatch({
5070
4986
  type: SelectedItemKeyDownNavigationPrevious
5071
4987
  });
5072
- },
5073
- [keyNavigationNext]() {
4988
+ }, _ref[keyNavigationNext] = function () {
5074
4989
  dispatch({
5075
4990
  type: SelectedItemKeyDownNavigationNext
5076
4991
  });
5077
- },
5078
- Delete() {
4992
+ }, _ref.Delete = function Delete() {
5079
4993
  dispatch({
5080
4994
  type: SelectedItemKeyDownDelete
5081
4995
  });
5082
- },
5083
- Backspace() {
4996
+ }, _ref.Backspace = function Backspace() {
5084
4997
  dispatch({
5085
4998
  type: SelectedItemKeyDownBackspace
5086
4999
  });
5087
- }
5088
- }), [dispatch, keyNavigationNext, keyNavigationPrevious]);
5089
- const dropdownKeyDownHandlers = react.useMemo(() => ({
5090
- [keyNavigationPrevious](event) {
5000
+ }, _ref;
5001
+ }, [dispatch, keyNavigationNext, keyNavigationPrevious]);
5002
+ var dropdownKeyDownHandlers = react.useMemo(function () {
5003
+ var _ref2;
5004
+ return _ref2 = {}, _ref2[keyNavigationPrevious] = function (event) {
5091
5005
  if (isKeyDownOperationPermitted(event)) {
5092
5006
  dispatch({
5093
5007
  type: DropdownKeyDownNavigationPrevious
5094
5008
  });
5095
5009
  }
5096
- },
5097
- Backspace(event) {
5010
+ }, _ref2.Backspace = function Backspace(event) {
5098
5011
  if (isKeyDownOperationPermitted(event)) {
5099
5012
  dispatch({
5100
5013
  type: DropdownKeyDownBackspace
5101
5014
  });
5102
5015
  }
5103
- }
5104
- }), [dispatch, keyNavigationPrevious]);
5016
+ }, _ref2;
5017
+ }, [dispatch, keyNavigationPrevious]);
5105
5018
 
5106
5019
  // Getter props.
5107
- const getSelectedItemProps = react.useCallback(function (_temp) {
5108
- let {
5109
- refKey = 'ref',
5110
- ref,
5111
- onClick,
5112
- onKeyDown,
5113
- selectedItem,
5114
- index,
5115
- ...rest
5116
- } = _temp === void 0 ? {} : _temp;
5117
- const {
5118
- state: latestState
5119
- } = latest.current;
5120
- const itemIndex = getItemIndex(index, selectedItem, latestState.selectedItems);
5020
+ var getSelectedItemProps = react.useCallback(function (_temp) {
5021
+ var _extends2;
5022
+ var _ref3 = _temp === void 0 ? {} : _temp,
5023
+ _ref3$refKey = _ref3.refKey,
5024
+ refKey = _ref3$refKey === void 0 ? 'ref' : _ref3$refKey,
5025
+ ref = _ref3.ref,
5026
+ onClick = _ref3.onClick,
5027
+ onKeyDown = _ref3.onKeyDown,
5028
+ selectedItem = _ref3.selectedItem,
5029
+ index = _ref3.index,
5030
+ rest = _objectWithoutPropertiesLoose(_ref3, _excluded);
5031
+ var latestState = latest.current.state;
5032
+ var itemIndex = getItemIndex(index, selectedItem, latestState.selectedItems);
5121
5033
  if (itemIndex < 0) {
5122
5034
  throw new Error('Pass either selectedItem or index in getSelectedItemProps!');
5123
5035
  }
5124
- const selectedItemHandleClick = () => {
5036
+ var selectedItemHandleClick = function selectedItemHandleClick() {
5125
5037
  dispatch({
5126
5038
  type: SelectedItemClick,
5127
- index
5039
+ index: index
5128
5040
  });
5129
5041
  };
5130
- const selectedItemHandleKeyDown = event => {
5131
- const key = normalizeArrowKey(event);
5042
+ var selectedItemHandleKeyDown = function selectedItemHandleKeyDown(event) {
5043
+ var key = normalizeArrowKey(event);
5132
5044
  if (key && selectedItemKeyDownHandlers[key]) {
5133
5045
  selectedItemKeyDownHandlers[key](event);
5134
5046
  }
5135
5047
  };
5136
- return {
5137
- [refKey]: handleRefs(ref, selectedItemNode => {
5138
- if (selectedItemNode) {
5139
- selectedItemRefs.current.push(selectedItemNode);
5140
- }
5141
- }),
5142
- tabIndex: index === latestState.activeIndex ? 0 : -1,
5143
- onClick: callAllEventHandlers(onClick, selectedItemHandleClick),
5144
- onKeyDown: callAllEventHandlers(onKeyDown, selectedItemHandleKeyDown),
5145
- ...rest
5146
- };
5048
+ return _extends((_extends2 = {}, _extends2[refKey] = handleRefs(ref, function (selectedItemNode) {
5049
+ if (selectedItemNode) {
5050
+ selectedItemRefs.current.push(selectedItemNode);
5051
+ }
5052
+ }), _extends2.tabIndex = index === latestState.activeIndex ? 0 : -1, _extends2.onClick = callAllEventHandlers(onClick, selectedItemHandleClick), _extends2.onKeyDown = callAllEventHandlers(onKeyDown, selectedItemHandleKeyDown), _extends2), rest);
5147
5053
  }, [dispatch, latest, selectedItemKeyDownHandlers]);
5148
- const getDropdownProps = react.useCallback(function (_temp2, _temp3) {
5149
- let {
5150
- refKey = 'ref',
5151
- ref,
5152
- onKeyDown,
5153
- onClick,
5154
- preventKeyAction = false,
5155
- ...rest
5156
- } = _temp2 === void 0 ? {} : _temp2;
5157
- let {
5158
- suppressRefError = false
5159
- } = _temp3 === void 0 ? {} : _temp3;
5054
+ var getDropdownProps = react.useCallback(function (_temp2, _temp3) {
5055
+ var _extends3;
5056
+ var _ref4 = _temp2 === void 0 ? {} : _temp2,
5057
+ _ref4$refKey = _ref4.refKey,
5058
+ refKey = _ref4$refKey === void 0 ? 'ref' : _ref4$refKey,
5059
+ ref = _ref4.ref,
5060
+ onKeyDown = _ref4.onKeyDown,
5061
+ onClick = _ref4.onClick,
5062
+ _ref4$preventKeyActio = _ref4.preventKeyAction,
5063
+ preventKeyAction = _ref4$preventKeyActio === void 0 ? false : _ref4$preventKeyActio,
5064
+ rest = _objectWithoutPropertiesLoose(_ref4, _excluded2);
5065
+ var _ref5 = _temp3 === void 0 ? {} : _temp3,
5066
+ _ref5$suppressRefErro = _ref5.suppressRefError,
5067
+ suppressRefError = _ref5$suppressRefErro === void 0 ? false : _ref5$suppressRefErro;
5160
5068
  setGetterPropCallInfo('getDropdownProps', suppressRefError, refKey, dropdownRef);
5161
- const dropdownHandleKeyDown = event => {
5162
- const key = normalizeArrowKey(event);
5069
+ var dropdownHandleKeyDown = function dropdownHandleKeyDown(event) {
5070
+ var key = normalizeArrowKey(event);
5163
5071
  if (key && dropdownKeyDownHandlers[key]) {
5164
5072
  dropdownKeyDownHandlers[key](event);
5165
5073
  }
5166
5074
  };
5167
- const dropdownHandleClick = () => {
5075
+ var dropdownHandleClick = function dropdownHandleClick() {
5168
5076
  dispatch({
5169
5077
  type: DropdownClick
5170
5078
  });
5171
5079
  };
5172
- return {
5173
- [refKey]: handleRefs(ref, dropdownNode => {
5174
- if (dropdownNode) {
5175
- dropdownRef.current = dropdownNode;
5176
- }
5177
- }),
5178
- ...(!preventKeyAction && {
5179
- onKeyDown: callAllEventHandlers(onKeyDown, dropdownHandleKeyDown),
5180
- onClick: callAllEventHandlers(onClick, dropdownHandleClick)
5181
- }),
5182
- ...rest
5183
- };
5080
+ return _extends((_extends3 = {}, _extends3[refKey] = handleRefs(ref, function (dropdownNode) {
5081
+ if (dropdownNode) {
5082
+ dropdownRef.current = dropdownNode;
5083
+ }
5084
+ }), _extends3), !preventKeyAction && {
5085
+ onKeyDown: callAllEventHandlers(onKeyDown, dropdownHandleKeyDown),
5086
+ onClick: callAllEventHandlers(onClick, dropdownHandleClick)
5087
+ }, rest);
5184
5088
  }, [dispatch, dropdownKeyDownHandlers, setGetterPropCallInfo]);
5185
5089
 
5186
5090
  // returns
5187
- const addSelectedItem = react.useCallback(selectedItem => {
5091
+ var addSelectedItem = react.useCallback(function (selectedItem) {
5188
5092
  dispatch({
5189
5093
  type: FunctionAddSelectedItem,
5190
- selectedItem
5094
+ selectedItem: selectedItem
5191
5095
  });
5192
5096
  }, [dispatch]);
5193
- const removeSelectedItem = react.useCallback(selectedItem => {
5097
+ var removeSelectedItem = react.useCallback(function (selectedItem) {
5194
5098
  dispatch({
5195
5099
  type: FunctionRemoveSelectedItem,
5196
- selectedItem
5100
+ selectedItem: selectedItem
5197
5101
  });
5198
5102
  }, [dispatch]);
5199
- const setSelectedItems = react.useCallback(newSelectedItems => {
5103
+ var setSelectedItems = react.useCallback(function (newSelectedItems) {
5200
5104
  dispatch({
5201
5105
  type: FunctionSetSelectedItems,
5202
5106
  selectedItems: newSelectedItems
5203
5107
  });
5204
5108
  }, [dispatch]);
5205
- const setActiveIndex = react.useCallback(newActiveIndex => {
5109
+ var setActiveIndex = react.useCallback(function (newActiveIndex) {
5206
5110
  dispatch({
5207
5111
  type: FunctionSetActiveIndex,
5208
5112
  activeIndex: newActiveIndex
5209
5113
  });
5210
5114
  }, [dispatch]);
5211
- const reset = react.useCallback(() => {
5115
+ var reset = react.useCallback(function () {
5212
5116
  dispatch({
5213
5117
  type: FunctionReset
5214
5118
  });
5215
5119
  }, [dispatch]);
5216
5120
  return {
5217
- getSelectedItemProps,
5218
- getDropdownProps,
5219
- addSelectedItem,
5220
- removeSelectedItem,
5221
- setSelectedItems,
5222
- setActiveIndex,
5223
- reset,
5224
- selectedItems,
5225
- activeIndex
5121
+ getSelectedItemProps: getSelectedItemProps,
5122
+ getDropdownProps: getDropdownProps,
5123
+ addSelectedItem: addSelectedItem,
5124
+ removeSelectedItem: removeSelectedItem,
5125
+ setSelectedItems: setSelectedItems,
5126
+ setActiveIndex: setActiveIndex,
5127
+ reset: reset,
5128
+ selectedItems: selectedItems,
5129
+ activeIndex: activeIndex
5226
5130
  };
5227
5131
  }
5228
5132