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.
@@ -8,55 +8,6 @@
8
8
 
9
9
  var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
10
10
 
11
- function _objectWithoutPropertiesLoose(source, excluded) {
12
- if (source == null) return {};
13
- var target = {};
14
- var sourceKeys = Object.keys(source);
15
- var key, i;
16
- for (i = 0; i < sourceKeys.length; i++) {
17
- key = sourceKeys[i];
18
- if (excluded.indexOf(key) >= 0) continue;
19
- target[key] = source[key];
20
- }
21
- return target;
22
- }
23
-
24
- function _extends() {
25
- _extends = Object.assign ? Object.assign.bind() : function (target) {
26
- for (var i = 1; i < arguments.length; i++) {
27
- var source = arguments[i];
28
- for (var key in source) {
29
- if (Object.prototype.hasOwnProperty.call(source, key)) {
30
- target[key] = source[key];
31
- }
32
- }
33
- }
34
- return target;
35
- };
36
- return _extends.apply(this, arguments);
37
- }
38
-
39
- function _assertThisInitialized(self) {
40
- if (self === void 0) {
41
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
42
- }
43
- return self;
44
- }
45
-
46
- function _setPrototypeOf(o, p) {
47
- _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
48
- o.__proto__ = p;
49
- return o;
50
- };
51
- return _setPrototypeOf(o, p);
52
- }
53
-
54
- function _inheritsLoose(subClass, superClass) {
55
- subClass.prototype = Object.create(superClass.prototype);
56
- subClass.prototype.constructor = subClass;
57
- _setPrototypeOf(subClass, superClass);
58
- }
59
-
60
11
  var reactIs = {exports: {}};
61
12
 
62
13
  /** @license React v17.0.2
@@ -296,9 +247,9 @@
296
247
  reactIs.exports = reactIs_development;
297
248
  }
298
249
 
299
- 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};
250
+ 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};
300
251
 
301
- var idCounter = 0;
252
+ let idCounter = 0;
302
253
 
303
254
  /**
304
255
  * Accepts a parameter and returns it if it's a function
@@ -322,15 +273,17 @@
322
273
  if (!node) {
323
274
  return;
324
275
  }
325
- var actions = i(node, {
276
+ const actions = o(node, {
326
277
  boundary: menuNode,
327
278
  block: 'nearest',
328
279
  scrollMode: 'if-needed'
329
280
  });
330
- actions.forEach(function (_ref) {
331
- var el = _ref.el,
332
- top = _ref.top,
333
- left = _ref.left;
281
+ actions.forEach(_ref => {
282
+ let {
283
+ el,
284
+ top,
285
+ left
286
+ } = _ref;
334
287
  el.scrollTop = top;
335
288
  el.scrollLeft = left;
336
289
  });
@@ -343,7 +296,7 @@
343
296
  * @return {Boolean} whether the parent is the child or the child is in the parent
344
297
  */
345
298
  function isOrContainsNode(parent, child, environment) {
346
- var result = parent === child || child instanceof environment.Node && parent.contains && parent.contains(child);
299
+ const result = parent === child || child instanceof environment.Node && parent.contains && parent.contains(child);
347
300
  return result;
348
301
  }
349
302
 
@@ -356,7 +309,7 @@
356
309
  * @return {Function} the debounced function
357
310
  */
358
311
  function debounce(fn, time) {
359
- var timeoutId;
312
+ let timeoutId;
360
313
  function cancel() {
361
314
  if (timeoutId) {
362
315
  clearTimeout(timeoutId);
@@ -367,9 +320,9 @@
367
320
  args[_key] = arguments[_key];
368
321
  }
369
322
  cancel();
370
- timeoutId = setTimeout(function () {
323
+ timeoutId = setTimeout(() => {
371
324
  timeoutId = null;
372
- fn.apply(void 0, args);
325
+ fn(...args);
373
326
  }, time);
374
327
  }
375
328
  wrapper.cancel = cancel;
@@ -391,9 +344,9 @@
391
344
  for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
392
345
  args[_key3 - 1] = arguments[_key3];
393
346
  }
394
- return fns.some(function (fn) {
347
+ return fns.some(fn => {
395
348
  if (fn) {
396
- fn.apply(void 0, [event].concat(args));
349
+ fn(event, ...args);
397
350
  }
398
351
  return event.preventDownshiftDefault || event.hasOwnProperty('nativeEvent') && event.nativeEvent.preventDownshiftDefault;
399
352
  });
@@ -403,8 +356,8 @@
403
356
  for (var _len4 = arguments.length, refs = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
404
357
  refs[_key4] = arguments[_key4];
405
358
  }
406
- return function (node) {
407
- refs.forEach(function (ref) {
359
+ return node => {
360
+ refs.forEach(ref => {
408
361
  if (typeof ref === 'function') {
409
362
  ref(node);
410
363
  } else if (ref) {
@@ -438,9 +391,11 @@
438
391
  * @return {String} the a11y status message
439
392
  */
440
393
  function getA11yStatusMessage$1(_ref2) {
441
- var isOpen = _ref2.isOpen,
442
- resultCount = _ref2.resultCount,
443
- previousResultCount = _ref2.previousResultCount;
394
+ let {
395
+ isOpen,
396
+ resultCount,
397
+ previousResultCount
398
+ } = _ref2;
444
399
  if (!isOpen) {
445
400
  return '';
446
401
  }
@@ -448,7 +403,7 @@
448
403
  return 'No results are available.';
449
404
  }
450
405
  if (resultCount !== previousResultCount) {
451
- return resultCount + " result" + (resultCount === 1 ? ' is' : 's are') + " available, use up and down arrow keys to navigate. Press Enter key to select.";
406
+ return `${resultCount} result${resultCount === 1 ? ' is' : 's are'} available, use up and down arrow keys to navigate. Press Enter key to select.`;
452
407
  }
453
408
  return '';
454
409
  }
@@ -502,9 +457,9 @@
502
457
  */
503
458
  function requiredProp(fnName, propName) {
504
459
  // eslint-disable-next-line no-console
505
- console.error("The property \"" + propName + "\" is required in \"" + fnName + "\"");
460
+ console.error(`The property "${propName}" is required in "${fnName}"`);
506
461
  }
507
- var stateKeys = ['highlightedIndex', 'inputValue', 'isOpen', 'selectedItem', 'type'];
462
+ const stateKeys = ['highlightedIndex', 'inputValue', 'isOpen', 'selectedItem', 'type'];
508
463
  /**
509
464
  * @param {Object} state the state object
510
465
  * @return {Object} state that is relevant to downshift
@@ -513,8 +468,8 @@
513
468
  if (state === void 0) {
514
469
  state = {};
515
470
  }
516
- var result = {};
517
- stateKeys.forEach(function (k) {
471
+ const result = {};
472
+ stateKeys.forEach(k => {
518
473
  if (state.hasOwnProperty(k)) {
519
474
  result[k] = state[k];
520
475
  }
@@ -534,7 +489,7 @@
534
489
  * @returns {Object} The merged controlled state.
535
490
  */
536
491
  function getState(state, props) {
537
- return Object.keys(state).reduce(function (prevState, key) {
492
+ return Object.keys(state).reduce((prevState, key) => {
538
493
  prevState[key] = isControlledProp(props, key) ? props[key] : state[key];
539
494
  return prevState;
540
495
  }, {});
@@ -559,11 +514,13 @@
559
514
  * @return {String} keyboard key
560
515
  */
561
516
  function normalizeArrowKey(event) {
562
- var key = event.key,
563
- keyCode = event.keyCode;
517
+ const {
518
+ key,
519
+ keyCode
520
+ } = event;
564
521
  /* istanbul ignore next (ie) */
565
522
  if (keyCode >= 37 && keyCode <= 40 && key.indexOf('Arrow') !== 0) {
566
- return "Arrow" + key;
523
+ return `Arrow${key}`;
567
524
  }
568
525
  return key;
569
526
  }
@@ -595,17 +552,17 @@
595
552
  if (itemCount === 0) {
596
553
  return -1;
597
554
  }
598
- var itemsLastIndex = itemCount - 1;
555
+ const itemsLastIndex = itemCount - 1;
599
556
  if (typeof baseIndex !== 'number' || baseIndex < 0 || baseIndex >= itemCount) {
600
557
  baseIndex = moveAmount > 0 ? -1 : itemsLastIndex + 1;
601
558
  }
602
- var newIndex = baseIndex + moveAmount;
559
+ let newIndex = baseIndex + moveAmount;
603
560
  if (newIndex < 0) {
604
561
  newIndex = circular ? itemsLastIndex : 0;
605
562
  } else if (newIndex > itemsLastIndex) {
606
563
  newIndex = circular ? 0 : itemsLastIndex;
607
564
  }
608
- var nonDisabledNewIndex = getNextNonDisabledIndex(moveAmount, newIndex, itemCount, getItemNodeFromIndex, circular);
565
+ const nonDisabledNewIndex = getNextNonDisabledIndex(moveAmount, newIndex, itemCount, getItemNodeFromIndex, circular);
609
566
  if (nonDisabledNewIndex === -1) {
610
567
  return baseIndex >= itemCount ? -1 : baseIndex;
611
568
  }
@@ -623,20 +580,20 @@
623
580
  * @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.
624
581
  */
625
582
  function getNextNonDisabledIndex(moveAmount, baseIndex, itemCount, getItemNodeFromIndex, circular) {
626
- var currentElementNode = getItemNodeFromIndex(baseIndex);
583
+ const currentElementNode = getItemNodeFromIndex(baseIndex);
627
584
  if (!currentElementNode || !currentElementNode.hasAttribute('disabled')) {
628
585
  return baseIndex;
629
586
  }
630
587
  if (moveAmount > 0) {
631
- for (var index = baseIndex + 1; index < itemCount; index++) {
588
+ for (let index = baseIndex + 1; index < itemCount; index++) {
632
589
  if (!getItemNodeFromIndex(index).hasAttribute('disabled')) {
633
590
  return index;
634
591
  }
635
592
  }
636
593
  } else {
637
- for (var _index = baseIndex - 1; _index >= 0; _index--) {
638
- if (!getItemNodeFromIndex(_index).hasAttribute('disabled')) {
639
- return _index;
594
+ for (let index = baseIndex - 1; index >= 0; index--) {
595
+ if (!getItemNodeFromIndex(index).hasAttribute('disabled')) {
596
+ return index;
640
597
  }
641
598
  }
642
599
  }
@@ -660,30 +617,28 @@
660
617
  if (checkActiveElement === void 0) {
661
618
  checkActiveElement = true;
662
619
  }
663
- return downshiftElements.some(function (contextNode) {
664
- return contextNode && (isOrContainsNode(contextNode, target, environment) || checkActiveElement && isOrContainsNode(contextNode, environment.document.activeElement, environment));
665
- });
620
+ return downshiftElements.some(contextNode => contextNode && (isOrContainsNode(contextNode, target, environment) || checkActiveElement && isOrContainsNode(contextNode, environment.document.activeElement, environment)));
666
621
  }
667
622
 
668
623
  // eslint-disable-next-line import/no-mutable-exports
669
- var validateControlledUnchanged = noop;
624
+ let validateControlledUnchanged = noop;
670
625
  /* istanbul ignore next */
671
626
  {
672
- validateControlledUnchanged = function validateControlledUnchanged(state, prevProps, nextProps) {
673
- 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";
674
- Object.keys(state).forEach(function (propKey) {
627
+ validateControlledUnchanged = (state, prevProps, nextProps) => {
628
+ 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`;
629
+ Object.keys(state).forEach(propKey => {
675
630
  if (prevProps[propKey] !== undefined && nextProps[propKey] === undefined) {
676
631
  // eslint-disable-next-line no-console
677
- console.error("downshift: A component has changed the controlled prop \"" + propKey + "\" to be uncontrolled. " + warningDescription);
632
+ console.error(`downshift: A component has changed the controlled prop "${propKey}" to be uncontrolled. ${warningDescription}`);
678
633
  } else if (prevProps[propKey] === undefined && nextProps[propKey] !== undefined) {
679
634
  // eslint-disable-next-line no-console
680
- console.error("downshift: A component has changed the uncontrolled prop \"" + propKey + "\" to be controlled. " + warningDescription);
635
+ console.error(`downshift: A component has changed the uncontrolled prop "${propKey}" to be controlled. ${warningDescription}`);
681
636
  }
682
637
  });
683
638
  };
684
639
  }
685
640
 
686
- var cleanupStatus = debounce(function (documentProp) {
641
+ const cleanupStatus = debounce(documentProp => {
687
642
  getStatusDiv(documentProp).textContent = '';
688
643
  }, 500);
689
644
 
@@ -692,7 +647,7 @@
692
647
  * @param {Object} documentProp document passed by the user.
693
648
  */
694
649
  function setStatus(status, documentProp) {
695
- var div = getStatusDiv(documentProp);
650
+ const div = getStatusDiv(documentProp);
696
651
  if (!status) {
697
652
  return;
698
653
  }
@@ -709,7 +664,7 @@
709
664
  if (documentProp === void 0) {
710
665
  documentProp = document;
711
666
  }
712
- var statusDiv = documentProp.getElementById('a11y-status-message');
667
+ let statusDiv = documentProp.getElementById('a11y-status-message');
713
668
  if (statusDiv) {
714
669
  return statusDiv;
715
670
  }
@@ -732,23 +687,23 @@
732
687
  return statusDiv;
733
688
  }
734
689
 
735
- var unknown = '__autocomplete_unknown__' ;
736
- var mouseUp = '__autocomplete_mouseup__' ;
737
- var itemMouseEnter = '__autocomplete_item_mouseenter__' ;
738
- var keyDownArrowUp = '__autocomplete_keydown_arrow_up__' ;
739
- var keyDownArrowDown = '__autocomplete_keydown_arrow_down__' ;
740
- var keyDownEscape = '__autocomplete_keydown_escape__' ;
741
- var keyDownEnter = '__autocomplete_keydown_enter__' ;
742
- var keyDownHome = '__autocomplete_keydown_home__' ;
743
- var keyDownEnd = '__autocomplete_keydown_end__' ;
744
- var clickItem = '__autocomplete_click_item__' ;
745
- var blurInput = '__autocomplete_blur_input__' ;
746
- var changeInput = '__autocomplete_change_input__' ;
747
- var keyDownSpaceButton = '__autocomplete_keydown_space_button__' ;
748
- var clickButton = '__autocomplete_click_button__' ;
749
- var blurButton = '__autocomplete_blur_button__' ;
750
- var controlledPropUpdatedSelectedItem = '__autocomplete_controlled_prop_updated_selected_item__' ;
751
- var touchEnd = '__autocomplete_touchend__' ;
690
+ const unknown = '__autocomplete_unknown__' ;
691
+ const mouseUp = '__autocomplete_mouseup__' ;
692
+ const itemMouseEnter = '__autocomplete_item_mouseenter__' ;
693
+ const keyDownArrowUp = '__autocomplete_keydown_arrow_up__' ;
694
+ const keyDownArrowDown = '__autocomplete_keydown_arrow_down__' ;
695
+ const keyDownEscape = '__autocomplete_keydown_escape__' ;
696
+ const keyDownEnter = '__autocomplete_keydown_enter__' ;
697
+ const keyDownHome = '__autocomplete_keydown_home__' ;
698
+ const keyDownEnd = '__autocomplete_keydown_end__' ;
699
+ const clickItem = '__autocomplete_click_item__' ;
700
+ const blurInput = '__autocomplete_blur_input__' ;
701
+ const changeInput = '__autocomplete_change_input__' ;
702
+ const keyDownSpaceButton = '__autocomplete_keydown_space_button__' ;
703
+ const clickButton = '__autocomplete_click_button__' ;
704
+ const blurButton = '__autocomplete_blur_button__' ;
705
+ const controlledPropUpdatedSelectedItem = '__autocomplete_controlled_prop_updated_selected_item__' ;
706
+ const touchEnd = '__autocomplete_touchend__' ;
752
707
 
753
708
  var stateChangeTypes$3 = /*#__PURE__*/Object.freeze({
754
709
  __proto__: null,
@@ -771,48 +726,37 @@
771
726
  touchEnd: touchEnd
772
727
  });
773
728
 
774
- var _excluded$4 = ["refKey", "ref"],
775
- _excluded2$3 = ["onClick", "onPress", "onKeyDown", "onKeyUp", "onBlur"],
776
- _excluded3$2 = ["onKeyDown", "onBlur", "onChange", "onInput", "onChangeText"],
777
- _excluded4$1 = ["refKey", "ref"],
778
- _excluded5 = ["onMouseMove", "onMouseDown", "onClick", "onPress", "index", "item"];
779
- var Downshift = /*#__PURE__*/function () {
780
- var Downshift = /*#__PURE__*/function (_Component) {
781
- _inheritsLoose(Downshift, _Component);
782
- function Downshift(_props) {
729
+ /* eslint camelcase:0 */
730
+ const Downshift = /*#__PURE__*/(() => {
731
+ class Downshift extends preact.Component {
732
+ constructor(_props) {
783
733
  var _this;
784
- _this = _Component.call(this, _props) || this;
785
- // fancy destructuring + defaults + aliases
786
- // this basically says each value of state should either be set to
787
- // the initial value or the default value if the initial value is not provided
788
- _this.id = _this.props.id || "downshift-" + generateId();
789
- _this.menuId = _this.props.menuId || _this.id + "-menu";
790
- _this.labelId = _this.props.labelId || _this.id + "-label";
791
- _this.inputId = _this.props.inputId || _this.id + "-input";
792
- _this.getItemId = _this.props.getItemId || function (index) {
793
- return _this.id + "-item-" + index;
794
- };
795
- _this.input = null;
796
- _this.items = [];
797
- _this.itemCount = null;
798
- _this.previousResultCount = 0;
799
- _this.timeoutIds = [];
800
- _this.internalSetTimeout = function (fn, time) {
801
- var id = setTimeout(function () {
802
- _this.timeoutIds = _this.timeoutIds.filter(function (i) {
803
- return i !== id;
804
- });
734
+ super(_props);
735
+ _this = this;
736
+ this.id = this.props.id || `downshift-${generateId()}`;
737
+ this.menuId = this.props.menuId || `${this.id}-menu`;
738
+ this.labelId = this.props.labelId || `${this.id}-label`;
739
+ this.inputId = this.props.inputId || `${this.id}-input`;
740
+ this.getItemId = this.props.getItemId || (index => `${this.id}-item-${index}`);
741
+ this.input = null;
742
+ this.items = [];
743
+ this.itemCount = null;
744
+ this.previousResultCount = 0;
745
+ this.timeoutIds = [];
746
+ this.internalSetTimeout = (fn, time) => {
747
+ const id = setTimeout(() => {
748
+ this.timeoutIds = this.timeoutIds.filter(i => i !== id);
805
749
  fn();
806
750
  }, time);
807
- _this.timeoutIds.push(id);
751
+ this.timeoutIds.push(id);
808
752
  };
809
- _this.setItemCount = function (count) {
810
- _this.itemCount = count;
753
+ this.setItemCount = count => {
754
+ this.itemCount = count;
811
755
  };
812
- _this.unsetItemCount = function () {
813
- _this.itemCount = null;
756
+ this.unsetItemCount = () => {
757
+ this.itemCount = null;
814
758
  };
815
- _this.setHighlightedIndex = function (highlightedIndex, otherStateToSet) {
759
+ this.setHighlightedIndex = function (highlightedIndex, otherStateToSet) {
816
760
  if (highlightedIndex === void 0) {
817
761
  highlightedIndex = _this.props.defaultHighlightedIndex;
818
762
  }
@@ -820,41 +764,43 @@
820
764
  otherStateToSet = {};
821
765
  }
822
766
  otherStateToSet = pickState(otherStateToSet);
823
- _this.internalSetState(_extends({
824
- highlightedIndex: highlightedIndex
825
- }, otherStateToSet));
826
- };
827
- _this.clearSelection = function (cb) {
828
767
  _this.internalSetState({
768
+ highlightedIndex,
769
+ ...otherStateToSet
770
+ });
771
+ };
772
+ this.clearSelection = cb => {
773
+ this.internalSetState({
829
774
  selectedItem: null,
830
775
  inputValue: '',
831
- highlightedIndex: _this.props.defaultHighlightedIndex,
832
- isOpen: _this.props.defaultIsOpen
776
+ highlightedIndex: this.props.defaultHighlightedIndex,
777
+ isOpen: this.props.defaultIsOpen
833
778
  }, cb);
834
779
  };
835
- _this.selectItem = function (item, otherStateToSet, cb) {
780
+ this.selectItem = (item, otherStateToSet, cb) => {
836
781
  otherStateToSet = pickState(otherStateToSet);
837
- _this.internalSetState(_extends({
838
- isOpen: _this.props.defaultIsOpen,
839
- highlightedIndex: _this.props.defaultHighlightedIndex,
782
+ this.internalSetState({
783
+ isOpen: this.props.defaultIsOpen,
784
+ highlightedIndex: this.props.defaultHighlightedIndex,
840
785
  selectedItem: item,
841
- inputValue: _this.props.itemToString(item)
842
- }, otherStateToSet), cb);
786
+ inputValue: this.props.itemToString(item),
787
+ ...otherStateToSet
788
+ }, cb);
843
789
  };
844
- _this.selectItemAtIndex = function (itemIndex, otherStateToSet, cb) {
845
- var item = _this.items[itemIndex];
790
+ this.selectItemAtIndex = (itemIndex, otherStateToSet, cb) => {
791
+ const item = this.items[itemIndex];
846
792
  if (item == null) {
847
793
  return;
848
794
  }
849
- _this.selectItem(item, otherStateToSet, cb);
795
+ this.selectItem(item, otherStateToSet, cb);
850
796
  };
851
- _this.selectHighlightedItem = function (otherStateToSet, cb) {
852
- return _this.selectItemAtIndex(_this.getState().highlightedIndex, otherStateToSet, cb);
797
+ this.selectHighlightedItem = (otherStateToSet, cb) => {
798
+ return this.selectItemAtIndex(this.getState().highlightedIndex, otherStateToSet, cb);
853
799
  };
854
- _this.internalSetState = function (stateToSet, cb) {
855
- var isItemSelected, onChangeArg;
856
- var onStateChangeArg = {};
857
- var isStateToSetFunction = typeof stateToSet === 'function';
800
+ this.internalSetState = (stateToSet, cb) => {
801
+ let isItemSelected, onChangeArg;
802
+ const onStateChangeArg = {};
803
+ const isStateToSetFunction = typeof stateToSet === 'function';
858
804
 
859
805
  // we want to call `onInputValueChange` before the `setState` call
860
806
  // so someone controlling the `inputValue` state gets notified of
@@ -862,21 +808,24 @@
862
808
  // preserving the cursor position.
863
809
  // See https://github.com/downshift-js/downshift/issues/217 for more info.
864
810
  if (!isStateToSetFunction && stateToSet.hasOwnProperty('inputValue')) {
865
- _this.props.onInputValueChange(stateToSet.inputValue, _extends({}, _this.getStateAndHelpers(), stateToSet));
811
+ this.props.onInputValueChange(stateToSet.inputValue, {
812
+ ...this.getStateAndHelpers(),
813
+ ...stateToSet
814
+ });
866
815
  }
867
- return _this.setState(function (state) {
868
- state = _this.getState(state);
869
- var newStateToSet = isStateToSetFunction ? stateToSet(state) : stateToSet;
816
+ return this.setState(state => {
817
+ state = this.getState(state);
818
+ let newStateToSet = isStateToSetFunction ? stateToSet(state) : stateToSet;
870
819
 
871
820
  // Your own function that could modify the state that will be set.
872
- newStateToSet = _this.props.stateReducer(state, newStateToSet);
821
+ newStateToSet = this.props.stateReducer(state, newStateToSet);
873
822
 
874
823
  // checks if an item is selected, regardless of if it's different from
875
824
  // what was selected before
876
825
  // used to determine if onSelect and onChange callbacks should be called
877
826
  isItemSelected = newStateToSet.hasOwnProperty('selectedItem');
878
827
  // this keeps track of the object we want to call with setState
879
- var nextState = {};
828
+ const nextState = {};
880
829
  // we need to call on change if the outside world is controlling any of our state
881
830
  // and we're trying to update that state. OR if the selection has changed and we're
882
831
  // trying to update the selection
@@ -884,7 +833,7 @@
884
833
  onChangeArg = newStateToSet.selectedItem;
885
834
  }
886
835
  newStateToSet.type = newStateToSet.type || unknown;
887
- Object.keys(newStateToSet).forEach(function (key) {
836
+ Object.keys(newStateToSet).forEach(key => {
888
837
  // onStateChangeArg should only have the state that is
889
838
  // actually changing
890
839
  if (state[key] !== newStateToSet[key]) {
@@ -901,7 +850,7 @@
901
850
  }
902
851
  newStateToSet[key];
903
852
  // if it's coming from props, then we don't care to set it internally
904
- if (!isControlledProp(_this.props, key)) {
853
+ if (!isControlledProp(this.props, key)) {
905
854
  nextState[key] = newStateToSet[key];
906
855
  }
907
856
  });
@@ -909,58 +858,66 @@
909
858
  // if stateToSet is a function, then we weren't able to call onInputValueChange
910
859
  // earlier, so we'll call it now that we know what the inputValue state will be.
911
860
  if (isStateToSetFunction && newStateToSet.hasOwnProperty('inputValue')) {
912
- _this.props.onInputValueChange(newStateToSet.inputValue, _extends({}, _this.getStateAndHelpers(), newStateToSet));
861
+ this.props.onInputValueChange(newStateToSet.inputValue, {
862
+ ...this.getStateAndHelpers(),
863
+ ...newStateToSet
864
+ });
913
865
  }
914
866
  return nextState;
915
- }, function () {
867
+ }, () => {
916
868
  // call the provided callback if it's a function
917
869
  cbToCb(cb)();
918
870
 
919
871
  // only call the onStateChange and onChange callbacks if
920
872
  // we have relevant information to pass them.
921
- var hasMoreStateThanType = Object.keys(onStateChangeArg).length > 1;
873
+ const hasMoreStateThanType = Object.keys(onStateChangeArg).length > 1;
922
874
  if (hasMoreStateThanType) {
923
- _this.props.onStateChange(onStateChangeArg, _this.getStateAndHelpers());
875
+ this.props.onStateChange(onStateChangeArg, this.getStateAndHelpers());
924
876
  }
925
877
  if (isItemSelected) {
926
- _this.props.onSelect(stateToSet.selectedItem, _this.getStateAndHelpers());
878
+ this.props.onSelect(stateToSet.selectedItem, this.getStateAndHelpers());
927
879
  }
928
880
  if (onChangeArg !== undefined) {
929
- _this.props.onChange(onChangeArg, _this.getStateAndHelpers());
881
+ this.props.onChange(onChangeArg, this.getStateAndHelpers());
930
882
  }
931
883
  // this is currently undocumented and therefore subject to change
932
884
  // We'll try to not break it, but just be warned.
933
- _this.props.onUserAction(onStateChangeArg, _this.getStateAndHelpers());
885
+ this.props.onUserAction(onStateChangeArg, this.getStateAndHelpers());
934
886
  });
935
887
  };
936
- _this.rootRef = function (node) {
937
- return _this._rootNode = node;
938
- };
939
- _this.getRootProps = function (_temp, _temp2) {
940
- var _extends2;
941
- var _ref = _temp === void 0 ? {} : _temp,
942
- _ref$refKey = _ref.refKey,
943
- refKey = _ref$refKey === void 0 ? 'ref' : _ref$refKey,
944
- ref = _ref.ref,
945
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$4);
946
- var _ref2 = _temp2 === void 0 ? {} : _temp2,
947
- _ref2$suppressRefErro = _ref2.suppressRefError,
948
- suppressRefError = _ref2$suppressRefErro === void 0 ? false : _ref2$suppressRefErro;
888
+ this.rootRef = node => this._rootNode = node;
889
+ this.getRootProps = function (_temp, _temp2) {
890
+ let {
891
+ refKey = 'ref',
892
+ ref,
893
+ ...rest
894
+ } = _temp === void 0 ? {} : _temp;
895
+ let {
896
+ suppressRefError = false
897
+ } = _temp2 === void 0 ? {} : _temp2;
949
898
  // this is used in the render to know whether the user has called getRootProps.
950
899
  // It uses that to know whether to apply the props automatically
951
900
  _this.getRootProps.called = true;
952
901
  _this.getRootProps.refKey = refKey;
953
902
  _this.getRootProps.suppressRefError = suppressRefError;
954
- var _this$getState = _this.getState(),
955
- isOpen = _this$getState.isOpen;
956
- 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);
903
+ const {
904
+ isOpen
905
+ } = _this.getState();
906
+ return {
907
+ [refKey]: handleRefs(ref, _this.rootRef),
908
+ role: 'combobox',
909
+ 'aria-expanded': isOpen,
910
+ 'aria-haspopup': 'listbox',
911
+ 'aria-owns': isOpen ? _this.menuId : null,
912
+ 'aria-labelledby': _this.labelId,
913
+ ...rest
914
+ };
957
915
  };
958
- _this.keyDownHandlers = {
959
- ArrowDown: function ArrowDown(event) {
960
- var _this2 = this;
916
+ this.keyDownHandlers = {
917
+ ArrowDown(event) {
961
918
  event.preventDefault();
962
919
  if (this.getState().isOpen) {
963
- var amount = event.shiftKey ? 5 : 1;
920
+ const amount = event.shiftKey ? 5 : 1;
964
921
  this.moveHighlightedIndex(amount, {
965
922
  type: keyDownArrowDown
966
923
  });
@@ -968,26 +925,24 @@
968
925
  this.internalSetState({
969
926
  isOpen: true,
970
927
  type: keyDownArrowDown
971
- }, function () {
972
- var itemCount = _this2.getItemCount();
928
+ }, () => {
929
+ const itemCount = this.getItemCount();
973
930
  if (itemCount > 0) {
974
- var _this2$getState = _this2.getState(),
975
- highlightedIndex = _this2$getState.highlightedIndex;
976
- var nextHighlightedIndex = getNextWrappingIndex(1, highlightedIndex, itemCount, function (index) {
977
- return _this2.getItemNodeFromIndex(index);
978
- });
979
- _this2.setHighlightedIndex(nextHighlightedIndex, {
931
+ const {
932
+ highlightedIndex
933
+ } = this.getState();
934
+ const nextHighlightedIndex = getNextWrappingIndex(1, highlightedIndex, itemCount, index => this.getItemNodeFromIndex(index));
935
+ this.setHighlightedIndex(nextHighlightedIndex, {
980
936
  type: keyDownArrowDown
981
937
  });
982
938
  }
983
939
  });
984
940
  }
985
941
  },
986
- ArrowUp: function ArrowUp(event) {
987
- var _this3 = this;
942
+ ArrowUp(event) {
988
943
  event.preventDefault();
989
944
  if (this.getState().isOpen) {
990
- var amount = event.shiftKey ? -5 : -1;
945
+ const amount = event.shiftKey ? -5 : -1;
991
946
  this.moveHighlightedIndex(amount, {
992
947
  type: keyDownArrowUp
993
948
  });
@@ -995,32 +950,32 @@
995
950
  this.internalSetState({
996
951
  isOpen: true,
997
952
  type: keyDownArrowUp
998
- }, function () {
999
- var itemCount = _this3.getItemCount();
953
+ }, () => {
954
+ const itemCount = this.getItemCount();
1000
955
  if (itemCount > 0) {
1001
- var _this3$getState = _this3.getState(),
1002
- highlightedIndex = _this3$getState.highlightedIndex;
1003
- var nextHighlightedIndex = getNextWrappingIndex(-1, highlightedIndex, itemCount, function (index) {
1004
- return _this3.getItemNodeFromIndex(index);
1005
- });
1006
- _this3.setHighlightedIndex(nextHighlightedIndex, {
956
+ const {
957
+ highlightedIndex
958
+ } = this.getState();
959
+ const nextHighlightedIndex = getNextWrappingIndex(-1, highlightedIndex, itemCount, index => this.getItemNodeFromIndex(index));
960
+ this.setHighlightedIndex(nextHighlightedIndex, {
1007
961
  type: keyDownArrowUp
1008
962
  });
1009
963
  }
1010
964
  });
1011
965
  }
1012
966
  },
1013
- Enter: function Enter(event) {
967
+ Enter(event) {
1014
968
  if (event.which === 229) {
1015
969
  return;
1016
970
  }
1017
- var _this$getState2 = this.getState(),
1018
- isOpen = _this$getState2.isOpen,
1019
- highlightedIndex = _this$getState2.highlightedIndex;
971
+ const {
972
+ isOpen,
973
+ highlightedIndex
974
+ } = this.getState();
1020
975
  if (isOpen && highlightedIndex != null) {
1021
976
  event.preventDefault();
1022
- var item = this.items[highlightedIndex];
1023
- var itemNode = this.getItemNodeFromIndex(highlightedIndex);
977
+ const item = this.items[highlightedIndex];
978
+ const itemNode = this.getItemNodeFromIndex(highlightedIndex);
1024
979
  if (item == null || itemNode && itemNode.hasAttribute('disabled')) {
1025
980
  return;
1026
981
  }
@@ -1029,109 +984,112 @@
1029
984
  });
1030
985
  }
1031
986
  },
1032
- Escape: function Escape(event) {
987
+ Escape(event) {
1033
988
  event.preventDefault();
1034
- this.reset(_extends({
1035
- type: keyDownEscape
1036
- }, !this.state.isOpen && {
1037
- selectedItem: null,
1038
- inputValue: ''
1039
- }));
989
+ this.reset({
990
+ type: keyDownEscape,
991
+ ...(!this.state.isOpen && {
992
+ selectedItem: null,
993
+ inputValue: ''
994
+ })
995
+ });
1040
996
  }
1041
997
  };
1042
- _this.buttonKeyDownHandlers = _extends({}, _this.keyDownHandlers, {
1043
- ' ': function _(event) {
998
+ this.buttonKeyDownHandlers = {
999
+ ...this.keyDownHandlers,
1000
+ ' '(event) {
1044
1001
  event.preventDefault();
1045
1002
  this.toggleMenu({
1046
1003
  type: keyDownSpaceButton
1047
1004
  });
1048
1005
  }
1049
- });
1050
- _this.inputKeyDownHandlers = _extends({}, _this.keyDownHandlers, {
1051
- Home: function Home(event) {
1052
- var _this4 = this;
1053
- var _this$getState3 = this.getState(),
1054
- isOpen = _this$getState3.isOpen;
1006
+ };
1007
+ this.inputKeyDownHandlers = {
1008
+ ...this.keyDownHandlers,
1009
+ Home(event) {
1010
+ const {
1011
+ isOpen
1012
+ } = this.getState();
1055
1013
  if (!isOpen) {
1056
1014
  return;
1057
1015
  }
1058
1016
  event.preventDefault();
1059
- var itemCount = this.getItemCount();
1017
+ const itemCount = this.getItemCount();
1060
1018
  if (itemCount <= 0 || !isOpen) {
1061
1019
  return;
1062
1020
  }
1063
1021
 
1064
1022
  // get next non-disabled starting downwards from 0 if that's disabled.
1065
- var newHighlightedIndex = getNextNonDisabledIndex(1, 0, itemCount, function (index) {
1066
- return _this4.getItemNodeFromIndex(index);
1067
- }, false);
1023
+ const newHighlightedIndex = getNextNonDisabledIndex(1, 0, itemCount, index => this.getItemNodeFromIndex(index), false);
1068
1024
  this.setHighlightedIndex(newHighlightedIndex, {
1069
1025
  type: keyDownHome
1070
1026
  });
1071
1027
  },
1072
- End: function End(event) {
1073
- var _this5 = this;
1074
- var _this$getState4 = this.getState(),
1075
- isOpen = _this$getState4.isOpen;
1028
+ End(event) {
1029
+ const {
1030
+ isOpen
1031
+ } = this.getState();
1076
1032
  if (!isOpen) {
1077
1033
  return;
1078
1034
  }
1079
1035
  event.preventDefault();
1080
- var itemCount = this.getItemCount();
1036
+ const itemCount = this.getItemCount();
1081
1037
  if (itemCount <= 0 || !isOpen) {
1082
1038
  return;
1083
1039
  }
1084
1040
 
1085
1041
  // get next non-disabled starting upwards from last index if that's disabled.
1086
- var newHighlightedIndex = getNextNonDisabledIndex(-1, itemCount - 1, itemCount, function (index) {
1087
- return _this5.getItemNodeFromIndex(index);
1088
- }, false);
1042
+ const newHighlightedIndex = getNextNonDisabledIndex(-1, itemCount - 1, itemCount, index => this.getItemNodeFromIndex(index), false);
1089
1043
  this.setHighlightedIndex(newHighlightedIndex, {
1090
1044
  type: keyDownEnd
1091
1045
  });
1092
1046
  }
1093
- });
1094
- _this.getToggleButtonProps = function (_temp3) {
1095
- var _ref3 = _temp3 === void 0 ? {} : _temp3,
1096
- onClick = _ref3.onClick;
1097
- _ref3.onPress;
1098
- var onKeyDown = _ref3.onKeyDown,
1099
- onKeyUp = _ref3.onKeyUp,
1100
- onBlur = _ref3.onBlur,
1101
- rest = _objectWithoutPropertiesLoose(_ref3, _excluded2$3);
1102
- var _this$getState5 = _this.getState(),
1103
- isOpen = _this$getState5.isOpen;
1104
- var enabledEventHandlers = {
1047
+ };
1048
+ this.getToggleButtonProps = function (_temp3) {
1049
+ let {
1050
+ onClick,
1051
+ onPress,
1052
+ onKeyDown,
1053
+ onKeyUp,
1054
+ onBlur,
1055
+ ...rest
1056
+ } = _temp3 === void 0 ? {} : _temp3;
1057
+ const {
1058
+ isOpen
1059
+ } = _this.getState();
1060
+ const enabledEventHandlers = {
1105
1061
  onClick: callAllEventHandlers(onClick, _this.buttonHandleClick),
1106
1062
  onKeyDown: callAllEventHandlers(onKeyDown, _this.buttonHandleKeyDown),
1107
1063
  onKeyUp: callAllEventHandlers(onKeyUp, _this.buttonHandleKeyUp),
1108
1064
  onBlur: callAllEventHandlers(onBlur, _this.buttonHandleBlur)
1109
1065
  };
1110
- var eventHandlers = rest.disabled ? {} : enabledEventHandlers;
1111
- return _extends({
1066
+ const eventHandlers = rest.disabled ? {} : enabledEventHandlers;
1067
+ return {
1112
1068
  type: 'button',
1113
1069
  role: 'button',
1114
1070
  'aria-label': isOpen ? 'close menu' : 'open menu',
1115
1071
  'aria-haspopup': true,
1116
- 'data-toggle': true
1117
- }, eventHandlers, rest);
1072
+ 'data-toggle': true,
1073
+ ...eventHandlers,
1074
+ ...rest
1075
+ };
1118
1076
  };
1119
- _this.buttonHandleKeyUp = function (event) {
1077
+ this.buttonHandleKeyUp = event => {
1120
1078
  // Prevent click event from emitting in Firefox
1121
1079
  event.preventDefault();
1122
1080
  };
1123
- _this.buttonHandleKeyDown = function (event) {
1124
- var key = normalizeArrowKey(event);
1125
- if (_this.buttonKeyDownHandlers[key]) {
1126
- _this.buttonKeyDownHandlers[key].call(_assertThisInitialized(_this), event);
1081
+ this.buttonHandleKeyDown = event => {
1082
+ const key = normalizeArrowKey(event);
1083
+ if (this.buttonKeyDownHandlers[key]) {
1084
+ this.buttonKeyDownHandlers[key].call(this, event);
1127
1085
  }
1128
1086
  };
1129
- _this.buttonHandleClick = function (event) {
1087
+ this.buttonHandleClick = event => {
1130
1088
  event.preventDefault();
1131
1089
  // handle odd case for Safari and Firefox which
1132
1090
  // don't give the button the focus properly.
1133
1091
  /* istanbul ignore if (can't reasonably test this) */
1134
- if (_this.props.environment.document.activeElement === _this.props.environment.document.body) {
1092
+ if (this.props.environment.document.activeElement === this.props.environment.document.body) {
1135
1093
  event.target.focus();
1136
1094
  }
1137
1095
  // to simplify testing components that use downshift, we'll not wrap this in a setTimeout
@@ -1139,55 +1097,59 @@
1139
1097
  // when building for production and should therefore have no impact on production code.
1140
1098
  {
1141
1099
  // Ensure that toggle of menu occurs after the potential blur event in iOS
1142
- _this.internalSetTimeout(function () {
1143
- return _this.toggleMenu({
1144
- type: clickButton
1145
- });
1146
- });
1100
+ this.internalSetTimeout(() => this.toggleMenu({
1101
+ type: clickButton
1102
+ }));
1147
1103
  }
1148
1104
  };
1149
- _this.buttonHandleBlur = function (event) {
1150
- var blurTarget = event.target; // Save blur target for comparison with activeElement later
1105
+ this.buttonHandleBlur = event => {
1106
+ const blurTarget = event.target; // Save blur target for comparison with activeElement later
1151
1107
  // Need setTimeout, so that when the user presses Tab, the activeElement is the next focused element, not body element
1152
- _this.internalSetTimeout(function () {
1153
- 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)
1108
+ this.internalSetTimeout(() => {
1109
+ 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)
1154
1110
  ) {
1155
- _this.reset({
1111
+ this.reset({
1156
1112
  type: blurButton
1157
1113
  });
1158
1114
  }
1159
1115
  });
1160
1116
  };
1161
- _this.getLabelProps = function (props) {
1162
- return _extends({
1163
- htmlFor: _this.inputId,
1164
- id: _this.labelId
1165
- }, props);
1166
- };
1167
- _this.getInputProps = function (_temp4) {
1168
- var _ref4 = _temp4 === void 0 ? {} : _temp4,
1169
- onKeyDown = _ref4.onKeyDown,
1170
- onBlur = _ref4.onBlur,
1171
- onChange = _ref4.onChange,
1172
- onInput = _ref4.onInput;
1173
- _ref4.onChangeText;
1174
- var rest = _objectWithoutPropertiesLoose(_ref4, _excluded3$2);
1175
- var onChangeKey;
1176
- var eventHandlers = {};
1117
+ this.getLabelProps = props => {
1118
+ return {
1119
+ htmlFor: this.inputId,
1120
+ id: this.labelId,
1121
+ ...props
1122
+ };
1123
+ };
1124
+ this.getInputProps = function (_temp4) {
1125
+ let {
1126
+ onKeyDown,
1127
+ onBlur,
1128
+ onChange,
1129
+ onInput,
1130
+ onChangeText,
1131
+ ...rest
1132
+ } = _temp4 === void 0 ? {} : _temp4;
1133
+ let onChangeKey;
1134
+ let eventHandlers = {};
1177
1135
 
1178
1136
  /* istanbul ignore next (preact) */
1179
1137
  {
1180
1138
  onChangeKey = 'onInput';
1181
1139
  }
1182
- var _this$getState6 = _this.getState(),
1183
- inputValue = _this$getState6.inputValue,
1184
- isOpen = _this$getState6.isOpen,
1185
- highlightedIndex = _this$getState6.highlightedIndex;
1140
+ const {
1141
+ inputValue,
1142
+ isOpen,
1143
+ highlightedIndex
1144
+ } = _this.getState();
1186
1145
  if (!rest.disabled) {
1187
- var _eventHandlers;
1188
- eventHandlers = (_eventHandlers = {}, _eventHandlers[onChangeKey] = callAllEventHandlers(onChange, onInput, _this.inputHandleChange), _eventHandlers.onKeyDown = callAllEventHandlers(onKeyDown, _this.inputHandleKeyDown), _eventHandlers.onBlur = callAllEventHandlers(onBlur, _this.inputHandleBlur), _eventHandlers);
1146
+ eventHandlers = {
1147
+ [onChangeKey]: callAllEventHandlers(onChange, onInput, _this.inputHandleChange),
1148
+ onKeyDown: callAllEventHandlers(onKeyDown, _this.inputHandleKeyDown),
1149
+ onBlur: callAllEventHandlers(onBlur, _this.inputHandleBlur)
1150
+ };
1189
1151
  }
1190
- return _extends({
1152
+ return {
1191
1153
  'aria-autocomplete': 'list',
1192
1154
  'aria-activedescendant': isOpen && typeof highlightedIndex === 'number' && highlightedIndex >= 0 ? _this.getItemId(highlightedIndex) : null,
1193
1155
  'aria-controls': isOpen ? _this.menuId : null,
@@ -1196,76 +1158,82 @@
1196
1158
  // revert back since autocomplete="nope" is ignored on latest Chrome and Opera
1197
1159
  autoComplete: 'off',
1198
1160
  value: inputValue,
1199
- id: _this.inputId
1200
- }, eventHandlers, rest);
1161
+ id: _this.inputId,
1162
+ ...eventHandlers,
1163
+ ...rest
1164
+ };
1201
1165
  };
1202
- _this.inputHandleKeyDown = function (event) {
1203
- var key = normalizeArrowKey(event);
1204
- if (key && _this.inputKeyDownHandlers[key]) {
1205
- _this.inputKeyDownHandlers[key].call(_assertThisInitialized(_this), event);
1166
+ this.inputHandleKeyDown = event => {
1167
+ const key = normalizeArrowKey(event);
1168
+ if (key && this.inputKeyDownHandlers[key]) {
1169
+ this.inputKeyDownHandlers[key].call(this, event);
1206
1170
  }
1207
1171
  };
1208
- _this.inputHandleChange = function (event) {
1209
- _this.internalSetState({
1172
+ this.inputHandleChange = event => {
1173
+ this.internalSetState({
1210
1174
  type: changeInput,
1211
1175
  isOpen: true,
1212
1176
  inputValue: event.target.value,
1213
- highlightedIndex: _this.props.defaultHighlightedIndex
1177
+ highlightedIndex: this.props.defaultHighlightedIndex
1214
1178
  });
1215
1179
  };
1216
- _this.inputHandleBlur = function () {
1180
+ this.inputHandleBlur = () => {
1217
1181
  // Need setTimeout, so that when the user presses Tab, the activeElement is the next focused element, not the body element
1218
- _this.internalSetTimeout(function () {
1219
- 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);
1220
- if (!_this.isMouseDown && !downshiftButtonIsActive) {
1221
- _this.reset({
1182
+ this.internalSetTimeout(() => {
1183
+ 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);
1184
+ if (!this.isMouseDown && !downshiftButtonIsActive) {
1185
+ this.reset({
1222
1186
  type: blurInput
1223
1187
  });
1224
1188
  }
1225
1189
  });
1226
1190
  };
1227
- _this.menuRef = function (node) {
1228
- _this._menuNode = node;
1229
- };
1230
- _this.getMenuProps = function (_temp5, _temp6) {
1231
- var _extends3;
1232
- var _ref5 = _temp5 === void 0 ? {} : _temp5,
1233
- _ref5$refKey = _ref5.refKey,
1234
- refKey = _ref5$refKey === void 0 ? 'ref' : _ref5$refKey,
1235
- ref = _ref5.ref,
1236
- props = _objectWithoutPropertiesLoose(_ref5, _excluded4$1);
1237
- var _ref6 = _temp6 === void 0 ? {} : _temp6,
1238
- _ref6$suppressRefErro = _ref6.suppressRefError,
1239
- suppressRefError = _ref6$suppressRefErro === void 0 ? false : _ref6$suppressRefErro;
1191
+ this.menuRef = node => {
1192
+ this._menuNode = node;
1193
+ };
1194
+ this.getMenuProps = function (_temp5, _temp6) {
1195
+ let {
1196
+ refKey = 'ref',
1197
+ ref,
1198
+ ...props
1199
+ } = _temp5 === void 0 ? {} : _temp5;
1200
+ let {
1201
+ suppressRefError = false
1202
+ } = _temp6 === void 0 ? {} : _temp6;
1240
1203
  _this.getMenuProps.called = true;
1241
1204
  _this.getMenuProps.refKey = refKey;
1242
1205
  _this.getMenuProps.suppressRefError = suppressRefError;
1243
- 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);
1244
- };
1245
- _this.getItemProps = function (_temp7) {
1246
- var _enabledEventHandlers;
1247
- var _ref7 = _temp7 === void 0 ? {} : _temp7,
1248
- onMouseMove = _ref7.onMouseMove,
1249
- onMouseDown = _ref7.onMouseDown,
1250
- onClick = _ref7.onClick;
1251
- _ref7.onPress;
1252
- var index = _ref7.index,
1253
- _ref7$item = _ref7.item,
1254
- item = _ref7$item === void 0 ? requiredProp('getItemProps', 'item') : _ref7$item,
1255
- rest = _objectWithoutPropertiesLoose(_ref7, _excluded5);
1206
+ return {
1207
+ [refKey]: handleRefs(ref, _this.menuRef),
1208
+ role: 'listbox',
1209
+ 'aria-labelledby': props && props['aria-label'] ? null : _this.labelId,
1210
+ id: _this.menuId,
1211
+ ...props
1212
+ };
1213
+ };
1214
+ this.getItemProps = function (_temp7) {
1215
+ let {
1216
+ onMouseMove,
1217
+ onMouseDown,
1218
+ onClick,
1219
+ onPress,
1220
+ index,
1221
+ item = requiredProp('getItemProps', 'item'),
1222
+ ...rest
1223
+ } = _temp7 === void 0 ? {} : _temp7;
1256
1224
  if (index === undefined) {
1257
1225
  _this.items.push(item);
1258
1226
  index = _this.items.indexOf(item);
1259
1227
  } else {
1260
1228
  _this.items[index] = item;
1261
1229
  }
1262
- var onSelectKey = 'onClick';
1263
- var customClickHandler = onClick;
1264
- var enabledEventHandlers = (_enabledEventHandlers = {
1230
+ const onSelectKey = 'onClick';
1231
+ const customClickHandler = onClick;
1232
+ const enabledEventHandlers = {
1265
1233
  // onMouseMove is used over onMouseEnter here. onMouseMove
1266
1234
  // is only triggered on actual mouse movement while onMouseEnter
1267
1235
  // can fire on DOM changes, interrupting keyboard navigation
1268
- onMouseMove: callAllEventHandlers(onMouseMove, function () {
1236
+ onMouseMove: callAllEventHandlers(onMouseMove, () => {
1269
1237
  if (index === _this.getState().highlightedIndex) {
1270
1238
  return;
1271
1239
  }
@@ -1278,66 +1246,75 @@
1278
1246
  // from under the user which is currently scrolling/moving the
1279
1247
  // cursor
1280
1248
  _this.avoidScrolling = true;
1281
- _this.internalSetTimeout(function () {
1282
- return _this.avoidScrolling = false;
1283
- }, 250);
1249
+ _this.internalSetTimeout(() => _this.avoidScrolling = false, 250);
1284
1250
  }),
1285
- onMouseDown: callAllEventHandlers(onMouseDown, function (event) {
1251
+ onMouseDown: callAllEventHandlers(onMouseDown, event => {
1286
1252
  // This prevents the activeElement from being changed
1287
1253
  // to the item so it can remain with the current activeElement
1288
1254
  // which is a more common use case.
1289
1255
  event.preventDefault();
1256
+ }),
1257
+ [onSelectKey]: callAllEventHandlers(customClickHandler, () => {
1258
+ _this.selectItemAtIndex(index, {
1259
+ type: clickItem
1260
+ });
1290
1261
  })
1291
- }, _enabledEventHandlers[onSelectKey] = callAllEventHandlers(customClickHandler, function () {
1292
- _this.selectItemAtIndex(index, {
1293
- type: clickItem
1294
- });
1295
- }), _enabledEventHandlers);
1262
+ };
1296
1263
 
1297
1264
  // Passing down the onMouseDown handler to prevent redirect
1298
1265
  // of the activeElement if clicking on disabled items
1299
- var eventHandlers = rest.disabled ? {
1266
+ const eventHandlers = rest.disabled ? {
1300
1267
  onMouseDown: enabledEventHandlers.onMouseDown
1301
1268
  } : enabledEventHandlers;
1302
- return _extends({
1269
+ return {
1303
1270
  id: _this.getItemId(index),
1304
1271
  role: 'option',
1305
- 'aria-selected': _this.getState().highlightedIndex === index
1306
- }, eventHandlers, rest);
1272
+ 'aria-selected': _this.getState().highlightedIndex === index,
1273
+ ...eventHandlers,
1274
+ ...rest
1275
+ };
1307
1276
  };
1308
- _this.clearItems = function () {
1309
- _this.items = [];
1277
+ this.clearItems = () => {
1278
+ this.items = [];
1310
1279
  };
1311
- _this.reset = function (otherStateToSet, cb) {
1280
+ this.reset = function (otherStateToSet, cb) {
1312
1281
  if (otherStateToSet === void 0) {
1313
1282
  otherStateToSet = {};
1314
1283
  }
1315
1284
  otherStateToSet = pickState(otherStateToSet);
1316
- _this.internalSetState(function (_ref8) {
1317
- var selectedItem = _ref8.selectedItem;
1318
- return _extends({
1285
+ _this.internalSetState(_ref => {
1286
+ let {
1287
+ selectedItem
1288
+ } = _ref;
1289
+ return {
1319
1290
  isOpen: _this.props.defaultIsOpen,
1320
1291
  highlightedIndex: _this.props.defaultHighlightedIndex,
1321
- inputValue: _this.props.itemToString(selectedItem)
1322
- }, otherStateToSet);
1292
+ inputValue: _this.props.itemToString(selectedItem),
1293
+ ...otherStateToSet
1294
+ };
1323
1295
  }, cb);
1324
1296
  };
1325
- _this.toggleMenu = function (otherStateToSet, cb) {
1297
+ this.toggleMenu = function (otherStateToSet, cb) {
1326
1298
  if (otherStateToSet === void 0) {
1327
1299
  otherStateToSet = {};
1328
1300
  }
1329
1301
  otherStateToSet = pickState(otherStateToSet);
1330
- _this.internalSetState(function (_ref9) {
1331
- var isOpen = _ref9.isOpen;
1332
- return _extends({
1333
- isOpen: !isOpen
1334
- }, isOpen && {
1335
- highlightedIndex: _this.props.defaultHighlightedIndex
1336
- }, otherStateToSet);
1337
- }, function () {
1338
- var _this$getState7 = _this.getState(),
1339
- isOpen = _this$getState7.isOpen,
1340
- highlightedIndex = _this$getState7.highlightedIndex;
1302
+ _this.internalSetState(_ref2 => {
1303
+ let {
1304
+ isOpen
1305
+ } = _ref2;
1306
+ return {
1307
+ isOpen: !isOpen,
1308
+ ...(isOpen && {
1309
+ highlightedIndex: _this.props.defaultHighlightedIndex
1310
+ }),
1311
+ ...otherStateToSet
1312
+ };
1313
+ }, () => {
1314
+ const {
1315
+ isOpen,
1316
+ highlightedIndex
1317
+ } = _this.getState();
1341
1318
  if (isOpen) {
1342
1319
  if (_this.getItemCount() > 0 && typeof highlightedIndex === 'number') {
1343
1320
  _this.setHighlightedIndex(highlightedIndex, otherStateToSet);
@@ -1346,58 +1323,57 @@
1346
1323
  cbToCb(cb)();
1347
1324
  });
1348
1325
  };
1349
- _this.openMenu = function (cb) {
1350
- _this.internalSetState({
1326
+ this.openMenu = cb => {
1327
+ this.internalSetState({
1351
1328
  isOpen: true
1352
1329
  }, cb);
1353
1330
  };
1354
- _this.closeMenu = function (cb) {
1355
- _this.internalSetState({
1331
+ this.closeMenu = cb => {
1332
+ this.internalSetState({
1356
1333
  isOpen: false
1357
1334
  }, cb);
1358
1335
  };
1359
- _this.updateStatus = debounce(function () {
1360
- var state = _this.getState();
1361
- var item = _this.items[state.highlightedIndex];
1362
- var resultCount = _this.getItemCount();
1363
- var status = _this.props.getA11yStatusMessage(_extends({
1364
- itemToString: _this.props.itemToString,
1365
- previousResultCount: _this.previousResultCount,
1366
- resultCount: resultCount,
1367
- highlightedItem: item
1368
- }, state));
1369
- _this.previousResultCount = resultCount;
1370
- setStatus(status, _this.props.environment.document);
1336
+ this.updateStatus = debounce(() => {
1337
+ const state = this.getState();
1338
+ const item = this.items[state.highlightedIndex];
1339
+ const resultCount = this.getItemCount();
1340
+ const status = this.props.getA11yStatusMessage({
1341
+ itemToString: this.props.itemToString,
1342
+ previousResultCount: this.previousResultCount,
1343
+ resultCount,
1344
+ highlightedItem: item,
1345
+ ...state
1346
+ });
1347
+ this.previousResultCount = resultCount;
1348
+ setStatus(status, this.props.environment.document);
1371
1349
  }, 200);
1372
- var _this$props = _this.props,
1373
- defaultHighlightedIndex = _this$props.defaultHighlightedIndex,
1374
- _this$props$initialHi = _this$props.initialHighlightedIndex,
1375
- _highlightedIndex = _this$props$initialHi === void 0 ? defaultHighlightedIndex : _this$props$initialHi,
1376
- defaultIsOpen = _this$props.defaultIsOpen,
1377
- _this$props$initialIs = _this$props.initialIsOpen,
1378
- _isOpen = _this$props$initialIs === void 0 ? defaultIsOpen : _this$props$initialIs,
1379
- _this$props$initialIn = _this$props.initialInputValue,
1380
- _inputValue = _this$props$initialIn === void 0 ? '' : _this$props$initialIn,
1381
- _this$props$initialSe = _this$props.initialSelectedItem,
1382
- _selectedItem = _this$props$initialSe === void 0 ? null : _this$props$initialSe;
1383
- var _state = _this.getState({
1350
+ // fancy destructuring + defaults + aliases
1351
+ // this basically says each value of state should either be set to
1352
+ // the initial value or the default value if the initial value is not provided
1353
+ const {
1354
+ defaultHighlightedIndex,
1355
+ initialHighlightedIndex: _highlightedIndex = defaultHighlightedIndex,
1356
+ defaultIsOpen,
1357
+ initialIsOpen: _isOpen = defaultIsOpen,
1358
+ initialInputValue: _inputValue = '',
1359
+ initialSelectedItem: _selectedItem = null
1360
+ } = this.props;
1361
+ const _state = this.getState({
1384
1362
  highlightedIndex: _highlightedIndex,
1385
1363
  isOpen: _isOpen,
1386
1364
  inputValue: _inputValue,
1387
1365
  selectedItem: _selectedItem
1388
1366
  });
1389
- if (_state.selectedItem != null && _this.props.initialInputValue === undefined) {
1390
- _state.inputValue = _this.props.itemToString(_state.selectedItem);
1367
+ if (_state.selectedItem != null && this.props.initialInputValue === undefined) {
1368
+ _state.inputValue = this.props.itemToString(_state.selectedItem);
1391
1369
  }
1392
- _this.state = _state;
1393
- return _this;
1370
+ this.state = _state;
1394
1371
  }
1395
- var _proto = Downshift.prototype;
1396
1372
  /**
1397
1373
  * Clear all running timeouts
1398
1374
  */
1399
- _proto.internalClearTimeouts = function internalClearTimeouts() {
1400
- this.timeoutIds.forEach(function (id) {
1375
+ internalClearTimeouts() {
1376
+ this.timeoutIds.forEach(id => {
1401
1377
  clearTimeout(id);
1402
1378
  });
1403
1379
  this.timeoutIds = [];
@@ -1411,113 +1387,117 @@
1411
1387
  *
1412
1388
  * @param {Object} stateToMerge defaults to this.state
1413
1389
  * @return {Object} the state
1414
- */;
1415
- _proto.getState = function getState$1(stateToMerge) {
1390
+ */
1391
+ getState(stateToMerge) {
1416
1392
  if (stateToMerge === void 0) {
1417
1393
  stateToMerge = this.state;
1418
1394
  }
1419
1395
  return getState(stateToMerge, this.props);
1420
- };
1421
- _proto.getItemCount = function getItemCount() {
1396
+ }
1397
+ getItemCount() {
1422
1398
  // things read better this way. They're in priority order:
1423
1399
  // 1. `this.itemCount`
1424
1400
  // 2. `this.props.itemCount`
1425
1401
  // 3. `this.items.length`
1426
- var itemCount = this.items.length;
1402
+ let itemCount = this.items.length;
1427
1403
  if (this.itemCount != null) {
1428
1404
  itemCount = this.itemCount;
1429
1405
  } else if (this.props.itemCount !== undefined) {
1430
1406
  itemCount = this.props.itemCount;
1431
1407
  }
1432
1408
  return itemCount;
1433
- };
1434
- _proto.getItemNodeFromIndex = function getItemNodeFromIndex(index) {
1409
+ }
1410
+ getItemNodeFromIndex(index) {
1435
1411
  return this.props.environment.document.getElementById(this.getItemId(index));
1436
- };
1437
- _proto.scrollHighlightedItemIntoView = function scrollHighlightedItemIntoView() {
1412
+ }
1413
+ scrollHighlightedItemIntoView() {
1438
1414
  /* istanbul ignore else (react-native) */
1439
1415
  {
1440
- var node = this.getItemNodeFromIndex(this.getState().highlightedIndex);
1416
+ const node = this.getItemNodeFromIndex(this.getState().highlightedIndex);
1441
1417
  this.props.scrollIntoView(node, this._menuNode);
1442
1418
  }
1443
- };
1444
- _proto.moveHighlightedIndex = function moveHighlightedIndex(amount, otherStateToSet) {
1445
- var _this6 = this;
1446
- var itemCount = this.getItemCount();
1447
- var _this$getState8 = this.getState(),
1448
- highlightedIndex = _this$getState8.highlightedIndex;
1419
+ }
1420
+ moveHighlightedIndex(amount, otherStateToSet) {
1421
+ const itemCount = this.getItemCount();
1422
+ const {
1423
+ highlightedIndex
1424
+ } = this.getState();
1449
1425
  if (itemCount > 0) {
1450
- var nextHighlightedIndex = getNextWrappingIndex(amount, highlightedIndex, itemCount, function (index) {
1451
- return _this6.getItemNodeFromIndex(index);
1452
- });
1426
+ const nextHighlightedIndex = getNextWrappingIndex(amount, highlightedIndex, itemCount, index => this.getItemNodeFromIndex(index));
1453
1427
  this.setHighlightedIndex(nextHighlightedIndex, otherStateToSet);
1454
1428
  }
1455
- };
1456
- _proto.getStateAndHelpers = function getStateAndHelpers() {
1457
- var _this$getState9 = this.getState(),
1458
- highlightedIndex = _this$getState9.highlightedIndex,
1459
- inputValue = _this$getState9.inputValue,
1460
- selectedItem = _this$getState9.selectedItem,
1461
- isOpen = _this$getState9.isOpen;
1462
- var itemToString = this.props.itemToString;
1463
- var id = this.id;
1464
- var getRootProps = this.getRootProps,
1465
- getToggleButtonProps = this.getToggleButtonProps,
1466
- getLabelProps = this.getLabelProps,
1467
- getMenuProps = this.getMenuProps,
1468
- getInputProps = this.getInputProps,
1469
- getItemProps = this.getItemProps,
1470
- openMenu = this.openMenu,
1471
- closeMenu = this.closeMenu,
1472
- toggleMenu = this.toggleMenu,
1473
- selectItem = this.selectItem,
1474
- selectItemAtIndex = this.selectItemAtIndex,
1475
- selectHighlightedItem = this.selectHighlightedItem,
1476
- setHighlightedIndex = this.setHighlightedIndex,
1477
- clearSelection = this.clearSelection,
1478
- clearItems = this.clearItems,
1479
- reset = this.reset,
1480
- setItemCount = this.setItemCount,
1481
- unsetItemCount = this.unsetItemCount,
1482
- setState = this.internalSetState;
1429
+ }
1430
+ getStateAndHelpers() {
1431
+ const {
1432
+ highlightedIndex,
1433
+ inputValue,
1434
+ selectedItem,
1435
+ isOpen
1436
+ } = this.getState();
1437
+ const {
1438
+ itemToString
1439
+ } = this.props;
1440
+ const {
1441
+ id
1442
+ } = this;
1443
+ const {
1444
+ getRootProps,
1445
+ getToggleButtonProps,
1446
+ getLabelProps,
1447
+ getMenuProps,
1448
+ getInputProps,
1449
+ getItemProps,
1450
+ openMenu,
1451
+ closeMenu,
1452
+ toggleMenu,
1453
+ selectItem,
1454
+ selectItemAtIndex,
1455
+ selectHighlightedItem,
1456
+ setHighlightedIndex,
1457
+ clearSelection,
1458
+ clearItems,
1459
+ reset,
1460
+ setItemCount,
1461
+ unsetItemCount,
1462
+ internalSetState: setState
1463
+ } = this;
1483
1464
  return {
1484
1465
  // prop getters
1485
- getRootProps: getRootProps,
1486
- getToggleButtonProps: getToggleButtonProps,
1487
- getLabelProps: getLabelProps,
1488
- getMenuProps: getMenuProps,
1489
- getInputProps: getInputProps,
1490
- getItemProps: getItemProps,
1466
+ getRootProps,
1467
+ getToggleButtonProps,
1468
+ getLabelProps,
1469
+ getMenuProps,
1470
+ getInputProps,
1471
+ getItemProps,
1491
1472
  // actions
1492
- reset: reset,
1493
- openMenu: openMenu,
1494
- closeMenu: closeMenu,
1495
- toggleMenu: toggleMenu,
1496
- selectItem: selectItem,
1497
- selectItemAtIndex: selectItemAtIndex,
1498
- selectHighlightedItem: selectHighlightedItem,
1499
- setHighlightedIndex: setHighlightedIndex,
1500
- clearSelection: clearSelection,
1501
- clearItems: clearItems,
1502
- setItemCount: setItemCount,
1503
- unsetItemCount: unsetItemCount,
1504
- setState: setState,
1473
+ reset,
1474
+ openMenu,
1475
+ closeMenu,
1476
+ toggleMenu,
1477
+ selectItem,
1478
+ selectItemAtIndex,
1479
+ selectHighlightedItem,
1480
+ setHighlightedIndex,
1481
+ clearSelection,
1482
+ clearItems,
1483
+ setItemCount,
1484
+ unsetItemCount,
1485
+ setState,
1505
1486
  // props
1506
- itemToString: itemToString,
1487
+ itemToString,
1507
1488
  // derived
1508
- id: id,
1489
+ id,
1509
1490
  // state
1510
- highlightedIndex: highlightedIndex,
1511
- inputValue: inputValue,
1512
- isOpen: isOpen,
1513
- selectedItem: selectedItem
1491
+ highlightedIndex,
1492
+ inputValue,
1493
+ isOpen,
1494
+ selectedItem
1514
1495
  };
1515
1496
  }
1516
1497
 
1517
1498
  //////////////////////////// ROOT
1518
- ;
1519
- _proto.componentDidMount = function componentDidMount() {
1520
- var _this7 = this;
1499
+
1500
+ componentDidMount() {
1521
1501
  /* istanbul ignore if (react-native) */
1522
1502
  if (this.getMenuProps.called && !this.getMenuProps.suppressRefError) {
1523
1503
  validateGetMenuPropsCalledCorrectly(this._menuNode, this.getMenuProps);
@@ -1530,20 +1510,18 @@
1530
1510
  // down long enough for the list to disappear (because the blur event fires on the input)
1531
1511
  // this.isMouseDown is used in the blur handler on the input to determine whether the blur event should
1532
1512
  // trigger hiding the menu.
1533
- var onMouseDown = function onMouseDown() {
1534
- _this7.isMouseDown = true;
1513
+ const onMouseDown = () => {
1514
+ this.isMouseDown = true;
1535
1515
  };
1536
- var onMouseUp = function onMouseUp(event) {
1537
- _this7.isMouseDown = false;
1516
+ const onMouseUp = event => {
1517
+ this.isMouseDown = false;
1538
1518
  // if the target element or the activeElement is within a downshift node
1539
1519
  // then we don't want to reset downshift
1540
- var contextWithinDownshift = targetWithinDownshift(event.target, [_this7._rootNode, _this7._menuNode], _this7.props.environment);
1541
- if (!contextWithinDownshift && _this7.getState().isOpen) {
1542
- _this7.reset({
1520
+ const contextWithinDownshift = targetWithinDownshift(event.target, [this._rootNode, this._menuNode], this.props.environment);
1521
+ if (!contextWithinDownshift && this.getState().isOpen) {
1522
+ this.reset({
1543
1523
  type: mouseUp
1544
- }, function () {
1545
- return _this7.props.onOuterClick(_this7.getStateAndHelpers());
1546
- });
1524
+ }, () => this.props.onOuterClick(this.getStateAndHelpers()));
1547
1525
  }
1548
1526
  };
1549
1527
  // Touching an element in iOS gives focus and hover states, but touching out of
@@ -1552,31 +1530,31 @@
1552
1530
  // this.isTouchMove helps us track whether the user is tapping or swiping on a touch screen.
1553
1531
  // If the user taps outside of Downshift, the component should be reset,
1554
1532
  // but not if the user is swiping
1555
- var onTouchStart = function onTouchStart() {
1556
- _this7.isTouchMove = false;
1533
+ const onTouchStart = () => {
1534
+ this.isTouchMove = false;
1557
1535
  };
1558
- var onTouchMove = function onTouchMove() {
1559
- _this7.isTouchMove = true;
1536
+ const onTouchMove = () => {
1537
+ this.isTouchMove = true;
1560
1538
  };
1561
- var onTouchEnd = function onTouchEnd(event) {
1562
- var contextWithinDownshift = targetWithinDownshift(event.target, [_this7._rootNode, _this7._menuNode], _this7.props.environment, false);
1563
- if (!_this7.isTouchMove && !contextWithinDownshift && _this7.getState().isOpen) {
1564
- _this7.reset({
1539
+ const onTouchEnd = event => {
1540
+ const contextWithinDownshift = targetWithinDownshift(event.target, [this._rootNode, this._menuNode], this.props.environment, false);
1541
+ if (!this.isTouchMove && !contextWithinDownshift && this.getState().isOpen) {
1542
+ this.reset({
1565
1543
  type: touchEnd
1566
- }, function () {
1567
- return _this7.props.onOuterClick(_this7.getStateAndHelpers());
1568
- });
1544
+ }, () => this.props.onOuterClick(this.getStateAndHelpers()));
1569
1545
  }
1570
1546
  };
1571
- var environment = this.props.environment;
1547
+ const {
1548
+ environment
1549
+ } = this.props;
1572
1550
  environment.addEventListener('mousedown', onMouseDown);
1573
1551
  environment.addEventListener('mouseup', onMouseUp);
1574
1552
  environment.addEventListener('touchstart', onTouchStart);
1575
1553
  environment.addEventListener('touchmove', onTouchMove);
1576
1554
  environment.addEventListener('touchend', onTouchEnd);
1577
- this.cleanup = function () {
1578
- _this7.internalClearTimeouts();
1579
- _this7.updateStatus.cancel();
1555
+ this.cleanup = () => {
1556
+ this.internalClearTimeouts();
1557
+ this.updateStatus.cancel();
1580
1558
  environment.removeEventListener('mousedown', onMouseDown);
1581
1559
  environment.removeEventListener('mouseup', onMouseUp);
1582
1560
  environment.removeEventListener('touchstart', onTouchStart);
@@ -1584,17 +1562,19 @@
1584
1562
  environment.removeEventListener('touchend', onTouchEnd);
1585
1563
  };
1586
1564
  }
1587
- };
1588
- _proto.shouldScroll = function shouldScroll(prevState, prevProps) {
1589
- var _ref10 = this.props.highlightedIndex === undefined ? this.getState() : this.props,
1590
- currentHighlightedIndex = _ref10.highlightedIndex;
1591
- var _ref11 = prevProps.highlightedIndex === undefined ? prevState : prevProps,
1592
- prevHighlightedIndex = _ref11.highlightedIndex;
1593
- var scrollWhenOpen = currentHighlightedIndex && this.getState().isOpen && !prevState.isOpen;
1594
- var scrollWhenNavigating = currentHighlightedIndex !== prevHighlightedIndex;
1565
+ }
1566
+ shouldScroll(prevState, prevProps) {
1567
+ const {
1568
+ highlightedIndex: currentHighlightedIndex
1569
+ } = this.props.highlightedIndex === undefined ? this.getState() : this.props;
1570
+ const {
1571
+ highlightedIndex: prevHighlightedIndex
1572
+ } = prevProps.highlightedIndex === undefined ? prevState : prevProps;
1573
+ const scrollWhenOpen = currentHighlightedIndex && this.getState().isOpen && !prevState.isOpen;
1574
+ const scrollWhenNavigating = currentHighlightedIndex !== prevHighlightedIndex;
1595
1575
  return scrollWhenOpen || scrollWhenNavigating;
1596
- };
1597
- _proto.componentDidUpdate = function componentDidUpdate(prevProps, prevState) {
1576
+ }
1577
+ componentDidUpdate(prevProps, prevState) {
1598
1578
  {
1599
1579
  validateControlledUnchanged(this.state, prevProps, this.props);
1600
1580
  /* istanbul ignore if (react-native) */
@@ -1616,12 +1596,13 @@
1616
1596
  {
1617
1597
  this.updateStatus();
1618
1598
  }
1619
- };
1620
- _proto.componentWillUnmount = function componentWillUnmount() {
1599
+ }
1600
+ componentWillUnmount() {
1621
1601
  this.cleanup(); // avoids memory leak
1622
- };
1623
- _proto.render = function render() {
1624
- var children = unwrapArray(this.props.children, noop);
1602
+ }
1603
+
1604
+ render() {
1605
+ const children = unwrapArray(this.props.children, noop);
1625
1606
  // because the items are rerendered every time we call the children
1626
1607
  // we clear this out each render and it will be populated again as
1627
1608
  // getItemProps is called.
@@ -1641,7 +1622,7 @@
1641
1622
  this.getLabelProps.called = false;
1642
1623
  // and something similar for getInputProps
1643
1624
  this.getInputProps.called = false;
1644
- var element = unwrapArray(children(this.getStateAndHelpers()));
1625
+ const element = unwrapArray(children(this.getStateAndHelpers()));
1645
1626
  if (!element) {
1646
1627
  return null;
1647
1628
  }
@@ -1663,14 +1644,13 @@
1663
1644
 
1664
1645
  throw new Error('downshift: If you return a non-DOM element, you must apply the getRootProps function');
1665
1646
  }
1666
- };
1667
- return Downshift;
1668
- }(preact.Component);
1647
+ }
1648
+ }
1669
1649
  Downshift.defaultProps = {
1670
1650
  defaultHighlightedIndex: null,
1671
1651
  defaultIsOpen: false,
1672
1652
  getA11yStatusMessage: getA11yStatusMessage$1,
1673
- itemToString: function itemToString(i) {
1653
+ itemToString: i => {
1674
1654
  if (i == null) {
1675
1655
  return '';
1676
1656
  }
@@ -1686,76 +1666,81 @@
1686
1666
  onChange: noop,
1687
1667
  onSelect: noop,
1688
1668
  onOuterClick: noop,
1689
- selectedItemChanged: function selectedItemChanged(prevItem, item) {
1690
- return prevItem !== item;
1691
- },
1669
+ selectedItemChanged: (prevItem, item) => prevItem !== item,
1692
1670
  environment: /* istanbul ignore next (ssr) */
1693
1671
  typeof window === 'undefined' ? {} : window,
1694
- stateReducer: function stateReducer(state, stateToSet) {
1695
- return stateToSet;
1696
- },
1672
+ stateReducer: (state, stateToSet) => stateToSet,
1697
1673
  suppressRefError: false,
1698
- scrollIntoView: scrollIntoView
1674
+ scrollIntoView
1699
1675
  };
1700
1676
  Downshift.stateChangeTypes = stateChangeTypes$3;
1701
1677
  return Downshift;
1702
- }();
1678
+ })();
1703
1679
  var Downshift$1 = Downshift;
1704
- function validateGetMenuPropsCalledCorrectly(node, _ref12) {
1705
- var refKey = _ref12.refKey;
1680
+ function validateGetMenuPropsCalledCorrectly(node, _ref3) {
1681
+ let {
1682
+ refKey
1683
+ } = _ref3;
1706
1684
  if (!node) {
1707
1685
  // eslint-disable-next-line no-console
1708
- console.error("downshift: The ref prop \"" + refKey + "\" from getMenuProps was not applied correctly on your menu element.");
1686
+ console.error(`downshift: The ref prop "${refKey}" from getMenuProps was not applied correctly on your menu element.`);
1709
1687
  }
1710
1688
  }
1711
- function validateGetRootPropsCalledCorrectly(element, _ref13) {
1712
- var refKey = _ref13.refKey;
1713
- var refKeySpecified = refKey !== 'ref';
1714
- var isComposite = !isDOMElement(element);
1689
+ function validateGetRootPropsCalledCorrectly(element, _ref4) {
1690
+ let {
1691
+ refKey
1692
+ } = _ref4;
1693
+ const refKeySpecified = refKey !== 'ref';
1694
+ const isComposite = !isDOMElement(element);
1715
1695
  if (isComposite && !refKeySpecified && !reactIs.exports.isForwardRef(element)) {
1716
1696
  // eslint-disable-next-line no-console
1717
1697
  console.error('downshift: You returned a non-DOM element. You must specify a refKey in getRootProps');
1718
1698
  } else if (!isComposite && refKeySpecified) {
1719
1699
  // eslint-disable-next-line no-console
1720
- console.error("downshift: You returned a DOM element. You should not specify a refKey in getRootProps. You specified \"" + refKey + "\"");
1700
+ console.error(`downshift: You returned a DOM element. You should not specify a refKey in getRootProps. You specified "${refKey}"`);
1721
1701
  }
1722
1702
  if (!reactIs.exports.isForwardRef(element) && !getElementProps(element)[refKey]) {
1723
1703
  // eslint-disable-next-line no-console
1724
- console.error("downshift: You must apply the ref prop \"" + refKey + "\" from getRootProps onto your root element.");
1704
+ console.error(`downshift: You must apply the ref prop "${refKey}" from getRootProps onto your root element.`);
1725
1705
  }
1726
1706
  }
1727
1707
 
1728
- var _excluded$3 = ["isInitialMount", "highlightedIndex", "items", "environment"];
1729
- var dropdownDefaultStateValues = {
1708
+ const dropdownDefaultStateValues = {
1730
1709
  highlightedIndex: -1,
1731
1710
  isOpen: false,
1732
1711
  selectedItem: null,
1733
1712
  inputValue: ''
1734
1713
  };
1735
1714
  function callOnChangeProps(action, state, newState) {
1736
- var props = action.props,
1737
- type = action.type;
1738
- var changes = {};
1739
- Object.keys(state).forEach(function (key) {
1715
+ const {
1716
+ props,
1717
+ type
1718
+ } = action;
1719
+ const changes = {};
1720
+ Object.keys(state).forEach(key => {
1740
1721
  invokeOnChangeHandler(key, action, state, newState);
1741
1722
  if (newState[key] !== state[key]) {
1742
1723
  changes[key] = newState[key];
1743
1724
  }
1744
1725
  });
1745
1726
  if (props.onStateChange && Object.keys(changes).length) {
1746
- props.onStateChange(_extends({
1747
- type: type
1748
- }, changes));
1727
+ props.onStateChange({
1728
+ type,
1729
+ ...changes
1730
+ });
1749
1731
  }
1750
1732
  }
1751
1733
  function invokeOnChangeHandler(key, action, state, newState) {
1752
- var props = action.props,
1753
- type = action.type;
1754
- var handler = "on" + capitalizeString(key) + "Change";
1734
+ const {
1735
+ props,
1736
+ type
1737
+ } = action;
1738
+ const handler = `on${capitalizeString(key)}Change`;
1755
1739
  if (props[handler] && newState[key] !== undefined && newState[key] !== state[key]) {
1756
- props[handler](_extends({
1757
- type: type
1758
- }, newState));
1740
+ props[handler]({
1741
+ type,
1742
+ ...newState
1743
+ });
1759
1744
  }
1760
1745
  }
1761
1746
 
@@ -1777,36 +1762,37 @@
1777
1762
  * @returns {string} The a11y message.
1778
1763
  */
1779
1764
  function getA11ySelectionMessage(selectionParameters) {
1780
- var selectedItem = selectionParameters.selectedItem,
1781
- itemToStringLocal = selectionParameters.itemToString;
1782
- return selectedItem ? itemToStringLocal(selectedItem) + " has been selected." : '';
1765
+ const {
1766
+ selectedItem,
1767
+ itemToString: itemToStringLocal
1768
+ } = selectionParameters;
1769
+ return selectedItem ? `${itemToStringLocal(selectedItem)} has been selected.` : '';
1783
1770
  }
1784
1771
 
1785
1772
  /**
1786
1773
  * Debounced call for updating the a11y message.
1787
1774
  */
1788
- var updateA11yStatus = debounce(function (getA11yMessage, document) {
1775
+ const updateA11yStatus = debounce((getA11yMessage, document) => {
1789
1776
  setStatus(getA11yMessage(), document);
1790
1777
  }, 200);
1791
1778
 
1792
1779
  // istanbul ignore next
1793
- var useIsomorphicLayoutEffect = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined' ? preact.useLayoutEffect : preact.useEffect;
1780
+ const useIsomorphicLayoutEffect = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined' ? preact.useLayoutEffect : preact.useEffect;
1794
1781
  function useElementIds(_ref) {
1795
- var _ref$id = _ref.id,
1796
- id = _ref$id === void 0 ? "downshift-" + generateId() : _ref$id,
1797
- labelId = _ref.labelId,
1798
- menuId = _ref.menuId,
1799
- getItemId = _ref.getItemId,
1800
- toggleButtonId = _ref.toggleButtonId,
1801
- inputId = _ref.inputId;
1802
- var elementIdsRef = preact.useRef({
1803
- labelId: labelId || id + "-label",
1804
- menuId: menuId || id + "-menu",
1805
- getItemId: getItemId || function (index) {
1806
- return id + "-item-" + index;
1807
- },
1808
- toggleButtonId: toggleButtonId || id + "-toggle-button",
1809
- inputId: inputId || id + "-input"
1782
+ let {
1783
+ id = `downshift-${generateId()}`,
1784
+ labelId,
1785
+ menuId,
1786
+ getItemId,
1787
+ toggleButtonId,
1788
+ inputId
1789
+ } = _ref;
1790
+ const elementIdsRef = preact.useRef({
1791
+ labelId: labelId || `${id}-label`,
1792
+ menuId: menuId || `${id}-menu`,
1793
+ getItemId: getItemId || (index => `${id}-item-${index}`),
1794
+ toggleButtonId: toggleButtonId || `${id}-toggle-button`,
1795
+ inputId: inputId || `${id}-input`
1810
1796
  });
1811
1797
  return elementIdsRef.current;
1812
1798
  }
@@ -1826,10 +1812,10 @@
1826
1812
  return /^\S{1}$/.test(key);
1827
1813
  }
1828
1814
  function capitalizeString(string) {
1829
- return "" + string.slice(0, 1).toUpperCase() + string.slice(1);
1815
+ return `${string.slice(0, 1).toUpperCase()}${string.slice(1)}`;
1830
1816
  }
1831
1817
  function useLatestRef(val) {
1832
- var ref = preact.useRef(val);
1818
+ const ref = preact.useRef(val);
1833
1819
  // technically this is not "concurrent mode safe" because we're manipulating
1834
1820
  // the value during render (so it's not idempotent). However, the places this
1835
1821
  // hook is used is to support memoizing callbacks which will be called
@@ -1850,28 +1836,26 @@
1850
1836
  * @returns {Array} An array with the state and an action dispatcher.
1851
1837
  */
1852
1838
  function useEnhancedReducer(reducer, initialState, props) {
1853
- var prevStateRef = preact.useRef();
1854
- var actionRef = preact.useRef();
1855
- var enhancedReducer = preact.useCallback(function (state, action) {
1839
+ const prevStateRef = preact.useRef();
1840
+ const actionRef = preact.useRef();
1841
+ const enhancedReducer = preact.useCallback((state, action) => {
1856
1842
  actionRef.current = action;
1857
1843
  state = getState(state, action.props);
1858
- var changes = reducer(state, action);
1859
- var newState = action.props.stateReducer(state, _extends({}, action, {
1860
- changes: changes
1861
- }));
1844
+ const changes = reducer(state, action);
1845
+ const newState = action.props.stateReducer(state, {
1846
+ ...action,
1847
+ changes
1848
+ });
1862
1849
  return newState;
1863
1850
  }, [reducer]);
1864
- var _useReducer = preact.useReducer(enhancedReducer, initialState),
1865
- state = _useReducer[0],
1866
- dispatch = _useReducer[1];
1867
- var propsRef = useLatestRef(props);
1868
- var dispatchWithProps = preact.useCallback(function (action) {
1869
- return dispatch(_extends({
1870
- props: propsRef.current
1871
- }, action));
1872
- }, [propsRef]);
1873
- var action = actionRef.current;
1874
- preact.useEffect(function () {
1851
+ const [state, dispatch] = preact.useReducer(enhancedReducer, initialState);
1852
+ const propsRef = useLatestRef(props);
1853
+ const dispatchWithProps = preact.useCallback(action => dispatch({
1854
+ props: propsRef.current,
1855
+ ...action
1856
+ }), [propsRef]);
1857
+ const action = actionRef.current;
1858
+ preact.useEffect(() => {
1875
1859
  if (action && prevStateRef.current && prevStateRef.current !== state) {
1876
1860
  callOnChangeProps(action, getState(prevStateRef.current, action.props), state);
1877
1861
  }
@@ -1890,16 +1874,14 @@
1890
1874
  * @returns {Array} An array with the state and an action dispatcher.
1891
1875
  */
1892
1876
  function useControlledReducer$1(reducer, initialState, props) {
1893
- var _useEnhancedReducer = useEnhancedReducer(reducer, initialState, props),
1894
- state = _useEnhancedReducer[0],
1895
- dispatch = _useEnhancedReducer[1];
1877
+ const [state, dispatch] = useEnhancedReducer(reducer, initialState, props);
1896
1878
  return [getState(state, props), dispatch];
1897
1879
  }
1898
- var defaultProps$3 = {
1899
- itemToString: itemToString,
1900
- stateReducer: stateReducer,
1901
- getA11ySelectionMessage: getA11ySelectionMessage,
1902
- scrollIntoView: scrollIntoView,
1880
+ const defaultProps$3 = {
1881
+ itemToString,
1882
+ stateReducer,
1883
+ getA11ySelectionMessage,
1884
+ scrollIntoView,
1903
1885
  environment: /* istanbul ignore next (ssr) */
1904
1886
  typeof window === 'undefined' ? {} : window
1905
1887
  };
@@ -1907,7 +1889,7 @@
1907
1889
  if (defaultStateValues === void 0) {
1908
1890
  defaultStateValues = dropdownDefaultStateValues;
1909
1891
  }
1910
- var defaultValue = props["default" + capitalizeString(propKey)];
1892
+ const defaultValue = props[`default${capitalizeString(propKey)}`];
1911
1893
  if (defaultValue !== undefined) {
1912
1894
  return defaultValue;
1913
1895
  }
@@ -1917,34 +1899,38 @@
1917
1899
  if (defaultStateValues === void 0) {
1918
1900
  defaultStateValues = dropdownDefaultStateValues;
1919
1901
  }
1920
- var value = props[propKey];
1902
+ const value = props[propKey];
1921
1903
  if (value !== undefined) {
1922
1904
  return value;
1923
1905
  }
1924
- var initialValue = props["initial" + capitalizeString(propKey)];
1906
+ const initialValue = props[`initial${capitalizeString(propKey)}`];
1925
1907
  if (initialValue !== undefined) {
1926
1908
  return initialValue;
1927
1909
  }
1928
1910
  return getDefaultValue$1(props, propKey, defaultStateValues);
1929
1911
  }
1930
1912
  function getInitialState$2(props) {
1931
- var selectedItem = getInitialValue$1(props, 'selectedItem');
1932
- var isOpen = getInitialValue$1(props, 'isOpen');
1933
- var highlightedIndex = getInitialValue$1(props, 'highlightedIndex');
1934
- var inputValue = getInitialValue$1(props, 'inputValue');
1913
+ const selectedItem = getInitialValue$1(props, 'selectedItem');
1914
+ const isOpen = getInitialValue$1(props, 'isOpen');
1915
+ const highlightedIndex = getInitialValue$1(props, 'highlightedIndex');
1916
+ const inputValue = getInitialValue$1(props, 'inputValue');
1935
1917
  return {
1936
1918
  highlightedIndex: highlightedIndex < 0 && selectedItem && isOpen ? props.items.indexOf(selectedItem) : highlightedIndex,
1937
- isOpen: isOpen,
1938
- selectedItem: selectedItem,
1939
- inputValue: inputValue
1919
+ isOpen,
1920
+ selectedItem,
1921
+ inputValue
1940
1922
  };
1941
1923
  }
1942
1924
  function getHighlightedIndexOnOpen(props, state, offset) {
1943
- var items = props.items,
1944
- initialHighlightedIndex = props.initialHighlightedIndex,
1945
- defaultHighlightedIndex = props.defaultHighlightedIndex;
1946
- var selectedItem = state.selectedItem,
1947
- highlightedIndex = state.highlightedIndex;
1925
+ const {
1926
+ items,
1927
+ initialHighlightedIndex,
1928
+ defaultHighlightedIndex
1929
+ } = props;
1930
+ const {
1931
+ selectedItem,
1932
+ highlightedIndex
1933
+ } = state;
1948
1934
  if (items.length === 0) {
1949
1935
  return -1;
1950
1936
  }
@@ -1975,34 +1961,30 @@
1975
1961
  * @returns {Object} Ref containing whether mouseDown or touchMove event is happening
1976
1962
  */
1977
1963
  function useMouseAndTouchTracker(isOpen, downshiftElementRefs, environment, handleBlur) {
1978
- var mouseAndTouchTrackersRef = preact.useRef({
1964
+ const mouseAndTouchTrackersRef = preact.useRef({
1979
1965
  isMouseDown: false,
1980
1966
  isTouchMove: false
1981
1967
  });
1982
- preact.useEffect(function () {
1968
+ preact.useEffect(() => {
1983
1969
  // The same strategy for checking if a click occurred inside or outside downsift
1984
1970
  // as in downshift.js.
1985
- var onMouseDown = function onMouseDown() {
1971
+ const onMouseDown = () => {
1986
1972
  mouseAndTouchTrackersRef.current.isMouseDown = true;
1987
1973
  };
1988
- var onMouseUp = function onMouseUp(event) {
1974
+ const onMouseUp = event => {
1989
1975
  mouseAndTouchTrackersRef.current.isMouseDown = false;
1990
- if (isOpen && !targetWithinDownshift(event.target, downshiftElementRefs.map(function (ref) {
1991
- return ref.current;
1992
- }), environment)) {
1976
+ if (isOpen && !targetWithinDownshift(event.target, downshiftElementRefs.map(ref => ref.current), environment)) {
1993
1977
  handleBlur();
1994
1978
  }
1995
1979
  };
1996
- var onTouchStart = function onTouchStart() {
1980
+ const onTouchStart = () => {
1997
1981
  mouseAndTouchTrackersRef.current.isTouchMove = false;
1998
1982
  };
1999
- var onTouchMove = function onTouchMove() {
1983
+ const onTouchMove = () => {
2000
1984
  mouseAndTouchTrackersRef.current.isTouchMove = true;
2001
1985
  };
2002
- var onTouchEnd = function onTouchEnd(event) {
2003
- if (isOpen && !mouseAndTouchTrackersRef.current.isTouchMove && !targetWithinDownshift(event.target, downshiftElementRefs.map(function (ref) {
2004
- return ref.current;
2005
- }), environment, false)) {
1986
+ const onTouchEnd = event => {
1987
+ if (isOpen && !mouseAndTouchTrackersRef.current.isTouchMove && !targetWithinDownshift(event.target, downshiftElementRefs.map(ref => ref.current), environment, false)) {
2006
1988
  handleBlur();
2007
1989
  }
2008
1990
  };
@@ -2025,9 +2007,7 @@
2025
2007
 
2026
2008
  /* istanbul ignore next */
2027
2009
  // eslint-disable-next-line import/no-mutable-exports
2028
- var useGetterPropsCalledChecker = function useGetterPropsCalledChecker() {
2029
- return noop;
2030
- };
2010
+ let useGetterPropsCalledChecker = () => noop;
2031
2011
  /**
2032
2012
  * Custom hook that checks if getter props are called correctly.
2033
2013
  *
@@ -2036,77 +2016,82 @@
2036
2016
  */
2037
2017
  /* istanbul ignore next */
2038
2018
  {
2039
- useGetterPropsCalledChecker = function useGetterPropsCalledChecker() {
2040
- var isInitialMountRef = preact.useRef(true);
2019
+ useGetterPropsCalledChecker = function () {
2020
+ const isInitialMountRef = preact.useRef(true);
2041
2021
  for (var _len = arguments.length, propKeys = new Array(_len), _key = 0; _key < _len; _key++) {
2042
2022
  propKeys[_key] = arguments[_key];
2043
2023
  }
2044
- var getterPropsCalledRef = preact.useRef(propKeys.reduce(function (acc, propKey) {
2024
+ const getterPropsCalledRef = preact.useRef(propKeys.reduce((acc, propKey) => {
2045
2025
  acc[propKey] = {};
2046
2026
  return acc;
2047
2027
  }, {}));
2048
- preact.useEffect(function () {
2049
- Object.keys(getterPropsCalledRef.current).forEach(function (propKey) {
2050
- var propCallInfo = getterPropsCalledRef.current[propKey];
2028
+ preact.useEffect(() => {
2029
+ Object.keys(getterPropsCalledRef.current).forEach(propKey => {
2030
+ const propCallInfo = getterPropsCalledRef.current[propKey];
2051
2031
  if (isInitialMountRef.current) {
2052
2032
  if (!Object.keys(propCallInfo).length) {
2053
2033
  // eslint-disable-next-line no-console
2054
- console.error("downshift: You forgot to call the " + propKey + " getter function on your component / element.");
2034
+ console.error(`downshift: You forgot to call the ${propKey} getter function on your component / element.`);
2055
2035
  return;
2056
2036
  }
2057
2037
  }
2058
- var suppressRefError = propCallInfo.suppressRefError,
2059
- refKey = propCallInfo.refKey,
2060
- elementRef = propCallInfo.elementRef;
2038
+ const {
2039
+ suppressRefError,
2040
+ refKey,
2041
+ elementRef
2042
+ } = propCallInfo;
2061
2043
  if ((!elementRef || !elementRef.current) && !suppressRefError) {
2062
2044
  // eslint-disable-next-line no-console
2063
- console.error("downshift: The ref prop \"" + refKey + "\" from " + propKey + " was not applied correctly on your element.");
2045
+ console.error(`downshift: The ref prop "${refKey}" from ${propKey} was not applied correctly on your element.`);
2064
2046
  }
2065
2047
  });
2066
2048
  isInitialMountRef.current = false;
2067
2049
  });
2068
- var setGetterPropCallInfo = preact.useCallback(function (propKey, suppressRefError, refKey, elementRef) {
2050
+ const setGetterPropCallInfo = preact.useCallback((propKey, suppressRefError, refKey, elementRef) => {
2069
2051
  getterPropsCalledRef.current[propKey] = {
2070
- suppressRefError: suppressRefError,
2071
- refKey: refKey,
2072
- elementRef: elementRef
2052
+ suppressRefError,
2053
+ refKey,
2054
+ elementRef
2073
2055
  };
2074
2056
  }, []);
2075
2057
  return setGetterPropCallInfo;
2076
2058
  };
2077
2059
  }
2078
2060
  function useA11yMessageSetter(getA11yMessage, dependencyArray, _ref2) {
2079
- var isInitialMount = _ref2.isInitialMount,
2080
- highlightedIndex = _ref2.highlightedIndex,
2081
- items = _ref2.items,
2082
- environment = _ref2.environment,
2083
- rest = _objectWithoutPropertiesLoose(_ref2, _excluded$3);
2061
+ let {
2062
+ isInitialMount,
2063
+ highlightedIndex,
2064
+ items,
2065
+ environment,
2066
+ ...rest
2067
+ } = _ref2;
2084
2068
  // Sets a11y status message on changes in state.
2085
- preact.useEffect(function () {
2069
+ preact.useEffect(() => {
2086
2070
  if (isInitialMount || false) {
2087
2071
  return;
2088
2072
  }
2089
- updateA11yStatus(function () {
2090
- return getA11yMessage(_extends({
2091
- highlightedIndex: highlightedIndex,
2092
- highlightedItem: items[highlightedIndex],
2093
- resultCount: items.length
2094
- }, rest));
2095
- }, environment.document);
2073
+ updateA11yStatus(() => getA11yMessage({
2074
+ highlightedIndex,
2075
+ highlightedItem: items[highlightedIndex],
2076
+ resultCount: items.length,
2077
+ ...rest
2078
+ }), environment.document);
2096
2079
  // eslint-disable-next-line react-hooks/exhaustive-deps
2097
2080
  }, dependencyArray);
2098
2081
  }
2099
2082
  function useScrollIntoView(_ref3) {
2100
- var highlightedIndex = _ref3.highlightedIndex,
2101
- isOpen = _ref3.isOpen,
2102
- itemRefs = _ref3.itemRefs,
2103
- getItemNodeFromIndex = _ref3.getItemNodeFromIndex,
2104
- menuElement = _ref3.menuElement,
2105
- scrollIntoViewProp = _ref3.scrollIntoView;
2083
+ let {
2084
+ highlightedIndex,
2085
+ isOpen,
2086
+ itemRefs,
2087
+ getItemNodeFromIndex,
2088
+ menuElement,
2089
+ scrollIntoView: scrollIntoViewProp
2090
+ } = _ref3;
2106
2091
  // used not to scroll on highlight by mouse.
2107
- var shouldScrollRef = preact.useRef(true);
2092
+ const shouldScrollRef = preact.useRef(true);
2108
2093
  // Scroll on highlighted item if change comes from keyboard.
2109
- useIsomorphicLayoutEffect(function () {
2094
+ useIsomorphicLayoutEffect(() => {
2110
2095
  if (highlightedIndex < 0 || !isOpen || !Object.keys(itemRefs.current).length) {
2111
2096
  return;
2112
2097
  }
@@ -2121,16 +2106,18 @@
2121
2106
  }
2122
2107
 
2123
2108
  // eslint-disable-next-line import/no-mutable-exports
2124
- var useControlPropsValidator = noop;
2109
+ let useControlPropsValidator = noop;
2125
2110
  /* istanbul ignore next */
2126
2111
  {
2127
- useControlPropsValidator = function useControlPropsValidator(_ref4) {
2128
- var isInitialMount = _ref4.isInitialMount,
2129
- props = _ref4.props,
2130
- state = _ref4.state;
2112
+ useControlPropsValidator = _ref4 => {
2113
+ let {
2114
+ isInitialMount,
2115
+ props,
2116
+ state
2117
+ } = _ref4;
2131
2118
  // used for checking when props are moving from controlled to uncontrolled.
2132
- var prevPropsRef = preact.useRef(props);
2133
- preact.useEffect(function () {
2119
+ const prevPropsRef = preact.useRef(props);
2120
+ preact.useEffect(() => {
2134
2121
  if (isInitialMount) {
2135
2122
  return;
2136
2123
  }
@@ -2141,9 +2128,11 @@
2141
2128
  }
2142
2129
 
2143
2130
  function downshiftCommonReducer(state, action, stateChangeTypes) {
2144
- var type = action.type,
2145
- props = action.props;
2146
- var changes;
2131
+ const {
2132
+ type,
2133
+ props
2134
+ } = action;
2135
+ let changes;
2147
2136
  switch (type) {
2148
2137
  case stateChangeTypes.ItemMouseMove:
2149
2138
  changes = {
@@ -2194,7 +2183,10 @@
2194
2183
  default:
2195
2184
  throw new Error('Reducer called without proper action type.');
2196
2185
  }
2197
- return _extends({}, state, changes);
2186
+ return {
2187
+ ...state,
2188
+ ...changes
2189
+ };
2198
2190
  }
2199
2191
  /* eslint-enable complexity */
2200
2192
 
@@ -2306,28 +2298,28 @@
2306
2298
  };
2307
2299
  }
2308
2300
 
2309
- var ToggleButtonClick$1 = '__togglebutton_click__' ;
2310
- var ToggleButtonKeyDownArrowDown = '__togglebutton_keydown_arrow_down__' ;
2311
- var ToggleButtonKeyDownArrowUp = '__togglebutton_keydown_arrow_up__' ;
2312
- var ToggleButtonKeyDownCharacter = '__togglebutton_keydown_character__' ;
2313
- var ToggleButtonKeyDownEscape = '__togglebutton_keydown_escape__' ;
2314
- var ToggleButtonKeyDownHome = '__togglebutton_keydown_home__' ;
2315
- var ToggleButtonKeyDownEnd = '__togglebutton_keydown_end__' ;
2316
- var ToggleButtonKeyDownEnter = '__togglebutton_keydown_enter__' ;
2317
- var ToggleButtonKeyDownSpaceButton = '__togglebutton_keydown_space_button__' ;
2318
- var ToggleButtonKeyDownPageUp = '__togglebutton_keydown_page_up__' ;
2319
- var ToggleButtonKeyDownPageDown = '__togglebutton_keydown_page_down__' ;
2320
- var ToggleButtonBlur = '__togglebutton_blur__' ;
2321
- var MenuMouseLeave$1 = '__menu_mouse_leave__' ;
2322
- var ItemMouseMove$1 = '__item_mouse_move__' ;
2323
- var ItemClick$1 = '__item_click__' ;
2324
- var FunctionToggleMenu$1 = '__function_toggle_menu__' ;
2325
- var FunctionOpenMenu$1 = '__function_open_menu__' ;
2326
- var FunctionCloseMenu$1 = '__function_close_menu__' ;
2327
- var FunctionSetHighlightedIndex$1 = '__function_set_highlighted_index__' ;
2328
- var FunctionSelectItem$1 = '__function_select_item__' ;
2329
- var FunctionSetInputValue$1 = '__function_set_input_value__' ;
2330
- var FunctionReset$2 = '__function_reset__' ;
2301
+ const ToggleButtonClick$1 = '__togglebutton_click__' ;
2302
+ const ToggleButtonKeyDownArrowDown = '__togglebutton_keydown_arrow_down__' ;
2303
+ const ToggleButtonKeyDownArrowUp = '__togglebutton_keydown_arrow_up__' ;
2304
+ const ToggleButtonKeyDownCharacter = '__togglebutton_keydown_character__' ;
2305
+ const ToggleButtonKeyDownEscape = '__togglebutton_keydown_escape__' ;
2306
+ const ToggleButtonKeyDownHome = '__togglebutton_keydown_home__' ;
2307
+ const ToggleButtonKeyDownEnd = '__togglebutton_keydown_end__' ;
2308
+ const ToggleButtonKeyDownEnter = '__togglebutton_keydown_enter__' ;
2309
+ const ToggleButtonKeyDownSpaceButton = '__togglebutton_keydown_space_button__' ;
2310
+ const ToggleButtonKeyDownPageUp = '__togglebutton_keydown_page_up__' ;
2311
+ const ToggleButtonKeyDownPageDown = '__togglebutton_keydown_page_down__' ;
2312
+ const ToggleButtonBlur = '__togglebutton_blur__' ;
2313
+ const MenuMouseLeave$1 = '__menu_mouse_leave__' ;
2314
+ const ItemMouseMove$1 = '__item_mouse_move__' ;
2315
+ const ItemClick$1 = '__item_click__' ;
2316
+ const FunctionToggleMenu$1 = '__function_toggle_menu__' ;
2317
+ const FunctionOpenMenu$1 = '__function_open_menu__' ;
2318
+ const FunctionCloseMenu$1 = '__function_close_menu__' ;
2319
+ const FunctionSetHighlightedIndex$1 = '__function_set_highlighted_index__' ;
2320
+ const FunctionSelectItem$1 = '__function_select_item__' ;
2321
+ const FunctionSetInputValue$1 = '__function_set_input_value__' ;
2322
+ const FunctionReset$2 = '__function_reset__' ;
2331
2323
 
2332
2324
  var stateChangeTypes$2 = /*#__PURE__*/Object.freeze({
2333
2325
  __proto__: null,
@@ -2357,10 +2349,12 @@
2357
2349
 
2358
2350
  /* eslint-disable complexity */
2359
2351
  function downshiftSelectReducer(state, action) {
2360
- var type = action.type,
2361
- props = action.props,
2362
- altKey = action.altKey;
2363
- var changes;
2352
+ const {
2353
+ type,
2354
+ props,
2355
+ altKey
2356
+ } = action;
2357
+ let changes;
2364
2358
  switch (type) {
2365
2359
  case ItemClick$1:
2366
2360
  changes = {
@@ -2371,10 +2365,10 @@
2371
2365
  break;
2372
2366
  case ToggleButtonKeyDownCharacter:
2373
2367
  {
2374
- var lowercasedKey = action.key;
2375
- var inputValue = "" + state.inputValue + lowercasedKey;
2376
- var prevHighlightedIndex = !state.isOpen && state.selectedItem ? props.items.indexOf(state.selectedItem) : state.highlightedIndex;
2377
- var highlightedIndex = getItemIndexByCharacterKey({
2368
+ const lowercasedKey = action.key;
2369
+ const inputValue = `${state.inputValue}${lowercasedKey}`;
2370
+ const prevHighlightedIndex = !state.isOpen && state.selectedItem ? props.items.indexOf(state.selectedItem) : state.highlightedIndex;
2371
+ const highlightedIndex = getItemIndexByCharacterKey({
2378
2372
  keysSoFar: inputValue,
2379
2373
  highlightedIndex: prevHighlightedIndex,
2380
2374
  items: props.items,
@@ -2382,33 +2376,34 @@
2382
2376
  getItemNodeFromIndex: action.getItemNodeFromIndex
2383
2377
  });
2384
2378
  changes = {
2385
- inputValue: inputValue,
2386
- highlightedIndex: highlightedIndex,
2379
+ inputValue,
2380
+ highlightedIndex,
2387
2381
  isOpen: true
2388
2382
  };
2389
2383
  }
2390
2384
  break;
2391
2385
  case ToggleButtonKeyDownArrowDown:
2392
2386
  {
2393
- var _highlightedIndex = state.isOpen ? getNextWrappingIndex(1, state.highlightedIndex, props.items.length, action.getItemNodeFromIndex, false) : altKey && state.selectedItem == null ? -1 : getHighlightedIndexOnOpen(props, state, 1);
2387
+ const highlightedIndex = state.isOpen ? getNextWrappingIndex(1, state.highlightedIndex, props.items.length, action.getItemNodeFromIndex, false) : altKey && state.selectedItem == null ? -1 : getHighlightedIndexOnOpen(props, state, 1);
2394
2388
  changes = {
2395
- highlightedIndex: _highlightedIndex,
2389
+ highlightedIndex,
2396
2390
  isOpen: true
2397
2391
  };
2398
2392
  }
2399
2393
  break;
2400
2394
  case ToggleButtonKeyDownArrowUp:
2401
2395
  if (state.isOpen && altKey) {
2402
- changes = _extends({
2396
+ changes = {
2403
2397
  isOpen: getDefaultValue$1(props, 'isOpen'),
2404
- highlightedIndex: getDefaultValue$1(props, 'highlightedIndex')
2405
- }, state.highlightedIndex >= 0 && {
2406
- selectedItem: props.items[state.highlightedIndex]
2407
- });
2398
+ highlightedIndex: getDefaultValue$1(props, 'highlightedIndex'),
2399
+ ...(state.highlightedIndex >= 0 && {
2400
+ selectedItem: props.items[state.highlightedIndex]
2401
+ })
2402
+ };
2408
2403
  } else {
2409
- var _highlightedIndex2 = state.isOpen ? getNextWrappingIndex(-1, state.highlightedIndex, props.items.length, action.getItemNodeFromIndex, false) : getHighlightedIndexOnOpen(props, state, -1);
2404
+ const highlightedIndex = state.isOpen ? getNextWrappingIndex(-1, state.highlightedIndex, props.items.length, action.getItemNodeFromIndex, false) : getHighlightedIndexOnOpen(props, state, -1);
2410
2405
  changes = {
2411
- highlightedIndex: _highlightedIndex2,
2406
+ highlightedIndex,
2412
2407
  isOpen: true
2413
2408
  };
2414
2409
  }
@@ -2416,12 +2411,13 @@
2416
2411
  // only triggered when menu is open.
2417
2412
  case ToggleButtonKeyDownEnter:
2418
2413
  case ToggleButtonKeyDownSpaceButton:
2419
- changes = _extends({
2414
+ changes = {
2420
2415
  isOpen: getDefaultValue$1(props, 'isOpen'),
2421
- highlightedIndex: getDefaultValue$1(props, 'highlightedIndex')
2422
- }, state.highlightedIndex >= 0 && {
2423
- selectedItem: props.items[state.highlightedIndex]
2424
- });
2416
+ highlightedIndex: getDefaultValue$1(props, 'highlightedIndex'),
2417
+ ...(state.highlightedIndex >= 0 && {
2418
+ selectedItem: props.items[state.highlightedIndex]
2419
+ })
2420
+ };
2425
2421
  break;
2426
2422
  case ToggleButtonKeyDownHome:
2427
2423
  changes = {
@@ -2452,12 +2448,13 @@
2452
2448
  };
2453
2449
  break;
2454
2450
  case ToggleButtonBlur:
2455
- changes = _extends({
2451
+ changes = {
2456
2452
  isOpen: false,
2457
- highlightedIndex: -1
2458
- }, state.highlightedIndex >= 0 && {
2459
- selectedItem: props.items[state.highlightedIndex]
2460
- });
2453
+ highlightedIndex: -1,
2454
+ ...(state.highlightedIndex >= 0 && {
2455
+ selectedItem: props.items[state.highlightedIndex]
2456
+ })
2457
+ };
2461
2458
  break;
2462
2459
  case FunctionSelectItem$1:
2463
2460
  changes = {
@@ -2467,13 +2464,13 @@
2467
2464
  default:
2468
2465
  return downshiftCommonReducer(state, action, stateChangeTypes$2);
2469
2466
  }
2470
- return _extends({}, state, changes);
2467
+ return {
2468
+ ...state,
2469
+ ...changes
2470
+ };
2471
2471
  }
2472
2472
  /* eslint-enable complexity */
2473
2473
 
2474
- var _excluded$2 = ["onMouseLeave", "refKey", "onKeyDown", "onBlur", "ref"],
2475
- _excluded2$2 = ["onBlur", "onClick", "onKeyDown", "refKey", "ref"],
2476
- _excluded3$1 = ["item", "index", "onMouseMove", "onClick", "refKey", "ref", "disabled"];
2477
2474
  useSelect.stateChangeTypes = stateChangeTypes$2;
2478
2475
  function useSelect(userProps) {
2479
2476
  if (userProps === void 0) {
@@ -2481,76 +2478,81 @@
2481
2478
  }
2482
2479
  validatePropTypes$2(userProps, useSelect);
2483
2480
  // Props defaults and destructuring.
2484
- var props = _extends({}, defaultProps$2, userProps);
2485
- var items = props.items,
2486
- scrollIntoView = props.scrollIntoView,
2487
- environment = props.environment,
2488
- itemToString = props.itemToString,
2489
- getA11ySelectionMessage = props.getA11ySelectionMessage,
2490
- getA11yStatusMessage = props.getA11yStatusMessage;
2481
+ const props = {
2482
+ ...defaultProps$2,
2483
+ ...userProps
2484
+ };
2485
+ const {
2486
+ items,
2487
+ scrollIntoView,
2488
+ environment,
2489
+ itemToString,
2490
+ getA11ySelectionMessage,
2491
+ getA11yStatusMessage
2492
+ } = props;
2491
2493
  // Initial state depending on controlled props.
2492
- var initialState = getInitialState$2(props);
2493
- var _useControlledReducer = useControlledReducer$1(downshiftSelectReducer, initialState, props),
2494
- state = _useControlledReducer[0],
2495
- dispatch = _useControlledReducer[1];
2496
- var isOpen = state.isOpen,
2497
- highlightedIndex = state.highlightedIndex,
2498
- selectedItem = state.selectedItem,
2499
- inputValue = state.inputValue;
2494
+ const initialState = getInitialState$2(props);
2495
+ const [state, dispatch] = useControlledReducer$1(downshiftSelectReducer, initialState, props);
2496
+ const {
2497
+ isOpen,
2498
+ highlightedIndex,
2499
+ selectedItem,
2500
+ inputValue
2501
+ } = state;
2500
2502
 
2501
2503
  // Element efs.
2502
- var toggleButtonRef = preact.useRef(null);
2503
- var menuRef = preact.useRef(null);
2504
- var itemRefs = preact.useRef({});
2504
+ const toggleButtonRef = preact.useRef(null);
2505
+ const menuRef = preact.useRef(null);
2506
+ const itemRefs = preact.useRef({});
2505
2507
  // used to keep the inputValue clearTimeout object between renders.
2506
- var clearTimeoutRef = preact.useRef(null);
2508
+ const clearTimeoutRef = preact.useRef(null);
2507
2509
  // prevent id re-generation between renders.
2508
- var elementIds = useElementIds(props);
2510
+ const elementIds = useElementIds(props);
2509
2511
  // used to keep track of how many items we had on previous cycle.
2510
- var previousResultCountRef = preact.useRef();
2511
- var isInitialMountRef = preact.useRef(true);
2512
+ const previousResultCountRef = preact.useRef();
2513
+ const isInitialMountRef = preact.useRef(true);
2512
2514
  // utility callback to get item element.
2513
- var latest = useLatestRef({
2514
- state: state,
2515
- props: props
2515
+ const latest = useLatestRef({
2516
+ state,
2517
+ props
2516
2518
  });
2517
2519
 
2518
2520
  // Some utils.
2519
- var getItemNodeFromIndex = preact.useCallback(function (index) {
2520
- return itemRefs.current[elementIds.getItemId(index)];
2521
- }, [elementIds]);
2521
+ const getItemNodeFromIndex = preact.useCallback(index => itemRefs.current[elementIds.getItemId(index)], [elementIds]);
2522
2522
 
2523
2523
  // Effects.
2524
2524
  // Sets a11y status message on changes in state.
2525
- useA11yMessageSetter(getA11yStatusMessage, [isOpen, highlightedIndex, inputValue, items], _extends({
2525
+ useA11yMessageSetter(getA11yStatusMessage, [isOpen, highlightedIndex, inputValue, items], {
2526
2526
  isInitialMount: isInitialMountRef.current,
2527
2527
  previousResultCount: previousResultCountRef.current,
2528
- items: items,
2529
- environment: environment,
2530
- itemToString: itemToString
2531
- }, state));
2528
+ items,
2529
+ environment,
2530
+ itemToString,
2531
+ ...state
2532
+ });
2532
2533
  // Sets a11y status message on changes in selectedItem.
2533
- useA11yMessageSetter(getA11ySelectionMessage, [selectedItem], _extends({
2534
+ useA11yMessageSetter(getA11ySelectionMessage, [selectedItem], {
2534
2535
  isInitialMount: isInitialMountRef.current,
2535
2536
  previousResultCount: previousResultCountRef.current,
2536
- items: items,
2537
- environment: environment,
2538
- itemToString: itemToString
2539
- }, state));
2537
+ items,
2538
+ environment,
2539
+ itemToString,
2540
+ ...state
2541
+ });
2540
2542
  // Scroll on highlighted item if change comes from keyboard.
2541
- var shouldScrollRef = useScrollIntoView({
2543
+ const shouldScrollRef = useScrollIntoView({
2542
2544
  menuElement: menuRef.current,
2543
- highlightedIndex: highlightedIndex,
2544
- isOpen: isOpen,
2545
- itemRefs: itemRefs,
2546
- scrollIntoView: scrollIntoView,
2547
- getItemNodeFromIndex: getItemNodeFromIndex
2545
+ highlightedIndex,
2546
+ isOpen,
2547
+ itemRefs,
2548
+ scrollIntoView,
2549
+ getItemNodeFromIndex
2548
2550
  });
2549
2551
 
2550
2552
  // Sets cleanup for the keysSoFar callback, debounded after 500ms.
2551
- preact.useEffect(function () {
2553
+ preact.useEffect(() => {
2552
2554
  // init the clean function here as we need access to dispatch.
2553
- clearTimeoutRef.current = debounce(function (outerDispatch) {
2555
+ clearTimeoutRef.current = debounce(outerDispatch => {
2554
2556
  outerDispatch({
2555
2557
  type: FunctionSetInputValue$1,
2556
2558
  inputValue: ''
@@ -2558,13 +2560,13 @@
2558
2560
  }, 500);
2559
2561
 
2560
2562
  // Cancel any pending debounced calls on mount
2561
- return function () {
2563
+ return () => {
2562
2564
  clearTimeoutRef.current.cancel();
2563
2565
  };
2564
2566
  }, []);
2565
2567
 
2566
2568
  // Invokes the keysSoFar callback set up above.
2567
- preact.useEffect(function () {
2569
+ preact.useEffect(() => {
2568
2570
  if (!inputValue) {
2569
2571
  return;
2570
2572
  }
@@ -2572,234 +2574,249 @@
2572
2574
  }, [dispatch, inputValue]);
2573
2575
  useControlPropsValidator({
2574
2576
  isInitialMount: isInitialMountRef.current,
2575
- props: props,
2576
- state: state
2577
+ props,
2578
+ state
2577
2579
  });
2578
- preact.useEffect(function () {
2580
+ preact.useEffect(() => {
2579
2581
  if (isInitialMountRef.current) {
2580
2582
  return;
2581
2583
  }
2582
2584
  previousResultCountRef.current = items.length;
2583
2585
  });
2584
2586
  // Add mouse/touch events to document.
2585
- var mouseAndTouchTrackersRef = useMouseAndTouchTracker(isOpen, [menuRef, toggleButtonRef], environment, function () {
2587
+ const mouseAndTouchTrackersRef = useMouseAndTouchTracker(isOpen, [menuRef, toggleButtonRef], environment, () => {
2586
2588
  dispatch({
2587
2589
  type: ToggleButtonBlur
2588
2590
  });
2589
2591
  });
2590
- var setGetterPropCallInfo = useGetterPropsCalledChecker('getMenuProps', 'getToggleButtonProps');
2592
+ const setGetterPropCallInfo = useGetterPropsCalledChecker('getMenuProps', 'getToggleButtonProps');
2591
2593
  // Make initial ref false.
2592
- preact.useEffect(function () {
2594
+ preact.useEffect(() => {
2593
2595
  isInitialMountRef.current = false;
2594
- return function () {
2596
+ return () => {
2595
2597
  isInitialMountRef.current = true;
2596
2598
  };
2597
2599
  }, []);
2598
2600
  // Reset itemRefs on close.
2599
- preact.useEffect(function () {
2601
+ preact.useEffect(() => {
2600
2602
  if (!isOpen) {
2601
2603
  itemRefs.current = {};
2602
2604
  }
2603
2605
  }, [isOpen]);
2604
2606
 
2605
2607
  // Event handler functions.
2606
- var toggleButtonKeyDownHandlers = preact.useMemo(function () {
2607
- return {
2608
- ArrowDown: function ArrowDown(event) {
2609
- event.preventDefault();
2608
+ const toggleButtonKeyDownHandlers = preact.useMemo(() => ({
2609
+ ArrowDown(event) {
2610
+ event.preventDefault();
2611
+ dispatch({
2612
+ type: ToggleButtonKeyDownArrowDown,
2613
+ getItemNodeFromIndex,
2614
+ altKey: event.altKey
2615
+ });
2616
+ },
2617
+ ArrowUp(event) {
2618
+ event.preventDefault();
2619
+ dispatch({
2620
+ type: ToggleButtonKeyDownArrowUp,
2621
+ getItemNodeFromIndex,
2622
+ altKey: event.altKey
2623
+ });
2624
+ },
2625
+ Home(event) {
2626
+ event.preventDefault();
2627
+ dispatch({
2628
+ type: ToggleButtonKeyDownHome,
2629
+ getItemNodeFromIndex
2630
+ });
2631
+ },
2632
+ End(event) {
2633
+ event.preventDefault();
2634
+ dispatch({
2635
+ type: ToggleButtonKeyDownEnd,
2636
+ getItemNodeFromIndex
2637
+ });
2638
+ },
2639
+ Escape() {
2640
+ if (latest.current.state.isOpen) {
2610
2641
  dispatch({
2611
- type: ToggleButtonKeyDownArrowDown,
2612
- getItemNodeFromIndex: getItemNodeFromIndex,
2613
- altKey: event.altKey
2642
+ type: ToggleButtonKeyDownEscape
2614
2643
  });
2615
- },
2616
- ArrowUp: function ArrowUp(event) {
2644
+ }
2645
+ },
2646
+ Enter(event) {
2647
+ event.preventDefault();
2648
+ dispatch({
2649
+ type: latest.current.state.isOpen ? ToggleButtonKeyDownEnter : ToggleButtonClick$1
2650
+ });
2651
+ },
2652
+ PageUp(event) {
2653
+ if (latest.current.state.isOpen) {
2617
2654
  event.preventDefault();
2618
2655
  dispatch({
2619
- type: ToggleButtonKeyDownArrowUp,
2620
- getItemNodeFromIndex: getItemNodeFromIndex,
2621
- altKey: event.altKey
2656
+ type: ToggleButtonKeyDownPageUp,
2657
+ getItemNodeFromIndex
2622
2658
  });
2623
- },
2624
- Home: function Home(event) {
2659
+ }
2660
+ },
2661
+ PageDown(event) {
2662
+ if (latest.current.state.isOpen) {
2625
2663
  event.preventDefault();
2626
2664
  dispatch({
2627
- type: ToggleButtonKeyDownHome,
2628
- getItemNodeFromIndex: getItemNodeFromIndex
2665
+ type: ToggleButtonKeyDownPageDown,
2666
+ getItemNodeFromIndex
2629
2667
  });
2630
- },
2631
- End: function End(event) {
2632
- event.preventDefault();
2668
+ }
2669
+ },
2670
+ ' '(event) {
2671
+ event.preventDefault();
2672
+ const currentState = latest.current.state;
2673
+ if (!currentState.isOpen) {
2633
2674
  dispatch({
2634
- type: ToggleButtonKeyDownEnd,
2635
- getItemNodeFromIndex: getItemNodeFromIndex
2675
+ type: ToggleButtonClick$1
2636
2676
  });
2637
- },
2638
- Escape: function Escape() {
2639
- if (latest.current.state.isOpen) {
2640
- dispatch({
2641
- type: ToggleButtonKeyDownEscape
2642
- });
2643
- }
2644
- },
2645
- Enter: function Enter(event) {
2646
- event.preventDefault();
2677
+ return;
2678
+ }
2679
+ if (currentState.inputValue) {
2647
2680
  dispatch({
2648
- type: latest.current.state.isOpen ? ToggleButtonKeyDownEnter : ToggleButtonClick$1
2681
+ type: ToggleButtonKeyDownCharacter,
2682
+ key: ' ',
2683
+ getItemNodeFromIndex
2684
+ });
2685
+ } else {
2686
+ dispatch({
2687
+ type: ToggleButtonKeyDownSpaceButton
2649
2688
  });
2650
- },
2651
- PageUp: function PageUp(event) {
2652
- if (latest.current.state.isOpen) {
2653
- event.preventDefault();
2654
- dispatch({
2655
- type: ToggleButtonKeyDownPageUp,
2656
- getItemNodeFromIndex: getItemNodeFromIndex
2657
- });
2658
- }
2659
- },
2660
- PageDown: function PageDown(event) {
2661
- if (latest.current.state.isOpen) {
2662
- event.preventDefault();
2663
- dispatch({
2664
- type: ToggleButtonKeyDownPageDown,
2665
- getItemNodeFromIndex: getItemNodeFromIndex
2666
- });
2667
- }
2668
- },
2669
- ' ': function _(event) {
2670
- event.preventDefault();
2671
- var currentState = latest.current.state;
2672
- if (!currentState.isOpen) {
2673
- dispatch({
2674
- type: ToggleButtonClick$1
2675
- });
2676
- return;
2677
- }
2678
- if (currentState.inputValue) {
2679
- dispatch({
2680
- type: ToggleButtonKeyDownCharacter,
2681
- key: ' ',
2682
- getItemNodeFromIndex: getItemNodeFromIndex
2683
- });
2684
- } else {
2685
- dispatch({
2686
- type: ToggleButtonKeyDownSpaceButton
2687
- });
2688
- }
2689
2689
  }
2690
- };
2691
- }, [dispatch, getItemNodeFromIndex, latest]);
2690
+ }
2691
+ }), [dispatch, getItemNodeFromIndex, latest]);
2692
2692
 
2693
2693
  // Action functions.
2694
- var toggleMenu = preact.useCallback(function () {
2694
+ const toggleMenu = preact.useCallback(() => {
2695
2695
  dispatch({
2696
2696
  type: FunctionToggleMenu$1
2697
2697
  });
2698
2698
  }, [dispatch]);
2699
- var closeMenu = preact.useCallback(function () {
2699
+ const closeMenu = preact.useCallback(() => {
2700
2700
  dispatch({
2701
2701
  type: FunctionCloseMenu$1
2702
2702
  });
2703
2703
  }, [dispatch]);
2704
- var openMenu = preact.useCallback(function () {
2704
+ const openMenu = preact.useCallback(() => {
2705
2705
  dispatch({
2706
2706
  type: FunctionOpenMenu$1
2707
2707
  });
2708
2708
  }, [dispatch]);
2709
- var setHighlightedIndex = preact.useCallback(function (newHighlightedIndex) {
2709
+ const setHighlightedIndex = preact.useCallback(newHighlightedIndex => {
2710
2710
  dispatch({
2711
2711
  type: FunctionSetHighlightedIndex$1,
2712
2712
  highlightedIndex: newHighlightedIndex
2713
2713
  });
2714
2714
  }, [dispatch]);
2715
- var selectItem = preact.useCallback(function (newSelectedItem) {
2715
+ const selectItem = preact.useCallback(newSelectedItem => {
2716
2716
  dispatch({
2717
2717
  type: FunctionSelectItem$1,
2718
2718
  selectedItem: newSelectedItem
2719
2719
  });
2720
2720
  }, [dispatch]);
2721
- var reset = preact.useCallback(function () {
2721
+ const reset = preact.useCallback(() => {
2722
2722
  dispatch({
2723
2723
  type: FunctionReset$2
2724
2724
  });
2725
2725
  }, [dispatch]);
2726
- var setInputValue = preact.useCallback(function (newInputValue) {
2726
+ const setInputValue = preact.useCallback(newInputValue => {
2727
2727
  dispatch({
2728
2728
  type: FunctionSetInputValue$1,
2729
2729
  inputValue: newInputValue
2730
2730
  });
2731
2731
  }, [dispatch]);
2732
2732
  // Getter functions.
2733
- var getLabelProps = preact.useCallback(function (labelProps) {
2734
- return _extends({
2735
- id: elementIds.labelId,
2736
- htmlFor: elementIds.toggleButtonId
2737
- }, labelProps);
2738
- }, [elementIds]);
2739
- var getMenuProps = preact.useCallback(function (_temp, _temp2) {
2740
- var _extends2;
2741
- var _ref = _temp === void 0 ? {} : _temp,
2742
- onMouseLeave = _ref.onMouseLeave,
2743
- _ref$refKey = _ref.refKey,
2744
- refKey = _ref$refKey === void 0 ? 'ref' : _ref$refKey;
2745
- _ref.onKeyDown;
2746
- _ref.onBlur;
2747
- var ref = _ref.ref,
2748
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$2);
2749
- var _ref2 = _temp2 === void 0 ? {} : _temp2,
2750
- _ref2$suppressRefErro = _ref2.suppressRefError,
2751
- suppressRefError = _ref2$suppressRefErro === void 0 ? false : _ref2$suppressRefErro;
2752
- var menuHandleMouseLeave = function menuHandleMouseLeave() {
2733
+ const getLabelProps = preact.useCallback(labelProps => ({
2734
+ id: elementIds.labelId,
2735
+ htmlFor: elementIds.toggleButtonId,
2736
+ ...labelProps
2737
+ }), [elementIds]);
2738
+ const getMenuProps = preact.useCallback(function (_temp, _temp2) {
2739
+ let {
2740
+ onMouseLeave,
2741
+ refKey = 'ref',
2742
+ onKeyDown,
2743
+ onBlur,
2744
+ ref,
2745
+ ...rest
2746
+ } = _temp === void 0 ? {} : _temp;
2747
+ let {
2748
+ suppressRefError = false
2749
+ } = _temp2 === void 0 ? {} : _temp2;
2750
+ const menuHandleMouseLeave = () => {
2753
2751
  dispatch({
2754
2752
  type: MenuMouseLeave$1
2755
2753
  });
2756
2754
  };
2757
2755
  setGetterPropCallInfo('getMenuProps', suppressRefError, refKey, menuRef);
2758
- return _extends((_extends2 = {}, _extends2[refKey] = handleRefs(ref, function (menuNode) {
2759
- menuRef.current = menuNode;
2760
- }), _extends2.id = elementIds.menuId, _extends2.role = 'listbox', _extends2['aria-labelledby'] = elementIds.labelId, _extends2.tabIndex = -1, _extends2.onMouseLeave = callAllEventHandlers(onMouseLeave, menuHandleMouseLeave), _extends2), rest);
2756
+ return {
2757
+ [refKey]: handleRefs(ref, menuNode => {
2758
+ menuRef.current = menuNode;
2759
+ }),
2760
+ id: elementIds.menuId,
2761
+ role: 'listbox',
2762
+ 'aria-labelledby': elementIds.labelId,
2763
+ tabIndex: -1,
2764
+ onMouseLeave: callAllEventHandlers(onMouseLeave, menuHandleMouseLeave),
2765
+ ...rest
2766
+ };
2761
2767
  }, [dispatch, setGetterPropCallInfo, elementIds]);
2762
- var getToggleButtonProps = preact.useCallback(function (_temp3, _temp4) {
2763
- var _extends3;
2764
- var _ref3 = _temp3 === void 0 ? {} : _temp3,
2765
- onBlur = _ref3.onBlur,
2766
- onClick = _ref3.onClick,
2767
- onKeyDown = _ref3.onKeyDown,
2768
- _ref3$refKey = _ref3.refKey,
2769
- refKey = _ref3$refKey === void 0 ? 'ref' : _ref3$refKey,
2770
- ref = _ref3.ref,
2771
- rest = _objectWithoutPropertiesLoose(_ref3, _excluded2$2);
2772
- var _ref4 = _temp4 === void 0 ? {} : _temp4,
2773
- _ref4$suppressRefErro = _ref4.suppressRefError,
2774
- suppressRefError = _ref4$suppressRefErro === void 0 ? false : _ref4$suppressRefErro;
2775
- var latestState = latest.current.state;
2776
- var toggleButtonHandleClick = function toggleButtonHandleClick() {
2768
+ const getToggleButtonProps = preact.useCallback(function (_temp3, _temp4) {
2769
+ let {
2770
+ onBlur,
2771
+ onClick,
2772
+ onKeyDown,
2773
+ refKey = 'ref',
2774
+ ref,
2775
+ ...rest
2776
+ } = _temp3 === void 0 ? {} : _temp3;
2777
+ let {
2778
+ suppressRefError = false
2779
+ } = _temp4 === void 0 ? {} : _temp4;
2780
+ const latestState = latest.current.state;
2781
+ const toggleButtonHandleClick = () => {
2777
2782
  dispatch({
2778
2783
  type: ToggleButtonClick$1
2779
2784
  });
2780
2785
  };
2781
- var toggleButtonHandleBlur = function toggleButtonHandleBlur() {
2786
+ const toggleButtonHandleBlur = () => {
2782
2787
  if (latestState.isOpen && !mouseAndTouchTrackersRef.current.isMouseDown) {
2783
2788
  dispatch({
2784
2789
  type: ToggleButtonBlur
2785
2790
  });
2786
2791
  }
2787
2792
  };
2788
- var toggleButtonHandleKeyDown = function toggleButtonHandleKeyDown(event) {
2789
- var key = normalizeArrowKey(event);
2793
+ const toggleButtonHandleKeyDown = event => {
2794
+ const key = normalizeArrowKey(event);
2790
2795
  if (key && toggleButtonKeyDownHandlers[key]) {
2791
2796
  toggleButtonKeyDownHandlers[key](event);
2792
2797
  } else if (isAcceptedCharacterKey(key)) {
2793
2798
  dispatch({
2794
2799
  type: ToggleButtonKeyDownCharacter,
2795
- key: key,
2796
- getItemNodeFromIndex: getItemNodeFromIndex
2800
+ key,
2801
+ getItemNodeFromIndex
2797
2802
  });
2798
2803
  }
2799
2804
  };
2800
- var toggleProps = _extends((_extends3 = {}, _extends3[refKey] = handleRefs(ref, function (toggleButtonNode) {
2801
- toggleButtonRef.current = toggleButtonNode;
2802
- }), _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);
2805
+ const toggleProps = {
2806
+ [refKey]: handleRefs(ref, toggleButtonNode => {
2807
+ toggleButtonRef.current = toggleButtonNode;
2808
+ }),
2809
+ 'aria-activedescendant': latestState.isOpen && latestState.highlightedIndex > -1 ? elementIds.getItemId(latestState.highlightedIndex) : '',
2810
+ 'aria-controls': elementIds.menuId,
2811
+ 'aria-expanded': latest.current.state.isOpen,
2812
+ 'aria-haspopup': 'listbox',
2813
+ 'aria-labelledby': `${elementIds.labelId}`,
2814
+ id: elementIds.toggleButtonId,
2815
+ role: 'combobox',
2816
+ tabIndex: 0,
2817
+ onBlur: callAllEventHandlers(onBlur, toggleButtonHandleBlur),
2818
+ ...rest
2819
+ };
2803
2820
  if (!rest.disabled) {
2804
2821
  toggleProps.onClick = callAllEventHandlers(onClick, toggleButtonHandleClick);
2805
2822
  toggleProps.onKeyDown = callAllEventHandlers(onKeyDown, toggleButtonHandleKeyDown);
@@ -2807,54 +2824,56 @@
2807
2824
  setGetterPropCallInfo('getToggleButtonProps', suppressRefError, refKey, toggleButtonRef);
2808
2825
  return toggleProps;
2809
2826
  }, [latest, elementIds, setGetterPropCallInfo, dispatch, mouseAndTouchTrackersRef, toggleButtonKeyDownHandlers, getItemNodeFromIndex]);
2810
- var getItemProps = preact.useCallback(function (_temp5) {
2811
- var _extends4;
2812
- var _ref5 = _temp5 === void 0 ? {} : _temp5,
2813
- itemProp = _ref5.item,
2814
- indexProp = _ref5.index,
2815
- onMouseMove = _ref5.onMouseMove,
2816
- onClick = _ref5.onClick,
2817
- _ref5$refKey = _ref5.refKey,
2818
- refKey = _ref5$refKey === void 0 ? 'ref' : _ref5$refKey,
2819
- ref = _ref5.ref,
2820
- disabled = _ref5.disabled,
2821
- rest = _objectWithoutPropertiesLoose(_ref5, _excluded3$1);
2822
- var _latest$current = latest.current,
2823
- latestState = _latest$current.state,
2824
- latestProps = _latest$current.props;
2825
- var item = itemProp != null ? itemProp : items[indexProp];
2826
- var index = getItemIndex(indexProp, item, latestProps.items);
2827
- var itemHandleMouseMove = function itemHandleMouseMove() {
2827
+ const getItemProps = preact.useCallback(function (_temp5) {
2828
+ let {
2829
+ item: itemProp,
2830
+ index: indexProp,
2831
+ onMouseMove,
2832
+ onClick,
2833
+ refKey = 'ref',
2834
+ ref,
2835
+ disabled,
2836
+ ...rest
2837
+ } = _temp5 === void 0 ? {} : _temp5;
2838
+ const {
2839
+ state: latestState,
2840
+ props: latestProps
2841
+ } = latest.current;
2842
+ const item = itemProp ?? items[indexProp];
2843
+ const index = getItemIndex(indexProp, item, latestProps.items);
2844
+ const itemHandleMouseMove = () => {
2828
2845
  if (index === latestState.highlightedIndex) {
2829
2846
  return;
2830
2847
  }
2831
2848
  shouldScrollRef.current = false;
2832
2849
  dispatch({
2833
2850
  type: ItemMouseMove$1,
2834
- index: index,
2835
- disabled: disabled
2851
+ index,
2852
+ disabled
2836
2853
  });
2837
2854
  };
2838
- var itemHandleClick = function itemHandleClick() {
2855
+ const itemHandleClick = () => {
2839
2856
  dispatch({
2840
2857
  type: ItemClick$1,
2841
- index: index
2858
+ index
2842
2859
  });
2843
2860
  };
2844
- var itemIndex = getItemIndex(index, item, latestProps.items);
2861
+ const itemIndex = getItemIndex(index, item, latestProps.items);
2845
2862
  if (itemIndex < 0) {
2846
2863
  throw new Error('Pass either item or item index in getItemProps!');
2847
2864
  }
2848
- var itemProps = _extends((_extends4 = {
2849
- disabled: disabled,
2865
+ const itemProps = {
2866
+ disabled,
2850
2867
  role: 'option',
2851
- 'aria-selected': "" + (item === selectedItem),
2852
- id: elementIds.getItemId(itemIndex)
2853
- }, _extends4[refKey] = handleRefs(ref, function (itemNode) {
2854
- if (itemNode) {
2855
- itemRefs.current[elementIds.getItemId(itemIndex)] = itemNode;
2856
- }
2857
- }), _extends4), rest);
2868
+ 'aria-selected': `${item === selectedItem}`,
2869
+ id: elementIds.getItemId(itemIndex),
2870
+ [refKey]: handleRefs(ref, itemNode => {
2871
+ if (itemNode) {
2872
+ itemRefs.current[elementIds.getItemId(itemIndex)] = itemNode;
2873
+ }
2874
+ }),
2875
+ ...rest
2876
+ };
2858
2877
  if (!disabled) {
2859
2878
  itemProps.onClick = callAllEventHandlers(onClick, itemHandleClick);
2860
2879
  }
@@ -2863,49 +2882,49 @@
2863
2882
  }, [latest, items, selectedItem, elementIds, shouldScrollRef, dispatch]);
2864
2883
  return {
2865
2884
  // prop getters.
2866
- getToggleButtonProps: getToggleButtonProps,
2867
- getLabelProps: getLabelProps,
2868
- getMenuProps: getMenuProps,
2869
- getItemProps: getItemProps,
2885
+ getToggleButtonProps,
2886
+ getLabelProps,
2887
+ getMenuProps,
2888
+ getItemProps,
2870
2889
  // actions.
2871
- toggleMenu: toggleMenu,
2872
- openMenu: openMenu,
2873
- closeMenu: closeMenu,
2874
- setHighlightedIndex: setHighlightedIndex,
2875
- selectItem: selectItem,
2876
- reset: reset,
2877
- setInputValue: setInputValue,
2890
+ toggleMenu,
2891
+ openMenu,
2892
+ closeMenu,
2893
+ setHighlightedIndex,
2894
+ selectItem,
2895
+ reset,
2896
+ setInputValue,
2878
2897
  // state.
2879
- highlightedIndex: highlightedIndex,
2880
- isOpen: isOpen,
2881
- selectedItem: selectedItem,
2882
- inputValue: inputValue
2898
+ highlightedIndex,
2899
+ isOpen,
2900
+ selectedItem,
2901
+ inputValue
2883
2902
  };
2884
2903
  }
2885
2904
 
2886
- var InputKeyDownArrowDown = '__input_keydown_arrow_down__' ;
2887
- var InputKeyDownArrowUp = '__input_keydown_arrow_up__' ;
2888
- var InputKeyDownEscape = '__input_keydown_escape__' ;
2889
- var InputKeyDownHome = '__input_keydown_home__' ;
2890
- var InputKeyDownEnd = '__input_keydown_end__' ;
2891
- var InputKeyDownPageUp = '__input_keydown_page_up__' ;
2892
- var InputKeyDownPageDown = '__input_keydown_page_down__' ;
2893
- var InputKeyDownEnter = '__input_keydown_enter__' ;
2894
- var InputChange = '__input_change__' ;
2895
- var InputBlur = '__input_blur__' ;
2896
- var InputFocus = '__input_focus__' ;
2897
- var MenuMouseLeave = '__menu_mouse_leave__' ;
2898
- var ItemMouseMove = '__item_mouse_move__' ;
2899
- var ItemClick = '__item_click__' ;
2900
- var ToggleButtonClick = '__togglebutton_click__' ;
2901
- var FunctionToggleMenu = '__function_toggle_menu__' ;
2902
- var FunctionOpenMenu = '__function_open_menu__' ;
2903
- var FunctionCloseMenu = '__function_close_menu__' ;
2904
- var FunctionSetHighlightedIndex = '__function_set_highlighted_index__' ;
2905
- var FunctionSelectItem = '__function_select_item__' ;
2906
- var FunctionSetInputValue = '__function_set_input_value__' ;
2907
- var FunctionReset$1 = '__function_reset__' ;
2908
- var ControlledPropUpdatedSelectedItem = '__controlled_prop_updated_selected_item__' ;
2905
+ const InputKeyDownArrowDown = '__input_keydown_arrow_down__' ;
2906
+ const InputKeyDownArrowUp = '__input_keydown_arrow_up__' ;
2907
+ const InputKeyDownEscape = '__input_keydown_escape__' ;
2908
+ const InputKeyDownHome = '__input_keydown_home__' ;
2909
+ const InputKeyDownEnd = '__input_keydown_end__' ;
2910
+ const InputKeyDownPageUp = '__input_keydown_page_up__' ;
2911
+ const InputKeyDownPageDown = '__input_keydown_page_down__' ;
2912
+ const InputKeyDownEnter = '__input_keydown_enter__' ;
2913
+ const InputChange = '__input_change__' ;
2914
+ const InputBlur = '__input_blur__' ;
2915
+ const InputFocus = '__input_focus__' ;
2916
+ const MenuMouseLeave = '__menu_mouse_leave__' ;
2917
+ const ItemMouseMove = '__item_mouse_move__' ;
2918
+ const ItemClick = '__item_click__' ;
2919
+ const ToggleButtonClick = '__togglebutton_click__' ;
2920
+ const FunctionToggleMenu = '__function_toggle_menu__' ;
2921
+ const FunctionOpenMenu = '__function_open_menu__' ;
2922
+ const FunctionCloseMenu = '__function_close_menu__' ;
2923
+ const FunctionSetHighlightedIndex = '__function_set_highlighted_index__' ;
2924
+ const FunctionSelectItem = '__function_select_item__' ;
2925
+ const FunctionSetInputValue = '__function_set_input_value__' ;
2926
+ const FunctionReset$1 = '__function_reset__' ;
2927
+ const ControlledPropUpdatedSelectedItem = '__controlled_prop_updated_selected_item__' ;
2909
2928
 
2910
2929
  var stateChangeTypes$1 = /*#__PURE__*/Object.freeze({
2911
2930
  __proto__: null,
@@ -2935,17 +2954,22 @@
2935
2954
  });
2936
2955
 
2937
2956
  function getInitialState$1(props) {
2938
- var initialState = getInitialState$2(props);
2939
- var selectedItem = initialState.selectedItem;
2940
- var inputValue = initialState.inputValue;
2957
+ const initialState = getInitialState$2(props);
2958
+ const {
2959
+ selectedItem
2960
+ } = initialState;
2961
+ let {
2962
+ inputValue
2963
+ } = initialState;
2941
2964
  if (inputValue === '' && selectedItem && props.defaultInputValue === undefined && props.initialInputValue === undefined && props.inputValue === undefined) {
2942
2965
  inputValue = props.itemToString(selectedItem);
2943
2966
  }
2944
- return _extends({}, initialState, {
2945
- inputValue: inputValue
2946
- });
2967
+ return {
2968
+ ...initialState,
2969
+ inputValue
2970
+ };
2947
2971
  }
2948
- var propTypes$1 = {
2972
+ const propTypes$1 = {
2949
2973
  items: PropTypes__default["default"].array.isRequired,
2950
2974
  itemToString: PropTypes__default["default"].func,
2951
2975
  getA11yStatusMessage: PropTypes__default["default"].func,
@@ -2998,13 +3022,11 @@
2998
3022
  * @returns {Array} An array with the state and an action dispatcher.
2999
3023
  */
3000
3024
  function useControlledReducer(reducer, initialState, props) {
3001
- var previousSelectedItemRef = preact.useRef();
3002
- var _useEnhancedReducer = useEnhancedReducer(reducer, initialState, props),
3003
- state = _useEnhancedReducer[0],
3004
- dispatch = _useEnhancedReducer[1];
3025
+ const previousSelectedItemRef = preact.useRef();
3026
+ const [state, dispatch] = useEnhancedReducer(reducer, initialState, props);
3005
3027
 
3006
3028
  // ToDo: if needed, make same approach as selectedItemChanged from Downshift.
3007
- preact.useEffect(function () {
3029
+ preact.useEffect(() => {
3008
3030
  if (isControlledProp(props, 'selectedItem')) {
3009
3031
  if (previousSelectedItemRef.current !== props.selectedItem) {
3010
3032
  dispatch({
@@ -3019,23 +3041,26 @@
3019
3041
  }
3020
3042
 
3021
3043
  // eslint-disable-next-line import/no-mutable-exports
3022
- var validatePropTypes$1 = noop;
3044
+ let validatePropTypes$1 = noop;
3023
3045
  /* istanbul ignore next */
3024
3046
  {
3025
- validatePropTypes$1 = function validatePropTypes(options, caller) {
3047
+ validatePropTypes$1 = (options, caller) => {
3026
3048
  PropTypes__default["default"].checkPropTypes(propTypes$1, options, 'prop', caller.name);
3027
3049
  };
3028
3050
  }
3029
- var defaultProps$1 = _extends({}, defaultProps$3, {
3051
+ const defaultProps$1 = {
3052
+ ...defaultProps$3,
3030
3053
  getA11yStatusMessage: getA11yStatusMessage$1
3031
- });
3054
+ };
3032
3055
 
3033
3056
  /* eslint-disable complexity */
3034
3057
  function downshiftUseComboboxReducer(state, action) {
3035
- var type = action.type,
3036
- props = action.props,
3037
- altKey = action.altKey;
3038
- var changes;
3058
+ const {
3059
+ type,
3060
+ props,
3061
+ altKey
3062
+ } = action;
3063
+ let changes;
3039
3064
  switch (type) {
3040
3065
  case ItemClick:
3041
3066
  changes = {
@@ -3060,13 +3085,14 @@
3060
3085
  case InputKeyDownArrowUp:
3061
3086
  if (state.isOpen) {
3062
3087
  if (altKey) {
3063
- changes = _extends({
3088
+ changes = {
3064
3089
  isOpen: getDefaultValue$1(props, 'isOpen'),
3065
- highlightedIndex: getDefaultValue$1(props, 'highlightedIndex')
3066
- }, state.highlightedIndex >= 0 && {
3067
- selectedItem: props.items[state.highlightedIndex],
3068
- inputValue: props.itemToString(props.items[state.highlightedIndex])
3069
- });
3090
+ highlightedIndex: getDefaultValue$1(props, 'highlightedIndex'),
3091
+ ...(state.highlightedIndex >= 0 && {
3092
+ selectedItem: props.items[state.highlightedIndex],
3093
+ inputValue: props.itemToString(props.items[state.highlightedIndex])
3094
+ })
3095
+ };
3070
3096
  } else {
3071
3097
  changes = {
3072
3098
  highlightedIndex: getNextWrappingIndex(-1, state.highlightedIndex, props.items.length, action.getItemNodeFromIndex, true)
@@ -3080,22 +3106,24 @@
3080
3106
  }
3081
3107
  break;
3082
3108
  case InputKeyDownEnter:
3083
- changes = _extends({
3109
+ changes = {
3084
3110
  isOpen: getDefaultValue$1(props, 'isOpen'),
3085
- highlightedIndex: getDefaultValue$1(props, 'highlightedIndex')
3086
- }, state.highlightedIndex >= 0 && {
3087
- selectedItem: props.items[state.highlightedIndex],
3088
- inputValue: props.itemToString(props.items[state.highlightedIndex])
3089
- });
3111
+ highlightedIndex: getDefaultValue$1(props, 'highlightedIndex'),
3112
+ ...(state.highlightedIndex >= 0 && {
3113
+ selectedItem: props.items[state.highlightedIndex],
3114
+ inputValue: props.itemToString(props.items[state.highlightedIndex])
3115
+ })
3116
+ };
3090
3117
  break;
3091
3118
  case InputKeyDownEscape:
3092
- changes = _extends({
3119
+ changes = {
3093
3120
  isOpen: false,
3094
- highlightedIndex: -1
3095
- }, !state.isOpen && {
3096
- selectedItem: null,
3097
- inputValue: ''
3098
- });
3121
+ highlightedIndex: -1,
3122
+ ...(!state.isOpen && {
3123
+ selectedItem: null,
3124
+ inputValue: ''
3125
+ })
3126
+ };
3099
3127
  break;
3100
3128
  case InputKeyDownPageUp:
3101
3129
  changes = {
@@ -3118,13 +3146,14 @@
3118
3146
  };
3119
3147
  break;
3120
3148
  case InputBlur:
3121
- changes = _extends({
3149
+ changes = {
3122
3150
  isOpen: false,
3123
- highlightedIndex: -1
3124
- }, state.highlightedIndex >= 0 && action.selectItem && {
3125
- selectedItem: props.items[state.highlightedIndex],
3126
- inputValue: props.itemToString(props.items[state.highlightedIndex])
3127
- });
3151
+ highlightedIndex: -1,
3152
+ ...(state.highlightedIndex >= 0 && action.selectItem && {
3153
+ selectedItem: props.items[state.highlightedIndex],
3154
+ inputValue: props.itemToString(props.items[state.highlightedIndex])
3155
+ })
3156
+ };
3128
3157
  break;
3129
3158
  case InputChange:
3130
3159
  changes = {
@@ -3153,14 +3182,14 @@
3153
3182
  default:
3154
3183
  return downshiftCommonReducer(state, action, stateChangeTypes$1);
3155
3184
  }
3156
- return _extends({}, state, changes);
3185
+ return {
3186
+ ...state,
3187
+ ...changes
3188
+ };
3157
3189
  }
3158
3190
  /* eslint-enable complexity */
3159
3191
 
3160
- var _excluded$1 = ["onMouseLeave", "refKey", "ref"],
3161
- _excluded2$1 = ["item", "index", "refKey", "ref", "onMouseMove", "onMouseDown", "onClick", "onPress", "disabled"],
3162
- _excluded3 = ["onClick", "onPress", "refKey", "ref"],
3163
- _excluded4 = ["onKeyDown", "onChange", "onInput", "onFocus", "onBlur", "onChangeText", "refKey", "ref"];
3192
+ /* eslint-disable max-statements */
3164
3193
  useCombobox.stateChangeTypes = stateChangeTypes$1;
3165
3194
  function useCombobox(userProps) {
3166
3195
  if (userProps === void 0) {
@@ -3168,327 +3197,349 @@
3168
3197
  }
3169
3198
  validatePropTypes$1(userProps, useCombobox);
3170
3199
  // Props defaults and destructuring.
3171
- var props = _extends({}, defaultProps$1, userProps);
3172
- var initialIsOpen = props.initialIsOpen,
3173
- defaultIsOpen = props.defaultIsOpen,
3174
- items = props.items,
3175
- scrollIntoView = props.scrollIntoView,
3176
- environment = props.environment,
3177
- getA11yStatusMessage = props.getA11yStatusMessage,
3178
- getA11ySelectionMessage = props.getA11ySelectionMessage,
3179
- itemToString = props.itemToString;
3200
+ const props = {
3201
+ ...defaultProps$1,
3202
+ ...userProps
3203
+ };
3204
+ const {
3205
+ initialIsOpen,
3206
+ defaultIsOpen,
3207
+ items,
3208
+ scrollIntoView,
3209
+ environment,
3210
+ getA11yStatusMessage,
3211
+ getA11ySelectionMessage,
3212
+ itemToString
3213
+ } = props;
3180
3214
  // Initial state depending on controlled props.
3181
- var initialState = getInitialState$1(props);
3182
- var _useControlledReducer = useControlledReducer(downshiftUseComboboxReducer, initialState, props),
3183
- state = _useControlledReducer[0],
3184
- dispatch = _useControlledReducer[1];
3185
- var isOpen = state.isOpen,
3186
- highlightedIndex = state.highlightedIndex,
3187
- selectedItem = state.selectedItem,
3188
- inputValue = state.inputValue;
3215
+ const initialState = getInitialState$1(props);
3216
+ const [state, dispatch] = useControlledReducer(downshiftUseComboboxReducer, initialState, props);
3217
+ const {
3218
+ isOpen,
3219
+ highlightedIndex,
3220
+ selectedItem,
3221
+ inputValue
3222
+ } = state;
3189
3223
 
3190
3224
  // Element refs.
3191
- var menuRef = preact.useRef(null);
3192
- var itemRefs = preact.useRef({});
3193
- var inputRef = preact.useRef(null);
3194
- var toggleButtonRef = preact.useRef(null);
3195
- var isInitialMountRef = preact.useRef(true);
3225
+ const menuRef = preact.useRef(null);
3226
+ const itemRefs = preact.useRef({});
3227
+ const inputRef = preact.useRef(null);
3228
+ const toggleButtonRef = preact.useRef(null);
3229
+ const isInitialMountRef = preact.useRef(true);
3196
3230
  // prevent id re-generation between renders.
3197
- var elementIds = useElementIds(props);
3231
+ const elementIds = useElementIds(props);
3198
3232
  // used to keep track of how many items we had on previous cycle.
3199
- var previousResultCountRef = preact.useRef();
3233
+ const previousResultCountRef = preact.useRef();
3200
3234
  // utility callback to get item element.
3201
- var latest = useLatestRef({
3202
- state: state,
3203
- props: props
3235
+ const latest = useLatestRef({
3236
+ state,
3237
+ props
3204
3238
  });
3205
- var getItemNodeFromIndex = preact.useCallback(function (index) {
3206
- return itemRefs.current[elementIds.getItemId(index)];
3207
- }, [elementIds]);
3239
+ const getItemNodeFromIndex = preact.useCallback(index => itemRefs.current[elementIds.getItemId(index)], [elementIds]);
3208
3240
 
3209
3241
  // Effects.
3210
3242
  // Sets a11y status message on changes in state.
3211
- useA11yMessageSetter(getA11yStatusMessage, [isOpen, highlightedIndex, inputValue, items], _extends({
3243
+ useA11yMessageSetter(getA11yStatusMessage, [isOpen, highlightedIndex, inputValue, items], {
3212
3244
  isInitialMount: isInitialMountRef.current,
3213
3245
  previousResultCount: previousResultCountRef.current,
3214
- items: items,
3215
- environment: environment,
3216
- itemToString: itemToString
3217
- }, state));
3246
+ items,
3247
+ environment,
3248
+ itemToString,
3249
+ ...state
3250
+ });
3218
3251
  // Sets a11y status message on changes in selectedItem.
3219
- useA11yMessageSetter(getA11ySelectionMessage, [selectedItem], _extends({
3252
+ useA11yMessageSetter(getA11ySelectionMessage, [selectedItem], {
3220
3253
  isInitialMount: isInitialMountRef.current,
3221
3254
  previousResultCount: previousResultCountRef.current,
3222
- items: items,
3223
- environment: environment,
3224
- itemToString: itemToString
3225
- }, state));
3255
+ items,
3256
+ environment,
3257
+ itemToString,
3258
+ ...state
3259
+ });
3226
3260
  // Scroll on highlighted item if change comes from keyboard.
3227
- var shouldScrollRef = useScrollIntoView({
3261
+ const shouldScrollRef = useScrollIntoView({
3228
3262
  menuElement: menuRef.current,
3229
- highlightedIndex: highlightedIndex,
3230
- isOpen: isOpen,
3231
- itemRefs: itemRefs,
3232
- scrollIntoView: scrollIntoView,
3233
- getItemNodeFromIndex: getItemNodeFromIndex
3263
+ highlightedIndex,
3264
+ isOpen,
3265
+ itemRefs,
3266
+ scrollIntoView,
3267
+ getItemNodeFromIndex
3234
3268
  });
3235
3269
  useControlPropsValidator({
3236
3270
  isInitialMount: isInitialMountRef.current,
3237
- props: props,
3238
- state: state
3271
+ props,
3272
+ state
3239
3273
  });
3240
3274
  // Focus the input on first render if required.
3241
- preact.useEffect(function () {
3242
- var focusOnOpen = initialIsOpen || defaultIsOpen || isOpen;
3275
+ preact.useEffect(() => {
3276
+ const focusOnOpen = initialIsOpen || defaultIsOpen || isOpen;
3243
3277
  if (focusOnOpen && inputRef.current) {
3244
3278
  inputRef.current.focus();
3245
3279
  }
3246
3280
  // eslint-disable-next-line react-hooks/exhaustive-deps
3247
3281
  }, []);
3248
- preact.useEffect(function () {
3282
+ preact.useEffect(() => {
3249
3283
  if (isInitialMountRef.current) {
3250
3284
  return;
3251
3285
  }
3252
3286
  previousResultCountRef.current = items.length;
3253
3287
  });
3254
3288
  // Add mouse/touch events to document.
3255
- var mouseAndTouchTrackersRef = useMouseAndTouchTracker(isOpen, [inputRef, menuRef, toggleButtonRef], environment, function () {
3289
+ const mouseAndTouchTrackersRef = useMouseAndTouchTracker(isOpen, [inputRef, menuRef, toggleButtonRef], environment, () => {
3256
3290
  dispatch({
3257
3291
  type: InputBlur,
3258
3292
  selectItem: false
3259
3293
  });
3260
3294
  });
3261
- var setGetterPropCallInfo = useGetterPropsCalledChecker('getInputProps', 'getMenuProps');
3295
+ const setGetterPropCallInfo = useGetterPropsCalledChecker('getInputProps', 'getMenuProps');
3262
3296
  // Make initial ref false.
3263
- preact.useEffect(function () {
3297
+ preact.useEffect(() => {
3264
3298
  isInitialMountRef.current = false;
3265
- return function () {
3299
+ return () => {
3266
3300
  isInitialMountRef.current = true;
3267
3301
  };
3268
3302
  }, []);
3269
3303
  // Reset itemRefs on close.
3270
- preact.useEffect(function () {
3304
+ preact.useEffect(() => {
3271
3305
  if (!isOpen) {
3272
3306
  itemRefs.current = {};
3273
3307
  } else if (document.activeElement !== inputRef.current) {
3274
- var _inputRef$current;
3275
- inputRef == null ? void 0 : (_inputRef$current = inputRef.current) == null ? void 0 : _inputRef$current.focus();
3308
+ inputRef?.current?.focus();
3276
3309
  }
3277
3310
  }, [isOpen]);
3278
3311
 
3279
3312
  /* Event handler functions */
3280
- var inputKeyDownHandlers = preact.useMemo(function () {
3281
- return {
3282
- ArrowDown: function ArrowDown(event) {
3283
- event.preventDefault();
3284
- dispatch({
3285
- type: InputKeyDownArrowDown,
3286
- altKey: event.altKey,
3287
- getItemNodeFromIndex: getItemNodeFromIndex
3288
- });
3289
- },
3290
- ArrowUp: function ArrowUp(event) {
3291
- event.preventDefault();
3292
- dispatch({
3293
- type: InputKeyDownArrowUp,
3294
- altKey: event.altKey,
3295
- getItemNodeFromIndex: getItemNodeFromIndex
3296
- });
3297
- },
3298
- Home: function Home(event) {
3299
- if (!latest.current.state.isOpen) {
3300
- return;
3301
- }
3313
+ const inputKeyDownHandlers = preact.useMemo(() => ({
3314
+ ArrowDown(event) {
3315
+ event.preventDefault();
3316
+ dispatch({
3317
+ type: InputKeyDownArrowDown,
3318
+ altKey: event.altKey,
3319
+ getItemNodeFromIndex
3320
+ });
3321
+ },
3322
+ ArrowUp(event) {
3323
+ event.preventDefault();
3324
+ dispatch({
3325
+ type: InputKeyDownArrowUp,
3326
+ altKey: event.altKey,
3327
+ getItemNodeFromIndex
3328
+ });
3329
+ },
3330
+ Home(event) {
3331
+ if (!latest.current.state.isOpen) {
3332
+ return;
3333
+ }
3334
+ event.preventDefault();
3335
+ dispatch({
3336
+ type: InputKeyDownHome,
3337
+ getItemNodeFromIndex
3338
+ });
3339
+ },
3340
+ End(event) {
3341
+ if (!latest.current.state.isOpen) {
3342
+ return;
3343
+ }
3344
+ event.preventDefault();
3345
+ dispatch({
3346
+ type: InputKeyDownEnd,
3347
+ getItemNodeFromIndex
3348
+ });
3349
+ },
3350
+ Escape(event) {
3351
+ const latestState = latest.current.state;
3352
+ if (latestState.isOpen || latestState.inputValue || latestState.selectedItem || latestState.highlightedIndex > -1) {
3302
3353
  event.preventDefault();
3303
3354
  dispatch({
3304
- type: InputKeyDownHome,
3305
- getItemNodeFromIndex: getItemNodeFromIndex
3355
+ type: InputKeyDownEscape
3306
3356
  });
3307
- },
3308
- End: function End(event) {
3309
- if (!latest.current.state.isOpen) {
3310
- return;
3311
- }
3357
+ }
3358
+ },
3359
+ Enter(event) {
3360
+ const latestState = latest.current.state;
3361
+ // if closed or no highlighted index, do nothing.
3362
+ if (!latestState.isOpen || event.which === 229 // if IME composing, wait for next Enter keydown event.
3363
+ ) {
3364
+ return;
3365
+ }
3366
+ event.preventDefault();
3367
+ dispatch({
3368
+ type: InputKeyDownEnter,
3369
+ getItemNodeFromIndex
3370
+ });
3371
+ },
3372
+ PageUp(event) {
3373
+ if (latest.current.state.isOpen) {
3312
3374
  event.preventDefault();
3313
3375
  dispatch({
3314
- type: InputKeyDownEnd,
3315
- getItemNodeFromIndex: getItemNodeFromIndex
3376
+ type: InputKeyDownPageUp,
3377
+ getItemNodeFromIndex
3316
3378
  });
3317
- },
3318
- Escape: function Escape(event) {
3319
- var latestState = latest.current.state;
3320
- if (latestState.isOpen || latestState.inputValue || latestState.selectedItem || latestState.highlightedIndex > -1) {
3321
- event.preventDefault();
3322
- dispatch({
3323
- type: InputKeyDownEscape
3324
- });
3325
- }
3326
- },
3327
- Enter: function Enter(event) {
3328
- var latestState = latest.current.state;
3329
- // if closed or no highlighted index, do nothing.
3330
- if (!latestState.isOpen || event.which === 229 // if IME composing, wait for next Enter keydown event.
3331
- ) {
3332
- return;
3333
- }
3379
+ }
3380
+ },
3381
+ PageDown(event) {
3382
+ if (latest.current.state.isOpen) {
3334
3383
  event.preventDefault();
3335
3384
  dispatch({
3336
- type: InputKeyDownEnter,
3337
- getItemNodeFromIndex: getItemNodeFromIndex
3385
+ type: InputKeyDownPageDown,
3386
+ getItemNodeFromIndex
3338
3387
  });
3339
- },
3340
- PageUp: function PageUp(event) {
3341
- if (latest.current.state.isOpen) {
3342
- event.preventDefault();
3343
- dispatch({
3344
- type: InputKeyDownPageUp,
3345
- getItemNodeFromIndex: getItemNodeFromIndex
3346
- });
3347
- }
3348
- },
3349
- PageDown: function PageDown(event) {
3350
- if (latest.current.state.isOpen) {
3351
- event.preventDefault();
3352
- dispatch({
3353
- type: InputKeyDownPageDown,
3354
- getItemNodeFromIndex: getItemNodeFromIndex
3355
- });
3356
- }
3357
3388
  }
3358
- };
3359
- }, [dispatch, latest, getItemNodeFromIndex]);
3389
+ }
3390
+ }), [dispatch, latest, getItemNodeFromIndex]);
3360
3391
 
3361
3392
  // Getter props.
3362
- var getLabelProps = preact.useCallback(function (labelProps) {
3363
- return _extends({
3364
- id: elementIds.labelId,
3365
- htmlFor: elementIds.inputId
3366
- }, labelProps);
3367
- }, [elementIds]);
3368
- var getMenuProps = preact.useCallback(function (_temp, _temp2) {
3369
- var _extends2;
3370
- var _ref = _temp === void 0 ? {} : _temp,
3371
- onMouseLeave = _ref.onMouseLeave,
3372
- _ref$refKey = _ref.refKey,
3373
- refKey = _ref$refKey === void 0 ? 'ref' : _ref$refKey,
3374
- ref = _ref.ref,
3375
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$1);
3376
- var _ref2 = _temp2 === void 0 ? {} : _temp2,
3377
- _ref2$suppressRefErro = _ref2.suppressRefError,
3378
- suppressRefError = _ref2$suppressRefErro === void 0 ? false : _ref2$suppressRefErro;
3393
+ const getLabelProps = preact.useCallback(labelProps => ({
3394
+ id: elementIds.labelId,
3395
+ htmlFor: elementIds.inputId,
3396
+ ...labelProps
3397
+ }), [elementIds]);
3398
+ const getMenuProps = preact.useCallback(function (_temp, _temp2) {
3399
+ let {
3400
+ onMouseLeave,
3401
+ refKey = 'ref',
3402
+ ref,
3403
+ ...rest
3404
+ } = _temp === void 0 ? {} : _temp;
3405
+ let {
3406
+ suppressRefError = false
3407
+ } = _temp2 === void 0 ? {} : _temp2;
3379
3408
  setGetterPropCallInfo('getMenuProps', suppressRefError, refKey, menuRef);
3380
- return _extends((_extends2 = {}, _extends2[refKey] = handleRefs(ref, function (menuNode) {
3381
- menuRef.current = menuNode;
3382
- }), _extends2.id = elementIds.menuId, _extends2.role = 'listbox', _extends2['aria-labelledby'] = elementIds.labelId, _extends2.onMouseLeave = callAllEventHandlers(onMouseLeave, function () {
3383
- dispatch({
3384
- type: MenuMouseLeave
3385
- });
3386
- }), _extends2), rest);
3409
+ return {
3410
+ [refKey]: handleRefs(ref, menuNode => {
3411
+ menuRef.current = menuNode;
3412
+ }),
3413
+ id: elementIds.menuId,
3414
+ role: 'listbox',
3415
+ 'aria-labelledby': elementIds.labelId,
3416
+ onMouseLeave: callAllEventHandlers(onMouseLeave, () => {
3417
+ dispatch({
3418
+ type: MenuMouseLeave
3419
+ });
3420
+ }),
3421
+ ...rest
3422
+ };
3387
3423
  }, [dispatch, setGetterPropCallInfo, elementIds]);
3388
- var getItemProps = preact.useCallback(function (_temp3) {
3389
- var _extends3, _ref4;
3390
- var _ref3 = _temp3 === void 0 ? {} : _temp3,
3391
- item = _ref3.item,
3392
- index = _ref3.index,
3393
- _ref3$refKey = _ref3.refKey,
3394
- refKey = _ref3$refKey === void 0 ? 'ref' : _ref3$refKey,
3395
- ref = _ref3.ref,
3396
- onMouseMove = _ref3.onMouseMove,
3397
- onMouseDown = _ref3.onMouseDown,
3398
- onClick = _ref3.onClick;
3399
- _ref3.onPress;
3400
- var disabled = _ref3.disabled,
3401
- rest = _objectWithoutPropertiesLoose(_ref3, _excluded2$1);
3402
- var _latest$current = latest.current,
3403
- latestProps = _latest$current.props,
3404
- latestState = _latest$current.state;
3405
- var itemIndex = getItemIndex(index, item, latestProps.items);
3424
+ const getItemProps = preact.useCallback(function (_temp3) {
3425
+ let {
3426
+ item,
3427
+ index,
3428
+ refKey = 'ref',
3429
+ ref,
3430
+ onMouseMove,
3431
+ onMouseDown,
3432
+ onClick,
3433
+ onPress,
3434
+ disabled,
3435
+ ...rest
3436
+ } = _temp3 === void 0 ? {} : _temp3;
3437
+ const {
3438
+ props: latestProps,
3439
+ state: latestState
3440
+ } = latest.current;
3441
+ const itemIndex = getItemIndex(index, item, latestProps.items);
3406
3442
  if (itemIndex < 0) {
3407
3443
  throw new Error('Pass either item or item index in getItemProps!');
3408
3444
  }
3409
- var onSelectKey = 'onClick';
3410
- var customClickHandler = onClick;
3411
- var itemHandleMouseMove = function itemHandleMouseMove() {
3445
+ const onSelectKey = 'onClick';
3446
+ const customClickHandler = onClick;
3447
+ const itemHandleMouseMove = () => {
3412
3448
  if (index === latestState.highlightedIndex) {
3413
3449
  return;
3414
3450
  }
3415
3451
  shouldScrollRef.current = false;
3416
3452
  dispatch({
3417
3453
  type: ItemMouseMove,
3418
- index: index,
3419
- disabled: disabled
3454
+ index,
3455
+ disabled
3420
3456
  });
3421
3457
  };
3422
- var itemHandleClick = function itemHandleClick() {
3458
+ const itemHandleClick = () => {
3423
3459
  dispatch({
3424
3460
  type: ItemClick,
3425
- index: index
3461
+ index
3426
3462
  });
3427
3463
  };
3428
- var itemHandleMouseDown = function itemHandleMouseDown(e) {
3429
- return e.preventDefault();
3430
- };
3431
- return _extends((_extends3 = {}, _extends3[refKey] = handleRefs(ref, function (itemNode) {
3432
- if (itemNode) {
3433
- itemRefs.current[elementIds.getItemId(itemIndex)] = itemNode;
3434
- }
3435
- }), _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), {
3464
+ const itemHandleMouseDown = e => e.preventDefault();
3465
+ return {
3466
+ [refKey]: handleRefs(ref, itemNode => {
3467
+ if (itemNode) {
3468
+ itemRefs.current[elementIds.getItemId(itemIndex)] = itemNode;
3469
+ }
3470
+ }),
3471
+ disabled,
3472
+ role: 'option',
3473
+ 'aria-selected': `${itemIndex === latestState.highlightedIndex}`,
3474
+ id: elementIds.getItemId(itemIndex),
3475
+ ...(!disabled && {
3476
+ [onSelectKey]: callAllEventHandlers(customClickHandler, itemHandleClick)
3477
+ }),
3436
3478
  onMouseMove: callAllEventHandlers(onMouseMove, itemHandleMouseMove),
3437
- onMouseDown: callAllEventHandlers(onMouseDown, itemHandleMouseDown)
3438
- }, rest);
3479
+ onMouseDown: callAllEventHandlers(onMouseDown, itemHandleMouseDown),
3480
+ ...rest
3481
+ };
3439
3482
  }, [dispatch, latest, shouldScrollRef, elementIds]);
3440
- var getToggleButtonProps = preact.useCallback(function (_temp4) {
3441
- var _extends4;
3442
- var _ref5 = _temp4 === void 0 ? {} : _temp4,
3443
- onClick = _ref5.onClick;
3444
- _ref5.onPress;
3445
- var _ref5$refKey = _ref5.refKey,
3446
- refKey = _ref5$refKey === void 0 ? 'ref' : _ref5$refKey,
3447
- ref = _ref5.ref,
3448
- rest = _objectWithoutPropertiesLoose(_ref5, _excluded3);
3449
- var latestState = latest.current.state;
3450
- var toggleButtonHandleClick = function toggleButtonHandleClick() {
3483
+ const getToggleButtonProps = preact.useCallback(function (_temp4) {
3484
+ let {
3485
+ onClick,
3486
+ onPress,
3487
+ refKey = 'ref',
3488
+ ref,
3489
+ ...rest
3490
+ } = _temp4 === void 0 ? {} : _temp4;
3491
+ const latestState = latest.current.state;
3492
+ const toggleButtonHandleClick = () => {
3451
3493
  dispatch({
3452
3494
  type: ToggleButtonClick
3453
3495
  });
3454
3496
  };
3455
- return _extends((_extends4 = {}, _extends4[refKey] = handleRefs(ref, function (toggleButtonNode) {
3456
- toggleButtonRef.current = toggleButtonNode;
3457
- }), _extends4['aria-controls'] = elementIds.menuId, _extends4['aria-expanded'] = latestState.isOpen, _extends4.id = elementIds.toggleButtonId, _extends4.tabIndex = -1, _extends4), !rest.disabled && _extends({}, {
3458
- onClick: callAllEventHandlers(onClick, toggleButtonHandleClick)
3459
- }), rest);
3497
+ return {
3498
+ [refKey]: handleRefs(ref, toggleButtonNode => {
3499
+ toggleButtonRef.current = toggleButtonNode;
3500
+ }),
3501
+ 'aria-controls': elementIds.menuId,
3502
+ 'aria-expanded': latestState.isOpen,
3503
+ id: elementIds.toggleButtonId,
3504
+ tabIndex: -1,
3505
+ ...(!rest.disabled && {
3506
+ ...({
3507
+ onClick: callAllEventHandlers(onClick, toggleButtonHandleClick)
3508
+ })
3509
+ }),
3510
+ ...rest
3511
+ };
3460
3512
  }, [dispatch, latest, elementIds]);
3461
- var getInputProps = preact.useCallback(function (_temp5, _temp6) {
3462
- var _extends5;
3463
- var _ref6 = _temp5 === void 0 ? {} : _temp5,
3464
- onKeyDown = _ref6.onKeyDown,
3465
- onChange = _ref6.onChange,
3466
- onInput = _ref6.onInput,
3467
- onFocus = _ref6.onFocus,
3468
- onBlur = _ref6.onBlur;
3469
- _ref6.onChangeText;
3470
- var _ref6$refKey = _ref6.refKey,
3471
- refKey = _ref6$refKey === void 0 ? 'ref' : _ref6$refKey,
3472
- ref = _ref6.ref,
3473
- rest = _objectWithoutPropertiesLoose(_ref6, _excluded4);
3474
- var _ref7 = _temp6 === void 0 ? {} : _temp6,
3475
- _ref7$suppressRefErro = _ref7.suppressRefError,
3476
- suppressRefError = _ref7$suppressRefErro === void 0 ? false : _ref7$suppressRefErro;
3513
+ const getInputProps = preact.useCallback(function (_temp5, _temp6) {
3514
+ let {
3515
+ onKeyDown,
3516
+ onChange,
3517
+ onInput,
3518
+ onFocus,
3519
+ onBlur,
3520
+ onChangeText,
3521
+ refKey = 'ref',
3522
+ ref,
3523
+ ...rest
3524
+ } = _temp5 === void 0 ? {} : _temp5;
3525
+ let {
3526
+ suppressRefError = false
3527
+ } = _temp6 === void 0 ? {} : _temp6;
3477
3528
  setGetterPropCallInfo('getInputProps', suppressRefError, refKey, inputRef);
3478
- var latestState = latest.current.state;
3479
- var inputHandleKeyDown = function inputHandleKeyDown(event) {
3480
- var key = normalizeArrowKey(event);
3529
+ const latestState = latest.current.state;
3530
+ const inputHandleKeyDown = event => {
3531
+ const key = normalizeArrowKey(event);
3481
3532
  if (key && inputKeyDownHandlers[key]) {
3482
3533
  inputKeyDownHandlers[key](event);
3483
3534
  }
3484
3535
  };
3485
- var inputHandleChange = function inputHandleChange(event) {
3536
+ const inputHandleChange = event => {
3486
3537
  dispatch({
3487
3538
  type: InputChange,
3488
3539
  inputValue: event.target.value
3489
3540
  });
3490
3541
  };
3491
- var inputHandleBlur = function inputHandleBlur() {
3542
+ const inputHandleBlur = () => {
3492
3543
  /* istanbul ignore else */
3493
3544
  if (latestState.isOpen && !mouseAndTouchTrackersRef.current.isMouseDown) {
3494
3545
  dispatch({
@@ -3497,7 +3548,7 @@
3497
3548
  });
3498
3549
  }
3499
3550
  };
3500
- var inputHandleFocus = function inputHandleFocus() {
3551
+ const inputHandleFocus = () => {
3501
3552
  if (!latestState.isOpen) {
3502
3553
  dispatch({
3503
3554
  type: InputFocus
@@ -3506,80 +3557,99 @@
3506
3557
  };
3507
3558
 
3508
3559
  /* istanbul ignore next (preact) */
3509
- var onChangeKey = 'onInput' ;
3510
- var eventHandlers = {};
3560
+ const onChangeKey = 'onInput' ;
3561
+ let eventHandlers = {};
3511
3562
  if (!rest.disabled) {
3512
- var _eventHandlers;
3513
- eventHandlers = (_eventHandlers = {}, _eventHandlers[onChangeKey] = callAllEventHandlers(onChange, onInput, inputHandleChange), _eventHandlers.onKeyDown = callAllEventHandlers(onKeyDown, inputHandleKeyDown), _eventHandlers.onBlur = callAllEventHandlers(onBlur, inputHandleBlur), _eventHandlers.onFocus = callAllEventHandlers(onFocus, inputHandleFocus), _eventHandlers);
3563
+ eventHandlers = {
3564
+ [onChangeKey]: callAllEventHandlers(onChange, onInput, inputHandleChange),
3565
+ onKeyDown: callAllEventHandlers(onKeyDown, inputHandleKeyDown),
3566
+ onBlur: callAllEventHandlers(onBlur, inputHandleBlur),
3567
+ onFocus: callAllEventHandlers(onFocus, inputHandleFocus)
3568
+ };
3514
3569
  }
3515
- return _extends((_extends5 = {}, _extends5[refKey] = handleRefs(ref, function (inputNode) {
3516
- inputRef.current = inputNode;
3517
- }), _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);
3570
+ return {
3571
+ [refKey]: handleRefs(ref, inputNode => {
3572
+ inputRef.current = inputNode;
3573
+ }),
3574
+ 'aria-activedescendant': latestState.isOpen && latestState.highlightedIndex > -1 ? elementIds.getItemId(latestState.highlightedIndex) : '',
3575
+ 'aria-autocomplete': 'list',
3576
+ 'aria-controls': elementIds.menuId,
3577
+ 'aria-expanded': latestState.isOpen,
3578
+ 'aria-labelledby': elementIds.labelId,
3579
+ // https://developer.mozilla.org/en-US/docs/Web/Security/Securing_your_site/Turning_off_form_autocompletion
3580
+ // revert back since autocomplete="nope" is ignored on latest Chrome and Opera
3581
+ autoComplete: 'off',
3582
+ id: elementIds.inputId,
3583
+ role: 'combobox',
3584
+ value: latestState.inputValue,
3585
+ ...eventHandlers,
3586
+ ...rest
3587
+ };
3518
3588
  }, [dispatch, inputKeyDownHandlers, latest, mouseAndTouchTrackersRef, setGetterPropCallInfo, elementIds]);
3519
3589
 
3520
3590
  // returns
3521
- var toggleMenu = preact.useCallback(function () {
3591
+ const toggleMenu = preact.useCallback(() => {
3522
3592
  dispatch({
3523
3593
  type: FunctionToggleMenu
3524
3594
  });
3525
3595
  }, [dispatch]);
3526
- var closeMenu = preact.useCallback(function () {
3596
+ const closeMenu = preact.useCallback(() => {
3527
3597
  dispatch({
3528
3598
  type: FunctionCloseMenu
3529
3599
  });
3530
3600
  }, [dispatch]);
3531
- var openMenu = preact.useCallback(function () {
3601
+ const openMenu = preact.useCallback(() => {
3532
3602
  dispatch({
3533
3603
  type: FunctionOpenMenu
3534
3604
  });
3535
3605
  }, [dispatch]);
3536
- var setHighlightedIndex = preact.useCallback(function (newHighlightedIndex) {
3606
+ const setHighlightedIndex = preact.useCallback(newHighlightedIndex => {
3537
3607
  dispatch({
3538
3608
  type: FunctionSetHighlightedIndex,
3539
3609
  highlightedIndex: newHighlightedIndex
3540
3610
  });
3541
3611
  }, [dispatch]);
3542
- var selectItem = preact.useCallback(function (newSelectedItem) {
3612
+ const selectItem = preact.useCallback(newSelectedItem => {
3543
3613
  dispatch({
3544
3614
  type: FunctionSelectItem,
3545
3615
  selectedItem: newSelectedItem
3546
3616
  });
3547
3617
  }, [dispatch]);
3548
- var setInputValue = preact.useCallback(function (newInputValue) {
3618
+ const setInputValue = preact.useCallback(newInputValue => {
3549
3619
  dispatch({
3550
3620
  type: FunctionSetInputValue,
3551
3621
  inputValue: newInputValue
3552
3622
  });
3553
3623
  }, [dispatch]);
3554
- var reset = preact.useCallback(function () {
3624
+ const reset = preact.useCallback(() => {
3555
3625
  dispatch({
3556
3626
  type: FunctionReset$1
3557
3627
  });
3558
3628
  }, [dispatch]);
3559
3629
  return {
3560
3630
  // prop getters.
3561
- getItemProps: getItemProps,
3562
- getLabelProps: getLabelProps,
3563
- getMenuProps: getMenuProps,
3564
- getInputProps: getInputProps,
3565
- getToggleButtonProps: getToggleButtonProps,
3631
+ getItemProps,
3632
+ getLabelProps,
3633
+ getMenuProps,
3634
+ getInputProps,
3635
+ getToggleButtonProps,
3566
3636
  // actions.
3567
- toggleMenu: toggleMenu,
3568
- openMenu: openMenu,
3569
- closeMenu: closeMenu,
3570
- setHighlightedIndex: setHighlightedIndex,
3571
- setInputValue: setInputValue,
3572
- selectItem: selectItem,
3573
- reset: reset,
3637
+ toggleMenu,
3638
+ openMenu,
3639
+ closeMenu,
3640
+ setHighlightedIndex,
3641
+ setInputValue,
3642
+ selectItem,
3643
+ reset,
3574
3644
  // state.
3575
- highlightedIndex: highlightedIndex,
3576
- isOpen: isOpen,
3577
- selectedItem: selectedItem,
3578
- inputValue: inputValue
3645
+ highlightedIndex,
3646
+ isOpen,
3647
+ selectedItem,
3648
+ inputValue
3579
3649
  };
3580
3650
  }
3581
3651
 
3582
- var defaultStateValues = {
3652
+ const defaultStateValues = {
3583
3653
  activeIndex: -1,
3584
3654
  selectedItems: []
3585
3655
  };
@@ -3617,11 +3687,11 @@
3617
3687
  * @returns {Object} The initial state.
3618
3688
  */
3619
3689
  function getInitialState(props) {
3620
- var activeIndex = getInitialValue(props, 'activeIndex');
3621
- var selectedItems = getInitialValue(props, 'selectedItems');
3690
+ const activeIndex = getInitialValue(props, 'activeIndex');
3691
+ const selectedItems = getInitialValue(props, 'selectedItems');
3622
3692
  return {
3623
- activeIndex: activeIndex,
3624
- selectedItems: selectedItems
3693
+ activeIndex,
3694
+ selectedItems
3625
3695
  };
3626
3696
  }
3627
3697
 
@@ -3638,7 +3708,7 @@
3638
3708
  if (event.shiftKey || event.metaKey || event.ctrlKey || event.altKey) {
3639
3709
  return false;
3640
3710
  }
3641
- var element = event.target;
3711
+ const element = event.target;
3642
3712
  if (element instanceof HTMLInputElement &&
3643
3713
  // if element is a text input
3644
3714
  element.value !== '' && (
@@ -3657,11 +3727,13 @@
3657
3727
  * @returns {string} The a11y message.
3658
3728
  */
3659
3729
  function getA11yRemovalMessage(selectionParameters) {
3660
- var removedSelectedItem = selectionParameters.removedSelectedItem,
3661
- itemToStringLocal = selectionParameters.itemToString;
3662
- return itemToStringLocal(removedSelectedItem) + " has been removed.";
3730
+ const {
3731
+ removedSelectedItem,
3732
+ itemToString: itemToStringLocal
3733
+ } = selectionParameters;
3734
+ return `${itemToStringLocal(removedSelectedItem)} has been removed.`;
3663
3735
  }
3664
- var propTypes = {
3736
+ const propTypes = {
3665
3737
  selectedItems: PropTypes__default["default"].array,
3666
3738
  initialSelectedItems: PropTypes__default["default"].array,
3667
3739
  defaultSelectedItems: PropTypes__default["default"].array,
@@ -3685,37 +3757,37 @@
3685
3757
  })
3686
3758
  })
3687
3759
  };
3688
- var defaultProps = {
3760
+ const defaultProps = {
3689
3761
  itemToString: defaultProps$3.itemToString,
3690
3762
  stateReducer: defaultProps$3.stateReducer,
3691
3763
  environment: defaultProps$3.environment,
3692
- getA11yRemovalMessage: getA11yRemovalMessage,
3764
+ getA11yRemovalMessage,
3693
3765
  keyNavigationNext: 'ArrowRight',
3694
3766
  keyNavigationPrevious: 'ArrowLeft'
3695
3767
  };
3696
3768
 
3697
3769
  // eslint-disable-next-line import/no-mutable-exports
3698
- var validatePropTypes = noop;
3770
+ let validatePropTypes = noop;
3699
3771
  /* istanbul ignore next */
3700
3772
  {
3701
- validatePropTypes = function validatePropTypes(options, caller) {
3773
+ validatePropTypes = (options, caller) => {
3702
3774
  PropTypes__default["default"].checkPropTypes(propTypes, options, 'prop', caller.name);
3703
3775
  };
3704
3776
  }
3705
3777
 
3706
- var SelectedItemClick = '__selected_item_click__' ;
3707
- var SelectedItemKeyDownDelete = '__selected_item_keydown_delete__' ;
3708
- var SelectedItemKeyDownBackspace = '__selected_item_keydown_backspace__' ;
3709
- var SelectedItemKeyDownNavigationNext = '__selected_item_keydown_navigation_next__' ;
3710
- var SelectedItemKeyDownNavigationPrevious = '__selected_item_keydown_navigation_previous__' ;
3711
- var DropdownKeyDownNavigationPrevious = '__dropdown_keydown_navigation_previous__' ;
3712
- var DropdownKeyDownBackspace = '__dropdown_keydown_backspace__' ;
3713
- var DropdownClick = '__dropdown_click__' ;
3714
- var FunctionAddSelectedItem = '__function_add_selected_item__' ;
3715
- var FunctionRemoveSelectedItem = '__function_remove_selected_item__' ;
3716
- var FunctionSetSelectedItems = '__function_set_selected_items__' ;
3717
- var FunctionSetActiveIndex = '__function_set_active_index__' ;
3718
- var FunctionReset = '__function_reset__' ;
3778
+ const SelectedItemClick = '__selected_item_click__' ;
3779
+ const SelectedItemKeyDownDelete = '__selected_item_keydown_delete__' ;
3780
+ const SelectedItemKeyDownBackspace = '__selected_item_keydown_backspace__' ;
3781
+ const SelectedItemKeyDownNavigationNext = '__selected_item_keydown_navigation_next__' ;
3782
+ const SelectedItemKeyDownNavigationPrevious = '__selected_item_keydown_navigation_previous__' ;
3783
+ const DropdownKeyDownNavigationPrevious = '__dropdown_keydown_navigation_previous__' ;
3784
+ const DropdownKeyDownBackspace = '__dropdown_keydown_backspace__' ;
3785
+ const DropdownClick = '__dropdown_click__' ;
3786
+ const FunctionAddSelectedItem = '__function_add_selected_item__' ;
3787
+ const FunctionRemoveSelectedItem = '__function_remove_selected_item__' ;
3788
+ const FunctionSetSelectedItems = '__function_set_selected_items__' ;
3789
+ const FunctionSetActiveIndex = '__function_set_active_index__' ;
3790
+ const FunctionReset = '__function_reset__' ;
3719
3791
 
3720
3792
  var stateChangeTypes = /*#__PURE__*/Object.freeze({
3721
3793
  __proto__: null,
@@ -3736,13 +3808,17 @@
3736
3808
 
3737
3809
  /* eslint-disable complexity */
3738
3810
  function downshiftMultipleSelectionReducer(state, action) {
3739
- var type = action.type,
3740
- index = action.index,
3741
- props = action.props,
3742
- selectedItem = action.selectedItem;
3743
- var activeIndex = state.activeIndex,
3744
- selectedItems = state.selectedItems;
3745
- var changes;
3811
+ const {
3812
+ type,
3813
+ index,
3814
+ props,
3815
+ selectedItem
3816
+ } = action;
3817
+ const {
3818
+ activeIndex,
3819
+ selectedItems
3820
+ } = state;
3821
+ let changes;
3746
3822
  switch (type) {
3747
3823
  case SelectedItemClick:
3748
3824
  changes = {
@@ -3765,17 +3841,18 @@
3765
3841
  if (activeIndex < 0) {
3766
3842
  break;
3767
3843
  }
3768
- var newActiveIndex = activeIndex;
3844
+ let newActiveIndex = activeIndex;
3769
3845
  if (selectedItems.length === 1) {
3770
3846
  newActiveIndex = -1;
3771
3847
  } else if (activeIndex === selectedItems.length - 1) {
3772
3848
  newActiveIndex = selectedItems.length - 2;
3773
3849
  }
3774
- changes = _extends({
3775
- selectedItems: [].concat(selectedItems.slice(0, activeIndex), selectedItems.slice(activeIndex + 1))
3776
- }, {
3777
- activeIndex: newActiveIndex
3778
- });
3850
+ changes = {
3851
+ selectedItems: [...selectedItems.slice(0, activeIndex), ...selectedItems.slice(activeIndex + 1)],
3852
+ ...{
3853
+ activeIndex: newActiveIndex
3854
+ }
3855
+ };
3779
3856
  break;
3780
3857
  }
3781
3858
  case DropdownKeyDownNavigationPrevious:
@@ -3790,7 +3867,7 @@
3790
3867
  break;
3791
3868
  case FunctionAddSelectedItem:
3792
3869
  changes = {
3793
- selectedItems: [].concat(selectedItems, [selectedItem])
3870
+ selectedItems: [...selectedItems, selectedItem]
3794
3871
  };
3795
3872
  break;
3796
3873
  case DropdownClick:
@@ -3800,25 +3877,27 @@
3800
3877
  break;
3801
3878
  case FunctionRemoveSelectedItem:
3802
3879
  {
3803
- var _newActiveIndex = activeIndex;
3804
- var selectedItemIndex = selectedItems.indexOf(selectedItem);
3880
+ let newActiveIndex = activeIndex;
3881
+ const selectedItemIndex = selectedItems.indexOf(selectedItem);
3805
3882
  if (selectedItemIndex < 0) {
3806
3883
  break;
3807
3884
  }
3808
3885
  if (selectedItems.length === 1) {
3809
- _newActiveIndex = -1;
3886
+ newActiveIndex = -1;
3810
3887
  } else if (selectedItemIndex === selectedItems.length - 1) {
3811
- _newActiveIndex = selectedItems.length - 2;
3888
+ newActiveIndex = selectedItems.length - 2;
3812
3889
  }
3813
3890
  changes = {
3814
- selectedItems: [].concat(selectedItems.slice(0, selectedItemIndex), selectedItems.slice(selectedItemIndex + 1)),
3815
- activeIndex: _newActiveIndex
3891
+ selectedItems: [...selectedItems.slice(0, selectedItemIndex), ...selectedItems.slice(selectedItemIndex + 1)],
3892
+ activeIndex: newActiveIndex
3816
3893
  };
3817
3894
  break;
3818
3895
  }
3819
3896
  case FunctionSetSelectedItems:
3820
3897
  {
3821
- var newSelectedItems = action.selectedItems;
3898
+ const {
3899
+ selectedItems: newSelectedItems
3900
+ } = action;
3822
3901
  changes = {
3823
3902
  selectedItems: newSelectedItems
3824
3903
  };
@@ -3826,9 +3905,11 @@
3826
3905
  }
3827
3906
  case FunctionSetActiveIndex:
3828
3907
  {
3829
- var _newActiveIndex2 = action.activeIndex;
3908
+ const {
3909
+ activeIndex: newActiveIndex
3910
+ } = action;
3830
3911
  changes = {
3831
- activeIndex: _newActiveIndex2
3912
+ activeIndex: newActiveIndex
3832
3913
  };
3833
3914
  break;
3834
3915
  }
@@ -3841,11 +3922,12 @@
3841
3922
  default:
3842
3923
  throw new Error('Reducer called without proper action type.');
3843
3924
  }
3844
- return _extends({}, state, changes);
3925
+ return {
3926
+ ...state,
3927
+ ...changes
3928
+ };
3845
3929
  }
3846
3930
 
3847
- var _excluded = ["refKey", "ref", "onClick", "onKeyDown", "selectedItem", "index"],
3848
- _excluded2 = ["refKey", "ref", "onKeyDown", "onClick", "preventKeyAction"];
3849
3931
  useMultipleSelection.stateChangeTypes = stateChangeTypes;
3850
3932
  function useMultipleSelection(userProps) {
3851
3933
  if (userProps === void 0) {
@@ -3853,46 +3935,49 @@
3853
3935
  }
3854
3936
  validatePropTypes(userProps, useMultipleSelection);
3855
3937
  // Props defaults and destructuring.
3856
- var props = _extends({}, defaultProps, userProps);
3857
- var getA11yRemovalMessage = props.getA11yRemovalMessage,
3858
- itemToString = props.itemToString,
3859
- environment = props.environment,
3860
- keyNavigationNext = props.keyNavigationNext,
3861
- keyNavigationPrevious = props.keyNavigationPrevious;
3938
+ const props = {
3939
+ ...defaultProps,
3940
+ ...userProps
3941
+ };
3942
+ const {
3943
+ getA11yRemovalMessage,
3944
+ itemToString,
3945
+ environment,
3946
+ keyNavigationNext,
3947
+ keyNavigationPrevious
3948
+ } = props;
3862
3949
 
3863
3950
  // Reducer init.
3864
- var _useControlledReducer = useControlledReducer$1(downshiftMultipleSelectionReducer, getInitialState(props), props),
3865
- state = _useControlledReducer[0],
3866
- dispatch = _useControlledReducer[1];
3867
- var activeIndex = state.activeIndex,
3868
- selectedItems = state.selectedItems;
3951
+ const [state, dispatch] = useControlledReducer$1(downshiftMultipleSelectionReducer, getInitialState(props), props);
3952
+ const {
3953
+ activeIndex,
3954
+ selectedItems
3955
+ } = state;
3869
3956
 
3870
3957
  // Refs.
3871
- var isInitialMountRef = preact.useRef(true);
3872
- var dropdownRef = preact.useRef(null);
3873
- var previousSelectedItemsRef = preact.useRef(selectedItems);
3874
- var selectedItemRefs = preact.useRef();
3958
+ const isInitialMountRef = preact.useRef(true);
3959
+ const dropdownRef = preact.useRef(null);
3960
+ const previousSelectedItemsRef = preact.useRef(selectedItems);
3961
+ const selectedItemRefs = preact.useRef();
3875
3962
  selectedItemRefs.current = [];
3876
- var latest = useLatestRef({
3877
- state: state,
3878
- props: props
3963
+ const latest = useLatestRef({
3964
+ state,
3965
+ props
3879
3966
  });
3880
3967
 
3881
3968
  // Effects.
3882
3969
  /* Sets a11y status message on changes in selectedItem. */
3883
- preact.useEffect(function () {
3970
+ preact.useEffect(() => {
3884
3971
  if (isInitialMountRef.current) {
3885
3972
  return;
3886
3973
  }
3887
3974
  if (selectedItems.length < previousSelectedItemsRef.current.length) {
3888
- var removedSelectedItem = previousSelectedItemsRef.current.find(function (item) {
3889
- return selectedItems.indexOf(item) < 0;
3890
- });
3975
+ const removedSelectedItem = previousSelectedItemsRef.current.find(item => selectedItems.indexOf(item) < 0);
3891
3976
  setStatus(getA11yRemovalMessage({
3892
- itemToString: itemToString,
3977
+ itemToString,
3893
3978
  resultCount: selectedItems.length,
3894
- removedSelectedItem: removedSelectedItem,
3895
- activeIndex: activeIndex,
3979
+ removedSelectedItem,
3980
+ activeIndex,
3896
3981
  activeSelectedItem: selectedItems[activeIndex]
3897
3982
  }), environment.document);
3898
3983
  }
@@ -3901,7 +3986,7 @@
3901
3986
  // eslint-disable-next-line react-hooks/exhaustive-deps
3902
3987
  }, [selectedItems.length]);
3903
3988
  // Sets focus on active item.
3904
- preact.useEffect(function () {
3989
+ preact.useEffect(() => {
3905
3990
  if (isInitialMountRef.current) {
3906
3991
  return;
3907
3992
  }
@@ -3913,167 +3998,178 @@
3913
3998
  }, [activeIndex]);
3914
3999
  useControlPropsValidator({
3915
4000
  isInitialMount: isInitialMountRef.current,
3916
- props: props,
3917
- state: state
4001
+ props,
4002
+ state
3918
4003
  });
3919
- var setGetterPropCallInfo = useGetterPropsCalledChecker('getDropdownProps');
4004
+ const setGetterPropCallInfo = useGetterPropsCalledChecker('getDropdownProps');
3920
4005
  // Make initial ref false.
3921
- preact.useEffect(function () {
4006
+ preact.useEffect(() => {
3922
4007
  isInitialMountRef.current = false;
3923
- return function () {
4008
+ return () => {
3924
4009
  isInitialMountRef.current = true;
3925
4010
  };
3926
4011
  }, []);
3927
4012
 
3928
4013
  // Event handler functions.
3929
- var selectedItemKeyDownHandlers = preact.useMemo(function () {
3930
- var _ref;
3931
- return _ref = {}, _ref[keyNavigationPrevious] = function () {
4014
+ const selectedItemKeyDownHandlers = preact.useMemo(() => ({
4015
+ [keyNavigationPrevious]() {
3932
4016
  dispatch({
3933
4017
  type: SelectedItemKeyDownNavigationPrevious
3934
4018
  });
3935
- }, _ref[keyNavigationNext] = function () {
4019
+ },
4020
+ [keyNavigationNext]() {
3936
4021
  dispatch({
3937
4022
  type: SelectedItemKeyDownNavigationNext
3938
4023
  });
3939
- }, _ref.Delete = function Delete() {
4024
+ },
4025
+ Delete() {
3940
4026
  dispatch({
3941
4027
  type: SelectedItemKeyDownDelete
3942
4028
  });
3943
- }, _ref.Backspace = function Backspace() {
4029
+ },
4030
+ Backspace() {
3944
4031
  dispatch({
3945
4032
  type: SelectedItemKeyDownBackspace
3946
4033
  });
3947
- }, _ref;
3948
- }, [dispatch, keyNavigationNext, keyNavigationPrevious]);
3949
- var dropdownKeyDownHandlers = preact.useMemo(function () {
3950
- var _ref2;
3951
- return _ref2 = {}, _ref2[keyNavigationPrevious] = function (event) {
4034
+ }
4035
+ }), [dispatch, keyNavigationNext, keyNavigationPrevious]);
4036
+ const dropdownKeyDownHandlers = preact.useMemo(() => ({
4037
+ [keyNavigationPrevious](event) {
3952
4038
  if (isKeyDownOperationPermitted(event)) {
3953
4039
  dispatch({
3954
4040
  type: DropdownKeyDownNavigationPrevious
3955
4041
  });
3956
4042
  }
3957
- }, _ref2.Backspace = function Backspace(event) {
4043
+ },
4044
+ Backspace(event) {
3958
4045
  if (isKeyDownOperationPermitted(event)) {
3959
4046
  dispatch({
3960
4047
  type: DropdownKeyDownBackspace
3961
4048
  });
3962
4049
  }
3963
- }, _ref2;
3964
- }, [dispatch, keyNavigationPrevious]);
4050
+ }
4051
+ }), [dispatch, keyNavigationPrevious]);
3965
4052
 
3966
4053
  // Getter props.
3967
- var getSelectedItemProps = preact.useCallback(function (_temp) {
3968
- var _extends2;
3969
- var _ref3 = _temp === void 0 ? {} : _temp,
3970
- _ref3$refKey = _ref3.refKey,
3971
- refKey = _ref3$refKey === void 0 ? 'ref' : _ref3$refKey,
3972
- ref = _ref3.ref,
3973
- onClick = _ref3.onClick,
3974
- onKeyDown = _ref3.onKeyDown,
3975
- selectedItem = _ref3.selectedItem,
3976
- index = _ref3.index,
3977
- rest = _objectWithoutPropertiesLoose(_ref3, _excluded);
3978
- var latestState = latest.current.state;
3979
- var itemIndex = getItemIndex(index, selectedItem, latestState.selectedItems);
4054
+ const getSelectedItemProps = preact.useCallback(function (_temp) {
4055
+ let {
4056
+ refKey = 'ref',
4057
+ ref,
4058
+ onClick,
4059
+ onKeyDown,
4060
+ selectedItem,
4061
+ index,
4062
+ ...rest
4063
+ } = _temp === void 0 ? {} : _temp;
4064
+ const {
4065
+ state: latestState
4066
+ } = latest.current;
4067
+ const itemIndex = getItemIndex(index, selectedItem, latestState.selectedItems);
3980
4068
  if (itemIndex < 0) {
3981
4069
  throw new Error('Pass either selectedItem or index in getSelectedItemProps!');
3982
4070
  }
3983
- var selectedItemHandleClick = function selectedItemHandleClick() {
4071
+ const selectedItemHandleClick = () => {
3984
4072
  dispatch({
3985
4073
  type: SelectedItemClick,
3986
- index: index
4074
+ index
3987
4075
  });
3988
4076
  };
3989
- var selectedItemHandleKeyDown = function selectedItemHandleKeyDown(event) {
3990
- var key = normalizeArrowKey(event);
4077
+ const selectedItemHandleKeyDown = event => {
4078
+ const key = normalizeArrowKey(event);
3991
4079
  if (key && selectedItemKeyDownHandlers[key]) {
3992
4080
  selectedItemKeyDownHandlers[key](event);
3993
4081
  }
3994
4082
  };
3995
- return _extends((_extends2 = {}, _extends2[refKey] = handleRefs(ref, function (selectedItemNode) {
3996
- if (selectedItemNode) {
3997
- selectedItemRefs.current.push(selectedItemNode);
3998
- }
3999
- }), _extends2.tabIndex = index === latestState.activeIndex ? 0 : -1, _extends2.onClick = callAllEventHandlers(onClick, selectedItemHandleClick), _extends2.onKeyDown = callAllEventHandlers(onKeyDown, selectedItemHandleKeyDown), _extends2), rest);
4083
+ return {
4084
+ [refKey]: handleRefs(ref, selectedItemNode => {
4085
+ if (selectedItemNode) {
4086
+ selectedItemRefs.current.push(selectedItemNode);
4087
+ }
4088
+ }),
4089
+ tabIndex: index === latestState.activeIndex ? 0 : -1,
4090
+ onClick: callAllEventHandlers(onClick, selectedItemHandleClick),
4091
+ onKeyDown: callAllEventHandlers(onKeyDown, selectedItemHandleKeyDown),
4092
+ ...rest
4093
+ };
4000
4094
  }, [dispatch, latest, selectedItemKeyDownHandlers]);
4001
- var getDropdownProps = preact.useCallback(function (_temp2, _temp3) {
4002
- var _extends3;
4003
- var _ref4 = _temp2 === void 0 ? {} : _temp2,
4004
- _ref4$refKey = _ref4.refKey,
4005
- refKey = _ref4$refKey === void 0 ? 'ref' : _ref4$refKey,
4006
- ref = _ref4.ref,
4007
- onKeyDown = _ref4.onKeyDown,
4008
- onClick = _ref4.onClick,
4009
- _ref4$preventKeyActio = _ref4.preventKeyAction,
4010
- preventKeyAction = _ref4$preventKeyActio === void 0 ? false : _ref4$preventKeyActio,
4011
- rest = _objectWithoutPropertiesLoose(_ref4, _excluded2);
4012
- var _ref5 = _temp3 === void 0 ? {} : _temp3,
4013
- _ref5$suppressRefErro = _ref5.suppressRefError,
4014
- suppressRefError = _ref5$suppressRefErro === void 0 ? false : _ref5$suppressRefErro;
4095
+ const getDropdownProps = preact.useCallback(function (_temp2, _temp3) {
4096
+ let {
4097
+ refKey = 'ref',
4098
+ ref,
4099
+ onKeyDown,
4100
+ onClick,
4101
+ preventKeyAction = false,
4102
+ ...rest
4103
+ } = _temp2 === void 0 ? {} : _temp2;
4104
+ let {
4105
+ suppressRefError = false
4106
+ } = _temp3 === void 0 ? {} : _temp3;
4015
4107
  setGetterPropCallInfo('getDropdownProps', suppressRefError, refKey, dropdownRef);
4016
- var dropdownHandleKeyDown = function dropdownHandleKeyDown(event) {
4017
- var key = normalizeArrowKey(event);
4108
+ const dropdownHandleKeyDown = event => {
4109
+ const key = normalizeArrowKey(event);
4018
4110
  if (key && dropdownKeyDownHandlers[key]) {
4019
4111
  dropdownKeyDownHandlers[key](event);
4020
4112
  }
4021
4113
  };
4022
- var dropdownHandleClick = function dropdownHandleClick() {
4114
+ const dropdownHandleClick = () => {
4023
4115
  dispatch({
4024
4116
  type: DropdownClick
4025
4117
  });
4026
4118
  };
4027
- return _extends((_extends3 = {}, _extends3[refKey] = handleRefs(ref, function (dropdownNode) {
4028
- if (dropdownNode) {
4029
- dropdownRef.current = dropdownNode;
4030
- }
4031
- }), _extends3), !preventKeyAction && {
4032
- onKeyDown: callAllEventHandlers(onKeyDown, dropdownHandleKeyDown),
4033
- onClick: callAllEventHandlers(onClick, dropdownHandleClick)
4034
- }, rest);
4119
+ return {
4120
+ [refKey]: handleRefs(ref, dropdownNode => {
4121
+ if (dropdownNode) {
4122
+ dropdownRef.current = dropdownNode;
4123
+ }
4124
+ }),
4125
+ ...(!preventKeyAction && {
4126
+ onKeyDown: callAllEventHandlers(onKeyDown, dropdownHandleKeyDown),
4127
+ onClick: callAllEventHandlers(onClick, dropdownHandleClick)
4128
+ }),
4129
+ ...rest
4130
+ };
4035
4131
  }, [dispatch, dropdownKeyDownHandlers, setGetterPropCallInfo]);
4036
4132
 
4037
4133
  // returns
4038
- var addSelectedItem = preact.useCallback(function (selectedItem) {
4134
+ const addSelectedItem = preact.useCallback(selectedItem => {
4039
4135
  dispatch({
4040
4136
  type: FunctionAddSelectedItem,
4041
- selectedItem: selectedItem
4137
+ selectedItem
4042
4138
  });
4043
4139
  }, [dispatch]);
4044
- var removeSelectedItem = preact.useCallback(function (selectedItem) {
4140
+ const removeSelectedItem = preact.useCallback(selectedItem => {
4045
4141
  dispatch({
4046
4142
  type: FunctionRemoveSelectedItem,
4047
- selectedItem: selectedItem
4143
+ selectedItem
4048
4144
  });
4049
4145
  }, [dispatch]);
4050
- var setSelectedItems = preact.useCallback(function (newSelectedItems) {
4146
+ const setSelectedItems = preact.useCallback(newSelectedItems => {
4051
4147
  dispatch({
4052
4148
  type: FunctionSetSelectedItems,
4053
4149
  selectedItems: newSelectedItems
4054
4150
  });
4055
4151
  }, [dispatch]);
4056
- var setActiveIndex = preact.useCallback(function (newActiveIndex) {
4152
+ const setActiveIndex = preact.useCallback(newActiveIndex => {
4057
4153
  dispatch({
4058
4154
  type: FunctionSetActiveIndex,
4059
4155
  activeIndex: newActiveIndex
4060
4156
  });
4061
4157
  }, [dispatch]);
4062
- var reset = preact.useCallback(function () {
4158
+ const reset = preact.useCallback(() => {
4063
4159
  dispatch({
4064
4160
  type: FunctionReset
4065
4161
  });
4066
4162
  }, [dispatch]);
4067
4163
  return {
4068
- getSelectedItemProps: getSelectedItemProps,
4069
- getDropdownProps: getDropdownProps,
4070
- addSelectedItem: addSelectedItem,
4071
- removeSelectedItem: removeSelectedItem,
4072
- setSelectedItems: setSelectedItems,
4073
- setActiveIndex: setActiveIndex,
4074
- reset: reset,
4075
- selectedItems: selectedItems,
4076
- activeIndex: activeIndex
4164
+ getSelectedItemProps,
4165
+ getDropdownProps,
4166
+ addSelectedItem,
4167
+ removeSelectedItem,
4168
+ setSelectedItems,
4169
+ setActiveIndex,
4170
+ reset,
4171
+ selectedItems,
4172
+ activeIndex
4077
4173
  };
4078
4174
  }
4079
4175