downshift 7.1.2 → 7.1.3-alpha.1

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