downshift 6.1.6 → 6.1.9

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.
@@ -2,68 +2,12 @@
2
2
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('preact'), require('prop-types')) :
3
3
  typeof define === 'function' && define.amd ? define(['exports', 'preact', 'prop-types'], factory) :
4
4
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Downshift = {}, global.preact, global.PropTypes));
5
- }(this, (function (exports, preact, PropTypes) { 'use strict';
5
+ })(this, (function (exports, preact, PropTypes) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
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
-
17
- for (i = 0; i < sourceKeys.length; i++) {
18
- key = sourceKeys[i];
19
- if (excluded.indexOf(key) >= 0) continue;
20
- target[key] = source[key];
21
- }
22
-
23
- return target;
24
- }
25
-
26
- function _extends() {
27
- _extends = Object.assign || function (target) {
28
- for (var i = 1; i < arguments.length; i++) {
29
- var source = arguments[i];
30
-
31
- for (var key in source) {
32
- if (Object.prototype.hasOwnProperty.call(source, key)) {
33
- target[key] = source[key];
34
- }
35
- }
36
- }
37
-
38
- return target;
39
- };
40
-
41
- return _extends.apply(this, arguments);
42
- }
43
-
44
- function _assertThisInitialized(self) {
45
- if (self === void 0) {
46
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
47
- }
48
-
49
- return self;
50
- }
51
-
52
- function _setPrototypeOf(o, p) {
53
- _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
54
- o.__proto__ = p;
55
- return o;
56
- };
57
-
58
- return _setPrototypeOf(o, p);
59
- }
60
-
61
- function _inheritsLoose(subClass, superClass) {
62
- subClass.prototype = Object.create(superClass.prototype);
63
- subClass.prototype.constructor = subClass;
64
- _setPrototypeOf(subClass, superClass);
65
- }
66
-
67
11
  var reactIs = {exports: {}};
68
12
 
69
13
  /** @license React v17.0.2
@@ -305,7 +249,7 @@
305
249
 
306
250
  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}function computeScrollIntoView(e,i){var o=window,l=i.scrollMode,d=i.block,u=i.inline,h=i.boundary,a=i.skipOverflowHiddenElements,c="function"==typeof h?h:function(t){return t!==h};if(!t(e))throw new TypeError("Invalid target");for(var f=document.scrollingElement||document.documentElement,s=[],p=e;t(p)&&c(p);){if((p=p.parentElement)===f){s.push(p);break}null!=p&&p===document.body&&n(p)&&!n(document.documentElement)||null!=p&&n(p,a)&&s.push(p);}for(var m=o.visualViewport?o.visualViewport.width:innerWidth,g=o.visualViewport?o.visualViewport.height:innerHeight,w=window.scrollX||pageXOffset,v=window.scrollY||pageYOffset,W=e.getBoundingClientRect(),b=W.height,H=W.width,y=W.top,E=W.right,M=W.bottom,V=W.left,x="start"===d||"nearest"===d?y:"end"===d?M:y+b/2,I="center"===u?V+H/2:"end"===u?E:V,C=[],T=0;T<s.length;T++){var k=s[T],B=k.getBoundingClientRect(),D=B.height,O=B.width,R=B.top,X=B.right,Y=B.bottom,L=B.left;if("if-needed"===l&&y>=0&&V>=0&&M<=g&&E<=m&&y>=R&&M<=Y&&V>=L&&E<=X)return C;var S=getComputedStyle(k),j=parseInt(S.borderLeftWidth,10),q=parseInt(S.borderTopWidth,10),z=parseInt(S.borderRightWidth,10),A=parseInt(S.borderBottomWidth,10),F=0,G=0,J="offsetWidth"in k?k.offsetWidth-k.clientWidth-j-z:0,K="offsetHeight"in k?k.offsetHeight-k.clientHeight-q-A:0;if(f===k)F="start"===d?x:"end"===d?x-g:"nearest"===d?r(v,v+g,g,q,A,v+x,v+x+b,b):x-g/2,G="start"===u?I:"center"===u?I-m/2:"end"===u?I-m:r(w,w+m,m,j,z,w+I,w+I+H,H),F=Math.max(0,F+v),G=Math.max(0,G+w);else {F="start"===d?x-R-q:"end"===d?x-Y+A+K:"nearest"===d?r(R,Y,D,q,A+K,x,x+b,b):x-(R+D/2)+K/2,G="start"===u?I-L-j:"center"===u?I-(L+O/2)+J/2:"end"===u?I-X+z+J:r(L,X,O,j,z+J,I,I+H,H);var N=k.scrollLeft,P=k.scrollTop;x+=P-(F=Math.max(0,Math.min(P+F,k.scrollHeight-D+K))),I+=N-(G=Math.max(0,Math.min(N+G,k.scrollWidth-O+J)));}C.push({el:k,top:F,left:G});}return C}
307
251
 
308
- var idCounter = 0;
252
+ let idCounter = 0;
309
253
  /**
310
254
  * Accepts a parameter and returns it if it's a function
311
255
  * or a noop function if it's not. This allows us to
@@ -332,15 +276,17 @@
332
276
  return;
333
277
  }
334
278
 
335
- var actions = computeScrollIntoView(node, {
279
+ const actions = computeScrollIntoView(node, {
336
280
  boundary: menuNode,
337
281
  block: 'nearest',
338
282
  scrollMode: 'if-needed'
339
283
  });
340
- actions.forEach(function (_ref) {
341
- var el = _ref.el,
342
- top = _ref.top,
343
- left = _ref.left;
284
+ actions.forEach(_ref => {
285
+ let {
286
+ el,
287
+ top,
288
+ left
289
+ } = _ref;
344
290
  el.scrollTop = top;
345
291
  el.scrollLeft = left;
346
292
  });
@@ -354,7 +300,7 @@
354
300
 
355
301
 
356
302
  function isOrContainsNode(parent, child, environment) {
357
- var result = parent === child || child instanceof environment.Node && parent.contains && parent.contains(child);
303
+ const result = parent === child || child instanceof environment.Node && parent.contains && parent.contains(child);
358
304
  return result;
359
305
  }
360
306
  /**
@@ -368,7 +314,7 @@
368
314
 
369
315
 
370
316
  function debounce(fn, time) {
371
- var timeoutId;
317
+ let timeoutId;
372
318
 
373
319
  function cancel() {
374
320
  if (timeoutId) {
@@ -382,9 +328,9 @@
382
328
  }
383
329
 
384
330
  cancel();
385
- timeoutId = setTimeout(function () {
331
+ timeoutId = setTimeout(() => {
386
332
  timeoutId = null;
387
- fn.apply(void 0, args);
333
+ fn(...args);
388
334
  }, time);
389
335
  }
390
336
 
@@ -410,9 +356,9 @@
410
356
  args[_key3 - 1] = arguments[_key3];
411
357
  }
412
358
 
413
- return fns.some(function (fn) {
359
+ return fns.some(fn => {
414
360
  if (fn) {
415
- fn.apply(void 0, [event].concat(args));
361
+ fn(event, ...args);
416
362
  }
417
363
 
418
364
  return event.preventDownshiftDefault || event.hasOwnProperty('nativeEvent') && event.nativeEvent.preventDownshiftDefault;
@@ -425,8 +371,8 @@
425
371
  refs[_key4] = arguments[_key4];
426
372
  }
427
373
 
428
- return function (node) {
429
- refs.forEach(function (ref) {
374
+ return node => {
375
+ refs.forEach(ref => {
430
376
  if (typeof ref === 'function') {
431
377
  ref(node);
432
378
  } else if (ref) {
@@ -463,9 +409,11 @@
463
409
 
464
410
 
465
411
  function getA11yStatusMessage$1(_ref2) {
466
- var isOpen = _ref2.isOpen,
467
- resultCount = _ref2.resultCount,
468
- previousResultCount = _ref2.previousResultCount;
412
+ let {
413
+ isOpen,
414
+ resultCount,
415
+ previousResultCount
416
+ } = _ref2;
469
417
 
470
418
  if (!isOpen) {
471
419
  return '';
@@ -541,7 +489,7 @@
541
489
  console.error("The property \"" + propName + "\" is required in \"" + fnName + "\"");
542
490
  }
543
491
 
544
- var stateKeys = ['highlightedIndex', 'inputValue', 'isOpen', 'selectedItem', 'type'];
492
+ const stateKeys = ['highlightedIndex', 'inputValue', 'isOpen', 'selectedItem', 'type'];
545
493
  /**
546
494
  * @param {Object} state the state object
547
495
  * @return {Object} state that is relevant to downshift
@@ -552,8 +500,8 @@
552
500
  state = {};
553
501
  }
554
502
 
555
- var result = {};
556
- stateKeys.forEach(function (k) {
503
+ const result = {};
504
+ stateKeys.forEach(k => {
557
505
  if (state.hasOwnProperty(k)) {
558
506
  result[k] = state[k];
559
507
  }
@@ -574,7 +522,7 @@
574
522
 
575
523
 
576
524
  function getState(state, props) {
577
- return Object.keys(state).reduce(function (prevState, key) {
525
+ return Object.keys(state).reduce((prevState, key) => {
578
526
  prevState[key] = isControlledProp(props, key) ? props[key] : state[key];
579
527
  return prevState;
580
528
  }, {});
@@ -601,8 +549,10 @@
601
549
 
602
550
 
603
551
  function normalizeArrowKey(event) {
604
- var key = event.key,
605
- keyCode = event.keyCode;
552
+ const {
553
+ key,
554
+ keyCode
555
+ } = event;
606
556
  /* istanbul ignore next (ie) */
607
557
 
608
558
  if (keyCode >= 37 && keyCode <= 40 && key.indexOf('Arrow') !== 0) {
@@ -643,13 +593,13 @@
643
593
  return -1;
644
594
  }
645
595
 
646
- var itemsLastIndex = itemCount - 1;
596
+ const itemsLastIndex = itemCount - 1;
647
597
 
648
598
  if (typeof baseIndex !== 'number' || baseIndex < 0 || baseIndex >= itemCount) {
649
599
  baseIndex = moveAmount > 0 ? -1 : itemsLastIndex + 1;
650
600
  }
651
601
 
652
- var newIndex = baseIndex + moveAmount;
602
+ let newIndex = baseIndex + moveAmount;
653
603
 
654
604
  if (newIndex < 0) {
655
605
  newIndex = circular ? itemsLastIndex : 0;
@@ -657,7 +607,7 @@
657
607
  newIndex = circular ? 0 : itemsLastIndex;
658
608
  }
659
609
 
660
- var nonDisabledNewIndex = getNextNonDisabledIndex(moveAmount, newIndex, itemCount, getItemNodeFromIndex, circular);
610
+ const nonDisabledNewIndex = getNextNonDisabledIndex(moveAmount, newIndex, itemCount, getItemNodeFromIndex, circular);
661
611
 
662
612
  if (nonDisabledNewIndex === -1) {
663
613
  return baseIndex >= itemCount ? -1 : baseIndex;
@@ -678,22 +628,22 @@
678
628
 
679
629
 
680
630
  function getNextNonDisabledIndex(moveAmount, baseIndex, itemCount, getItemNodeFromIndex, circular) {
681
- var currentElementNode = getItemNodeFromIndex(baseIndex);
631
+ const currentElementNode = getItemNodeFromIndex(baseIndex);
682
632
 
683
633
  if (!currentElementNode || !currentElementNode.hasAttribute('disabled')) {
684
634
  return baseIndex;
685
635
  }
686
636
 
687
637
  if (moveAmount > 0) {
688
- for (var index = baseIndex + 1; index < itemCount; index++) {
638
+ for (let index = baseIndex + 1; index < itemCount; index++) {
689
639
  if (!getItemNodeFromIndex(index).hasAttribute('disabled')) {
690
640
  return index;
691
641
  }
692
642
  }
693
643
  } else {
694
- for (var _index = baseIndex - 1; _index >= 0; _index--) {
695
- if (!getItemNodeFromIndex(_index).hasAttribute('disabled')) {
696
- return _index;
644
+ for (let index = baseIndex - 1; index >= 0; index--) {
645
+ if (!getItemNodeFromIndex(index).hasAttribute('disabled')) {
646
+ return index;
697
647
  }
698
648
  }
699
649
  }
@@ -721,19 +671,17 @@
721
671
  checkActiveElement = true;
722
672
  }
723
673
 
724
- return downshiftElements.some(function (contextNode) {
725
- return contextNode && (isOrContainsNode(contextNode, target, environment) || checkActiveElement && isOrContainsNode(contextNode, environment.document.activeElement, environment));
726
- });
674
+ return downshiftElements.some(contextNode => contextNode && (isOrContainsNode(contextNode, target, environment) || checkActiveElement && isOrContainsNode(contextNode, environment.document.activeElement, environment)));
727
675
  } // eslint-disable-next-line import/no-mutable-exports
728
676
 
729
677
 
730
- var validateControlledUnchanged = noop;
678
+ let validateControlledUnchanged = noop;
731
679
  /* istanbul ignore next */
732
680
 
733
681
  {
734
- validateControlledUnchanged = function validateControlledUnchanged(state, prevProps, nextProps) {
735
- 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";
736
- Object.keys(state).forEach(function (propKey) {
682
+ validateControlledUnchanged = (state, prevProps, nextProps) => {
683
+ 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";
684
+ Object.keys(state).forEach(propKey => {
737
685
  if (prevProps[propKey] !== undefined && nextProps[propKey] === undefined) {
738
686
  // eslint-disable-next-line no-console
739
687
  console.error("downshift: A component has changed the controlled prop \"" + propKey + "\" to be uncontrolled. " + warningDescription);
@@ -745,7 +693,7 @@
745
693
  };
746
694
  }
747
695
 
748
- var cleanupStatus = debounce(function (documentProp) {
696
+ const cleanupStatus = debounce(documentProp => {
749
697
  getStatusDiv(documentProp).textContent = '';
750
698
  }, 500);
751
699
  /**
@@ -754,7 +702,7 @@
754
702
  */
755
703
 
756
704
  function setStatus(status, documentProp) {
757
- var div = getStatusDiv(documentProp);
705
+ const div = getStatusDiv(documentProp);
758
706
 
759
707
  if (!status) {
760
708
  return;
@@ -775,7 +723,7 @@
775
723
  documentProp = document;
776
724
  }
777
725
 
778
- var statusDiv = documentProp.getElementById('a11y-status-message');
726
+ let statusDiv = documentProp.getElementById('a11y-status-message');
779
727
 
780
728
  if (statusDiv) {
781
729
  return statusDiv;
@@ -800,23 +748,23 @@
800
748
  return statusDiv;
801
749
  }
802
750
 
803
- var unknown = '__autocomplete_unknown__' ;
804
- var mouseUp = '__autocomplete_mouseup__' ;
805
- var itemMouseEnter = '__autocomplete_item_mouseenter__' ;
806
- var keyDownArrowUp = '__autocomplete_keydown_arrow_up__' ;
807
- var keyDownArrowDown = '__autocomplete_keydown_arrow_down__' ;
808
- var keyDownEscape = '__autocomplete_keydown_escape__' ;
809
- var keyDownEnter = '__autocomplete_keydown_enter__' ;
810
- var keyDownHome = '__autocomplete_keydown_home__' ;
811
- var keyDownEnd = '__autocomplete_keydown_end__' ;
812
- var clickItem = '__autocomplete_click_item__' ;
813
- var blurInput = '__autocomplete_blur_input__' ;
814
- var changeInput = '__autocomplete_change_input__' ;
815
- var keyDownSpaceButton = '__autocomplete_keydown_space_button__' ;
816
- var clickButton = '__autocomplete_click_button__' ;
817
- var blurButton = '__autocomplete_blur_button__' ;
818
- var controlledPropUpdatedSelectedItem = '__autocomplete_controlled_prop_updated_selected_item__' ;
819
- var touchEnd = '__autocomplete_touchend__' ;
751
+ const unknown = '__autocomplete_unknown__' ;
752
+ const mouseUp = '__autocomplete_mouseup__' ;
753
+ const itemMouseEnter = '__autocomplete_item_mouseenter__' ;
754
+ const keyDownArrowUp = '__autocomplete_keydown_arrow_up__' ;
755
+ const keyDownArrowDown = '__autocomplete_keydown_arrow_down__' ;
756
+ const keyDownEscape = '__autocomplete_keydown_escape__' ;
757
+ const keyDownEnter = '__autocomplete_keydown_enter__' ;
758
+ const keyDownHome = '__autocomplete_keydown_home__' ;
759
+ const keyDownEnd = '__autocomplete_keydown_end__' ;
760
+ const clickItem = '__autocomplete_click_item__' ;
761
+ const blurInput = '__autocomplete_blur_input__' ;
762
+ const changeInput = '__autocomplete_change_input__' ;
763
+ const keyDownSpaceButton = '__autocomplete_keydown_space_button__' ;
764
+ const clickButton = '__autocomplete_click_button__' ;
765
+ const blurButton = '__autocomplete_blur_button__' ;
766
+ const controlledPropUpdatedSelectedItem = '__autocomplete_controlled_prop_updated_selected_item__' ;
767
+ const touchEnd = '__autocomplete_touchend__' ;
820
768
 
821
769
  var stateChangeTypes$3 = /*#__PURE__*/Object.freeze({
822
770
  __proto__: null,
@@ -839,58 +787,45 @@
839
787
  touchEnd: touchEnd
840
788
  });
841
789
 
842
- var _excluded$4 = ["refKey", "ref"],
843
- _excluded2$3 = ["onClick", "onPress", "onKeyDown", "onKeyUp", "onBlur"],
844
- _excluded3$2 = ["onKeyDown", "onBlur", "onChange", "onInput", "onChangeText"],
845
- _excluded4$1 = ["refKey", "ref"],
846
- _excluded5$1 = ["onMouseMove", "onMouseDown", "onClick", "onPress", "index", "item"];
790
+ /* eslint camelcase:0 */
847
791
 
848
- var Downshift = /*#__PURE__*/function () {
849
- var Downshift = /*#__PURE__*/function (_Component) {
850
- _inheritsLoose(Downshift, _Component);
851
-
852
- function Downshift(_props) {
792
+ const Downshift = /*#__PURE__*/(() => {
793
+ class Downshift extends preact.Component {
794
+ constructor(_props) {
853
795
  var _this;
854
796
 
855
- _this = _Component.call(this, _props) || this; // fancy destructuring + defaults + aliases
856
- // this basically says each value of state should either be set to
857
- // the initial value or the default value if the initial value is not provided
858
-
859
- _this.id = _this.props.id || "downshift-" + generateId();
860
- _this.menuId = _this.props.menuId || _this.id + "-menu";
861
- _this.labelId = _this.props.labelId || _this.id + "-label";
862
- _this.inputId = _this.props.inputId || _this.id + "-input";
797
+ super(_props);
798
+ _this = this;
799
+ this.id = this.props.id || "downshift-" + generateId();
800
+ this.menuId = this.props.menuId || this.id + "-menu";
801
+ this.labelId = this.props.labelId || this.id + "-label";
802
+ this.inputId = this.props.inputId || this.id + "-input";
863
803
 
864
- _this.getItemId = _this.props.getItemId || function (index) {
865
- return _this.id + "-item-" + index;
866
- };
804
+ this.getItemId = this.props.getItemId || (index => this.id + "-item-" + index);
867
805
 
868
- _this.input = null;
869
- _this.items = [];
870
- _this.itemCount = null;
871
- _this.previousResultCount = 0;
872
- _this.timeoutIds = [];
806
+ this.input = null;
807
+ this.items = [];
808
+ this.itemCount = null;
809
+ this.previousResultCount = 0;
810
+ this.timeoutIds = [];
873
811
 
874
- _this.internalSetTimeout = function (fn, time) {
875
- var id = setTimeout(function () {
876
- _this.timeoutIds = _this.timeoutIds.filter(function (i) {
877
- return i !== id;
878
- });
812
+ this.internalSetTimeout = (fn, time) => {
813
+ const id = setTimeout(() => {
814
+ this.timeoutIds = this.timeoutIds.filter(i => i !== id);
879
815
  fn();
880
816
  }, time);
881
-
882
- _this.timeoutIds.push(id);
817
+ this.timeoutIds.push(id);
883
818
  };
884
819
 
885
- _this.setItemCount = function (count) {
886
- _this.itemCount = count;
820
+ this.setItemCount = count => {
821
+ this.itemCount = count;
887
822
  };
888
823
 
889
- _this.unsetItemCount = function () {
890
- _this.itemCount = null;
824
+ this.unsetItemCount = () => {
825
+ this.itemCount = null;
891
826
  };
892
827
 
893
- _this.setHighlightedIndex = function (highlightedIndex, otherStateToSet) {
828
+ this.setHighlightedIndex = function (highlightedIndex, otherStateToSet) {
894
829
  if (highlightedIndex === void 0) {
895
830
  highlightedIndex = _this.props.defaultHighlightedIndex;
896
831
  }
@@ -901,71 +836,72 @@
901
836
 
902
837
  otherStateToSet = pickState(otherStateToSet);
903
838
 
904
- _this.internalSetState(_extends({
905
- highlightedIndex: highlightedIndex
906
- }, otherStateToSet));
839
+ _this.internalSetState({
840
+ highlightedIndex,
841
+ ...otherStateToSet
842
+ });
907
843
  };
908
844
 
909
- _this.clearSelection = function (cb) {
910
- _this.internalSetState({
845
+ this.clearSelection = cb => {
846
+ this.internalSetState({
911
847
  selectedItem: null,
912
848
  inputValue: '',
913
- highlightedIndex: _this.props.defaultHighlightedIndex,
914
- isOpen: _this.props.defaultIsOpen
849
+ highlightedIndex: this.props.defaultHighlightedIndex,
850
+ isOpen: this.props.defaultIsOpen
915
851
  }, cb);
916
852
  };
917
853
 
918
- _this.selectItem = function (item, otherStateToSet, cb) {
854
+ this.selectItem = (item, otherStateToSet, cb) => {
919
855
  otherStateToSet = pickState(otherStateToSet);
920
-
921
- _this.internalSetState(_extends({
922
- isOpen: _this.props.defaultIsOpen,
923
- highlightedIndex: _this.props.defaultHighlightedIndex,
856
+ this.internalSetState({
857
+ isOpen: this.props.defaultIsOpen,
858
+ highlightedIndex: this.props.defaultHighlightedIndex,
924
859
  selectedItem: item,
925
- inputValue: _this.props.itemToString(item)
926
- }, otherStateToSet), cb);
860
+ inputValue: this.props.itemToString(item),
861
+ ...otherStateToSet
862
+ }, cb);
927
863
  };
928
864
 
929
- _this.selectItemAtIndex = function (itemIndex, otherStateToSet, cb) {
930
- var item = _this.items[itemIndex];
865
+ this.selectItemAtIndex = (itemIndex, otherStateToSet, cb) => {
866
+ const item = this.items[itemIndex];
931
867
 
932
868
  if (item == null) {
933
869
  return;
934
870
  }
935
871
 
936
- _this.selectItem(item, otherStateToSet, cb);
872
+ this.selectItem(item, otherStateToSet, cb);
937
873
  };
938
874
 
939
- _this.selectHighlightedItem = function (otherStateToSet, cb) {
940
- return _this.selectItemAtIndex(_this.getState().highlightedIndex, otherStateToSet, cb);
875
+ this.selectHighlightedItem = (otherStateToSet, cb) => {
876
+ return this.selectItemAtIndex(this.getState().highlightedIndex, otherStateToSet, cb);
941
877
  };
942
878
 
943
- _this.internalSetState = function (stateToSet, cb) {
944
- var isItemSelected, onChangeArg;
945
- var onStateChangeArg = {};
946
- var isStateToSetFunction = typeof stateToSet === 'function'; // we want to call `onInputValueChange` before the `setState` call
879
+ this.internalSetState = (stateToSet, cb) => {
880
+ let isItemSelected, onChangeArg;
881
+ const onStateChangeArg = {};
882
+ const isStateToSetFunction = typeof stateToSet === 'function'; // we want to call `onInputValueChange` before the `setState` call
947
883
  // so someone controlling the `inputValue` state gets notified of
948
884
  // the input change as soon as possible. This avoids issues with
949
885
  // preserving the cursor position.
950
886
  // See https://github.com/downshift-js/downshift/issues/217 for more info.
951
887
 
952
888
  if (!isStateToSetFunction && stateToSet.hasOwnProperty('inputValue')) {
953
- _this.props.onInputValueChange(stateToSet.inputValue, _extends({}, _this.getStateAndHelpers(), stateToSet));
889
+ this.props.onInputValueChange(stateToSet.inputValue, { ...this.getStateAndHelpers(),
890
+ ...stateToSet
891
+ });
954
892
  }
955
893
 
956
- return _this.setState(function (state) {
957
- state = _this.getState(state);
958
- var newStateToSet = isStateToSetFunction ? stateToSet(state) : stateToSet; // Your own function that could modify the state that will be set.
894
+ return this.setState(state => {
895
+ state = this.getState(state);
896
+ let newStateToSet = isStateToSetFunction ? stateToSet(state) : stateToSet; // Your own function that could modify the state that will be set.
959
897
 
960
- newStateToSet = _this.props.stateReducer(state, newStateToSet); // checks if an item is selected, regardless of if it's different from
898
+ newStateToSet = this.props.stateReducer(state, newStateToSet); // checks if an item is selected, regardless of if it's different from
961
899
  // what was selected before
962
900
  // used to determine if onSelect and onChange callbacks should be called
963
901
 
964
902
  isItemSelected = newStateToSet.hasOwnProperty('selectedItem'); // this keeps track of the object we want to call with setState
965
903
 
966
- var nextState = {}; // this is just used to tell whether the state changed
967
-
968
- var nextFullState = {}; // we need to call on change if the outside world is controlling any of our state
904
+ const nextState = {}; // this is just used to tell whether the state changed
969
905
  // and we're trying to update that state. OR if the selection has changed and we're
970
906
  // trying to update the selection
971
907
 
@@ -974,7 +910,7 @@
974
910
  }
975
911
 
976
912
  newStateToSet.type = newStateToSet.type || unknown;
977
- Object.keys(newStateToSet).forEach(function (key) {
913
+ Object.keys(newStateToSet).forEach(key => {
978
914
  // onStateChangeArg should only have the state that is
979
915
  // actually changing
980
916
  if (state[key] !== newStateToSet[key]) {
@@ -991,81 +927,84 @@
991
927
  return;
992
928
  }
993
929
 
994
- nextFullState[key] = newStateToSet[key]; // if it's coming from props, then we don't care to set it internally
930
+ newStateToSet[key]; // if it's coming from props, then we don't care to set it internally
995
931
 
996
- if (!isControlledProp(_this.props, key)) {
932
+ if (!isControlledProp(this.props, key)) {
997
933
  nextState[key] = newStateToSet[key];
998
934
  }
999
935
  }); // if stateToSet is a function, then we weren't able to call onInputValueChange
1000
936
  // earlier, so we'll call it now that we know what the inputValue state will be.
1001
937
 
1002
938
  if (isStateToSetFunction && newStateToSet.hasOwnProperty('inputValue')) {
1003
- _this.props.onInputValueChange(newStateToSet.inputValue, _extends({}, _this.getStateAndHelpers(), newStateToSet));
939
+ this.props.onInputValueChange(newStateToSet.inputValue, { ...this.getStateAndHelpers(),
940
+ ...newStateToSet
941
+ });
1004
942
  }
1005
943
 
1006
944
  return nextState;
1007
- }, function () {
945
+ }, () => {
1008
946
  // call the provided callback if it's a function
1009
947
  cbToCb(cb)(); // only call the onStateChange and onChange callbacks if
1010
948
  // we have relevant information to pass them.
1011
949
 
1012
- var hasMoreStateThanType = Object.keys(onStateChangeArg).length > 1;
950
+ const hasMoreStateThanType = Object.keys(onStateChangeArg).length > 1;
1013
951
 
1014
952
  if (hasMoreStateThanType) {
1015
- _this.props.onStateChange(onStateChangeArg, _this.getStateAndHelpers());
953
+ this.props.onStateChange(onStateChangeArg, this.getStateAndHelpers());
1016
954
  }
1017
955
 
1018
956
  if (isItemSelected) {
1019
- _this.props.onSelect(stateToSet.selectedItem, _this.getStateAndHelpers());
957
+ this.props.onSelect(stateToSet.selectedItem, this.getStateAndHelpers());
1020
958
  }
1021
959
 
1022
960
  if (onChangeArg !== undefined) {
1023
- _this.props.onChange(onChangeArg, _this.getStateAndHelpers());
961
+ this.props.onChange(onChangeArg, this.getStateAndHelpers());
1024
962
  } // this is currently undocumented and therefore subject to change
1025
963
  // We'll try to not break it, but just be warned.
1026
964
 
1027
965
 
1028
- _this.props.onUserAction(onStateChangeArg, _this.getStateAndHelpers());
966
+ this.props.onUserAction(onStateChangeArg, this.getStateAndHelpers());
1029
967
  });
1030
968
  };
1031
969
 
1032
- _this.rootRef = function (node) {
1033
- return _this._rootNode = node;
1034
- };
1035
-
1036
- _this.getRootProps = function (_temp, _temp2) {
1037
- var _extends2;
1038
-
1039
- var _ref = _temp === void 0 ? {} : _temp,
1040
- _ref$refKey = _ref.refKey,
1041
- refKey = _ref$refKey === void 0 ? 'ref' : _ref$refKey,
1042
- ref = _ref.ref,
1043
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$4);
1044
-
1045
- var _ref2 = _temp2 === void 0 ? {} : _temp2,
1046
- _ref2$suppressRefErro = _ref2.suppressRefError,
1047
- suppressRefError = _ref2$suppressRefErro === void 0 ? false : _ref2$suppressRefErro;
1048
-
970
+ this.rootRef = node => this._rootNode = node;
971
+
972
+ this.getRootProps = function (_temp, _temp2) {
973
+ let {
974
+ refKey = 'ref',
975
+ ref,
976
+ ...rest
977
+ } = _temp === void 0 ? {} : _temp;
978
+ let {
979
+ suppressRefError = false
980
+ } = _temp2 === void 0 ? {} : _temp2;
1049
981
  // this is used in the render to know whether the user has called getRootProps.
1050
982
  // It uses that to know whether to apply the props automatically
1051
983
  _this.getRootProps.called = true;
1052
984
  _this.getRootProps.refKey = refKey;
1053
985
  _this.getRootProps.suppressRefError = suppressRefError;
1054
986
 
1055
- var _this$getState = _this.getState(),
1056
- isOpen = _this$getState.isOpen;
987
+ const {
988
+ isOpen
989
+ } = _this.getState();
1057
990
 
1058
- 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);
991
+ return {
992
+ [refKey]: handleRefs(ref, _this.rootRef),
993
+ role: 'combobox',
994
+ 'aria-expanded': isOpen,
995
+ 'aria-haspopup': 'listbox',
996
+ 'aria-owns': isOpen ? _this.menuId : null,
997
+ 'aria-labelledby': _this.labelId,
998
+ ...rest
999
+ };
1059
1000
  };
1060
1001
 
1061
- _this.keyDownHandlers = {
1062
- ArrowDown: function ArrowDown(event) {
1063
- var _this2 = this;
1064
-
1002
+ this.keyDownHandlers = {
1003
+ ArrowDown(event) {
1065
1004
  event.preventDefault();
1066
1005
 
1067
1006
  if (this.getState().isOpen) {
1068
- var amount = event.shiftKey ? 5 : 1;
1007
+ const amount = event.shiftKey ? 5 : 1;
1069
1008
  this.moveHighlightedIndex(amount, {
1070
1009
  type: keyDownArrowDown
1071
1010
  });
@@ -1073,31 +1012,27 @@
1073
1012
  this.internalSetState({
1074
1013
  isOpen: true,
1075
1014
  type: keyDownArrowDown
1076
- }, function () {
1077
- var itemCount = _this2.getItemCount();
1015
+ }, () => {
1016
+ const itemCount = this.getItemCount();
1078
1017
 
1079
1018
  if (itemCount > 0) {
1080
- var _this2$getState = _this2.getState(),
1081
- highlightedIndex = _this2$getState.highlightedIndex;
1082
-
1083
- var nextHighlightedIndex = getNextWrappingIndex(1, highlightedIndex, itemCount, function (index) {
1084
- return _this2.getItemNodeFromIndex(index);
1085
- });
1086
-
1087
- _this2.setHighlightedIndex(nextHighlightedIndex, {
1019
+ const {
1020
+ highlightedIndex
1021
+ } = this.getState();
1022
+ const nextHighlightedIndex = getNextWrappingIndex(1, highlightedIndex, itemCount, index => this.getItemNodeFromIndex(index));
1023
+ this.setHighlightedIndex(nextHighlightedIndex, {
1088
1024
  type: keyDownArrowDown
1089
1025
  });
1090
1026
  }
1091
1027
  });
1092
1028
  }
1093
1029
  },
1094
- ArrowUp: function ArrowUp(event) {
1095
- var _this3 = this;
1096
1030
 
1031
+ ArrowUp(event) {
1097
1032
  event.preventDefault();
1098
1033
 
1099
1034
  if (this.getState().isOpen) {
1100
- var amount = event.shiftKey ? -5 : -1;
1035
+ const amount = event.shiftKey ? -5 : -1;
1101
1036
  this.moveHighlightedIndex(amount, {
1102
1037
  type: keyDownArrowUp
1103
1038
  });
@@ -1105,37 +1040,36 @@
1105
1040
  this.internalSetState({
1106
1041
  isOpen: true,
1107
1042
  type: keyDownArrowUp
1108
- }, function () {
1109
- var itemCount = _this3.getItemCount();
1043
+ }, () => {
1044
+ const itemCount = this.getItemCount();
1110
1045
 
1111
1046
  if (itemCount > 0) {
1112
- var _this3$getState = _this3.getState(),
1113
- highlightedIndex = _this3$getState.highlightedIndex;
1114
-
1115
- var nextHighlightedIndex = getNextWrappingIndex(-1, highlightedIndex, itemCount, function (index) {
1116
- return _this3.getItemNodeFromIndex(index);
1117
- });
1118
-
1119
- _this3.setHighlightedIndex(nextHighlightedIndex, {
1047
+ const {
1048
+ highlightedIndex
1049
+ } = this.getState();
1050
+ const nextHighlightedIndex = getNextWrappingIndex(-1, highlightedIndex, itemCount, index => this.getItemNodeFromIndex(index));
1051
+ this.setHighlightedIndex(nextHighlightedIndex, {
1120
1052
  type: keyDownArrowUp
1121
1053
  });
1122
1054
  }
1123
1055
  });
1124
1056
  }
1125
1057
  },
1126
- Enter: function Enter(event) {
1058
+
1059
+ Enter(event) {
1127
1060
  if (event.which === 229) {
1128
1061
  return;
1129
1062
  }
1130
1063
 
1131
- var _this$getState2 = this.getState(),
1132
- isOpen = _this$getState2.isOpen,
1133
- highlightedIndex = _this$getState2.highlightedIndex;
1064
+ const {
1065
+ isOpen,
1066
+ highlightedIndex
1067
+ } = this.getState();
1134
1068
 
1135
1069
  if (isOpen && highlightedIndex != null) {
1136
1070
  event.preventDefault();
1137
- var item = this.items[highlightedIndex];
1138
- var itemNode = this.getItemNodeFromIndex(highlightedIndex);
1071
+ const item = this.items[highlightedIndex];
1072
+ const itemNode = this.getItemNodeFromIndex(highlightedIndex);
1139
1073
 
1140
1074
  if (item == null || itemNode && itemNode.hasAttribute('disabled')) {
1141
1075
  return;
@@ -1146,125 +1080,131 @@
1146
1080
  });
1147
1081
  }
1148
1082
  },
1149
- Escape: function Escape(event) {
1083
+
1084
+ Escape(event) {
1150
1085
  event.preventDefault();
1151
- this.reset(_extends({
1152
- type: keyDownEscape
1153
- }, !this.state.isOpen && {
1154
- selectedItem: null,
1155
- inputValue: ''
1156
- }));
1086
+ this.reset({
1087
+ type: keyDownEscape,
1088
+ ...(!this.state.isOpen && {
1089
+ selectedItem: null,
1090
+ inputValue: ''
1091
+ })
1092
+ });
1157
1093
  }
1094
+
1158
1095
  };
1159
- _this.buttonKeyDownHandlers = _extends({}, _this.keyDownHandlers, {
1160
- ' ': function _(event) {
1096
+ this.buttonKeyDownHandlers = { ...this.keyDownHandlers,
1097
+
1098
+ ' '(event) {
1161
1099
  event.preventDefault();
1162
1100
  this.toggleMenu({
1163
1101
  type: keyDownSpaceButton
1164
1102
  });
1165
1103
  }
1166
- });
1167
- _this.inputKeyDownHandlers = _extends({}, _this.keyDownHandlers, {
1168
- Home: function Home(event) {
1169
- var _this4 = this;
1170
1104
 
1171
- var _this$getState3 = this.getState(),
1172
- isOpen = _this$getState3.isOpen;
1105
+ };
1106
+ this.inputKeyDownHandlers = { ...this.keyDownHandlers,
1107
+
1108
+ Home(event) {
1109
+ const {
1110
+ isOpen
1111
+ } = this.getState();
1173
1112
 
1174
1113
  if (!isOpen) {
1175
1114
  return;
1176
1115
  }
1177
1116
 
1178
1117
  event.preventDefault();
1179
- var itemCount = this.getItemCount();
1118
+ const itemCount = this.getItemCount();
1180
1119
 
1181
1120
  if (itemCount <= 0 || !isOpen) {
1182
1121
  return;
1183
1122
  } // get next non-disabled starting downwards from 0 if that's disabled.
1184
1123
 
1185
1124
 
1186
- var newHighlightedIndex = getNextNonDisabledIndex(1, 0, itemCount, function (index) {
1187
- return _this4.getItemNodeFromIndex(index);
1188
- }, false);
1125
+ const newHighlightedIndex = getNextNonDisabledIndex(1, 0, itemCount, index => this.getItemNodeFromIndex(index), false);
1189
1126
  this.setHighlightedIndex(newHighlightedIndex, {
1190
1127
  type: keyDownHome
1191
1128
  });
1192
1129
  },
1193
- End: function End(event) {
1194
- var _this5 = this;
1195
1130
 
1196
- var _this$getState4 = this.getState(),
1197
- isOpen = _this$getState4.isOpen;
1131
+ End(event) {
1132
+ const {
1133
+ isOpen
1134
+ } = this.getState();
1198
1135
 
1199
1136
  if (!isOpen) {
1200
1137
  return;
1201
1138
  }
1202
1139
 
1203
1140
  event.preventDefault();
1204
- var itemCount = this.getItemCount();
1141
+ const itemCount = this.getItemCount();
1205
1142
 
1206
1143
  if (itemCount <= 0 || !isOpen) {
1207
1144
  return;
1208
1145
  } // get next non-disabled starting upwards from last index if that's disabled.
1209
1146
 
1210
1147
 
1211
- var newHighlightedIndex = getNextNonDisabledIndex(-1, itemCount - 1, itemCount, function (index) {
1212
- return _this5.getItemNodeFromIndex(index);
1213
- }, false);
1148
+ const newHighlightedIndex = getNextNonDisabledIndex(-1, itemCount - 1, itemCount, index => this.getItemNodeFromIndex(index), false);
1214
1149
  this.setHighlightedIndex(newHighlightedIndex, {
1215
1150
  type: keyDownEnd
1216
1151
  });
1217
1152
  }
1218
- });
1219
1153
 
1220
- _this.getToggleButtonProps = function (_temp3) {
1221
- var _ref3 = _temp3 === void 0 ? {} : _temp3,
1222
- onClick = _ref3.onClick;
1223
- _ref3.onPress;
1224
- var onKeyDown = _ref3.onKeyDown,
1225
- onKeyUp = _ref3.onKeyUp,
1226
- onBlur = _ref3.onBlur,
1227
- rest = _objectWithoutPropertiesLoose(_ref3, _excluded2$3);
1228
-
1229
- var _this$getState5 = _this.getState(),
1230
- isOpen = _this$getState5.isOpen;
1154
+ };
1231
1155
 
1232
- var enabledEventHandlers = {
1156
+ this.getToggleButtonProps = function (_temp3) {
1157
+ let {
1158
+ onClick,
1159
+ onPress,
1160
+ onKeyDown,
1161
+ onKeyUp,
1162
+ onBlur,
1163
+ ...rest
1164
+ } = _temp3 === void 0 ? {} : _temp3;
1165
+
1166
+ const {
1167
+ isOpen
1168
+ } = _this.getState();
1169
+
1170
+ const enabledEventHandlers = {
1233
1171
  onClick: callAllEventHandlers(onClick, _this.buttonHandleClick),
1234
1172
  onKeyDown: callAllEventHandlers(onKeyDown, _this.buttonHandleKeyDown),
1235
1173
  onKeyUp: callAllEventHandlers(onKeyUp, _this.buttonHandleKeyUp),
1236
1174
  onBlur: callAllEventHandlers(onBlur, _this.buttonHandleBlur)
1237
1175
  };
1238
- var eventHandlers = rest.disabled ? {} : enabledEventHandlers;
1239
- return _extends({
1176
+ const eventHandlers = rest.disabled ? {} : enabledEventHandlers;
1177
+ return {
1240
1178
  type: 'button',
1241
1179
  role: 'button',
1242
1180
  'aria-label': isOpen ? 'close menu' : 'open menu',
1243
1181
  'aria-haspopup': true,
1244
- 'data-toggle': true
1245
- }, eventHandlers, rest);
1182
+ 'data-toggle': true,
1183
+ ...eventHandlers,
1184
+ ...rest
1185
+ };
1246
1186
  };
1247
1187
 
1248
- _this.buttonHandleKeyUp = function (event) {
1188
+ this.buttonHandleKeyUp = event => {
1249
1189
  // Prevent click event from emitting in Firefox
1250
1190
  event.preventDefault();
1251
1191
  };
1252
1192
 
1253
- _this.buttonHandleKeyDown = function (event) {
1254
- var key = normalizeArrowKey(event);
1193
+ this.buttonHandleKeyDown = event => {
1194
+ const key = normalizeArrowKey(event);
1255
1195
 
1256
- if (_this.buttonKeyDownHandlers[key]) {
1257
- _this.buttonKeyDownHandlers[key].call(_assertThisInitialized(_this), event);
1196
+ if (this.buttonKeyDownHandlers[key]) {
1197
+ this.buttonKeyDownHandlers[key].call(this, event);
1258
1198
  }
1259
1199
  };
1260
1200
 
1261
- _this.buttonHandleClick = function (event) {
1201
+ this.buttonHandleClick = event => {
1262
1202
  event.preventDefault(); // handle odd case for Safari and Firefox which
1263
1203
  // don't give the button the focus properly.
1264
1204
 
1265
1205
  /* istanbul ignore if (can't reasonably test this) */
1266
1206
 
1267
- if (_this.props.environment.document.activeElement === _this.props.environment.document.body) {
1207
+ if (this.props.environment.document.activeElement === this.props.environment.document.body) {
1268
1208
  event.target.focus();
1269
1209
  } // to simplify testing components that use downshift, we'll not wrap this in a setTimeout
1270
1210
  // if the NODE_ENV is test. With the proper build system, this should be dead code eliminated
@@ -1273,64 +1213,66 @@
1273
1213
 
1274
1214
  {
1275
1215
  // Ensure that toggle of menu occurs after the potential blur event in iOS
1276
- _this.internalSetTimeout(function () {
1277
- return _this.toggleMenu({
1278
- type: clickButton
1279
- });
1280
- });
1216
+ this.internalSetTimeout(() => this.toggleMenu({
1217
+ type: clickButton
1218
+ }));
1281
1219
  }
1282
1220
  };
1283
1221
 
1284
- _this.buttonHandleBlur = function (event) {
1285
- var blurTarget = event.target; // Save blur target for comparison with activeElement later
1222
+ this.buttonHandleBlur = event => {
1223
+ const blurTarget = event.target; // Save blur target for comparison with activeElement later
1286
1224
  // Need setTimeout, so that when the user presses Tab, the activeElement is the next focused element, not body element
1287
1225
 
1288
- _this.internalSetTimeout(function () {
1289
- 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)
1226
+ this.internalSetTimeout(() => {
1227
+ 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)
1290
1228
  ) {
1291
- _this.reset({
1229
+ this.reset({
1292
1230
  type: blurButton
1293
1231
  });
1294
1232
  }
1295
1233
  });
1296
1234
  };
1297
1235
 
1298
- _this.getLabelProps = function (props) {
1299
- return _extends({
1300
- htmlFor: _this.inputId,
1301
- id: _this.labelId
1302
- }, props);
1236
+ this.getLabelProps = props => {
1237
+ return {
1238
+ htmlFor: this.inputId,
1239
+ id: this.labelId,
1240
+ ...props
1241
+ };
1303
1242
  };
1304
1243
 
1305
- _this.getInputProps = function (_temp4) {
1306
- var _ref4 = _temp4 === void 0 ? {} : _temp4,
1307
- onKeyDown = _ref4.onKeyDown,
1308
- onBlur = _ref4.onBlur,
1309
- onChange = _ref4.onChange,
1310
- onInput = _ref4.onInput;
1311
- _ref4.onChangeText;
1312
- var rest = _objectWithoutPropertiesLoose(_ref4, _excluded3$2);
1313
-
1314
- var onChangeKey;
1315
- var eventHandlers = {};
1244
+ this.getInputProps = function (_temp4) {
1245
+ let {
1246
+ onKeyDown,
1247
+ onBlur,
1248
+ onChange,
1249
+ onInput,
1250
+ onChangeText,
1251
+ ...rest
1252
+ } = _temp4 === void 0 ? {} : _temp4;
1253
+ let onChangeKey;
1254
+ let eventHandlers = {};
1316
1255
  /* istanbul ignore next (preact) */
1317
1256
 
1318
1257
  {
1319
1258
  onChangeKey = 'onInput';
1320
1259
  }
1321
1260
 
1322
- var _this$getState6 = _this.getState(),
1323
- inputValue = _this$getState6.inputValue,
1324
- isOpen = _this$getState6.isOpen,
1325
- highlightedIndex = _this$getState6.highlightedIndex;
1261
+ const {
1262
+ inputValue,
1263
+ isOpen,
1264
+ highlightedIndex
1265
+ } = _this.getState();
1326
1266
 
1327
1267
  if (!rest.disabled) {
1328
- var _eventHandlers;
1329
-
1330
- eventHandlers = (_eventHandlers = {}, _eventHandlers[onChangeKey] = callAllEventHandlers(onChange, onInput, _this.inputHandleChange), _eventHandlers.onKeyDown = callAllEventHandlers(onKeyDown, _this.inputHandleKeyDown), _eventHandlers.onBlur = callAllEventHandlers(onBlur, _this.inputHandleBlur), _eventHandlers);
1268
+ eventHandlers = {
1269
+ [onChangeKey]: callAllEventHandlers(onChange, onInput, _this.inputHandleChange),
1270
+ onKeyDown: callAllEventHandlers(onKeyDown, _this.inputHandleKeyDown),
1271
+ onBlur: callAllEventHandlers(onBlur, _this.inputHandleBlur)
1272
+ };
1331
1273
  }
1332
1274
 
1333
- return _extends({
1275
+ return {
1334
1276
  'aria-autocomplete': 'list',
1335
1277
  'aria-activedescendant': isOpen && typeof highlightedIndex === 'number' && highlightedIndex >= 0 ? _this.getItemId(highlightedIndex) : null,
1336
1278
  'aria-controls': isOpen ? _this.menuId : null,
@@ -1339,75 +1281,77 @@
1339
1281
  // revert back since autocomplete="nope" is ignored on latest Chrome and Opera
1340
1282
  autoComplete: 'off',
1341
1283
  value: inputValue,
1342
- id: _this.inputId
1343
- }, eventHandlers, rest);
1284
+ id: _this.inputId,
1285
+ ...eventHandlers,
1286
+ ...rest
1287
+ };
1344
1288
  };
1345
1289
 
1346
- _this.inputHandleKeyDown = function (event) {
1347
- var key = normalizeArrowKey(event);
1290
+ this.inputHandleKeyDown = event => {
1291
+ const key = normalizeArrowKey(event);
1348
1292
 
1349
- if (key && _this.inputKeyDownHandlers[key]) {
1350
- _this.inputKeyDownHandlers[key].call(_assertThisInitialized(_this), event);
1293
+ if (key && this.inputKeyDownHandlers[key]) {
1294
+ this.inputKeyDownHandlers[key].call(this, event);
1351
1295
  }
1352
1296
  };
1353
1297
 
1354
- _this.inputHandleChange = function (event) {
1355
- _this.internalSetState({
1298
+ this.inputHandleChange = event => {
1299
+ this.internalSetState({
1356
1300
  type: changeInput,
1357
1301
  isOpen: true,
1358
1302
  inputValue: event.target.value,
1359
- highlightedIndex: _this.props.defaultHighlightedIndex
1303
+ highlightedIndex: this.props.defaultHighlightedIndex
1360
1304
  });
1361
1305
  };
1362
1306
 
1363
- _this.inputHandleBlur = function () {
1307
+ this.inputHandleBlur = () => {
1364
1308
  // Need setTimeout, so that when the user presses Tab, the activeElement is the next focused element, not the body element
1365
- _this.internalSetTimeout(function () {
1366
- 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);
1309
+ this.internalSetTimeout(() => {
1310
+ 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);
1367
1311
 
1368
- if (!_this.isMouseDown && !downshiftButtonIsActive) {
1369
- _this.reset({
1312
+ if (!this.isMouseDown && !downshiftButtonIsActive) {
1313
+ this.reset({
1370
1314
  type: blurInput
1371
1315
  });
1372
1316
  }
1373
1317
  });
1374
1318
  };
1375
1319
 
1376
- _this.menuRef = function (node) {
1377
- _this._menuNode = node;
1320
+ this.menuRef = node => {
1321
+ this._menuNode = node;
1378
1322
  };
1379
1323
 
1380
- _this.getMenuProps = function (_temp5, _temp6) {
1381
- var _extends3;
1382
-
1383
- var _ref5 = _temp5 === void 0 ? {} : _temp5,
1384
- _ref5$refKey = _ref5.refKey,
1385
- refKey = _ref5$refKey === void 0 ? 'ref' : _ref5$refKey,
1386
- ref = _ref5.ref,
1387
- props = _objectWithoutPropertiesLoose(_ref5, _excluded4$1);
1388
-
1389
- var _ref6 = _temp6 === void 0 ? {} : _temp6,
1390
- _ref6$suppressRefErro = _ref6.suppressRefError,
1391
- suppressRefError = _ref6$suppressRefErro === void 0 ? false : _ref6$suppressRefErro;
1392
-
1324
+ this.getMenuProps = function (_temp5, _temp6) {
1325
+ let {
1326
+ refKey = 'ref',
1327
+ ref,
1328
+ ...props
1329
+ } = _temp5 === void 0 ? {} : _temp5;
1330
+ let {
1331
+ suppressRefError = false
1332
+ } = _temp6 === void 0 ? {} : _temp6;
1393
1333
  _this.getMenuProps.called = true;
1394
1334
  _this.getMenuProps.refKey = refKey;
1395
1335
  _this.getMenuProps.suppressRefError = suppressRefError;
1396
- 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);
1336
+ return {
1337
+ [refKey]: handleRefs(ref, _this.menuRef),
1338
+ role: 'listbox',
1339
+ 'aria-labelledby': props && props['aria-label'] ? null : _this.labelId,
1340
+ id: _this.menuId,
1341
+ ...props
1342
+ };
1397
1343
  };
1398
1344
 
1399
- _this.getItemProps = function (_temp7) {
1400
- var _enabledEventHandlers;
1401
-
1402
- var _ref7 = _temp7 === void 0 ? {} : _temp7,
1403
- onMouseMove = _ref7.onMouseMove,
1404
- onMouseDown = _ref7.onMouseDown,
1405
- onClick = _ref7.onClick;
1406
- _ref7.onPress;
1407
- var index = _ref7.index,
1408
- _ref7$item = _ref7.item,
1409
- item = _ref7$item === void 0 ? requiredProp('getItemProps', 'item') : _ref7$item,
1410
- rest = _objectWithoutPropertiesLoose(_ref7, _excluded5$1);
1345
+ this.getItemProps = function (_temp7) {
1346
+ let {
1347
+ onMouseMove,
1348
+ onMouseDown,
1349
+ onClick,
1350
+ onPress,
1351
+ index,
1352
+ item = requiredProp('getItemProps', 'item'),
1353
+ ...rest
1354
+ } = _temp7 === void 0 ? {} : _temp7;
1411
1355
 
1412
1356
  if (index === undefined) {
1413
1357
  _this.items.push(item);
@@ -1417,13 +1361,13 @@
1417
1361
  _this.items[index] = item;
1418
1362
  }
1419
1363
 
1420
- var onSelectKey = 'onClick';
1421
- var customClickHandler = onClick;
1422
- var enabledEventHandlers = (_enabledEventHandlers = {
1364
+ const onSelectKey = 'onClick';
1365
+ const customClickHandler = onClick;
1366
+ const enabledEventHandlers = {
1423
1367
  // onMouseMove is used over onMouseEnter here. onMouseMove
1424
1368
  // is only triggered on actual mouse movement while onMouseEnter
1425
1369
  // can fire on DOM changes, interrupting keyboard navigation
1426
- onMouseMove: callAllEventHandlers(onMouseMove, function () {
1370
+ onMouseMove: callAllEventHandlers(onMouseMove, () => {
1427
1371
  if (index === _this.getState().highlightedIndex) {
1428
1372
  return;
1429
1373
  }
@@ -1438,72 +1382,81 @@
1438
1382
 
1439
1383
  _this.avoidScrolling = true;
1440
1384
 
1441
- _this.internalSetTimeout(function () {
1442
- return _this.avoidScrolling = false;
1443
- }, 250);
1385
+ _this.internalSetTimeout(() => _this.avoidScrolling = false, 250);
1444
1386
  }),
1445
- onMouseDown: callAllEventHandlers(onMouseDown, function (event) {
1387
+ onMouseDown: callAllEventHandlers(onMouseDown, event => {
1446
1388
  // This prevents the activeElement from being changed
1447
1389
  // to the item so it can remain with the current activeElement
1448
1390
  // which is a more common use case.
1449
1391
  event.preventDefault();
1392
+ }),
1393
+ [onSelectKey]: callAllEventHandlers(customClickHandler, () => {
1394
+ _this.selectItemAtIndex(index, {
1395
+ type: clickItem
1396
+ });
1450
1397
  })
1451
- }, _enabledEventHandlers[onSelectKey] = callAllEventHandlers(customClickHandler, function () {
1452
- _this.selectItemAtIndex(index, {
1453
- type: clickItem
1454
- });
1455
- }), _enabledEventHandlers); // Passing down the onMouseDown handler to prevent redirect
1398
+ }; // Passing down the onMouseDown handler to prevent redirect
1456
1399
  // of the activeElement if clicking on disabled items
1457
1400
 
1458
- var eventHandlers = rest.disabled ? {
1401
+ const eventHandlers = rest.disabled ? {
1459
1402
  onMouseDown: enabledEventHandlers.onMouseDown
1460
1403
  } : enabledEventHandlers;
1461
- return _extends({
1404
+ return {
1462
1405
  id: _this.getItemId(index),
1463
1406
  role: 'option',
1464
- 'aria-selected': _this.getState().highlightedIndex === index
1465
- }, eventHandlers, rest);
1407
+ 'aria-selected': _this.getState().highlightedIndex === index,
1408
+ ...eventHandlers,
1409
+ ...rest
1410
+ };
1466
1411
  };
1467
1412
 
1468
- _this.clearItems = function () {
1469
- _this.items = [];
1413
+ this.clearItems = () => {
1414
+ this.items = [];
1470
1415
  };
1471
1416
 
1472
- _this.reset = function (otherStateToSet, cb) {
1417
+ this.reset = function (otherStateToSet, cb) {
1473
1418
  if (otherStateToSet === void 0) {
1474
1419
  otherStateToSet = {};
1475
1420
  }
1476
1421
 
1477
1422
  otherStateToSet = pickState(otherStateToSet);
1478
1423
 
1479
- _this.internalSetState(function (_ref8) {
1480
- var selectedItem = _ref8.selectedItem;
1481
- return _extends({
1424
+ _this.internalSetState(_ref => {
1425
+ let {
1426
+ selectedItem
1427
+ } = _ref;
1428
+ return {
1482
1429
  isOpen: _this.props.defaultIsOpen,
1483
1430
  highlightedIndex: _this.props.defaultHighlightedIndex,
1484
- inputValue: _this.props.itemToString(selectedItem)
1485
- }, otherStateToSet);
1431
+ inputValue: _this.props.itemToString(selectedItem),
1432
+ ...otherStateToSet
1433
+ };
1486
1434
  }, cb);
1487
1435
  };
1488
1436
 
1489
- _this.toggleMenu = function (otherStateToSet, cb) {
1437
+ this.toggleMenu = function (otherStateToSet, cb) {
1490
1438
  if (otherStateToSet === void 0) {
1491
1439
  otherStateToSet = {};
1492
1440
  }
1493
1441
 
1494
1442
  otherStateToSet = pickState(otherStateToSet);
1495
1443
 
1496
- _this.internalSetState(function (_ref9) {
1497
- var isOpen = _ref9.isOpen;
1498
- return _extends({
1499
- isOpen: !isOpen
1500
- }, isOpen && {
1501
- highlightedIndex: _this.props.defaultHighlightedIndex
1502
- }, otherStateToSet);
1503
- }, function () {
1504
- var _this$getState7 = _this.getState(),
1505
- isOpen = _this$getState7.isOpen,
1506
- highlightedIndex = _this$getState7.highlightedIndex;
1444
+ _this.internalSetState(_ref2 => {
1445
+ let {
1446
+ isOpen
1447
+ } = _ref2;
1448
+ return {
1449
+ isOpen: !isOpen,
1450
+ ...(isOpen && {
1451
+ highlightedIndex: _this.props.defaultHighlightedIndex
1452
+ }),
1453
+ ...otherStateToSet
1454
+ };
1455
+ }, () => {
1456
+ const {
1457
+ isOpen,
1458
+ highlightedIndex
1459
+ } = _this.getState();
1507
1460
 
1508
1461
  if (isOpen) {
1509
1462
  if (_this.getItemCount() > 0 && typeof highlightedIndex === 'number') {
@@ -1515,70 +1468,63 @@
1515
1468
  });
1516
1469
  };
1517
1470
 
1518
- _this.openMenu = function (cb) {
1519
- _this.internalSetState({
1471
+ this.openMenu = cb => {
1472
+ this.internalSetState({
1520
1473
  isOpen: true
1521
1474
  }, cb);
1522
1475
  };
1523
1476
 
1524
- _this.closeMenu = function (cb) {
1525
- _this.internalSetState({
1477
+ this.closeMenu = cb => {
1478
+ this.internalSetState({
1526
1479
  isOpen: false
1527
1480
  }, cb);
1528
1481
  };
1529
1482
 
1530
- _this.updateStatus = debounce(function () {
1531
- var state = _this.getState();
1532
-
1533
- var item = _this.items[state.highlightedIndex];
1534
-
1535
- var resultCount = _this.getItemCount();
1536
-
1537
- var status = _this.props.getA11yStatusMessage(_extends({
1538
- itemToString: _this.props.itemToString,
1539
- previousResultCount: _this.previousResultCount,
1540
- resultCount: resultCount,
1541
- highlightedItem: item
1542
- }, state));
1543
-
1544
- _this.previousResultCount = resultCount;
1545
- setStatus(status, _this.props.environment.document);
1483
+ this.updateStatus = debounce(() => {
1484
+ const state = this.getState();
1485
+ const item = this.items[state.highlightedIndex];
1486
+ const resultCount = this.getItemCount();
1487
+ const status = this.props.getA11yStatusMessage({
1488
+ itemToString: this.props.itemToString,
1489
+ previousResultCount: this.previousResultCount,
1490
+ resultCount,
1491
+ highlightedItem: item,
1492
+ ...state
1493
+ });
1494
+ this.previousResultCount = resultCount;
1495
+ setStatus(status, this.props.environment.document);
1546
1496
  }, 200);
1547
-
1548
- var _this$props = _this.props,
1549
- defaultHighlightedIndex = _this$props.defaultHighlightedIndex,
1550
- _this$props$initialHi = _this$props.initialHighlightedIndex,
1551
- _highlightedIndex = _this$props$initialHi === void 0 ? defaultHighlightedIndex : _this$props$initialHi,
1552
- defaultIsOpen = _this$props.defaultIsOpen,
1553
- _this$props$initialIs = _this$props.initialIsOpen,
1554
- _isOpen = _this$props$initialIs === void 0 ? defaultIsOpen : _this$props$initialIs,
1555
- _this$props$initialIn = _this$props.initialInputValue,
1556
- _inputValue = _this$props$initialIn === void 0 ? '' : _this$props$initialIn,
1557
- _this$props$initialSe = _this$props.initialSelectedItem,
1558
- _selectedItem = _this$props$initialSe === void 0 ? null : _this$props$initialSe;
1559
-
1560
- var _state = _this.getState({
1497
+ // fancy destructuring + defaults + aliases
1498
+ // this basically says each value of state should either be set to
1499
+ // the initial value or the default value if the initial value is not provided
1500
+ const {
1501
+ defaultHighlightedIndex,
1502
+ initialHighlightedIndex: _highlightedIndex = defaultHighlightedIndex,
1503
+ defaultIsOpen,
1504
+ initialIsOpen: _isOpen = defaultIsOpen,
1505
+ initialInputValue: _inputValue = '',
1506
+ initialSelectedItem: _selectedItem = null
1507
+ } = this.props;
1508
+
1509
+ const _state = this.getState({
1561
1510
  highlightedIndex: _highlightedIndex,
1562
1511
  isOpen: _isOpen,
1563
1512
  inputValue: _inputValue,
1564
1513
  selectedItem: _selectedItem
1565
1514
  });
1566
1515
 
1567
- if (_state.selectedItem != null && _this.props.initialInputValue === undefined) {
1568
- _state.inputValue = _this.props.itemToString(_state.selectedItem);
1516
+ if (_state.selectedItem != null && this.props.initialInputValue === undefined) {
1517
+ _state.inputValue = this.props.itemToString(_state.selectedItem);
1569
1518
  }
1570
1519
 
1571
- _this.state = _state;
1572
- return _this;
1520
+ this.state = _state;
1573
1521
  }
1574
1522
 
1575
- var _proto = Downshift.prototype;
1576
-
1577
1523
  /**
1578
1524
  * Clear all running timeouts
1579
1525
  */
1580
- _proto.internalClearTimeouts = function internalClearTimeouts() {
1581
- this.timeoutIds.forEach(function (id) {
1526
+ internalClearTimeouts() {
1527
+ this.timeoutIds.forEach(id => {
1582
1528
  clearTimeout(id);
1583
1529
  });
1584
1530
  this.timeoutIds = [];
@@ -1592,22 +1538,22 @@
1592
1538
  * @param {Object} stateToMerge defaults to this.state
1593
1539
  * @return {Object} the state
1594
1540
  */
1595
- ;
1596
1541
 
1597
- _proto.getState = function getState$1(stateToMerge) {
1542
+
1543
+ getState(stateToMerge) {
1598
1544
  if (stateToMerge === void 0) {
1599
1545
  stateToMerge = this.state;
1600
1546
  }
1601
1547
 
1602
1548
  return getState(stateToMerge, this.props);
1603
- };
1549
+ }
1604
1550
 
1605
- _proto.getItemCount = function getItemCount() {
1551
+ getItemCount() {
1606
1552
  // things read better this way. They're in priority order:
1607
1553
  // 1. `this.itemCount`
1608
1554
  // 2. `this.props.itemCount`
1609
1555
  // 3. `this.items.length`
1610
- var itemCount = this.items.length;
1556
+ let itemCount = this.items.length;
1611
1557
 
1612
1558
  if (this.itemCount != null) {
1613
1559
  itemCount = this.itemCount;
@@ -1616,102 +1562,102 @@
1616
1562
  }
1617
1563
 
1618
1564
  return itemCount;
1619
- };
1565
+ }
1620
1566
 
1621
- _proto.getItemNodeFromIndex = function getItemNodeFromIndex(index) {
1567
+ getItemNodeFromIndex(index) {
1622
1568
  return this.props.environment.document.getElementById(this.getItemId(index));
1623
- };
1569
+ }
1624
1570
 
1625
- _proto.scrollHighlightedItemIntoView = function scrollHighlightedItemIntoView() {
1571
+ scrollHighlightedItemIntoView() {
1626
1572
  /* istanbul ignore else (react-native) */
1627
1573
  {
1628
- var node = this.getItemNodeFromIndex(this.getState().highlightedIndex);
1574
+ const node = this.getItemNodeFromIndex(this.getState().highlightedIndex);
1629
1575
  this.props.scrollIntoView(node, this._menuNode);
1630
1576
  }
1631
- };
1632
-
1633
- _proto.moveHighlightedIndex = function moveHighlightedIndex(amount, otherStateToSet) {
1634
- var _this6 = this;
1635
-
1636
- var itemCount = this.getItemCount();
1577
+ }
1637
1578
 
1638
- var _this$getState8 = this.getState(),
1639
- highlightedIndex = _this$getState8.highlightedIndex;
1579
+ moveHighlightedIndex(amount, otherStateToSet) {
1580
+ const itemCount = this.getItemCount();
1581
+ const {
1582
+ highlightedIndex
1583
+ } = this.getState();
1640
1584
 
1641
1585
  if (itemCount > 0) {
1642
- var nextHighlightedIndex = getNextWrappingIndex(amount, highlightedIndex, itemCount, function (index) {
1643
- return _this6.getItemNodeFromIndex(index);
1644
- });
1586
+ const nextHighlightedIndex = getNextWrappingIndex(amount, highlightedIndex, itemCount, index => this.getItemNodeFromIndex(index));
1645
1587
  this.setHighlightedIndex(nextHighlightedIndex, otherStateToSet);
1646
1588
  }
1647
- };
1589
+ }
1648
1590
 
1649
- _proto.getStateAndHelpers = function getStateAndHelpers() {
1650
- var _this$getState9 = this.getState(),
1651
- highlightedIndex = _this$getState9.highlightedIndex,
1652
- inputValue = _this$getState9.inputValue,
1653
- selectedItem = _this$getState9.selectedItem,
1654
- isOpen = _this$getState9.isOpen;
1655
-
1656
- var itemToString = this.props.itemToString;
1657
- var id = this.id;
1658
- var getRootProps = this.getRootProps,
1659
- getToggleButtonProps = this.getToggleButtonProps,
1660
- getLabelProps = this.getLabelProps,
1661
- getMenuProps = this.getMenuProps,
1662
- getInputProps = this.getInputProps,
1663
- getItemProps = this.getItemProps,
1664
- openMenu = this.openMenu,
1665
- closeMenu = this.closeMenu,
1666
- toggleMenu = this.toggleMenu,
1667
- selectItem = this.selectItem,
1668
- selectItemAtIndex = this.selectItemAtIndex,
1669
- selectHighlightedItem = this.selectHighlightedItem,
1670
- setHighlightedIndex = this.setHighlightedIndex,
1671
- clearSelection = this.clearSelection,
1672
- clearItems = this.clearItems,
1673
- reset = this.reset,
1674
- setItemCount = this.setItemCount,
1675
- unsetItemCount = this.unsetItemCount,
1676
- setState = this.internalSetState;
1591
+ getStateAndHelpers() {
1592
+ const {
1593
+ highlightedIndex,
1594
+ inputValue,
1595
+ selectedItem,
1596
+ isOpen
1597
+ } = this.getState();
1598
+ const {
1599
+ itemToString
1600
+ } = this.props;
1601
+ const {
1602
+ id
1603
+ } = this;
1604
+ const {
1605
+ getRootProps,
1606
+ getToggleButtonProps,
1607
+ getLabelProps,
1608
+ getMenuProps,
1609
+ getInputProps,
1610
+ getItemProps,
1611
+ openMenu,
1612
+ closeMenu,
1613
+ toggleMenu,
1614
+ selectItem,
1615
+ selectItemAtIndex,
1616
+ selectHighlightedItem,
1617
+ setHighlightedIndex,
1618
+ clearSelection,
1619
+ clearItems,
1620
+ reset,
1621
+ setItemCount,
1622
+ unsetItemCount,
1623
+ internalSetState: setState
1624
+ } = this;
1677
1625
  return {
1678
1626
  // prop getters
1679
- getRootProps: getRootProps,
1680
- getToggleButtonProps: getToggleButtonProps,
1681
- getLabelProps: getLabelProps,
1682
- getMenuProps: getMenuProps,
1683
- getInputProps: getInputProps,
1684
- getItemProps: getItemProps,
1627
+ getRootProps,
1628
+ getToggleButtonProps,
1629
+ getLabelProps,
1630
+ getMenuProps,
1631
+ getInputProps,
1632
+ getItemProps,
1685
1633
  // actions
1686
- reset: reset,
1687
- openMenu: openMenu,
1688
- closeMenu: closeMenu,
1689
- toggleMenu: toggleMenu,
1690
- selectItem: selectItem,
1691
- selectItemAtIndex: selectItemAtIndex,
1692
- selectHighlightedItem: selectHighlightedItem,
1693
- setHighlightedIndex: setHighlightedIndex,
1694
- clearSelection: clearSelection,
1695
- clearItems: clearItems,
1696
- setItemCount: setItemCount,
1697
- unsetItemCount: unsetItemCount,
1698
- setState: setState,
1634
+ reset,
1635
+ openMenu,
1636
+ closeMenu,
1637
+ toggleMenu,
1638
+ selectItem,
1639
+ selectItemAtIndex,
1640
+ selectHighlightedItem,
1641
+ setHighlightedIndex,
1642
+ clearSelection,
1643
+ clearItems,
1644
+ setItemCount,
1645
+ unsetItemCount,
1646
+ setState,
1699
1647
  // props
1700
- itemToString: itemToString,
1648
+ itemToString,
1701
1649
  // derived
1702
- id: id,
1650
+ id,
1703
1651
  // state
1704
- highlightedIndex: highlightedIndex,
1705
- inputValue: inputValue,
1706
- isOpen: isOpen,
1707
- selectedItem: selectedItem
1652
+ highlightedIndex,
1653
+ inputValue,
1654
+ isOpen,
1655
+ selectedItem
1708
1656
  };
1709
1657
  } //////////////////////////// ROOT
1710
- ;
1711
1658
 
1712
- _proto.componentDidMount = function componentDidMount() {
1713
- var _this7 = this;
1714
1659
 
1660
+ componentDidMount() {
1715
1661
  /* istanbul ignore if (react-native) */
1716
1662
  if (this.getMenuProps.called && !this.getMenuProps.suppressRefError) {
1717
1663
  validateGetMenuPropsCalledCorrectly(this._menuNode, this.getMenuProps);
@@ -1725,22 +1671,20 @@
1725
1671
  // down long enough for the list to disappear (because the blur event fires on the input)
1726
1672
  // this.isMouseDown is used in the blur handler on the input to determine whether the blur event should
1727
1673
  // trigger hiding the menu.
1728
- var onMouseDown = function onMouseDown() {
1729
- _this7.isMouseDown = true;
1674
+ const onMouseDown = () => {
1675
+ this.isMouseDown = true;
1730
1676
  };
1731
1677
 
1732
- var onMouseUp = function onMouseUp(event) {
1733
- _this7.isMouseDown = false; // if the target element or the activeElement is within a downshift node
1678
+ const onMouseUp = event => {
1679
+ this.isMouseDown = false; // if the target element or the activeElement is within a downshift node
1734
1680
  // then we don't want to reset downshift
1735
1681
 
1736
- var contextWithinDownshift = targetWithinDownshift(event.target, [_this7._rootNode, _this7._menuNode], _this7.props.environment);
1682
+ const contextWithinDownshift = targetWithinDownshift(event.target, [this._rootNode, this._menuNode], this.props.environment);
1737
1683
 
1738
- if (!contextWithinDownshift && _this7.getState().isOpen) {
1739
- _this7.reset({
1684
+ if (!contextWithinDownshift && this.getState().isOpen) {
1685
+ this.reset({
1740
1686
  type: mouseUp
1741
- }, function () {
1742
- return _this7.props.onOuterClick(_this7.getStateAndHelpers());
1743
- });
1687
+ }, () => this.props.onOuterClick(this.getStateAndHelpers()));
1744
1688
  }
1745
1689
  }; // Touching an element in iOS gives focus and hover states, but touching out of
1746
1690
  // the element will remove hover, and persist the focus state, resulting in the
@@ -1750,38 +1694,36 @@
1750
1694
  // but not if the user is swiping
1751
1695
 
1752
1696
 
1753
- var onTouchStart = function onTouchStart() {
1754
- _this7.isTouchMove = false;
1697
+ const onTouchStart = () => {
1698
+ this.isTouchMove = false;
1755
1699
  };
1756
1700
 
1757
- var onTouchMove = function onTouchMove() {
1758
- _this7.isTouchMove = true;
1701
+ const onTouchMove = () => {
1702
+ this.isTouchMove = true;
1759
1703
  };
1760
1704
 
1761
- var onTouchEnd = function onTouchEnd(event) {
1762
- var contextWithinDownshift = targetWithinDownshift(event.target, [_this7._rootNode, _this7._menuNode], _this7.props.environment, false);
1705
+ const onTouchEnd = event => {
1706
+ const contextWithinDownshift = targetWithinDownshift(event.target, [this._rootNode, this._menuNode], this.props.environment, false);
1763
1707
 
1764
- if (!_this7.isTouchMove && !contextWithinDownshift && _this7.getState().isOpen) {
1765
- _this7.reset({
1708
+ if (!this.isTouchMove && !contextWithinDownshift && this.getState().isOpen) {
1709
+ this.reset({
1766
1710
  type: touchEnd
1767
- }, function () {
1768
- return _this7.props.onOuterClick(_this7.getStateAndHelpers());
1769
- });
1711
+ }, () => this.props.onOuterClick(this.getStateAndHelpers()));
1770
1712
  }
1771
1713
  };
1772
1714
 
1773
- var environment = this.props.environment;
1715
+ const {
1716
+ environment
1717
+ } = this.props;
1774
1718
  environment.addEventListener('mousedown', onMouseDown);
1775
1719
  environment.addEventListener('mouseup', onMouseUp);
1776
1720
  environment.addEventListener('touchstart', onTouchStart);
1777
1721
  environment.addEventListener('touchmove', onTouchMove);
1778
1722
  environment.addEventListener('touchend', onTouchEnd);
1779
1723
 
1780
- this.cleanup = function () {
1781
- _this7.internalClearTimeouts();
1782
-
1783
- _this7.updateStatus.cancel();
1784
-
1724
+ this.cleanup = () => {
1725
+ this.internalClearTimeouts();
1726
+ this.updateStatus.cancel();
1785
1727
  environment.removeEventListener('mousedown', onMouseDown);
1786
1728
  environment.removeEventListener('mouseup', onMouseUp);
1787
1729
  environment.removeEventListener('touchstart', onTouchStart);
@@ -1789,21 +1731,21 @@
1789
1731
  environment.removeEventListener('touchend', onTouchEnd);
1790
1732
  };
1791
1733
  }
1792
- };
1793
-
1794
- _proto.shouldScroll = function shouldScroll(prevState, prevProps) {
1795
- var _ref10 = this.props.highlightedIndex === undefined ? this.getState() : this.props,
1796
- currentHighlightedIndex = _ref10.highlightedIndex;
1797
-
1798
- var _ref11 = prevProps.highlightedIndex === undefined ? prevState : prevProps,
1799
- prevHighlightedIndex = _ref11.highlightedIndex;
1734
+ }
1800
1735
 
1801
- var scrollWhenOpen = currentHighlightedIndex && this.getState().isOpen && !prevState.isOpen;
1802
- var scrollWhenNavigating = currentHighlightedIndex !== prevHighlightedIndex;
1736
+ shouldScroll(prevState, prevProps) {
1737
+ const {
1738
+ highlightedIndex: currentHighlightedIndex
1739
+ } = this.props.highlightedIndex === undefined ? this.getState() : this.props;
1740
+ const {
1741
+ highlightedIndex: prevHighlightedIndex
1742
+ } = prevProps.highlightedIndex === undefined ? prevState : prevProps;
1743
+ const scrollWhenOpen = currentHighlightedIndex && this.getState().isOpen && !prevState.isOpen;
1744
+ const scrollWhenNavigating = currentHighlightedIndex !== prevHighlightedIndex;
1803
1745
  return scrollWhenOpen || scrollWhenNavigating;
1804
- };
1746
+ }
1805
1747
 
1806
- _proto.componentDidUpdate = function componentDidUpdate(prevProps, prevState) {
1748
+ componentDidUpdate(prevProps, prevState) {
1807
1749
  {
1808
1750
  validateControlledUnchanged(this.state, prevProps, this.props);
1809
1751
  /* istanbul ignore if (react-native) */
@@ -1829,14 +1771,14 @@
1829
1771
  {
1830
1772
  this.updateStatus();
1831
1773
  }
1832
- };
1774
+ }
1833
1775
 
1834
- _proto.componentWillUnmount = function componentWillUnmount() {
1776
+ componentWillUnmount() {
1835
1777
  this.cleanup(); // avoids memory leak
1836
- };
1778
+ }
1837
1779
 
1838
- _proto.render = function render() {
1839
- var children = unwrapArray(this.props.children, noop); // because the items are rerendered every time we call the children
1780
+ render() {
1781
+ const children = unwrapArray(this.props.children, noop); // because the items are rerendered every time we call the children
1840
1782
  // we clear this out each render and it will be populated again as
1841
1783
  // getItemProps is called.
1842
1784
 
@@ -1856,7 +1798,7 @@
1856
1798
  this.getLabelProps.called = false; // and something similar for getInputProps
1857
1799
 
1858
1800
  this.getInputProps.called = false;
1859
- var element = unwrapArray(children(this.getStateAndHelpers()));
1801
+ const element = unwrapArray(children(this.getStateAndHelpers()));
1860
1802
 
1861
1803
  if (!element) {
1862
1804
  return null;
@@ -1881,16 +1823,15 @@
1881
1823
  // otherwise we can't query around the autocomplete
1882
1824
  throw new Error('downshift: If you return a non-DOM element, you must apply the getRootProps function');
1883
1825
  }
1884
- };
1826
+ }
1885
1827
 
1886
- return Downshift;
1887
- }(preact.Component);
1828
+ }
1888
1829
 
1889
1830
  Downshift.defaultProps = {
1890
1831
  defaultHighlightedIndex: null,
1891
1832
  defaultIsOpen: false,
1892
1833
  getA11yStatusMessage: getA11yStatusMessage$1,
1893
- itemToString: function itemToString(i) {
1834
+ itemToString: i => {
1894
1835
  if (i == null) {
1895
1836
  return '';
1896
1837
  }
@@ -1908,26 +1849,24 @@
1908
1849
  onChange: noop,
1909
1850
  onSelect: noop,
1910
1851
  onOuterClick: noop,
1911
- selectedItemChanged: function selectedItemChanged(prevItem, item) {
1912
- return prevItem !== item;
1913
- },
1852
+ selectedItemChanged: (prevItem, item) => prevItem !== item,
1914
1853
  environment:
1915
1854
  /* istanbul ignore next (ssr) */
1916
1855
  typeof window === 'undefined' ? {} : window,
1917
- stateReducer: function stateReducer(state, stateToSet) {
1918
- return stateToSet;
1919
- },
1856
+ stateReducer: (state, stateToSet) => stateToSet,
1920
1857
  suppressRefError: false,
1921
- scrollIntoView: scrollIntoView
1858
+ scrollIntoView
1922
1859
  };
1923
1860
  Downshift.stateChangeTypes = stateChangeTypes$3;
1924
1861
  return Downshift;
1925
- }();
1862
+ })();
1926
1863
 
1927
1864
  var Downshift$1 = Downshift;
1928
1865
 
1929
- function validateGetMenuPropsCalledCorrectly(node, _ref12) {
1930
- var refKey = _ref12.refKey;
1866
+ function validateGetMenuPropsCalledCorrectly(node, _ref3) {
1867
+ let {
1868
+ refKey
1869
+ } = _ref3;
1931
1870
 
1932
1871
  if (!node) {
1933
1872
  // eslint-disable-next-line no-console
@@ -1935,10 +1874,12 @@
1935
1874
  }
1936
1875
  }
1937
1876
 
1938
- function validateGetRootPropsCalledCorrectly(element, _ref13) {
1939
- var refKey = _ref13.refKey;
1940
- var refKeySpecified = refKey !== 'ref';
1941
- var isComposite = !isDOMElement(element);
1877
+ function validateGetRootPropsCalledCorrectly(element, _ref4) {
1878
+ let {
1879
+ refKey
1880
+ } = _ref4;
1881
+ const refKeySpecified = refKey !== 'ref';
1882
+ const isComposite = !isDOMElement(element);
1942
1883
 
1943
1884
  if (isComposite && !refKeySpecified && !reactIs.exports.isForwardRef(element)) {
1944
1885
  // eslint-disable-next-line no-console
@@ -1954,8 +1895,7 @@
1954
1895
  }
1955
1896
  }
1956
1897
 
1957
- var _excluded$3 = ["isInitialMount", "highlightedIndex", "items", "environment"];
1958
- var dropdownDefaultStateValues = {
1898
+ const dropdownDefaultStateValues = {
1959
1899
  highlightedIndex: -1,
1960
1900
  isOpen: false,
1961
1901
  selectedItem: null,
@@ -1963,10 +1903,12 @@
1963
1903
  };
1964
1904
 
1965
1905
  function callOnChangeProps(action, state, newState) {
1966
- var props = action.props,
1967
- type = action.type;
1968
- var changes = {};
1969
- Object.keys(state).forEach(function (key) {
1906
+ const {
1907
+ props,
1908
+ type
1909
+ } = action;
1910
+ const changes = {};
1911
+ Object.keys(state).forEach(key => {
1970
1912
  invokeOnChangeHandler(key, action, state, newState);
1971
1913
 
1972
1914
  if (newState[key] !== state[key]) {
@@ -1975,21 +1917,25 @@
1975
1917
  });
1976
1918
 
1977
1919
  if (props.onStateChange && Object.keys(changes).length) {
1978
- props.onStateChange(_extends({
1979
- type: type
1980
- }, changes));
1920
+ props.onStateChange({
1921
+ type,
1922
+ ...changes
1923
+ });
1981
1924
  }
1982
1925
  }
1983
1926
 
1984
1927
  function invokeOnChangeHandler(key, action, state, newState) {
1985
- var props = action.props,
1986
- type = action.type;
1987
- var handler = "on" + capitalizeString(key) + "Change";
1928
+ const {
1929
+ props,
1930
+ type
1931
+ } = action;
1932
+ const handler = "on" + capitalizeString(key) + "Change";
1988
1933
 
1989
1934
  if (props[handler] && newState[key] !== undefined && newState[key] !== state[key]) {
1990
- props[handler](_extends({
1991
- type: type
1992
- }, newState));
1935
+ props[handler]({
1936
+ type,
1937
+ ...newState
1938
+ });
1993
1939
  }
1994
1940
  }
1995
1941
  /**
@@ -2013,8 +1959,10 @@
2013
1959
 
2014
1960
 
2015
1961
  function getA11ySelectionMessage(selectionParameters) {
2016
- var selectedItem = selectionParameters.selectedItem,
2017
- itemToStringLocal = selectionParameters.itemToString;
1962
+ const {
1963
+ selectedItem,
1964
+ itemToString: itemToStringLocal
1965
+ } = selectionParameters;
2018
1966
  return selectedItem ? itemToStringLocal(selectedItem) + " has been selected." : '';
2019
1967
  }
2020
1968
  /**
@@ -2022,26 +1970,25 @@
2022
1970
  */
2023
1971
 
2024
1972
 
2025
- var updateA11yStatus = debounce(function (getA11yMessage, document) {
1973
+ const updateA11yStatus = debounce((getA11yMessage, document) => {
2026
1974
  setStatus(getA11yMessage(), document);
2027
1975
  }, 200); // istanbul ignore next
2028
1976
 
2029
- var useIsomorphicLayoutEffect = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined' ? preact.useLayoutEffect : preact.useEffect;
1977
+ const useIsomorphicLayoutEffect = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined' ? preact.useLayoutEffect : preact.useEffect;
2030
1978
 
2031
1979
  function useElementIds(_ref) {
2032
- var _ref$id = _ref.id,
2033
- id = _ref$id === void 0 ? "downshift-" + generateId() : _ref$id,
2034
- labelId = _ref.labelId,
2035
- menuId = _ref.menuId,
2036
- getItemId = _ref.getItemId,
2037
- toggleButtonId = _ref.toggleButtonId,
2038
- inputId = _ref.inputId;
2039
- var elementIdsRef = preact.useRef({
1980
+ let {
1981
+ id = "downshift-" + generateId(),
1982
+ labelId,
1983
+ menuId,
1984
+ getItemId,
1985
+ toggleButtonId,
1986
+ inputId
1987
+ } = _ref;
1988
+ const elementIdsRef = preact.useRef({
2040
1989
  labelId: labelId || id + "-label",
2041
1990
  menuId: menuId || id + "-menu",
2042
- getItemId: getItemId || function (index) {
2043
- return id + "-item-" + index;
2044
- },
1991
+ getItemId: getItemId || (index => id + "-item-" + index),
2045
1992
  toggleButtonId: toggleButtonId || id + "-toggle-button",
2046
1993
  inputId: inputId || id + "-input"
2047
1994
  });
@@ -2073,7 +2020,7 @@
2073
2020
  }
2074
2021
 
2075
2022
  function useLatestRef(val) {
2076
- var ref = preact.useRef(val); // technically this is not "concurrent mode safe" because we're manipulating
2023
+ const ref = preact.useRef(val); // technically this is not "concurrent mode safe" because we're manipulating
2077
2024
  // the value during render (so it's not idempotent). However, the places this
2078
2025
  // hook is used is to support memoizing callbacks which will be called
2079
2026
  // *during* render, so we need the latest values *during* render.
@@ -2095,30 +2042,25 @@
2095
2042
 
2096
2043
 
2097
2044
  function useEnhancedReducer(reducer, initialState, props) {
2098
- var prevStateRef = preact.useRef();
2099
- var actionRef = preact.useRef();
2100
- var enhancedReducer = preact.useCallback(function (state, action) {
2045
+ const prevStateRef = preact.useRef();
2046
+ const actionRef = preact.useRef();
2047
+ const enhancedReducer = preact.useCallback((state, action) => {
2101
2048
  actionRef.current = action;
2102
2049
  state = getState(state, action.props);
2103
- var changes = reducer(state, action);
2104
- var newState = action.props.stateReducer(state, _extends({}, action, {
2105
- changes: changes
2106
- }));
2050
+ const changes = reducer(state, action);
2051
+ const newState = action.props.stateReducer(state, { ...action,
2052
+ changes
2053
+ });
2107
2054
  return newState;
2108
2055
  }, [reducer]);
2109
-
2110
- var _useReducer = preact.useReducer(enhancedReducer, initialState),
2111
- state = _useReducer[0],
2112
- dispatch = _useReducer[1];
2113
-
2114
- var propsRef = useLatestRef(props);
2115
- var dispatchWithProps = preact.useCallback(function (action) {
2116
- return dispatch(_extends({
2117
- props: propsRef.current
2118
- }, action));
2119
- }, [propsRef]);
2120
- var action = actionRef.current;
2121
- preact.useEffect(function () {
2056
+ const [state, dispatch] = preact.useReducer(enhancedReducer, initialState);
2057
+ const propsRef = useLatestRef(props);
2058
+ const dispatchWithProps = preact.useCallback(action => dispatch({
2059
+ props: propsRef.current,
2060
+ ...action
2061
+ }), [propsRef]);
2062
+ const action = actionRef.current;
2063
+ preact.useEffect(() => {
2122
2064
  if (action && prevStateRef.current && prevStateRef.current !== state) {
2123
2065
  callOnChangeProps(action, getState(prevStateRef.current, action.props), state);
2124
2066
  }
@@ -2139,18 +2081,15 @@
2139
2081
 
2140
2082
 
2141
2083
  function useControlledReducer$1(reducer, initialState, props) {
2142
- var _useEnhancedReducer = useEnhancedReducer(reducer, initialState, props),
2143
- state = _useEnhancedReducer[0],
2144
- dispatch = _useEnhancedReducer[1];
2145
-
2084
+ const [state, dispatch] = useEnhancedReducer(reducer, initialState, props);
2146
2085
  return [getState(state, props), dispatch];
2147
2086
  }
2148
2087
 
2149
- var defaultProps$3 = {
2150
- itemToString: itemToString,
2151
- stateReducer: stateReducer,
2152
- getA11ySelectionMessage: getA11ySelectionMessage,
2153
- scrollIntoView: scrollIntoView,
2088
+ const defaultProps$3 = {
2089
+ itemToString,
2090
+ stateReducer,
2091
+ getA11ySelectionMessage,
2092
+ scrollIntoView,
2154
2093
  circularNavigation: false,
2155
2094
  environment:
2156
2095
  /* istanbul ignore next (ssr) */
@@ -2162,10 +2101,10 @@
2162
2101
  defaultStateValues = dropdownDefaultStateValues;
2163
2102
  }
2164
2103
 
2165
- var defaultPropKey = "default" + capitalizeString(propKey);
2104
+ const defaultValue = props["default" + capitalizeString(propKey)];
2166
2105
 
2167
- if (defaultPropKey in props) {
2168
- return props[defaultPropKey];
2106
+ if (defaultValue !== undefined) {
2107
+ return defaultValue;
2169
2108
  }
2170
2109
 
2171
2110
  return defaultStateValues[propKey];
@@ -2176,38 +2115,44 @@
2176
2115
  defaultStateValues = dropdownDefaultStateValues;
2177
2116
  }
2178
2117
 
2179
- if (propKey in props) {
2180
- return props[propKey];
2118
+ const value = props[propKey];
2119
+
2120
+ if (value !== undefined) {
2121
+ return value;
2181
2122
  }
2182
2123
 
2183
- var initialPropKey = "initial" + capitalizeString(propKey);
2124
+ const initialValue = props["initial" + capitalizeString(propKey)];
2184
2125
 
2185
- if (initialPropKey in props) {
2186
- return props[initialPropKey];
2126
+ if (initialValue !== undefined) {
2127
+ return initialValue;
2187
2128
  }
2188
2129
 
2189
2130
  return getDefaultValue$1(props, propKey, defaultStateValues);
2190
2131
  }
2191
2132
 
2192
2133
  function getInitialState$2(props) {
2193
- var selectedItem = getInitialValue$1(props, 'selectedItem');
2194
- var isOpen = getInitialValue$1(props, 'isOpen');
2195
- var highlightedIndex = getInitialValue$1(props, 'highlightedIndex');
2196
- var inputValue = getInitialValue$1(props, 'inputValue');
2134
+ const selectedItem = getInitialValue$1(props, 'selectedItem');
2135
+ const isOpen = getInitialValue$1(props, 'isOpen');
2136
+ const highlightedIndex = getInitialValue$1(props, 'highlightedIndex');
2137
+ const inputValue = getInitialValue$1(props, 'inputValue');
2197
2138
  return {
2198
2139
  highlightedIndex: highlightedIndex < 0 && selectedItem && isOpen ? props.items.indexOf(selectedItem) : highlightedIndex,
2199
- isOpen: isOpen,
2200
- selectedItem: selectedItem,
2201
- inputValue: inputValue
2140
+ isOpen,
2141
+ selectedItem,
2142
+ inputValue
2202
2143
  };
2203
2144
  }
2204
2145
 
2205
2146
  function getHighlightedIndexOnOpen(props, state, offset, getItemNodeFromIndex) {
2206
- var items = props.items,
2207
- initialHighlightedIndex = props.initialHighlightedIndex,
2208
- defaultHighlightedIndex = props.defaultHighlightedIndex;
2209
- var selectedItem = state.selectedItem,
2210
- highlightedIndex = state.highlightedIndex;
2147
+ const {
2148
+ items,
2149
+ initialHighlightedIndex,
2150
+ defaultHighlightedIndex
2151
+ } = props;
2152
+ const {
2153
+ selectedItem,
2154
+ highlightedIndex
2155
+ } = state;
2211
2156
 
2212
2157
  if (items.length === 0) {
2213
2158
  return -1;
@@ -2248,39 +2193,35 @@
2248
2193
 
2249
2194
 
2250
2195
  function useMouseAndTouchTracker(isOpen, downshiftElementRefs, environment, handleBlur) {
2251
- var mouseAndTouchTrackersRef = preact.useRef({
2196
+ const mouseAndTouchTrackersRef = preact.useRef({
2252
2197
  isMouseDown: false,
2253
2198
  isTouchMove: false
2254
2199
  });
2255
- preact.useEffect(function () {
2200
+ preact.useEffect(() => {
2256
2201
  // The same strategy for checking if a click occurred inside or outside downsift
2257
2202
  // as in downshift.js.
2258
- var onMouseDown = function onMouseDown() {
2203
+ const onMouseDown = () => {
2259
2204
  mouseAndTouchTrackersRef.current.isMouseDown = true;
2260
2205
  };
2261
2206
 
2262
- var onMouseUp = function onMouseUp(event) {
2207
+ const onMouseUp = event => {
2263
2208
  mouseAndTouchTrackersRef.current.isMouseDown = false;
2264
2209
 
2265
- if (isOpen && !targetWithinDownshift(event.target, downshiftElementRefs.map(function (ref) {
2266
- return ref.current;
2267
- }), environment)) {
2210
+ if (isOpen && !targetWithinDownshift(event.target, downshiftElementRefs.map(ref => ref.current), environment)) {
2268
2211
  handleBlur();
2269
2212
  }
2270
2213
  };
2271
2214
 
2272
- var onTouchStart = function onTouchStart() {
2215
+ const onTouchStart = () => {
2273
2216
  mouseAndTouchTrackersRef.current.isTouchMove = false;
2274
2217
  };
2275
2218
 
2276
- var onTouchMove = function onTouchMove() {
2219
+ const onTouchMove = () => {
2277
2220
  mouseAndTouchTrackersRef.current.isTouchMove = true;
2278
2221
  };
2279
2222
 
2280
- var onTouchEnd = function onTouchEnd(event) {
2281
- if (isOpen && !mouseAndTouchTrackersRef.current.isTouchMove && !targetWithinDownshift(event.target, downshiftElementRefs.map(function (ref) {
2282
- return ref.current;
2283
- }), environment, false)) {
2223
+ const onTouchEnd = event => {
2224
+ if (isOpen && !mouseAndTouchTrackersRef.current.isTouchMove && !targetWithinDownshift(event.target, downshiftElementRefs.map(ref => ref.current), environment, false)) {
2284
2225
  handleBlur();
2285
2226
  }
2286
2227
  };
@@ -2304,9 +2245,7 @@
2304
2245
  // eslint-disable-next-line import/no-mutable-exports
2305
2246
 
2306
2247
 
2307
- var useGetterPropsCalledChecker = function useGetterPropsCalledChecker() {
2308
- return noop;
2309
- };
2248
+ let useGetterPropsCalledChecker = () => noop;
2310
2249
  /**
2311
2250
  * Custom hook that checks if getter props are called correctly.
2312
2251
  *
@@ -2318,20 +2257,20 @@
2318
2257
 
2319
2258
 
2320
2259
  {
2321
- useGetterPropsCalledChecker = function useGetterPropsCalledChecker() {
2322
- var isInitialMountRef = preact.useRef(true);
2260
+ useGetterPropsCalledChecker = function () {
2261
+ const isInitialMountRef = preact.useRef(true);
2323
2262
 
2324
2263
  for (var _len = arguments.length, propKeys = new Array(_len), _key = 0; _key < _len; _key++) {
2325
2264
  propKeys[_key] = arguments[_key];
2326
2265
  }
2327
2266
 
2328
- var getterPropsCalledRef = preact.useRef(propKeys.reduce(function (acc, propKey) {
2267
+ const getterPropsCalledRef = preact.useRef(propKeys.reduce((acc, propKey) => {
2329
2268
  acc[propKey] = {};
2330
2269
  return acc;
2331
2270
  }, {}));
2332
- preact.useEffect(function () {
2333
- Object.keys(getterPropsCalledRef.current).forEach(function (propKey) {
2334
- var propCallInfo = getterPropsCalledRef.current[propKey];
2271
+ preact.useEffect(() => {
2272
+ Object.keys(getterPropsCalledRef.current).forEach(propKey => {
2273
+ const propCallInfo = getterPropsCalledRef.current[propKey];
2335
2274
 
2336
2275
  if (isInitialMountRef.current) {
2337
2276
  if (!Object.keys(propCallInfo).length) {
@@ -2341,9 +2280,11 @@
2341
2280
  }
2342
2281
  }
2343
2282
 
2344
- var suppressRefError = propCallInfo.suppressRefError,
2345
- refKey = propCallInfo.refKey,
2346
- elementRef = propCallInfo.elementRef;
2283
+ const {
2284
+ suppressRefError,
2285
+ refKey,
2286
+ elementRef
2287
+ } = propCallInfo;
2347
2288
 
2348
2289
  if ((!elementRef || !elementRef.current) && !suppressRefError) {
2349
2290
  // eslint-disable-next-line no-console
@@ -2352,11 +2293,11 @@
2352
2293
  });
2353
2294
  isInitialMountRef.current = false;
2354
2295
  });
2355
- var setGetterPropCallInfo = preact.useCallback(function (propKey, suppressRefError, refKey, elementRef) {
2296
+ const setGetterPropCallInfo = preact.useCallback((propKey, suppressRefError, refKey, elementRef) => {
2356
2297
  getterPropsCalledRef.current[propKey] = {
2357
- suppressRefError: suppressRefError,
2358
- refKey: refKey,
2359
- elementRef: elementRef
2298
+ suppressRefError,
2299
+ refKey,
2300
+ elementRef
2360
2301
  };
2361
2302
  }, []);
2362
2303
  return setGetterPropCallInfo;
@@ -2364,39 +2305,41 @@
2364
2305
  }
2365
2306
 
2366
2307
  function useA11yMessageSetter(getA11yMessage, dependencyArray, _ref2) {
2367
- var isInitialMount = _ref2.isInitialMount,
2368
- highlightedIndex = _ref2.highlightedIndex,
2369
- items = _ref2.items,
2370
- environment = _ref2.environment,
2371
- rest = _objectWithoutPropertiesLoose(_ref2, _excluded$3);
2372
-
2308
+ let {
2309
+ isInitialMount,
2310
+ highlightedIndex,
2311
+ items,
2312
+ environment,
2313
+ ...rest
2314
+ } = _ref2;
2373
2315
  // Sets a11y status message on changes in state.
2374
- preact.useEffect(function () {
2316
+ preact.useEffect(() => {
2375
2317
  if (isInitialMount || false) {
2376
2318
  return;
2377
2319
  }
2378
2320
 
2379
- updateA11yStatus(function () {
2380
- return getA11yMessage(_extends({
2381
- highlightedIndex: highlightedIndex,
2382
- highlightedItem: items[highlightedIndex],
2383
- resultCount: items.length
2384
- }, rest));
2385
- }, environment.document); // eslint-disable-next-line react-hooks/exhaustive-deps
2321
+ updateA11yStatus(() => getA11yMessage({
2322
+ highlightedIndex,
2323
+ highlightedItem: items[highlightedIndex],
2324
+ resultCount: items.length,
2325
+ ...rest
2326
+ }), environment.document); // eslint-disable-next-line react-hooks/exhaustive-deps
2386
2327
  }, dependencyArray);
2387
2328
  }
2388
2329
 
2389
2330
  function useScrollIntoView(_ref3) {
2390
- var highlightedIndex = _ref3.highlightedIndex,
2391
- isOpen = _ref3.isOpen,
2392
- itemRefs = _ref3.itemRefs,
2393
- getItemNodeFromIndex = _ref3.getItemNodeFromIndex,
2394
- menuElement = _ref3.menuElement,
2395
- scrollIntoViewProp = _ref3.scrollIntoView;
2331
+ let {
2332
+ highlightedIndex,
2333
+ isOpen,
2334
+ itemRefs,
2335
+ getItemNodeFromIndex,
2336
+ menuElement,
2337
+ scrollIntoView: scrollIntoViewProp
2338
+ } = _ref3;
2396
2339
  // used not to scroll on highlight by mouse.
2397
- var shouldScrollRef = preact.useRef(true); // Scroll on highlighted item if change comes from keyboard.
2340
+ const shouldScrollRef = preact.useRef(true); // Scroll on highlighted item if change comes from keyboard.
2398
2341
 
2399
- useIsomorphicLayoutEffect(function () {
2342
+ useIsomorphicLayoutEffect(() => {
2400
2343
  if (highlightedIndex < 0 || !isOpen || !Object.keys(itemRefs.current).length) {
2401
2344
  return;
2402
2345
  }
@@ -2412,17 +2355,19 @@
2412
2355
  } // eslint-disable-next-line import/no-mutable-exports
2413
2356
 
2414
2357
 
2415
- var useControlPropsValidator = noop;
2358
+ let useControlPropsValidator = noop;
2416
2359
  /* istanbul ignore next */
2417
2360
 
2418
2361
  {
2419
- useControlPropsValidator = function useControlPropsValidator(_ref4) {
2420
- var isInitialMount = _ref4.isInitialMount,
2421
- props = _ref4.props,
2422
- state = _ref4.state;
2362
+ useControlPropsValidator = _ref4 => {
2363
+ let {
2364
+ isInitialMount,
2365
+ props,
2366
+ state
2367
+ } = _ref4;
2423
2368
  // used for checking when props are moving from controlled to uncontrolled.
2424
- var prevPropsRef = preact.useRef(props);
2425
- preact.useEffect(function () {
2369
+ const prevPropsRef = preact.useRef(props);
2370
+ preact.useEffect(() => {
2426
2371
  if (isInitialMount) {
2427
2372
  return;
2428
2373
  }
@@ -2436,9 +2381,11 @@
2436
2381
  /* eslint-disable complexity */
2437
2382
 
2438
2383
  function downshiftCommonReducer(state, action, stateChangeTypes) {
2439
- var type = action.type,
2440
- props = action.props;
2441
- var changes;
2384
+ const {
2385
+ type,
2386
+ props
2387
+ } = action;
2388
+ let changes;
2442
2389
 
2443
2390
  switch (type) {
2444
2391
  case stateChangeTypes.ItemMouseMove:
@@ -2499,11 +2446,13 @@
2499
2446
  throw new Error('Reducer called without proper action type.');
2500
2447
  }
2501
2448
 
2502
- return _extends({}, state, changes);
2449
+ return { ...state,
2450
+ ...changes
2451
+ };
2503
2452
  }
2504
2453
  /* eslint-enable complexity */
2505
2454
 
2506
- /*! *****************************************************************************
2455
+ /******************************************************************************
2507
2456
  Copyright (c) Microsoft Corporation.
2508
2457
 
2509
2458
  Permission to use, copy, modify, and/or distribute this software for any
@@ -2548,37 +2497,37 @@
2548
2497
  return highlightedIndex;
2549
2498
  }
2550
2499
  var propTypes$2 = {
2551
- items: PropTypes__default['default'].array.isRequired,
2552
- itemToString: PropTypes__default['default'].func,
2553
- getA11yStatusMessage: PropTypes__default['default'].func,
2554
- getA11ySelectionMessage: PropTypes__default['default'].func,
2555
- circularNavigation: PropTypes__default['default'].bool,
2556
- highlightedIndex: PropTypes__default['default'].number,
2557
- defaultHighlightedIndex: PropTypes__default['default'].number,
2558
- initialHighlightedIndex: PropTypes__default['default'].number,
2559
- isOpen: PropTypes__default['default'].bool,
2560
- defaultIsOpen: PropTypes__default['default'].bool,
2561
- initialIsOpen: PropTypes__default['default'].bool,
2562
- selectedItem: PropTypes__default['default'].any,
2563
- initialSelectedItem: PropTypes__default['default'].any,
2564
- defaultSelectedItem: PropTypes__default['default'].any,
2565
- id: PropTypes__default['default'].string,
2566
- labelId: PropTypes__default['default'].string,
2567
- menuId: PropTypes__default['default'].string,
2568
- getItemId: PropTypes__default['default'].func,
2569
- toggleButtonId: PropTypes__default['default'].string,
2570
- stateReducer: PropTypes__default['default'].func,
2571
- onSelectedItemChange: PropTypes__default['default'].func,
2572
- onHighlightedIndexChange: PropTypes__default['default'].func,
2573
- onStateChange: PropTypes__default['default'].func,
2574
- onIsOpenChange: PropTypes__default['default'].func,
2575
- environment: PropTypes__default['default'].shape({
2576
- addEventListener: PropTypes__default['default'].func,
2577
- removeEventListener: PropTypes__default['default'].func,
2578
- document: PropTypes__default['default'].shape({
2579
- getElementById: PropTypes__default['default'].func,
2580
- activeElement: PropTypes__default['default'].any,
2581
- body: PropTypes__default['default'].any
2500
+ items: PropTypes__default["default"].array.isRequired,
2501
+ itemToString: PropTypes__default["default"].func,
2502
+ getA11yStatusMessage: PropTypes__default["default"].func,
2503
+ getA11ySelectionMessage: PropTypes__default["default"].func,
2504
+ circularNavigation: PropTypes__default["default"].bool,
2505
+ highlightedIndex: PropTypes__default["default"].number,
2506
+ defaultHighlightedIndex: PropTypes__default["default"].number,
2507
+ initialHighlightedIndex: PropTypes__default["default"].number,
2508
+ isOpen: PropTypes__default["default"].bool,
2509
+ defaultIsOpen: PropTypes__default["default"].bool,
2510
+ initialIsOpen: PropTypes__default["default"].bool,
2511
+ selectedItem: PropTypes__default["default"].any,
2512
+ initialSelectedItem: PropTypes__default["default"].any,
2513
+ defaultSelectedItem: PropTypes__default["default"].any,
2514
+ id: PropTypes__default["default"].string,
2515
+ labelId: PropTypes__default["default"].string,
2516
+ menuId: PropTypes__default["default"].string,
2517
+ getItemId: PropTypes__default["default"].func,
2518
+ toggleButtonId: PropTypes__default["default"].string,
2519
+ stateReducer: PropTypes__default["default"].func,
2520
+ onSelectedItemChange: PropTypes__default["default"].func,
2521
+ onHighlightedIndexChange: PropTypes__default["default"].func,
2522
+ onStateChange: PropTypes__default["default"].func,
2523
+ onIsOpenChange: PropTypes__default["default"].func,
2524
+ environment: PropTypes__default["default"].shape({
2525
+ addEventListener: PropTypes__default["default"].func,
2526
+ removeEventListener: PropTypes__default["default"].func,
2527
+ document: PropTypes__default["default"].shape({
2528
+ getElementById: PropTypes__default["default"].func,
2529
+ activeElement: PropTypes__default["default"].any,
2530
+ body: PropTypes__default["default"].any
2582
2531
  })
2583
2532
  })
2584
2533
  };
@@ -2599,7 +2548,7 @@
2599
2548
  return 'No results are available.';
2600
2549
  }
2601
2550
  if (resultCount !== previousResultCount) {
2602
- return resultCount + " result" + (resultCount === 1 ? ' is' : 's are') + " available, use up and down arrow keys to navigate. Press Enter or Space Bar keys to select.";
2551
+ return "".concat(resultCount, " result").concat(resultCount === 1 ? ' is' : 's are', " available, use up and down arrow keys to navigate. Press Enter or Space Bar keys to select.");
2603
2552
  }
2604
2553
  return '';
2605
2554
  }
@@ -2609,33 +2558,33 @@
2609
2558
  /* istanbul ignore next */
2610
2559
  {
2611
2560
  validatePropTypes$2 = function (options, caller) {
2612
- PropTypes__default['default'].checkPropTypes(propTypes$2, options, 'prop', caller.name);
2561
+ PropTypes__default["default"].checkPropTypes(propTypes$2, options, 'prop', caller.name);
2613
2562
  };
2614
2563
  }
2615
2564
 
2616
- var MenuKeyDownArrowDown = '__menu_keydown_arrow_down__' ;
2617
- var MenuKeyDownArrowUp = '__menu_keydown_arrow_up__' ;
2618
- var MenuKeyDownEscape = '__menu_keydown_escape__' ;
2619
- var MenuKeyDownHome = '__menu_keydown_home__' ;
2620
- var MenuKeyDownEnd = '__menu_keydown_end__' ;
2621
- var MenuKeyDownEnter = '__menu_keydown_enter__' ;
2622
- var MenuKeyDownSpaceButton = '__menu_keydown_space_button__' ;
2623
- var MenuKeyDownCharacter = '__menu_keydown_character__' ;
2624
- var MenuBlur = '__menu_blur__' ;
2625
- var MenuMouseLeave$1 = '__menu_mouse_leave__' ;
2626
- var ItemMouseMove$1 = '__item_mouse_move__' ;
2627
- var ItemClick$1 = '__item_click__' ;
2628
- var ToggleButtonClick$1 = '__togglebutton_click__' ;
2629
- var ToggleButtonKeyDownArrowDown = '__togglebutton_keydown_arrow_down__' ;
2630
- var ToggleButtonKeyDownArrowUp = '__togglebutton_keydown_arrow_up__' ;
2631
- var ToggleButtonKeyDownCharacter = '__togglebutton_keydown_character__' ;
2632
- var FunctionToggleMenu$1 = '__function_toggle_menu__' ;
2633
- var FunctionOpenMenu$1 = '__function_open_menu__' ;
2634
- var FunctionCloseMenu$1 = '__function_close_menu__' ;
2635
- var FunctionSetHighlightedIndex$1 = '__function_set_highlighted_index__' ;
2636
- var FunctionSelectItem$1 = '__function_select_item__' ;
2637
- var FunctionSetInputValue$1 = '__function_set_input_value__' ;
2638
- var FunctionReset$2 = '__function_reset__' ;
2565
+ const MenuKeyDownArrowDown = '__menu_keydown_arrow_down__' ;
2566
+ const MenuKeyDownArrowUp = '__menu_keydown_arrow_up__' ;
2567
+ const MenuKeyDownEscape = '__menu_keydown_escape__' ;
2568
+ const MenuKeyDownHome = '__menu_keydown_home__' ;
2569
+ const MenuKeyDownEnd = '__menu_keydown_end__' ;
2570
+ const MenuKeyDownEnter = '__menu_keydown_enter__' ;
2571
+ const MenuKeyDownSpaceButton = '__menu_keydown_space_button__' ;
2572
+ const MenuKeyDownCharacter = '__menu_keydown_character__' ;
2573
+ const MenuBlur = '__menu_blur__' ;
2574
+ const MenuMouseLeave$1 = '__menu_mouse_leave__' ;
2575
+ const ItemMouseMove$1 = '__item_mouse_move__' ;
2576
+ const ItemClick$1 = '__item_click__' ;
2577
+ const ToggleButtonClick$1 = '__togglebutton_click__' ;
2578
+ const ToggleButtonKeyDownArrowDown = '__togglebutton_keydown_arrow_down__' ;
2579
+ const ToggleButtonKeyDownArrowUp = '__togglebutton_keydown_arrow_up__' ;
2580
+ const ToggleButtonKeyDownCharacter = '__togglebutton_keydown_character__' ;
2581
+ const FunctionToggleMenu$1 = '__function_toggle_menu__' ;
2582
+ const FunctionOpenMenu$1 = '__function_open_menu__' ;
2583
+ const FunctionCloseMenu$1 = '__function_close_menu__' ;
2584
+ const FunctionSetHighlightedIndex$1 = '__function_set_highlighted_index__' ;
2585
+ const FunctionSelectItem$1 = '__function_select_item__' ;
2586
+ const FunctionSetInputValue$1 = '__function_set_input_value__' ;
2587
+ const FunctionReset$2 = '__function_reset__' ;
2639
2588
 
2640
2589
  var stateChangeTypes$2 = /*#__PURE__*/Object.freeze({
2641
2590
  __proto__: null,
@@ -2667,10 +2616,12 @@
2667
2616
  /* eslint-disable complexity */
2668
2617
 
2669
2618
  function downshiftSelectReducer(state, action) {
2670
- var type = action.type,
2671
- props = action.props,
2672
- shiftKey = action.shiftKey;
2673
- var changes;
2619
+ const {
2620
+ type,
2621
+ props,
2622
+ shiftKey
2623
+ } = action;
2624
+ let changes;
2674
2625
 
2675
2626
  switch (type) {
2676
2627
  case ItemClick$1:
@@ -2683,20 +2634,21 @@
2683
2634
 
2684
2635
  case ToggleButtonKeyDownCharacter:
2685
2636
  {
2686
- var lowercasedKey = action.key;
2687
- var inputValue = "" + state.inputValue + lowercasedKey;
2688
- var itemIndex = getItemIndexByCharacterKey({
2637
+ const lowercasedKey = action.key;
2638
+ const inputValue = "" + state.inputValue + lowercasedKey;
2639
+ const itemIndex = getItemIndexByCharacterKey({
2689
2640
  keysSoFar: inputValue,
2690
2641
  highlightedIndex: state.selectedItem ? props.items.indexOf(state.selectedItem) : -1,
2691
2642
  items: props.items,
2692
2643
  itemToString: props.itemToString,
2693
2644
  getItemNodeFromIndex: action.getItemNodeFromIndex
2694
2645
  });
2695
- changes = _extends({
2696
- inputValue: inputValue
2697
- }, itemIndex >= 0 && {
2698
- selectedItem: props.items[itemIndex]
2699
- });
2646
+ changes = {
2647
+ inputValue,
2648
+ ...(itemIndex >= 0 && {
2649
+ selectedItem: props.items[itemIndex]
2650
+ })
2651
+ };
2700
2652
  }
2701
2653
  break;
2702
2654
 
@@ -2716,12 +2668,13 @@
2716
2668
 
2717
2669
  case MenuKeyDownEnter:
2718
2670
  case MenuKeyDownSpaceButton:
2719
- changes = _extends({
2671
+ changes = {
2720
2672
  isOpen: getDefaultValue$1(props, 'isOpen'),
2721
- highlightedIndex: getDefaultValue$1(props, 'highlightedIndex')
2722
- }, state.highlightedIndex >= 0 && {
2723
- selectedItem: props.items[state.highlightedIndex]
2724
- });
2673
+ highlightedIndex: getDefaultValue$1(props, 'highlightedIndex'),
2674
+ ...(state.highlightedIndex >= 0 && {
2675
+ selectedItem: props.items[state.highlightedIndex]
2676
+ })
2677
+ };
2725
2678
  break;
2726
2679
 
2727
2680
  case MenuKeyDownHome:
@@ -2752,22 +2705,21 @@
2752
2705
 
2753
2706
  case MenuKeyDownCharacter:
2754
2707
  {
2755
- var _lowercasedKey = action.key;
2756
-
2757
- var _inputValue = "" + state.inputValue + _lowercasedKey;
2758
-
2759
- var highlightedIndex = getItemIndexByCharacterKey({
2760
- keysSoFar: _inputValue,
2708
+ const lowercasedKey = action.key;
2709
+ const inputValue = "" + state.inputValue + lowercasedKey;
2710
+ const highlightedIndex = getItemIndexByCharacterKey({
2711
+ keysSoFar: inputValue,
2761
2712
  highlightedIndex: state.highlightedIndex,
2762
2713
  items: props.items,
2763
2714
  itemToString: props.itemToString,
2764
2715
  getItemNodeFromIndex: action.getItemNodeFromIndex
2765
2716
  });
2766
- changes = _extends({
2767
- inputValue: _inputValue
2768
- }, highlightedIndex >= 0 && {
2769
- highlightedIndex: highlightedIndex
2770
- });
2717
+ changes = {
2718
+ inputValue,
2719
+ ...(highlightedIndex >= 0 && {
2720
+ highlightedIndex
2721
+ })
2722
+ };
2771
2723
  }
2772
2724
  break;
2773
2725
 
@@ -2793,13 +2745,13 @@
2793
2745
  return downshiftCommonReducer(state, action, stateChangeTypes$2);
2794
2746
  }
2795
2747
 
2796
- return _extends({}, state, changes);
2748
+ return { ...state,
2749
+ ...changes
2750
+ };
2797
2751
  }
2798
2752
  /* eslint-enable complexity */
2799
2753
 
2800
- var _excluded$2 = ["onMouseLeave", "refKey", "onKeyDown", "onBlur", "ref"],
2801
- _excluded2$2 = ["onClick", "onKeyDown", "refKey", "ref"],
2802
- _excluded3$1 = ["item", "index", "onMouseMove", "onClick", "refKey", "ref"];
2754
+ /* eslint-disable max-statements */
2803
2755
  useSelect.stateChangeTypes = stateChangeTypes$2;
2804
2756
 
2805
2757
  function useSelect(userProps) {
@@ -2809,91 +2761,92 @@
2809
2761
 
2810
2762
  validatePropTypes$2(userProps, useSelect); // Props defaults and destructuring.
2811
2763
 
2812
- var props = _extends({}, defaultProps$2, userProps);
2813
-
2814
- var items = props.items,
2815
- scrollIntoView = props.scrollIntoView,
2816
- environment = props.environment,
2817
- initialIsOpen = props.initialIsOpen,
2818
- defaultIsOpen = props.defaultIsOpen,
2819
- itemToString = props.itemToString,
2820
- getA11ySelectionMessage = props.getA11ySelectionMessage,
2821
- getA11yStatusMessage = props.getA11yStatusMessage; // Initial state depending on controlled props.
2822
-
2823
- var initialState = getInitialState$2(props);
2824
-
2825
- var _useControlledReducer = useControlledReducer$1(downshiftSelectReducer, initialState, props),
2826
- state = _useControlledReducer[0],
2827
- dispatch = _useControlledReducer[1];
2828
-
2829
- var isOpen = state.isOpen,
2830
- highlightedIndex = state.highlightedIndex,
2831
- selectedItem = state.selectedItem,
2832
- inputValue = state.inputValue; // Element efs.
2833
-
2834
- var toggleButtonRef = preact.useRef(null);
2835
- var menuRef = preact.useRef(null);
2836
- var itemRefs = preact.useRef({}); // used not to trigger menu blur action in some scenarios.
2837
-
2838
- var shouldBlurRef = preact.useRef(true); // used to keep the inputValue clearTimeout object between renders.
2839
-
2840
- var clearTimeoutRef = preact.useRef(null); // prevent id re-generation between renders.
2841
-
2842
- var elementIds = useElementIds(props); // used to keep track of how many items we had on previous cycle.
2843
-
2844
- var previousResultCountRef = preact.useRef();
2845
- var isInitialMountRef = preact.useRef(true); // utility callback to get item element.
2846
-
2847
- var latest = useLatestRef({
2848
- state: state,
2849
- props: props
2764
+ const props = { ...defaultProps$2,
2765
+ ...userProps
2766
+ };
2767
+ const {
2768
+ items,
2769
+ scrollIntoView,
2770
+ environment,
2771
+ initialIsOpen,
2772
+ defaultIsOpen,
2773
+ itemToString,
2774
+ getA11ySelectionMessage,
2775
+ getA11yStatusMessage
2776
+ } = props; // Initial state depending on controlled props.
2777
+
2778
+ const initialState = getInitialState$2(props);
2779
+ const [state, dispatch] = useControlledReducer$1(downshiftSelectReducer, initialState, props);
2780
+ const {
2781
+ isOpen,
2782
+ highlightedIndex,
2783
+ selectedItem,
2784
+ inputValue
2785
+ } = state; // Element efs.
2786
+
2787
+ const toggleButtonRef = preact.useRef(null);
2788
+ const menuRef = preact.useRef(null);
2789
+ const itemRefs = preact.useRef({}); // used not to trigger menu blur action in some scenarios.
2790
+
2791
+ const shouldBlurRef = preact.useRef(true); // used to keep the inputValue clearTimeout object between renders.
2792
+
2793
+ const clearTimeoutRef = preact.useRef(null); // prevent id re-generation between renders.
2794
+
2795
+ const elementIds = useElementIds(props); // used to keep track of how many items we had on previous cycle.
2796
+
2797
+ const previousResultCountRef = preact.useRef();
2798
+ const isInitialMountRef = preact.useRef(true); // utility callback to get item element.
2799
+
2800
+ const latest = useLatestRef({
2801
+ state,
2802
+ props
2850
2803
  }); // Some utils.
2851
2804
 
2852
- var getItemNodeFromIndex = preact.useCallback(function (index) {
2853
- return itemRefs.current[elementIds.getItemId(index)];
2854
- }, [elementIds]); // Effects.
2805
+ const getItemNodeFromIndex = preact.useCallback(index => itemRefs.current[elementIds.getItemId(index)], [elementIds]); // Effects.
2855
2806
  // Sets a11y status message on changes in state.
2856
2807
 
2857
- useA11yMessageSetter(getA11yStatusMessage, [isOpen, highlightedIndex, inputValue, items], _extends({
2808
+ useA11yMessageSetter(getA11yStatusMessage, [isOpen, highlightedIndex, inputValue, items], {
2858
2809
  isInitialMount: isInitialMountRef.current,
2859
2810
  previousResultCount: previousResultCountRef.current,
2860
- items: items,
2861
- environment: environment,
2862
- itemToString: itemToString
2863
- }, state)); // Sets a11y status message on changes in selectedItem.
2811
+ items,
2812
+ environment,
2813
+ itemToString,
2814
+ ...state
2815
+ }); // Sets a11y status message on changes in selectedItem.
2864
2816
 
2865
- useA11yMessageSetter(getA11ySelectionMessage, [selectedItem], _extends({
2817
+ useA11yMessageSetter(getA11ySelectionMessage, [selectedItem], {
2866
2818
  isInitialMount: isInitialMountRef.current,
2867
2819
  previousResultCount: previousResultCountRef.current,
2868
- items: items,
2869
- environment: environment,
2870
- itemToString: itemToString
2871
- }, state)); // Scroll on highlighted item if change comes from keyboard.
2820
+ items,
2821
+ environment,
2822
+ itemToString,
2823
+ ...state
2824
+ }); // Scroll on highlighted item if change comes from keyboard.
2872
2825
 
2873
- var shouldScrollRef = useScrollIntoView({
2826
+ const shouldScrollRef = useScrollIntoView({
2874
2827
  menuElement: menuRef.current,
2875
- highlightedIndex: highlightedIndex,
2876
- isOpen: isOpen,
2877
- itemRefs: itemRefs,
2878
- scrollIntoView: scrollIntoView,
2879
- getItemNodeFromIndex: getItemNodeFromIndex
2828
+ highlightedIndex,
2829
+ isOpen,
2830
+ itemRefs,
2831
+ scrollIntoView,
2832
+ getItemNodeFromIndex
2880
2833
  }); // Sets cleanup for the keysSoFar callback, debounded after 500ms.
2881
2834
 
2882
- preact.useEffect(function () {
2835
+ preact.useEffect(() => {
2883
2836
  // init the clean function here as we need access to dispatch.
2884
- clearTimeoutRef.current = debounce(function (outerDispatch) {
2837
+ clearTimeoutRef.current = debounce(outerDispatch => {
2885
2838
  outerDispatch({
2886
2839
  type: FunctionSetInputValue$1,
2887
2840
  inputValue: ''
2888
2841
  });
2889
2842
  }, 500); // Cancel any pending debounced calls on mount
2890
2843
 
2891
- return function () {
2844
+ return () => {
2892
2845
  clearTimeoutRef.current.cancel();
2893
2846
  };
2894
2847
  }, []); // Invokes the keysSoFar callback set up above.
2895
2848
 
2896
- preact.useEffect(function () {
2849
+ preact.useEffect(() => {
2897
2850
  if (!inputValue) {
2898
2851
  return;
2899
2852
  }
@@ -2902,12 +2855,12 @@
2902
2855
  }, [dispatch, inputValue]);
2903
2856
  useControlPropsValidator({
2904
2857
  isInitialMount: isInitialMountRef.current,
2905
- props: props,
2906
- state: state
2858
+ props,
2859
+ state
2907
2860
  });
2908
2861
  /* Controls the focus on the menu or the toggle button. */
2909
2862
 
2910
- preact.useEffect(function () {
2863
+ preact.useEffect(() => {
2911
2864
  // Don't focus menu on first render.
2912
2865
  if (isInitialMountRef.current) {
2913
2866
  // Unless it was initialised as open.
@@ -2938,7 +2891,7 @@
2938
2891
  } // eslint-disable-next-line react-hooks/exhaustive-deps
2939
2892
 
2940
2893
  }, [isOpen]);
2941
- preact.useEffect(function () {
2894
+ preact.useEffect(() => {
2942
2895
  if (isInitialMountRef.current) {
2943
2896
  return;
2944
2897
  }
@@ -2946,180 +2899,180 @@
2946
2899
  previousResultCountRef.current = items.length;
2947
2900
  }); // Add mouse/touch events to document.
2948
2901
 
2949
- var mouseAndTouchTrackersRef = useMouseAndTouchTracker(isOpen, [menuRef, toggleButtonRef], environment, function () {
2902
+ const mouseAndTouchTrackersRef = useMouseAndTouchTracker(isOpen, [menuRef, toggleButtonRef], environment, () => {
2950
2903
  dispatch({
2951
2904
  type: MenuBlur
2952
2905
  });
2953
2906
  });
2954
- var setGetterPropCallInfo = useGetterPropsCalledChecker('getMenuProps', 'getToggleButtonProps'); // Make initial ref false.
2907
+ const setGetterPropCallInfo = useGetterPropsCalledChecker('getMenuProps', 'getToggleButtonProps'); // Make initial ref false.
2955
2908
 
2956
- preact.useEffect(function () {
2909
+ preact.useEffect(() => {
2957
2910
  isInitialMountRef.current = false;
2958
2911
  }, []); // Reset itemRefs on close.
2959
2912
 
2960
- preact.useEffect(function () {
2913
+ preact.useEffect(() => {
2961
2914
  if (!isOpen) {
2962
2915
  itemRefs.current = {};
2963
2916
  }
2964
2917
  }, [isOpen]); // Event handler functions.
2965
2918
 
2966
- var toggleButtonKeyDownHandlers = preact.useMemo(function () {
2967
- return {
2968
- ArrowDown: function ArrowDown(event) {
2969
- event.preventDefault();
2970
- dispatch({
2971
- type: ToggleButtonKeyDownArrowDown,
2972
- getItemNodeFromIndex: getItemNodeFromIndex,
2973
- shiftKey: event.shiftKey
2974
- });
2975
- },
2976
- ArrowUp: function ArrowUp(event) {
2977
- event.preventDefault();
2978
- dispatch({
2979
- type: ToggleButtonKeyDownArrowUp,
2980
- getItemNodeFromIndex: getItemNodeFromIndex,
2981
- shiftKey: event.shiftKey
2982
- });
2983
- }
2984
- };
2985
- }, [dispatch, getItemNodeFromIndex]);
2986
- var menuKeyDownHandlers = preact.useMemo(function () {
2987
- return {
2988
- ArrowDown: function ArrowDown(event) {
2989
- event.preventDefault();
2990
- dispatch({
2991
- type: MenuKeyDownArrowDown,
2992
- getItemNodeFromIndex: getItemNodeFromIndex,
2993
- shiftKey: event.shiftKey
2994
- });
2995
- },
2996
- ArrowUp: function ArrowUp(event) {
2997
- event.preventDefault();
2998
- dispatch({
2999
- type: MenuKeyDownArrowUp,
3000
- getItemNodeFromIndex: getItemNodeFromIndex,
3001
- shiftKey: event.shiftKey
3002
- });
3003
- },
3004
- Home: function Home(event) {
3005
- event.preventDefault();
3006
- dispatch({
3007
- type: MenuKeyDownHome,
3008
- getItemNodeFromIndex: getItemNodeFromIndex
3009
- });
3010
- },
3011
- End: function End(event) {
3012
- event.preventDefault();
3013
- dispatch({
3014
- type: MenuKeyDownEnd,
3015
- getItemNodeFromIndex: getItemNodeFromIndex
3016
- });
3017
- },
3018
- Escape: function Escape() {
3019
- dispatch({
3020
- type: MenuKeyDownEscape
3021
- });
3022
- },
3023
- Enter: function Enter(event) {
3024
- event.preventDefault();
3025
- dispatch({
3026
- type: MenuKeyDownEnter
3027
- });
3028
- },
3029
- ' ': function _(event) {
3030
- event.preventDefault();
3031
- dispatch({
3032
- type: MenuKeyDownSpaceButton
3033
- });
3034
- }
3035
- };
3036
- }, [dispatch, getItemNodeFromIndex]); // Action functions.
2919
+ const toggleButtonKeyDownHandlers = preact.useMemo(() => ({
2920
+ ArrowDown(event) {
2921
+ event.preventDefault();
2922
+ dispatch({
2923
+ type: ToggleButtonKeyDownArrowDown,
2924
+ getItemNodeFromIndex,
2925
+ shiftKey: event.shiftKey
2926
+ });
2927
+ },
2928
+
2929
+ ArrowUp(event) {
2930
+ event.preventDefault();
2931
+ dispatch({
2932
+ type: ToggleButtonKeyDownArrowUp,
2933
+ getItemNodeFromIndex,
2934
+ shiftKey: event.shiftKey
2935
+ });
2936
+ }
2937
+
2938
+ }), [dispatch, getItemNodeFromIndex]);
2939
+ const menuKeyDownHandlers = preact.useMemo(() => ({
2940
+ ArrowDown(event) {
2941
+ event.preventDefault();
2942
+ dispatch({
2943
+ type: MenuKeyDownArrowDown,
2944
+ getItemNodeFromIndex,
2945
+ shiftKey: event.shiftKey
2946
+ });
2947
+ },
2948
+
2949
+ ArrowUp(event) {
2950
+ event.preventDefault();
2951
+ dispatch({
2952
+ type: MenuKeyDownArrowUp,
2953
+ getItemNodeFromIndex,
2954
+ shiftKey: event.shiftKey
2955
+ });
2956
+ },
2957
+
2958
+ Home(event) {
2959
+ event.preventDefault();
2960
+ dispatch({
2961
+ type: MenuKeyDownHome,
2962
+ getItemNodeFromIndex
2963
+ });
2964
+ },
3037
2965
 
3038
- var toggleMenu = preact.useCallback(function () {
2966
+ End(event) {
2967
+ event.preventDefault();
2968
+ dispatch({
2969
+ type: MenuKeyDownEnd,
2970
+ getItemNodeFromIndex
2971
+ });
2972
+ },
2973
+
2974
+ Escape() {
2975
+ dispatch({
2976
+ type: MenuKeyDownEscape
2977
+ });
2978
+ },
2979
+
2980
+ Enter(event) {
2981
+ event.preventDefault();
2982
+ dispatch({
2983
+ type: MenuKeyDownEnter
2984
+ });
2985
+ },
2986
+
2987
+ ' '(event) {
2988
+ event.preventDefault();
2989
+ dispatch({
2990
+ type: MenuKeyDownSpaceButton
2991
+ });
2992
+ }
2993
+
2994
+ }), [dispatch, getItemNodeFromIndex]); // Action functions.
2995
+
2996
+ const toggleMenu = preact.useCallback(() => {
3039
2997
  dispatch({
3040
2998
  type: FunctionToggleMenu$1
3041
2999
  });
3042
3000
  }, [dispatch]);
3043
- var closeMenu = preact.useCallback(function () {
3001
+ const closeMenu = preact.useCallback(() => {
3044
3002
  dispatch({
3045
3003
  type: FunctionCloseMenu$1
3046
3004
  });
3047
3005
  }, [dispatch]);
3048
- var openMenu = preact.useCallback(function () {
3006
+ const openMenu = preact.useCallback(() => {
3049
3007
  dispatch({
3050
3008
  type: FunctionOpenMenu$1
3051
3009
  });
3052
3010
  }, [dispatch]);
3053
- var setHighlightedIndex = preact.useCallback(function (newHighlightedIndex) {
3011
+ const setHighlightedIndex = preact.useCallback(newHighlightedIndex => {
3054
3012
  dispatch({
3055
3013
  type: FunctionSetHighlightedIndex$1,
3056
3014
  highlightedIndex: newHighlightedIndex
3057
3015
  });
3058
3016
  }, [dispatch]);
3059
- var selectItem = preact.useCallback(function (newSelectedItem) {
3017
+ const selectItem = preact.useCallback(newSelectedItem => {
3060
3018
  dispatch({
3061
3019
  type: FunctionSelectItem$1,
3062
3020
  selectedItem: newSelectedItem
3063
3021
  });
3064
3022
  }, [dispatch]);
3065
- var reset = preact.useCallback(function () {
3023
+ const reset = preact.useCallback(() => {
3066
3024
  dispatch({
3067
3025
  type: FunctionReset$2
3068
3026
  });
3069
3027
  }, [dispatch]);
3070
- var setInputValue = preact.useCallback(function (newInputValue) {
3028
+ const setInputValue = preact.useCallback(newInputValue => {
3071
3029
  dispatch({
3072
3030
  type: FunctionSetInputValue$1,
3073
3031
  inputValue: newInputValue
3074
3032
  });
3075
3033
  }, [dispatch]); // Getter functions.
3076
3034
 
3077
- var getLabelProps = preact.useCallback(function (labelProps) {
3078
- return _extends({
3079
- id: elementIds.labelId,
3080
- htmlFor: elementIds.toggleButtonId
3081
- }, labelProps);
3082
- }, [elementIds]);
3083
- var getMenuProps = preact.useCallback(function (_temp, _temp2) {
3084
- var _extends2;
3085
-
3086
- var _ref = _temp === void 0 ? {} : _temp,
3087
- onMouseLeave = _ref.onMouseLeave,
3088
- _ref$refKey = _ref.refKey,
3089
- refKey = _ref$refKey === void 0 ? 'ref' : _ref$refKey,
3090
- onKeyDown = _ref.onKeyDown,
3091
- onBlur = _ref.onBlur,
3092
- ref = _ref.ref,
3093
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$2);
3094
-
3095
- var _ref2 = _temp2 === void 0 ? {} : _temp2,
3096
- _ref2$suppressRefErro = _ref2.suppressRefError,
3097
- suppressRefError = _ref2$suppressRefErro === void 0 ? false : _ref2$suppressRefErro;
3098
-
3099
- var latestState = latest.current.state;
3100
-
3101
- var menuHandleKeyDown = function menuHandleKeyDown(event) {
3102
- var key = normalizeArrowKey(event);
3035
+ const getLabelProps = preact.useCallback(labelProps => ({
3036
+ id: elementIds.labelId,
3037
+ htmlFor: elementIds.toggleButtonId,
3038
+ ...labelProps
3039
+ }), [elementIds]);
3040
+ const getMenuProps = preact.useCallback(function (_temp, _temp2) {
3041
+ let {
3042
+ onMouseLeave,
3043
+ refKey = 'ref',
3044
+ onKeyDown,
3045
+ onBlur,
3046
+ ref,
3047
+ ...rest
3048
+ } = _temp === void 0 ? {} : _temp;
3049
+ let {
3050
+ suppressRefError = false
3051
+ } = _temp2 === void 0 ? {} : _temp2;
3052
+ const latestState = latest.current.state;
3053
+
3054
+ const menuHandleKeyDown = event => {
3055
+ const key = normalizeArrowKey(event);
3103
3056
 
3104
3057
  if (key && menuKeyDownHandlers[key]) {
3105
3058
  menuKeyDownHandlers[key](event);
3106
3059
  } else if (isAcceptedCharacterKey(key)) {
3107
3060
  dispatch({
3108
3061
  type: MenuKeyDownCharacter,
3109
- key: key,
3110
- getItemNodeFromIndex: getItemNodeFromIndex
3062
+ key,
3063
+ getItemNodeFromIndex
3111
3064
  });
3112
3065
  }
3113
3066
  };
3114
3067
 
3115
- var menuHandleBlur = function menuHandleBlur() {
3068
+ const menuHandleBlur = () => {
3116
3069
  // if the blur was a result of selection, we don't trigger this action.
3117
3070
  if (shouldBlurRef.current === false) {
3118
3071
  shouldBlurRef.current = true;
3119
3072
  return;
3120
3073
  }
3121
3074
 
3122
- var shouldBlur = !mouseAndTouchTrackersRef.current.isMouseDown;
3075
+ const shouldBlur = !mouseAndTouchTrackersRef.current.isMouseDown;
3123
3076
  /* istanbul ignore else */
3124
3077
 
3125
3078
  if (shouldBlur) {
@@ -3129,61 +3082,72 @@
3129
3082
  }
3130
3083
  };
3131
3084
 
3132
- var menuHandleMouseLeave = function menuHandleMouseLeave() {
3085
+ const menuHandleMouseLeave = () => {
3133
3086
  dispatch({
3134
3087
  type: MenuMouseLeave$1
3135
3088
  });
3136
3089
  };
3137
3090
 
3138
3091
  setGetterPropCallInfo('getMenuProps', suppressRefError, refKey, menuRef);
3139
- return _extends((_extends2 = {}, _extends2[refKey] = handleRefs(ref, function (menuNode) {
3140
- menuRef.current = menuNode;
3141
- }), _extends2.id = elementIds.menuId, _extends2.role = 'listbox', _extends2['aria-labelledby'] = elementIds.labelId, _extends2.tabIndex = -1, _extends2), latestState.isOpen && latestState.highlightedIndex > -1 && {
3142
- 'aria-activedescendant': elementIds.getItemId(latestState.highlightedIndex)
3143
- }, {
3092
+ return {
3093
+ [refKey]: handleRefs(ref, menuNode => {
3094
+ menuRef.current = menuNode;
3095
+ }),
3096
+ id: elementIds.menuId,
3097
+ role: 'listbox',
3098
+ 'aria-labelledby': elementIds.labelId,
3099
+ tabIndex: -1,
3100
+ ...(latestState.isOpen && latestState.highlightedIndex > -1 && {
3101
+ 'aria-activedescendant': elementIds.getItemId(latestState.highlightedIndex)
3102
+ }),
3144
3103
  onMouseLeave: callAllEventHandlers(onMouseLeave, menuHandleMouseLeave),
3145
3104
  onKeyDown: callAllEventHandlers(onKeyDown, menuHandleKeyDown),
3146
- onBlur: callAllEventHandlers(onBlur, menuHandleBlur)
3147
- }, rest);
3105
+ onBlur: callAllEventHandlers(onBlur, menuHandleBlur),
3106
+ ...rest
3107
+ };
3148
3108
  }, [dispatch, latest, menuKeyDownHandlers, mouseAndTouchTrackersRef, setGetterPropCallInfo, elementIds, getItemNodeFromIndex]);
3149
- var getToggleButtonProps = preact.useCallback(function (_temp3, _temp4) {
3150
- var _extends3;
3151
-
3152
- var _ref3 = _temp3 === void 0 ? {} : _temp3,
3153
- onClick = _ref3.onClick,
3154
- onKeyDown = _ref3.onKeyDown,
3155
- _ref3$refKey = _ref3.refKey,
3156
- refKey = _ref3$refKey === void 0 ? 'ref' : _ref3$refKey,
3157
- ref = _ref3.ref,
3158
- rest = _objectWithoutPropertiesLoose(_ref3, _excluded2$2);
3159
-
3160
- var _ref4 = _temp4 === void 0 ? {} : _temp4,
3161
- _ref4$suppressRefErro = _ref4.suppressRefError,
3162
- suppressRefError = _ref4$suppressRefErro === void 0 ? false : _ref4$suppressRefErro;
3163
-
3164
- var toggleButtonHandleClick = function toggleButtonHandleClick() {
3109
+ const getToggleButtonProps = preact.useCallback(function (_temp3, _temp4) {
3110
+ let {
3111
+ onClick,
3112
+ onKeyDown,
3113
+ refKey = 'ref',
3114
+ ref,
3115
+ ...rest
3116
+ } = _temp3 === void 0 ? {} : _temp3;
3117
+ let {
3118
+ suppressRefError = false
3119
+ } = _temp4 === void 0 ? {} : _temp4;
3120
+
3121
+ const toggleButtonHandleClick = () => {
3165
3122
  dispatch({
3166
3123
  type: ToggleButtonClick$1
3167
3124
  });
3168
3125
  };
3169
3126
 
3170
- var toggleButtonHandleKeyDown = function toggleButtonHandleKeyDown(event) {
3171
- var key = normalizeArrowKey(event);
3127
+ const toggleButtonHandleKeyDown = event => {
3128
+ const key = normalizeArrowKey(event);
3172
3129
 
3173
3130
  if (key && toggleButtonKeyDownHandlers[key]) {
3174
3131
  toggleButtonKeyDownHandlers[key](event);
3175
3132
  } else if (isAcceptedCharacterKey(key)) {
3176
3133
  dispatch({
3177
3134
  type: ToggleButtonKeyDownCharacter,
3178
- key: key,
3179
- getItemNodeFromIndex: getItemNodeFromIndex
3135
+ key,
3136
+ getItemNodeFromIndex
3180
3137
  });
3181
3138
  }
3182
3139
  };
3183
3140
 
3184
- var toggleProps = _extends((_extends3 = {}, _extends3[refKey] = handleRefs(ref, function (toggleButtonNode) {
3185
- toggleButtonRef.current = toggleButtonNode;
3186
- }), _extends3.id = elementIds.toggleButtonId, _extends3['aria-haspopup'] = 'listbox', _extends3['aria-expanded'] = latest.current.state.isOpen, _extends3['aria-labelledby'] = elementIds.labelId + " " + elementIds.toggleButtonId, _extends3), rest);
3141
+ const toggleProps = {
3142
+ [refKey]: handleRefs(ref, toggleButtonNode => {
3143
+ toggleButtonRef.current = toggleButtonNode;
3144
+ }),
3145
+ id: elementIds.toggleButtonId,
3146
+ 'aria-haspopup': 'listbox',
3147
+ 'aria-expanded': latest.current.state.isOpen,
3148
+ 'aria-labelledby': elementIds.labelId + " " + elementIds.toggleButtonId,
3149
+ ...rest
3150
+ };
3187
3151
 
3188
3152
  if (!rest.disabled) {
3189
3153
  toggleProps.onClick = callAllEventHandlers(onClick, toggleButtonHandleClick);
@@ -3193,24 +3157,22 @@
3193
3157
  setGetterPropCallInfo('getToggleButtonProps', suppressRefError, refKey, toggleButtonRef);
3194
3158
  return toggleProps;
3195
3159
  }, [dispatch, latest, toggleButtonKeyDownHandlers, setGetterPropCallInfo, elementIds, getItemNodeFromIndex]);
3196
- var getItemProps = preact.useCallback(function (_temp5) {
3197
- var _extends4;
3198
-
3199
- var _ref5 = _temp5 === void 0 ? {} : _temp5,
3200
- item = _ref5.item,
3201
- index = _ref5.index,
3202
- onMouseMove = _ref5.onMouseMove,
3203
- onClick = _ref5.onClick,
3204
- _ref5$refKey = _ref5.refKey,
3205
- refKey = _ref5$refKey === void 0 ? 'ref' : _ref5$refKey,
3206
- ref = _ref5.ref,
3207
- rest = _objectWithoutPropertiesLoose(_ref5, _excluded3$1);
3208
-
3209
- var _latest$current = latest.current,
3210
- latestState = _latest$current.state,
3211
- latestProps = _latest$current.props;
3212
-
3213
- var itemHandleMouseMove = function itemHandleMouseMove() {
3160
+ const getItemProps = preact.useCallback(function (_temp5) {
3161
+ let {
3162
+ item,
3163
+ index,
3164
+ onMouseMove,
3165
+ onClick,
3166
+ refKey = 'ref',
3167
+ ref,
3168
+ ...rest
3169
+ } = _temp5 === void 0 ? {} : _temp5;
3170
+ const {
3171
+ state: latestState,
3172
+ props: latestProps
3173
+ } = latest.current;
3174
+
3175
+ const itemHandleMouseMove = () => {
3214
3176
  if (index === latestState.highlightedIndex) {
3215
3177
  return;
3216
3178
  }
@@ -3218,32 +3180,34 @@
3218
3180
  shouldScrollRef.current = false;
3219
3181
  dispatch({
3220
3182
  type: ItemMouseMove$1,
3221
- index: index
3183
+ index
3222
3184
  });
3223
3185
  };
3224
3186
 
3225
- var itemHandleClick = function itemHandleClick() {
3187
+ const itemHandleClick = () => {
3226
3188
  dispatch({
3227
3189
  type: ItemClick$1,
3228
- index: index
3190
+ index
3229
3191
  });
3230
3192
  };
3231
3193
 
3232
- var itemIndex = getItemIndex(index, item, latestProps.items);
3194
+ const itemIndex = getItemIndex(index, item, latestProps.items);
3233
3195
 
3234
3196
  if (itemIndex < 0) {
3235
3197
  throw new Error('Pass either item or item index in getItemProps!');
3236
3198
  }
3237
3199
 
3238
- var itemProps = _extends((_extends4 = {
3200
+ const itemProps = {
3239
3201
  role: 'option',
3240
3202
  'aria-selected': "" + (itemIndex === latestState.highlightedIndex),
3241
- id: elementIds.getItemId(itemIndex)
3242
- }, _extends4[refKey] = handleRefs(ref, function (itemNode) {
3243
- if (itemNode) {
3244
- itemRefs.current[elementIds.getItemId(itemIndex)] = itemNode;
3245
- }
3246
- }), _extends4), rest);
3203
+ id: elementIds.getItemId(itemIndex),
3204
+ [refKey]: handleRefs(ref, itemNode => {
3205
+ if (itemNode) {
3206
+ itemRefs.current[elementIds.getItemId(itemIndex)] = itemNode;
3207
+ }
3208
+ }),
3209
+ ...rest
3210
+ };
3247
3211
 
3248
3212
  if (!rest.disabled) {
3249
3213
  itemProps.onMouseMove = callAllEventHandlers(onMouseMove, itemHandleMouseMove);
@@ -3254,46 +3218,46 @@
3254
3218
  }, [dispatch, latest, shouldScrollRef, elementIds]);
3255
3219
  return {
3256
3220
  // prop getters.
3257
- getToggleButtonProps: getToggleButtonProps,
3258
- getLabelProps: getLabelProps,
3259
- getMenuProps: getMenuProps,
3260
- getItemProps: getItemProps,
3221
+ getToggleButtonProps,
3222
+ getLabelProps,
3223
+ getMenuProps,
3224
+ getItemProps,
3261
3225
  // actions.
3262
- toggleMenu: toggleMenu,
3263
- openMenu: openMenu,
3264
- closeMenu: closeMenu,
3265
- setHighlightedIndex: setHighlightedIndex,
3266
- selectItem: selectItem,
3267
- reset: reset,
3268
- setInputValue: setInputValue,
3226
+ toggleMenu,
3227
+ openMenu,
3228
+ closeMenu,
3229
+ setHighlightedIndex,
3230
+ selectItem,
3231
+ reset,
3232
+ setInputValue,
3269
3233
  // state.
3270
- highlightedIndex: highlightedIndex,
3271
- isOpen: isOpen,
3272
- selectedItem: selectedItem,
3273
- inputValue: inputValue
3234
+ highlightedIndex,
3235
+ isOpen,
3236
+ selectedItem,
3237
+ inputValue
3274
3238
  };
3275
3239
  }
3276
3240
 
3277
- var InputKeyDownArrowDown = '__input_keydown_arrow_down__' ;
3278
- var InputKeyDownArrowUp = '__input_keydown_arrow_up__' ;
3279
- var InputKeyDownEscape = '__input_keydown_escape__' ;
3280
- var InputKeyDownHome = '__input_keydown_home__' ;
3281
- var InputKeyDownEnd = '__input_keydown_end__' ;
3282
- var InputKeyDownEnter = '__input_keydown_enter__' ;
3283
- var InputChange = '__input_change__' ;
3284
- var InputBlur = '__input_blur__' ;
3285
- var MenuMouseLeave = '__menu_mouse_leave__' ;
3286
- var ItemMouseMove = '__item_mouse_move__' ;
3287
- var ItemClick = '__item_click__' ;
3288
- var ToggleButtonClick = '__togglebutton_click__' ;
3289
- var FunctionToggleMenu = '__function_toggle_menu__' ;
3290
- var FunctionOpenMenu = '__function_open_menu__' ;
3291
- var FunctionCloseMenu = '__function_close_menu__' ;
3292
- var FunctionSetHighlightedIndex = '__function_set_highlighted_index__' ;
3293
- var FunctionSelectItem = '__function_select_item__' ;
3294
- var FunctionSetInputValue = '__function_set_input_value__' ;
3295
- var FunctionReset$1 = '__function_reset__' ;
3296
- var ControlledPropUpdatedSelectedItem = '__controlled_prop_updated_selected_item__' ;
3241
+ const InputKeyDownArrowDown = '__input_keydown_arrow_down__' ;
3242
+ const InputKeyDownArrowUp = '__input_keydown_arrow_up__' ;
3243
+ const InputKeyDownEscape = '__input_keydown_escape__' ;
3244
+ const InputKeyDownHome = '__input_keydown_home__' ;
3245
+ const InputKeyDownEnd = '__input_keydown_end__' ;
3246
+ const InputKeyDownEnter = '__input_keydown_enter__' ;
3247
+ const InputChange = '__input_change__' ;
3248
+ const InputBlur = '__input_blur__' ;
3249
+ const MenuMouseLeave = '__menu_mouse_leave__' ;
3250
+ const ItemMouseMove = '__item_mouse_move__' ;
3251
+ const ItemClick = '__item_click__' ;
3252
+ const ToggleButtonClick = '__togglebutton_click__' ;
3253
+ const FunctionToggleMenu = '__function_toggle_menu__' ;
3254
+ const FunctionOpenMenu = '__function_open_menu__' ;
3255
+ const FunctionCloseMenu = '__function_close_menu__' ;
3256
+ const FunctionSetHighlightedIndex = '__function_set_highlighted_index__' ;
3257
+ const FunctionSelectItem = '__function_select_item__' ;
3258
+ const FunctionSetInputValue = '__function_set_input_value__' ;
3259
+ const FunctionReset$1 = '__function_reset__' ;
3260
+ const ControlledPropUpdatedSelectedItem = '__controlled_prop_updated_selected_item__' ;
3297
3261
 
3298
3262
  var stateChangeTypes$1 = /*#__PURE__*/Object.freeze({
3299
3263
  __proto__: null,
@@ -3320,56 +3284,60 @@
3320
3284
  });
3321
3285
 
3322
3286
  function getInitialState$1(props) {
3323
- var initialState = getInitialState$2(props);
3324
- var selectedItem = initialState.selectedItem;
3325
- var inputValue = initialState.inputValue;
3287
+ const initialState = getInitialState$2(props);
3288
+ const {
3289
+ selectedItem
3290
+ } = initialState;
3291
+ let {
3292
+ inputValue
3293
+ } = initialState;
3326
3294
 
3327
3295
  if (inputValue === '' && selectedItem && props.defaultInputValue === undefined && props.initialInputValue === undefined && props.inputValue === undefined) {
3328
3296
  inputValue = props.itemToString(selectedItem);
3329
3297
  }
3330
3298
 
3331
- return _extends({}, initialState, {
3332
- inputValue: inputValue
3333
- });
3299
+ return { ...initialState,
3300
+ inputValue
3301
+ };
3334
3302
  }
3335
3303
 
3336
- var propTypes$1 = {
3337
- items: PropTypes__default['default'].array.isRequired,
3338
- itemToString: PropTypes__default['default'].func,
3339
- getA11yStatusMessage: PropTypes__default['default'].func,
3340
- getA11ySelectionMessage: PropTypes__default['default'].func,
3341
- circularNavigation: PropTypes__default['default'].bool,
3342
- highlightedIndex: PropTypes__default['default'].number,
3343
- defaultHighlightedIndex: PropTypes__default['default'].number,
3344
- initialHighlightedIndex: PropTypes__default['default'].number,
3345
- isOpen: PropTypes__default['default'].bool,
3346
- defaultIsOpen: PropTypes__default['default'].bool,
3347
- initialIsOpen: PropTypes__default['default'].bool,
3348
- selectedItem: PropTypes__default['default'].any,
3349
- initialSelectedItem: PropTypes__default['default'].any,
3350
- defaultSelectedItem: PropTypes__default['default'].any,
3351
- inputValue: PropTypes__default['default'].string,
3352
- defaultInputValue: PropTypes__default['default'].string,
3353
- initialInputValue: PropTypes__default['default'].string,
3354
- id: PropTypes__default['default'].string,
3355
- labelId: PropTypes__default['default'].string,
3356
- menuId: PropTypes__default['default'].string,
3357
- getItemId: PropTypes__default['default'].func,
3358
- inputId: PropTypes__default['default'].string,
3359
- toggleButtonId: PropTypes__default['default'].string,
3360
- stateReducer: PropTypes__default['default'].func,
3361
- onSelectedItemChange: PropTypes__default['default'].func,
3362
- onHighlightedIndexChange: PropTypes__default['default'].func,
3363
- onStateChange: PropTypes__default['default'].func,
3364
- onIsOpenChange: PropTypes__default['default'].func,
3365
- onInputValueChange: PropTypes__default['default'].func,
3366
- environment: PropTypes__default['default'].shape({
3367
- addEventListener: PropTypes__default['default'].func,
3368
- removeEventListener: PropTypes__default['default'].func,
3369
- document: PropTypes__default['default'].shape({
3370
- getElementById: PropTypes__default['default'].func,
3371
- activeElement: PropTypes__default['default'].any,
3372
- body: PropTypes__default['default'].any
3304
+ const propTypes$1 = {
3305
+ items: PropTypes__default["default"].array.isRequired,
3306
+ itemToString: PropTypes__default["default"].func,
3307
+ getA11yStatusMessage: PropTypes__default["default"].func,
3308
+ getA11ySelectionMessage: PropTypes__default["default"].func,
3309
+ circularNavigation: PropTypes__default["default"].bool,
3310
+ highlightedIndex: PropTypes__default["default"].number,
3311
+ defaultHighlightedIndex: PropTypes__default["default"].number,
3312
+ initialHighlightedIndex: PropTypes__default["default"].number,
3313
+ isOpen: PropTypes__default["default"].bool,
3314
+ defaultIsOpen: PropTypes__default["default"].bool,
3315
+ initialIsOpen: PropTypes__default["default"].bool,
3316
+ selectedItem: PropTypes__default["default"].any,
3317
+ initialSelectedItem: PropTypes__default["default"].any,
3318
+ defaultSelectedItem: PropTypes__default["default"].any,
3319
+ inputValue: PropTypes__default["default"].string,
3320
+ defaultInputValue: PropTypes__default["default"].string,
3321
+ initialInputValue: PropTypes__default["default"].string,
3322
+ id: PropTypes__default["default"].string,
3323
+ labelId: PropTypes__default["default"].string,
3324
+ menuId: PropTypes__default["default"].string,
3325
+ getItemId: PropTypes__default["default"].func,
3326
+ inputId: PropTypes__default["default"].string,
3327
+ toggleButtonId: PropTypes__default["default"].string,
3328
+ stateReducer: PropTypes__default["default"].func,
3329
+ onSelectedItemChange: PropTypes__default["default"].func,
3330
+ onHighlightedIndexChange: PropTypes__default["default"].func,
3331
+ onStateChange: PropTypes__default["default"].func,
3332
+ onIsOpenChange: PropTypes__default["default"].func,
3333
+ onInputValueChange: PropTypes__default["default"].func,
3334
+ environment: PropTypes__default["default"].shape({
3335
+ addEventListener: PropTypes__default["default"].func,
3336
+ removeEventListener: PropTypes__default["default"].func,
3337
+ document: PropTypes__default["default"].shape({
3338
+ getElementById: PropTypes__default["default"].func,
3339
+ activeElement: PropTypes__default["default"].any,
3340
+ body: PropTypes__default["default"].any
3373
3341
  })
3374
3342
  })
3375
3343
  };
@@ -3387,14 +3355,10 @@
3387
3355
  */
3388
3356
 
3389
3357
  function useControlledReducer(reducer, initialState, props) {
3390
- var previousSelectedItemRef = preact.useRef();
3391
-
3392
- var _useEnhancedReducer = useEnhancedReducer(reducer, initialState, props),
3393
- state = _useEnhancedReducer[0],
3394
- dispatch = _useEnhancedReducer[1]; // ToDo: if needed, make same approach as selectedItemChanged from Downshift.
3358
+ const previousSelectedItemRef = preact.useRef();
3359
+ const [state, dispatch] = useEnhancedReducer(reducer, initialState, props); // ToDo: if needed, make same approach as selectedItemChanged from Downshift.
3395
3360
 
3396
-
3397
- preact.useEffect(function () {
3361
+ preact.useEffect(() => {
3398
3362
  if (isControlledProp(props, 'selectedItem')) {
3399
3363
  if (previousSelectedItemRef.current !== props.selectedItem) {
3400
3364
  dispatch({
@@ -3410,27 +3374,29 @@
3410
3374
  } // eslint-disable-next-line import/no-mutable-exports
3411
3375
 
3412
3376
 
3413
- var validatePropTypes$1 = noop;
3377
+ let validatePropTypes$1 = noop;
3414
3378
  /* istanbul ignore next */
3415
3379
 
3416
3380
  {
3417
- validatePropTypes$1 = function validatePropTypes(options, caller) {
3418
- PropTypes__default['default'].checkPropTypes(propTypes$1, options, 'prop', caller.name);
3381
+ validatePropTypes$1 = (options, caller) => {
3382
+ PropTypes__default["default"].checkPropTypes(propTypes$1, options, 'prop', caller.name);
3419
3383
  };
3420
3384
  }
3421
3385
 
3422
- var defaultProps$1 = _extends({}, defaultProps$3, {
3386
+ const defaultProps$1 = { ...defaultProps$3,
3423
3387
  getA11yStatusMessage: getA11yStatusMessage$1,
3424
3388
  circularNavigation: true
3425
- });
3389
+ };
3426
3390
 
3427
3391
  /* eslint-disable complexity */
3428
3392
 
3429
3393
  function downshiftUseComboboxReducer(state, action) {
3430
- var type = action.type,
3431
- props = action.props,
3432
- shiftKey = action.shiftKey;
3433
- var changes;
3394
+ const {
3395
+ type,
3396
+ props,
3397
+ shiftKey
3398
+ } = action;
3399
+ let changes;
3434
3400
 
3435
3401
  switch (type) {
3436
3402
  case ItemClick:
@@ -3471,22 +3437,24 @@
3471
3437
  break;
3472
3438
 
3473
3439
  case InputKeyDownEnter:
3474
- changes = _extends({}, state.isOpen && state.highlightedIndex >= 0 && {
3475
- selectedItem: props.items[state.highlightedIndex],
3476
- isOpen: getDefaultValue$1(props, 'isOpen'),
3477
- highlightedIndex: getDefaultValue$1(props, 'highlightedIndex'),
3478
- inputValue: props.itemToString(props.items[state.highlightedIndex])
3479
- });
3440
+ changes = { ...(state.isOpen && state.highlightedIndex >= 0 && {
3441
+ selectedItem: props.items[state.highlightedIndex],
3442
+ isOpen: getDefaultValue$1(props, 'isOpen'),
3443
+ highlightedIndex: getDefaultValue$1(props, 'highlightedIndex'),
3444
+ inputValue: props.itemToString(props.items[state.highlightedIndex])
3445
+ })
3446
+ };
3480
3447
  break;
3481
3448
 
3482
3449
  case InputKeyDownEscape:
3483
- changes = _extends({
3450
+ changes = {
3484
3451
  isOpen: false,
3485
- highlightedIndex: -1
3486
- }, !state.isOpen && {
3487
- selectedItem: null,
3488
- inputValue: ''
3489
- });
3452
+ highlightedIndex: -1,
3453
+ ...(!state.isOpen && {
3454
+ selectedItem: null,
3455
+ inputValue: ''
3456
+ })
3457
+ };
3490
3458
  break;
3491
3459
 
3492
3460
  case InputKeyDownHome:
@@ -3502,13 +3470,14 @@
3502
3470
  break;
3503
3471
 
3504
3472
  case InputBlur:
3505
- changes = _extends({
3473
+ changes = {
3506
3474
  isOpen: false,
3507
- highlightedIndex: -1
3508
- }, state.highlightedIndex >= 0 && action.selectItem && {
3509
- selectedItem: props.items[state.highlightedIndex],
3510
- inputValue: props.itemToString(props.items[state.highlightedIndex])
3511
- });
3475
+ highlightedIndex: -1,
3476
+ ...(state.highlightedIndex >= 0 && action.selectItem && {
3477
+ selectedItem: props.items[state.highlightedIndex],
3478
+ inputValue: props.itemToString(props.items[state.highlightedIndex])
3479
+ })
3480
+ };
3512
3481
  break;
3513
3482
 
3514
3483
  case InputChange:
@@ -3536,15 +3505,13 @@
3536
3505
  return downshiftCommonReducer(state, action, stateChangeTypes$1);
3537
3506
  }
3538
3507
 
3539
- return _extends({}, state, changes);
3508
+ return { ...state,
3509
+ ...changes
3510
+ };
3540
3511
  }
3541
3512
  /* eslint-enable complexity */
3542
3513
 
3543
- var _excluded$1 = ["onMouseLeave", "refKey", "ref"],
3544
- _excluded2$1 = ["item", "index", "refKey", "ref", "onMouseMove", "onClick", "onPress"],
3545
- _excluded3 = ["onClick", "onPress", "refKey", "ref"],
3546
- _excluded4 = ["onKeyDown", "onChange", "onInput", "onBlur", "onChangeText", "refKey", "ref"],
3547
- _excluded5 = ["refKey", "ref"];
3514
+ /* eslint-disable max-statements */
3548
3515
  useCombobox.stateChangeTypes = stateChangeTypes$1;
3549
3516
 
3550
3517
  function useCombobox(userProps) {
@@ -3554,87 +3521,88 @@
3554
3521
 
3555
3522
  validatePropTypes$1(userProps, useCombobox); // Props defaults and destructuring.
3556
3523
 
3557
- var props = _extends({}, defaultProps$1, userProps);
3558
-
3559
- var initialIsOpen = props.initialIsOpen,
3560
- defaultIsOpen = props.defaultIsOpen,
3561
- items = props.items,
3562
- scrollIntoView = props.scrollIntoView,
3563
- environment = props.environment,
3564
- getA11yStatusMessage = props.getA11yStatusMessage,
3565
- getA11ySelectionMessage = props.getA11ySelectionMessage,
3566
- itemToString = props.itemToString; // Initial state depending on controlled props.
3567
-
3568
- var initialState = getInitialState$1(props);
3569
-
3570
- var _useControlledReducer = useControlledReducer(downshiftUseComboboxReducer, initialState, props),
3571
- state = _useControlledReducer[0],
3572
- dispatch = _useControlledReducer[1];
3573
-
3574
- var isOpen = state.isOpen,
3575
- highlightedIndex = state.highlightedIndex,
3576
- selectedItem = state.selectedItem,
3577
- inputValue = state.inputValue; // Element refs.
3578
-
3579
- var menuRef = preact.useRef(null);
3580
- var itemRefs = preact.useRef({});
3581
- var inputRef = preact.useRef(null);
3582
- var toggleButtonRef = preact.useRef(null);
3583
- var comboboxRef = preact.useRef(null);
3584
- var isInitialMountRef = preact.useRef(true); // prevent id re-generation between renders.
3585
-
3586
- var elementIds = useElementIds(props); // used to keep track of how many items we had on previous cycle.
3587
-
3588
- var previousResultCountRef = preact.useRef(); // utility callback to get item element.
3589
-
3590
- var latest = useLatestRef({
3591
- state: state,
3592
- props: props
3524
+ const props = { ...defaultProps$1,
3525
+ ...userProps
3526
+ };
3527
+ const {
3528
+ initialIsOpen,
3529
+ defaultIsOpen,
3530
+ items,
3531
+ scrollIntoView,
3532
+ environment,
3533
+ getA11yStatusMessage,
3534
+ getA11ySelectionMessage,
3535
+ itemToString
3536
+ } = props; // Initial state depending on controlled props.
3537
+
3538
+ const initialState = getInitialState$1(props);
3539
+ const [state, dispatch] = useControlledReducer(downshiftUseComboboxReducer, initialState, props);
3540
+ const {
3541
+ isOpen,
3542
+ highlightedIndex,
3543
+ selectedItem,
3544
+ inputValue
3545
+ } = state; // Element refs.
3546
+
3547
+ const menuRef = preact.useRef(null);
3548
+ const itemRefs = preact.useRef({});
3549
+ const inputRef = preact.useRef(null);
3550
+ const toggleButtonRef = preact.useRef(null);
3551
+ const comboboxRef = preact.useRef(null);
3552
+ const isInitialMountRef = preact.useRef(true); // prevent id re-generation between renders.
3553
+
3554
+ const elementIds = useElementIds(props); // used to keep track of how many items we had on previous cycle.
3555
+
3556
+ const previousResultCountRef = preact.useRef(); // utility callback to get item element.
3557
+
3558
+ const latest = useLatestRef({
3559
+ state,
3560
+ props
3593
3561
  });
3594
- var getItemNodeFromIndex = preact.useCallback(function (index) {
3595
- return itemRefs.current[elementIds.getItemId(index)];
3596
- }, [elementIds]); // Effects.
3562
+ const getItemNodeFromIndex = preact.useCallback(index => itemRefs.current[elementIds.getItemId(index)], [elementIds]); // Effects.
3597
3563
  // Sets a11y status message on changes in state.
3598
3564
 
3599
- useA11yMessageSetter(getA11yStatusMessage, [isOpen, highlightedIndex, inputValue, items], _extends({
3565
+ useA11yMessageSetter(getA11yStatusMessage, [isOpen, highlightedIndex, inputValue, items], {
3600
3566
  isInitialMount: isInitialMountRef.current,
3601
3567
  previousResultCount: previousResultCountRef.current,
3602
- items: items,
3603
- environment: environment,
3604
- itemToString: itemToString
3605
- }, state)); // Sets a11y status message on changes in selectedItem.
3568
+ items,
3569
+ environment,
3570
+ itemToString,
3571
+ ...state
3572
+ }); // Sets a11y status message on changes in selectedItem.
3606
3573
 
3607
- useA11yMessageSetter(getA11ySelectionMessage, [selectedItem], _extends({
3574
+ useA11yMessageSetter(getA11ySelectionMessage, [selectedItem], {
3608
3575
  isInitialMount: isInitialMountRef.current,
3609
3576
  previousResultCount: previousResultCountRef.current,
3610
- items: items,
3611
- environment: environment,
3612
- itemToString: itemToString
3613
- }, state)); // Scroll on highlighted item if change comes from keyboard.
3577
+ items,
3578
+ environment,
3579
+ itemToString,
3580
+ ...state
3581
+ }); // Scroll on highlighted item if change comes from keyboard.
3614
3582
 
3615
- var shouldScrollRef = useScrollIntoView({
3583
+ const shouldScrollRef = useScrollIntoView({
3616
3584
  menuElement: menuRef.current,
3617
- highlightedIndex: highlightedIndex,
3618
- isOpen: isOpen,
3619
- itemRefs: itemRefs,
3620
- scrollIntoView: scrollIntoView,
3621
- getItemNodeFromIndex: getItemNodeFromIndex
3585
+ highlightedIndex,
3586
+ isOpen,
3587
+ itemRefs,
3588
+ scrollIntoView,
3589
+ getItemNodeFromIndex
3622
3590
  });
3623
3591
  useControlPropsValidator({
3624
3592
  isInitialMount: isInitialMountRef.current,
3625
- props: props,
3626
- state: state
3593
+ props,
3594
+ state
3627
3595
  }); // Focus the input on first render if required.
3628
3596
 
3629
- preact.useEffect(function () {
3630
- var focusOnOpen = initialIsOpen || defaultIsOpen || isOpen;
3597
+ preact.useEffect(() => {
3598
+ const focusOnOpen = initialIsOpen || defaultIsOpen || isOpen;
3631
3599
 
3632
3600
  if (focusOnOpen && inputRef.current) {
3633
3601
  inputRef.current.focus();
3634
3602
  } // eslint-disable-next-line react-hooks/exhaustive-deps
3635
3603
 
3636
3604
  }, []);
3637
- preact.useEffect(function () {
3605
+ preact.useEffect(() => {
3638
3606
  if (isInitialMountRef.current) {
3639
3607
  return;
3640
3608
  }
@@ -3642,147 +3610,151 @@
3642
3610
  previousResultCountRef.current = items.length;
3643
3611
  }); // Add mouse/touch events to document.
3644
3612
 
3645
- var mouseAndTouchTrackersRef = useMouseAndTouchTracker(isOpen, [comboboxRef, menuRef, toggleButtonRef], environment, function () {
3613
+ const mouseAndTouchTrackersRef = useMouseAndTouchTracker(isOpen, [comboboxRef, menuRef, toggleButtonRef], environment, () => {
3646
3614
  dispatch({
3647
3615
  type: InputBlur,
3648
3616
  selectItem: false
3649
3617
  });
3650
3618
  });
3651
- var setGetterPropCallInfo = useGetterPropsCalledChecker('getInputProps', 'getComboboxProps', 'getMenuProps'); // Make initial ref false.
3619
+ const setGetterPropCallInfo = useGetterPropsCalledChecker('getInputProps', 'getComboboxProps', 'getMenuProps'); // Make initial ref false.
3652
3620
 
3653
- preact.useEffect(function () {
3621
+ preact.useEffect(() => {
3654
3622
  isInitialMountRef.current = false;
3655
3623
  }, []); // Reset itemRefs on close.
3656
3624
 
3657
- preact.useEffect(function () {
3625
+ preact.useEffect(() => {
3658
3626
  if (!isOpen) {
3659
3627
  itemRefs.current = {};
3660
3628
  }
3661
3629
  }, [isOpen]);
3662
3630
  /* Event handler functions */
3663
3631
 
3664
- var inputKeyDownHandlers = preact.useMemo(function () {
3665
- return {
3666
- ArrowDown: function ArrowDown(event) {
3667
- event.preventDefault();
3668
- dispatch({
3669
- type: InputKeyDownArrowDown,
3670
- shiftKey: event.shiftKey,
3671
- getItemNodeFromIndex: getItemNodeFromIndex
3672
- });
3673
- },
3674
- ArrowUp: function ArrowUp(event) {
3675
- event.preventDefault();
3676
- dispatch({
3677
- type: InputKeyDownArrowUp,
3678
- shiftKey: event.shiftKey,
3679
- getItemNodeFromIndex: getItemNodeFromIndex
3680
- });
3681
- },
3682
- Home: function Home(event) {
3683
- if (!latest.current.state.isOpen) {
3684
- return;
3685
- }
3632
+ const inputKeyDownHandlers = preact.useMemo(() => ({
3633
+ ArrowDown(event) {
3634
+ event.preventDefault();
3635
+ dispatch({
3636
+ type: InputKeyDownArrowDown,
3637
+ shiftKey: event.shiftKey,
3638
+ getItemNodeFromIndex
3639
+ });
3640
+ },
3686
3641
 
3687
- event.preventDefault();
3688
- dispatch({
3689
- type: InputKeyDownHome,
3690
- getItemNodeFromIndex: getItemNodeFromIndex
3691
- });
3692
- },
3693
- End: function End(event) {
3694
- if (!latest.current.state.isOpen) {
3695
- return;
3696
- }
3642
+ ArrowUp(event) {
3643
+ event.preventDefault();
3644
+ dispatch({
3645
+ type: InputKeyDownArrowUp,
3646
+ shiftKey: event.shiftKey,
3647
+ getItemNodeFromIndex
3648
+ });
3649
+ },
3697
3650
 
3698
- event.preventDefault();
3699
- dispatch({
3700
- type: InputKeyDownEnd,
3701
- getItemNodeFromIndex: getItemNodeFromIndex
3702
- });
3703
- },
3704
- Escape: function Escape() {
3705
- var latestState = latest.current.state;
3651
+ Home(event) {
3652
+ if (!latest.current.state.isOpen) {
3653
+ return;
3654
+ }
3706
3655
 
3707
- if (latestState.isOpen || latestState.inputValue || latestState.selectedItem || latestState.highlightedIndex > -1) {
3708
- dispatch({
3709
- type: InputKeyDownEscape
3710
- });
3711
- }
3712
- },
3713
- Enter: function Enter(event) {
3714
- var latestState = latest.current.state; // if closed or no highlighted index, do nothing.
3656
+ event.preventDefault();
3657
+ dispatch({
3658
+ type: InputKeyDownHome,
3659
+ getItemNodeFromIndex
3660
+ });
3661
+ },
3715
3662
 
3716
- if (!latestState.isOpen || latestState.highlightedIndex < 0 || event.which === 229 // if IME composing, wait for next Enter keydown event.
3717
- ) {
3718
- return;
3719
- }
3663
+ End(event) {
3664
+ if (!latest.current.state.isOpen) {
3665
+ return;
3666
+ }
3720
3667
 
3721
- event.preventDefault();
3668
+ event.preventDefault();
3669
+ dispatch({
3670
+ type: InputKeyDownEnd,
3671
+ getItemNodeFromIndex
3672
+ });
3673
+ },
3674
+
3675
+ Escape() {
3676
+ const latestState = latest.current.state;
3677
+
3678
+ if (latestState.isOpen || latestState.inputValue || latestState.selectedItem || latestState.highlightedIndex > -1) {
3722
3679
  dispatch({
3723
- type: InputKeyDownEnter,
3724
- getItemNodeFromIndex: getItemNodeFromIndex
3680
+ type: InputKeyDownEscape
3725
3681
  });
3726
3682
  }
3727
- };
3728
- }, [dispatch, latest, getItemNodeFromIndex]); // Getter props.
3729
-
3730
- var getLabelProps = preact.useCallback(function (labelProps) {
3731
- return _extends({
3732
- id: elementIds.labelId,
3733
- htmlFor: elementIds.inputId
3734
- }, labelProps);
3735
- }, [elementIds]);
3736
- var getMenuProps = preact.useCallback(function (_temp, _temp2) {
3737
- var _extends2;
3738
-
3739
- var _ref = _temp === void 0 ? {} : _temp,
3740
- onMouseLeave = _ref.onMouseLeave,
3741
- _ref$refKey = _ref.refKey,
3742
- refKey = _ref$refKey === void 0 ? 'ref' : _ref$refKey,
3743
- ref = _ref.ref,
3744
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$1);
3745
-
3746
- var _ref2 = _temp2 === void 0 ? {} : _temp2,
3747
- _ref2$suppressRefErro = _ref2.suppressRefError,
3748
- suppressRefError = _ref2$suppressRefErro === void 0 ? false : _ref2$suppressRefErro;
3683
+ },
3749
3684
 
3750
- setGetterPropCallInfo('getMenuProps', suppressRefError, refKey, menuRef);
3751
- return _extends((_extends2 = {}, _extends2[refKey] = handleRefs(ref, function (menuNode) {
3752
- menuRef.current = menuNode;
3753
- }), _extends2.id = elementIds.menuId, _extends2.role = 'listbox', _extends2['aria-labelledby'] = elementIds.labelId, _extends2.onMouseLeave = callAllEventHandlers(onMouseLeave, function () {
3685
+ Enter(event) {
3686
+ const latestState = latest.current.state; // if closed or no highlighted index, do nothing.
3687
+
3688
+ if (!latestState.isOpen || latestState.highlightedIndex < 0 || event.which === 229 // if IME composing, wait for next Enter keydown event.
3689
+ ) {
3690
+ return;
3691
+ }
3692
+
3693
+ event.preventDefault();
3754
3694
  dispatch({
3755
- type: MenuMouseLeave
3695
+ type: InputKeyDownEnter,
3696
+ getItemNodeFromIndex
3756
3697
  });
3757
- }), _extends2), rest);
3698
+ }
3699
+
3700
+ }), [dispatch, latest, getItemNodeFromIndex]); // Getter props.
3701
+
3702
+ const getLabelProps = preact.useCallback(labelProps => ({
3703
+ id: elementIds.labelId,
3704
+ htmlFor: elementIds.inputId,
3705
+ ...labelProps
3706
+ }), [elementIds]);
3707
+ const getMenuProps = preact.useCallback(function (_temp, _temp2) {
3708
+ let {
3709
+ onMouseLeave,
3710
+ refKey = 'ref',
3711
+ ref,
3712
+ ...rest
3713
+ } = _temp === void 0 ? {} : _temp;
3714
+ let {
3715
+ suppressRefError = false
3716
+ } = _temp2 === void 0 ? {} : _temp2;
3717
+ setGetterPropCallInfo('getMenuProps', suppressRefError, refKey, menuRef);
3718
+ return {
3719
+ [refKey]: handleRefs(ref, menuNode => {
3720
+ menuRef.current = menuNode;
3721
+ }),
3722
+ id: elementIds.menuId,
3723
+ role: 'listbox',
3724
+ 'aria-labelledby': elementIds.labelId,
3725
+ onMouseLeave: callAllEventHandlers(onMouseLeave, () => {
3726
+ dispatch({
3727
+ type: MenuMouseLeave
3728
+ });
3729
+ }),
3730
+ ...rest
3731
+ };
3758
3732
  }, [dispatch, setGetterPropCallInfo, elementIds]);
3759
- var getItemProps = preact.useCallback(function (_temp3) {
3760
- var _extends3, _ref4;
3761
-
3762
- var _ref3 = _temp3 === void 0 ? {} : _temp3,
3763
- item = _ref3.item,
3764
- index = _ref3.index,
3765
- _ref3$refKey = _ref3.refKey,
3766
- refKey = _ref3$refKey === void 0 ? 'ref' : _ref3$refKey,
3767
- ref = _ref3.ref,
3768
- onMouseMove = _ref3.onMouseMove,
3769
- onClick = _ref3.onClick;
3770
- _ref3.onPress;
3771
- var rest = _objectWithoutPropertiesLoose(_ref3, _excluded2$1);
3772
-
3773
- var _latest$current = latest.current,
3774
- latestProps = _latest$current.props,
3775
- latestState = _latest$current.state;
3776
- var itemIndex = getItemIndex(index, item, latestProps.items);
3733
+ const getItemProps = preact.useCallback(function (_temp3) {
3734
+ let {
3735
+ item,
3736
+ index,
3737
+ refKey = 'ref',
3738
+ ref,
3739
+ onMouseMove,
3740
+ onClick,
3741
+ onPress,
3742
+ ...rest
3743
+ } = _temp3 === void 0 ? {} : _temp3;
3744
+ const {
3745
+ props: latestProps,
3746
+ state: latestState
3747
+ } = latest.current;
3748
+ const itemIndex = getItemIndex(index, item, latestProps.items);
3777
3749
 
3778
3750
  if (itemIndex < 0) {
3779
3751
  throw new Error('Pass either item or item index in getItemProps!');
3780
3752
  }
3781
3753
 
3782
- var onSelectKey = 'onClick';
3783
- var customClickHandler = onClick;
3754
+ const onSelectKey = 'onClick';
3755
+ const customClickHandler = onClick;
3784
3756
 
3785
- var itemHandleMouseMove = function itemHandleMouseMove() {
3757
+ const itemHandleMouseMove = () => {
3786
3758
  if (index === latestState.highlightedIndex) {
3787
3759
  return;
3788
3760
  }
@@ -3790,14 +3762,14 @@
3790
3762
  shouldScrollRef.current = false;
3791
3763
  dispatch({
3792
3764
  type: ItemMouseMove,
3793
- index: index
3765
+ index
3794
3766
  });
3795
3767
  };
3796
3768
 
3797
- var itemHandleClick = function itemHandleClick() {
3769
+ const itemHandleClick = () => {
3798
3770
  dispatch({
3799
3771
  type: ItemClick,
3800
- index: index
3772
+ index
3801
3773
  });
3802
3774
 
3803
3775
  if (inputRef.current) {
@@ -3805,26 +3777,32 @@
3805
3777
  }
3806
3778
  };
3807
3779
 
3808
- return _extends((_extends3 = {}, _extends3[refKey] = handleRefs(ref, function (itemNode) {
3809
- if (itemNode) {
3810
- itemRefs.current[elementIds.getItemId(itemIndex)] = itemNode;
3811
- }
3812
- }), _extends3.role = 'option', _extends3['aria-selected'] = "" + (itemIndex === latestState.highlightedIndex), _extends3.id = elementIds.getItemId(itemIndex), _extends3), !rest.disabled && (_ref4 = {
3813
- onMouseMove: callAllEventHandlers(onMouseMove, itemHandleMouseMove)
3814
- }, _ref4[onSelectKey] = callAllEventHandlers(customClickHandler, itemHandleClick), _ref4), rest);
3780
+ return {
3781
+ [refKey]: handleRefs(ref, itemNode => {
3782
+ if (itemNode) {
3783
+ itemRefs.current[elementIds.getItemId(itemIndex)] = itemNode;
3784
+ }
3785
+ }),
3786
+ role: 'option',
3787
+ 'aria-selected': "" + (itemIndex === latestState.highlightedIndex),
3788
+ id: elementIds.getItemId(itemIndex),
3789
+ ...(!rest.disabled && {
3790
+ onMouseMove: callAllEventHandlers(onMouseMove, itemHandleMouseMove),
3791
+ [onSelectKey]: callAllEventHandlers(customClickHandler, itemHandleClick)
3792
+ }),
3793
+ ...rest
3794
+ };
3815
3795
  }, [dispatch, latest, shouldScrollRef, elementIds]);
3816
- var getToggleButtonProps = preact.useCallback(function (_temp4) {
3817
- var _extends4;
3818
-
3819
- var _ref5 = _temp4 === void 0 ? {} : _temp4,
3820
- onClick = _ref5.onClick;
3821
- _ref5.onPress;
3822
- var _ref5$refKey = _ref5.refKey,
3823
- refKey = _ref5$refKey === void 0 ? 'ref' : _ref5$refKey,
3824
- ref = _ref5.ref,
3825
- rest = _objectWithoutPropertiesLoose(_ref5, _excluded3);
3826
-
3827
- var toggleButtonHandleClick = function toggleButtonHandleClick() {
3796
+ const getToggleButtonProps = preact.useCallback(function (_temp4) {
3797
+ let {
3798
+ onClick,
3799
+ onPress,
3800
+ refKey = 'ref',
3801
+ ref,
3802
+ ...rest
3803
+ } = _temp4 === void 0 ? {} : _temp4;
3804
+
3805
+ const toggleButtonHandleClick = () => {
3828
3806
  dispatch({
3829
3807
  type: ToggleButtonClick
3830
3808
  });
@@ -3834,49 +3812,52 @@
3834
3812
  }
3835
3813
  };
3836
3814
 
3837
- return _extends((_extends4 = {}, _extends4[refKey] = handleRefs(ref, function (toggleButtonNode) {
3838
- toggleButtonRef.current = toggleButtonNode;
3839
- }), _extends4.id = elementIds.toggleButtonId, _extends4.tabIndex = -1, _extends4), !rest.disabled && _extends({}, {
3840
- onClick: callAllEventHandlers(onClick, toggleButtonHandleClick)
3841
- }), rest);
3815
+ return {
3816
+ [refKey]: handleRefs(ref, toggleButtonNode => {
3817
+ toggleButtonRef.current = toggleButtonNode;
3818
+ }),
3819
+ id: elementIds.toggleButtonId,
3820
+ tabIndex: -1,
3821
+ ...(!rest.disabled && { ...({
3822
+ onClick: callAllEventHandlers(onClick, toggleButtonHandleClick)
3823
+ })
3824
+ }),
3825
+ ...rest
3826
+ };
3842
3827
  }, [dispatch, latest, elementIds]);
3843
- var getInputProps = preact.useCallback(function (_temp5, _temp6) {
3844
- var _extends5;
3845
-
3846
- var _ref6 = _temp5 === void 0 ? {} : _temp5,
3847
- onKeyDown = _ref6.onKeyDown,
3848
- onChange = _ref6.onChange,
3849
- onInput = _ref6.onInput,
3850
- onBlur = _ref6.onBlur;
3851
- _ref6.onChangeText;
3852
- var _ref6$refKey = _ref6.refKey,
3853
- refKey = _ref6$refKey === void 0 ? 'ref' : _ref6$refKey,
3854
- ref = _ref6.ref,
3855
- rest = _objectWithoutPropertiesLoose(_ref6, _excluded4);
3856
-
3857
- var _ref7 = _temp6 === void 0 ? {} : _temp6,
3858
- _ref7$suppressRefErro = _ref7.suppressRefError,
3859
- suppressRefError = _ref7$suppressRefErro === void 0 ? false : _ref7$suppressRefErro;
3860
-
3828
+ const getInputProps = preact.useCallback(function (_temp5, _temp6) {
3829
+ let {
3830
+ onKeyDown,
3831
+ onChange,
3832
+ onInput,
3833
+ onBlur,
3834
+ onChangeText,
3835
+ refKey = 'ref',
3836
+ ref,
3837
+ ...rest
3838
+ } = _temp5 === void 0 ? {} : _temp5;
3839
+ let {
3840
+ suppressRefError = false
3841
+ } = _temp6 === void 0 ? {} : _temp6;
3861
3842
  setGetterPropCallInfo('getInputProps', suppressRefError, refKey, inputRef);
3862
- var latestState = latest.current.state;
3843
+ const latestState = latest.current.state;
3863
3844
 
3864
- var inputHandleKeyDown = function inputHandleKeyDown(event) {
3865
- var key = normalizeArrowKey(event);
3845
+ const inputHandleKeyDown = event => {
3846
+ const key = normalizeArrowKey(event);
3866
3847
 
3867
3848
  if (key && inputKeyDownHandlers[key]) {
3868
3849
  inputKeyDownHandlers[key](event);
3869
3850
  }
3870
3851
  };
3871
3852
 
3872
- var inputHandleChange = function inputHandleChange(event) {
3853
+ const inputHandleChange = event => {
3873
3854
  dispatch({
3874
3855
  type: InputChange,
3875
3856
  inputValue: event.target.value
3876
3857
  });
3877
3858
  };
3878
3859
 
3879
- var inputHandleBlur = function inputHandleBlur() {
3860
+ const inputHandleBlur = () => {
3880
3861
  /* istanbul ignore else */
3881
3862
  if (latestState.isOpen && !mouseAndTouchTrackersRef.current.isMouseDown) {
3882
3863
  dispatch({
@@ -3888,109 +3869,121 @@
3888
3869
  /* istanbul ignore next (preact) */
3889
3870
 
3890
3871
 
3891
- var onChangeKey = 'onInput' ;
3892
- var eventHandlers = {};
3872
+ const onChangeKey = 'onInput' ;
3873
+ let eventHandlers = {};
3893
3874
 
3894
3875
  if (!rest.disabled) {
3895
- var _eventHandlers;
3896
-
3897
- eventHandlers = (_eventHandlers = {}, _eventHandlers[onChangeKey] = callAllEventHandlers(onChange, onInput, inputHandleChange), _eventHandlers.onKeyDown = callAllEventHandlers(onKeyDown, inputHandleKeyDown), _eventHandlers.onBlur = callAllEventHandlers(onBlur, inputHandleBlur), _eventHandlers);
3876
+ eventHandlers = {
3877
+ [onChangeKey]: callAllEventHandlers(onChange, onInput, inputHandleChange),
3878
+ onKeyDown: callAllEventHandlers(onKeyDown, inputHandleKeyDown),
3879
+ onBlur: callAllEventHandlers(onBlur, inputHandleBlur)
3880
+ };
3898
3881
  }
3899
3882
 
3900
- return _extends((_extends5 = {}, _extends5[refKey] = handleRefs(ref, function (inputNode) {
3901
- inputRef.current = inputNode;
3902
- }), _extends5.id = elementIds.inputId, _extends5['aria-autocomplete'] = 'list', _extends5['aria-controls'] = elementIds.menuId, _extends5), latestState.isOpen && latestState.highlightedIndex > -1 && {
3903
- 'aria-activedescendant': elementIds.getItemId(latestState.highlightedIndex)
3904
- }, {
3883
+ return {
3884
+ [refKey]: handleRefs(ref, inputNode => {
3885
+ inputRef.current = inputNode;
3886
+ }),
3887
+ id: elementIds.inputId,
3888
+ 'aria-autocomplete': 'list',
3889
+ 'aria-controls': elementIds.menuId,
3890
+ ...(latestState.isOpen && latestState.highlightedIndex > -1 && {
3891
+ 'aria-activedescendant': elementIds.getItemId(latestState.highlightedIndex)
3892
+ }),
3905
3893
  'aria-labelledby': elementIds.labelId,
3906
3894
  // https://developer.mozilla.org/en-US/docs/Web/Security/Securing_your_site/Turning_off_form_autocompletion
3907
3895
  // revert back since autocomplete="nope" is ignored on latest Chrome and Opera
3908
3896
  autoComplete: 'off',
3909
- value: latestState.inputValue
3910
- }, eventHandlers, rest);
3897
+ value: latestState.inputValue,
3898
+ ...eventHandlers,
3899
+ ...rest
3900
+ };
3911
3901
  }, [dispatch, inputKeyDownHandlers, latest, mouseAndTouchTrackersRef, setGetterPropCallInfo, elementIds]);
3912
- var getComboboxProps = preact.useCallback(function (_temp7, _temp8) {
3913
- var _extends6;
3914
-
3915
- var _ref8 = _temp7 === void 0 ? {} : _temp7,
3916
- _ref8$refKey = _ref8.refKey,
3917
- refKey = _ref8$refKey === void 0 ? 'ref' : _ref8$refKey,
3918
- ref = _ref8.ref,
3919
- rest = _objectWithoutPropertiesLoose(_ref8, _excluded5);
3920
-
3921
- var _ref9 = _temp8 === void 0 ? {} : _temp8,
3922
- _ref9$suppressRefErro = _ref9.suppressRefError,
3923
- suppressRefError = _ref9$suppressRefErro === void 0 ? false : _ref9$suppressRefErro;
3924
-
3902
+ const getComboboxProps = preact.useCallback(function (_temp7, _temp8) {
3903
+ let {
3904
+ refKey = 'ref',
3905
+ ref,
3906
+ ...rest
3907
+ } = _temp7 === void 0 ? {} : _temp7;
3908
+ let {
3909
+ suppressRefError = false
3910
+ } = _temp8 === void 0 ? {} : _temp8;
3925
3911
  setGetterPropCallInfo('getComboboxProps', suppressRefError, refKey, comboboxRef);
3926
- return _extends((_extends6 = {}, _extends6[refKey] = handleRefs(ref, function (comboboxNode) {
3927
- comboboxRef.current = comboboxNode;
3928
- }), _extends6.role = 'combobox', _extends6['aria-haspopup'] = 'listbox', _extends6['aria-owns'] = elementIds.menuId, _extends6['aria-expanded'] = latest.current.state.isOpen, _extends6), rest);
3912
+ return {
3913
+ [refKey]: handleRefs(ref, comboboxNode => {
3914
+ comboboxRef.current = comboboxNode;
3915
+ }),
3916
+ role: 'combobox',
3917
+ 'aria-haspopup': 'listbox',
3918
+ 'aria-owns': elementIds.menuId,
3919
+ 'aria-expanded': latest.current.state.isOpen,
3920
+ ...rest
3921
+ };
3929
3922
  }, [latest, setGetterPropCallInfo, elementIds]); // returns
3930
3923
 
3931
- var toggleMenu = preact.useCallback(function () {
3924
+ const toggleMenu = preact.useCallback(() => {
3932
3925
  dispatch({
3933
3926
  type: FunctionToggleMenu
3934
3927
  });
3935
3928
  }, [dispatch]);
3936
- var closeMenu = preact.useCallback(function () {
3929
+ const closeMenu = preact.useCallback(() => {
3937
3930
  dispatch({
3938
3931
  type: FunctionCloseMenu
3939
3932
  });
3940
3933
  }, [dispatch]);
3941
- var openMenu = preact.useCallback(function () {
3934
+ const openMenu = preact.useCallback(() => {
3942
3935
  dispatch({
3943
3936
  type: FunctionOpenMenu
3944
3937
  });
3945
3938
  }, [dispatch]);
3946
- var setHighlightedIndex = preact.useCallback(function (newHighlightedIndex) {
3939
+ const setHighlightedIndex = preact.useCallback(newHighlightedIndex => {
3947
3940
  dispatch({
3948
3941
  type: FunctionSetHighlightedIndex,
3949
3942
  highlightedIndex: newHighlightedIndex
3950
3943
  });
3951
3944
  }, [dispatch]);
3952
- var selectItem = preact.useCallback(function (newSelectedItem) {
3945
+ const selectItem = preact.useCallback(newSelectedItem => {
3953
3946
  dispatch({
3954
3947
  type: FunctionSelectItem,
3955
3948
  selectedItem: newSelectedItem
3956
3949
  });
3957
3950
  }, [dispatch]);
3958
- var setInputValue = preact.useCallback(function (newInputValue) {
3951
+ const setInputValue = preact.useCallback(newInputValue => {
3959
3952
  dispatch({
3960
3953
  type: FunctionSetInputValue,
3961
3954
  inputValue: newInputValue
3962
3955
  });
3963
3956
  }, [dispatch]);
3964
- var reset = preact.useCallback(function () {
3957
+ const reset = preact.useCallback(() => {
3965
3958
  dispatch({
3966
3959
  type: FunctionReset$1
3967
3960
  });
3968
3961
  }, [dispatch]);
3969
3962
  return {
3970
3963
  // prop getters.
3971
- getItemProps: getItemProps,
3972
- getLabelProps: getLabelProps,
3973
- getMenuProps: getMenuProps,
3974
- getInputProps: getInputProps,
3975
- getComboboxProps: getComboboxProps,
3976
- getToggleButtonProps: getToggleButtonProps,
3964
+ getItemProps,
3965
+ getLabelProps,
3966
+ getMenuProps,
3967
+ getInputProps,
3968
+ getComboboxProps,
3969
+ getToggleButtonProps,
3977
3970
  // actions.
3978
- toggleMenu: toggleMenu,
3979
- openMenu: openMenu,
3980
- closeMenu: closeMenu,
3981
- setHighlightedIndex: setHighlightedIndex,
3982
- setInputValue: setInputValue,
3983
- selectItem: selectItem,
3984
- reset: reset,
3971
+ toggleMenu,
3972
+ openMenu,
3973
+ closeMenu,
3974
+ setHighlightedIndex,
3975
+ setInputValue,
3976
+ selectItem,
3977
+ reset,
3985
3978
  // state.
3986
- highlightedIndex: highlightedIndex,
3987
- isOpen: isOpen,
3988
- selectedItem: selectedItem,
3989
- inputValue: inputValue
3979
+ highlightedIndex,
3980
+ isOpen,
3981
+ selectedItem,
3982
+ inputValue
3990
3983
  };
3991
3984
  }
3992
3985
 
3993
- var defaultStateValues = {
3986
+ const defaultStateValues = {
3994
3987
  activeIndex: -1,
3995
3988
  selectedItems: []
3996
3989
  };
@@ -4030,11 +4023,11 @@
4030
4023
 
4031
4024
 
4032
4025
  function getInitialState(props) {
4033
- var activeIndex = getInitialValue(props, 'activeIndex');
4034
- var selectedItems = getInitialValue(props, 'selectedItems');
4026
+ const activeIndex = getInitialValue(props, 'activeIndex');
4027
+ const selectedItems = getInitialValue(props, 'selectedItems');
4035
4028
  return {
4036
- activeIndex: activeIndex,
4037
- selectedItems: selectedItems
4029
+ activeIndex,
4030
+ selectedItems
4038
4031
  };
4039
4032
  }
4040
4033
  /**
@@ -4053,10 +4046,12 @@
4053
4046
  return false;
4054
4047
  }
4055
4048
 
4056
- var element = event.target;
4049
+ const element = event.target;
4057
4050
 
4058
4051
  if (element instanceof HTMLInputElement && // if element is a text input
4059
- element.value !== '' && (element.selectionStart !== 0 || element.selectionEnd !== 0)) {
4052
+ element.value !== '' && ( // and we have text in it
4053
+ // and cursor is either not at the start or is currently highlighting text.
4054
+ element.selectionStart !== 0 || element.selectionEnd !== 0)) {
4060
4055
  return false;
4061
4056
  }
4062
4057
 
@@ -4071,66 +4066,68 @@
4071
4066
 
4072
4067
 
4073
4068
  function getA11yRemovalMessage(selectionParameters) {
4074
- var removedSelectedItem = selectionParameters.removedSelectedItem,
4075
- itemToStringLocal = selectionParameters.itemToString;
4069
+ const {
4070
+ removedSelectedItem,
4071
+ itemToString: itemToStringLocal
4072
+ } = selectionParameters;
4076
4073
  return itemToStringLocal(removedSelectedItem) + " has been removed.";
4077
4074
  }
4078
4075
 
4079
- var propTypes = {
4080
- selectedItems: PropTypes__default['default'].array,
4081
- initialSelectedItems: PropTypes__default['default'].array,
4082
- defaultSelectedItems: PropTypes__default['default'].array,
4083
- itemToString: PropTypes__default['default'].func,
4084
- getA11yRemovalMessage: PropTypes__default['default'].func,
4085
- stateReducer: PropTypes__default['default'].func,
4086
- activeIndex: PropTypes__default['default'].number,
4087
- initialActiveIndex: PropTypes__default['default'].number,
4088
- defaultActiveIndex: PropTypes__default['default'].number,
4089
- onActiveIndexChange: PropTypes__default['default'].func,
4090
- onSelectedItemsChange: PropTypes__default['default'].func,
4091
- keyNavigationNext: PropTypes__default['default'].string,
4092
- keyNavigationPrevious: PropTypes__default['default'].string,
4093
- environment: PropTypes__default['default'].shape({
4094
- addEventListener: PropTypes__default['default'].func,
4095
- removeEventListener: PropTypes__default['default'].func,
4096
- document: PropTypes__default['default'].shape({
4097
- getElementById: PropTypes__default['default'].func,
4098
- activeElement: PropTypes__default['default'].any,
4099
- body: PropTypes__default['default'].any
4076
+ const propTypes = {
4077
+ selectedItems: PropTypes__default["default"].array,
4078
+ initialSelectedItems: PropTypes__default["default"].array,
4079
+ defaultSelectedItems: PropTypes__default["default"].array,
4080
+ itemToString: PropTypes__default["default"].func,
4081
+ getA11yRemovalMessage: PropTypes__default["default"].func,
4082
+ stateReducer: PropTypes__default["default"].func,
4083
+ activeIndex: PropTypes__default["default"].number,
4084
+ initialActiveIndex: PropTypes__default["default"].number,
4085
+ defaultActiveIndex: PropTypes__default["default"].number,
4086
+ onActiveIndexChange: PropTypes__default["default"].func,
4087
+ onSelectedItemsChange: PropTypes__default["default"].func,
4088
+ keyNavigationNext: PropTypes__default["default"].string,
4089
+ keyNavigationPrevious: PropTypes__default["default"].string,
4090
+ environment: PropTypes__default["default"].shape({
4091
+ addEventListener: PropTypes__default["default"].func,
4092
+ removeEventListener: PropTypes__default["default"].func,
4093
+ document: PropTypes__default["default"].shape({
4094
+ getElementById: PropTypes__default["default"].func,
4095
+ activeElement: PropTypes__default["default"].any,
4096
+ body: PropTypes__default["default"].any
4100
4097
  })
4101
4098
  })
4102
4099
  };
4103
- var defaultProps = {
4100
+ const defaultProps = {
4104
4101
  itemToString: defaultProps$3.itemToString,
4105
4102
  stateReducer: defaultProps$3.stateReducer,
4106
4103
  environment: defaultProps$3.environment,
4107
- getA11yRemovalMessage: getA11yRemovalMessage,
4104
+ getA11yRemovalMessage,
4108
4105
  keyNavigationNext: 'ArrowRight',
4109
4106
  keyNavigationPrevious: 'ArrowLeft'
4110
4107
  }; // eslint-disable-next-line import/no-mutable-exports
4111
4108
 
4112
- var validatePropTypes = noop;
4109
+ let validatePropTypes = noop;
4113
4110
  /* istanbul ignore next */
4114
4111
 
4115
4112
  {
4116
- validatePropTypes = function validatePropTypes(options, caller) {
4117
- PropTypes__default['default'].checkPropTypes(propTypes, options, 'prop', caller.name);
4113
+ validatePropTypes = (options, caller) => {
4114
+ PropTypes__default["default"].checkPropTypes(propTypes, options, 'prop', caller.name);
4118
4115
  };
4119
4116
  }
4120
4117
 
4121
- var SelectedItemClick = '__selected_item_click__' ;
4122
- var SelectedItemKeyDownDelete = '__selected_item_keydown_delete__' ;
4123
- var SelectedItemKeyDownBackspace = '__selected_item_keydown_backspace__' ;
4124
- var SelectedItemKeyDownNavigationNext = '__selected_item_keydown_navigation_next__' ;
4125
- var SelectedItemKeyDownNavigationPrevious = '__selected_item_keydown_navigation_previous__' ;
4126
- var DropdownKeyDownNavigationPrevious = '__dropdown_keydown_navigation_previous__' ;
4127
- var DropdownKeyDownBackspace = '__dropdown_keydown_backspace__' ;
4128
- var DropdownClick = '__dropdown_click__' ;
4129
- var FunctionAddSelectedItem = '__function_add_selected_item__' ;
4130
- var FunctionRemoveSelectedItem = '__function_remove_selected_item__' ;
4131
- var FunctionSetSelectedItems = '__function_set_selected_items__' ;
4132
- var FunctionSetActiveIndex = '__function_set_active_index__' ;
4133
- var FunctionReset = '__function_reset__' ;
4118
+ const SelectedItemClick = '__selected_item_click__' ;
4119
+ const SelectedItemKeyDownDelete = '__selected_item_keydown_delete__' ;
4120
+ const SelectedItemKeyDownBackspace = '__selected_item_keydown_backspace__' ;
4121
+ const SelectedItemKeyDownNavigationNext = '__selected_item_keydown_navigation_next__' ;
4122
+ const SelectedItemKeyDownNavigationPrevious = '__selected_item_keydown_navigation_previous__' ;
4123
+ const DropdownKeyDownNavigationPrevious = '__dropdown_keydown_navigation_previous__' ;
4124
+ const DropdownKeyDownBackspace = '__dropdown_keydown_backspace__' ;
4125
+ const DropdownClick = '__dropdown_click__' ;
4126
+ const FunctionAddSelectedItem = '__function_add_selected_item__' ;
4127
+ const FunctionRemoveSelectedItem = '__function_remove_selected_item__' ;
4128
+ const FunctionSetSelectedItems = '__function_set_selected_items__' ;
4129
+ const FunctionSetActiveIndex = '__function_set_active_index__' ;
4130
+ const FunctionReset = '__function_reset__' ;
4134
4131
 
4135
4132
  var stateChangeTypes = /*#__PURE__*/Object.freeze({
4136
4133
  __proto__: null,
@@ -4152,13 +4149,17 @@
4152
4149
  /* eslint-disable complexity */
4153
4150
 
4154
4151
  function downshiftMultipleSelectionReducer(state, action) {
4155
- var type = action.type,
4156
- index = action.index,
4157
- props = action.props,
4158
- selectedItem = action.selectedItem;
4159
- var activeIndex = state.activeIndex,
4160
- selectedItems = state.selectedItems;
4161
- var changes;
4152
+ const {
4153
+ type,
4154
+ index,
4155
+ props,
4156
+ selectedItem
4157
+ } = action;
4158
+ const {
4159
+ activeIndex,
4160
+ selectedItems
4161
+ } = state;
4162
+ let changes;
4162
4163
 
4163
4164
  switch (type) {
4164
4165
  case SelectedItemClick:
@@ -4182,7 +4183,7 @@
4182
4183
  case SelectedItemKeyDownBackspace:
4183
4184
  case SelectedItemKeyDownDelete:
4184
4185
  {
4185
- var newActiveIndex = activeIndex;
4186
+ let newActiveIndex = activeIndex;
4186
4187
 
4187
4188
  if (selectedItems.length === 1) {
4188
4189
  newActiveIndex = -1;
@@ -4190,11 +4191,12 @@
4190
4191
  newActiveIndex = selectedItems.length - 2;
4191
4192
  }
4192
4193
 
4193
- changes = _extends({
4194
- selectedItems: [].concat(selectedItems.slice(0, activeIndex), selectedItems.slice(activeIndex + 1))
4195
- }, {
4196
- activeIndex: newActiveIndex
4197
- });
4194
+ changes = {
4195
+ selectedItems: [...selectedItems.slice(0, activeIndex), ...selectedItems.slice(activeIndex + 1)],
4196
+ ...{
4197
+ activeIndex: newActiveIndex
4198
+ }
4199
+ };
4198
4200
  break;
4199
4201
  }
4200
4202
 
@@ -4212,7 +4214,7 @@
4212
4214
 
4213
4215
  case FunctionAddSelectedItem:
4214
4216
  changes = {
4215
- selectedItems: [].concat(selectedItems, [selectedItem])
4217
+ selectedItems: [...selectedItems, selectedItem]
4216
4218
  };
4217
4219
  break;
4218
4220
 
@@ -4224,26 +4226,30 @@
4224
4226
 
4225
4227
  case FunctionRemoveSelectedItem:
4226
4228
  {
4227
- var _newActiveIndex = activeIndex;
4228
- var selectedItemIndex = selectedItems.indexOf(selectedItem);
4229
+ let newActiveIndex = activeIndex;
4230
+ const selectedItemIndex = selectedItems.indexOf(selectedItem);
4231
+
4232
+ if (selectedItemIndex >= 0) {
4233
+ if (selectedItems.length === 1) {
4234
+ newActiveIndex = -1;
4235
+ } else if (selectedItemIndex === selectedItems.length - 1) {
4236
+ newActiveIndex = selectedItems.length - 2;
4237
+ }
4229
4238
 
4230
- if (selectedItems.length === 1) {
4231
- _newActiveIndex = -1;
4232
- } else if (selectedItemIndex === selectedItems.length - 1) {
4233
- _newActiveIndex = selectedItems.length - 2;
4239
+ changes = {
4240
+ selectedItems: [...selectedItems.slice(0, selectedItemIndex), ...selectedItems.slice(selectedItemIndex + 1)],
4241
+ activeIndex: newActiveIndex
4242
+ };
4234
4243
  }
4235
4244
 
4236
- changes = _extends({
4237
- selectedItems: [].concat(selectedItems.slice(0, selectedItemIndex), selectedItems.slice(selectedItemIndex + 1))
4238
- }, {
4239
- activeIndex: _newActiveIndex
4240
- });
4241
4245
  break;
4242
4246
  }
4243
4247
 
4244
4248
  case FunctionSetSelectedItems:
4245
4249
  {
4246
- var newSelectedItems = action.selectedItems;
4250
+ const {
4251
+ selectedItems: newSelectedItems
4252
+ } = action;
4247
4253
  changes = {
4248
4254
  selectedItems: newSelectedItems
4249
4255
  };
@@ -4252,9 +4258,11 @@
4252
4258
 
4253
4259
  case FunctionSetActiveIndex:
4254
4260
  {
4255
- var _newActiveIndex2 = action.activeIndex;
4261
+ const {
4262
+ activeIndex: newActiveIndex
4263
+ } = action;
4256
4264
  changes = {
4257
- activeIndex: _newActiveIndex2
4265
+ activeIndex: newActiveIndex
4258
4266
  };
4259
4267
  break;
4260
4268
  }
@@ -4270,11 +4278,11 @@
4270
4278
  throw new Error('Reducer called without proper action type.');
4271
4279
  }
4272
4280
 
4273
- return _extends({}, state, changes);
4281
+ return { ...state,
4282
+ ...changes
4283
+ };
4274
4284
  }
4275
4285
 
4276
- var _excluded = ["refKey", "ref", "onClick", "onKeyDown", "selectedItem", "index"],
4277
- _excluded2 = ["refKey", "ref", "onKeyDown", "onClick", "preventKeyAction"];
4278
4286
  useMultipleSelection.stateChangeTypes = stateChangeTypes;
4279
4287
 
4280
4288
  function useMultipleSelection(userProps) {
@@ -4284,47 +4292,47 @@
4284
4292
 
4285
4293
  validatePropTypes(userProps, useMultipleSelection); // Props defaults and destructuring.
4286
4294
 
4287
- var props = _extends({}, defaultProps, userProps);
4288
-
4289
- var getA11yRemovalMessage = props.getA11yRemovalMessage,
4290
- itemToString = props.itemToString,
4291
- environment = props.environment,
4292
- keyNavigationNext = props.keyNavigationNext,
4293
- keyNavigationPrevious = props.keyNavigationPrevious; // Reducer init.
4294
-
4295
- var _useControlledReducer = useControlledReducer$1(downshiftMultipleSelectionReducer, getInitialState(props), props),
4296
- state = _useControlledReducer[0],
4297
- dispatch = _useControlledReducer[1];
4298
-
4299
- var activeIndex = state.activeIndex,
4300
- selectedItems = state.selectedItems; // Refs.
4301
-
4302
- var isInitialMountRef = preact.useRef(true);
4303
- var dropdownRef = preact.useRef(null);
4304
- var previousSelectedItemsRef = preact.useRef(selectedItems);
4305
- var selectedItemRefs = preact.useRef();
4295
+ const props = { ...defaultProps,
4296
+ ...userProps
4297
+ };
4298
+ const {
4299
+ getA11yRemovalMessage,
4300
+ itemToString,
4301
+ environment,
4302
+ keyNavigationNext,
4303
+ keyNavigationPrevious
4304
+ } = props; // Reducer init.
4305
+
4306
+ const [state, dispatch] = useControlledReducer$1(downshiftMultipleSelectionReducer, getInitialState(props), props);
4307
+ const {
4308
+ activeIndex,
4309
+ selectedItems
4310
+ } = state; // Refs.
4311
+
4312
+ const isInitialMountRef = preact.useRef(true);
4313
+ const dropdownRef = preact.useRef(null);
4314
+ const previousSelectedItemsRef = preact.useRef(selectedItems);
4315
+ const selectedItemRefs = preact.useRef();
4306
4316
  selectedItemRefs.current = [];
4307
- var latest = useLatestRef({
4308
- state: state,
4309
- props: props
4317
+ const latest = useLatestRef({
4318
+ state,
4319
+ props
4310
4320
  }); // Effects.
4311
4321
 
4312
4322
  /* Sets a11y status message on changes in selectedItem. */
4313
4323
 
4314
- preact.useEffect(function () {
4324
+ preact.useEffect(() => {
4315
4325
  if (isInitialMountRef.current) {
4316
4326
  return;
4317
4327
  }
4318
4328
 
4319
4329
  if (selectedItems.length < previousSelectedItemsRef.current.length) {
4320
- var removedSelectedItem = previousSelectedItemsRef.current.find(function (item) {
4321
- return selectedItems.indexOf(item) < 0;
4322
- });
4330
+ const removedSelectedItem = previousSelectedItemsRef.current.find(item => selectedItems.indexOf(item) < 0);
4323
4331
  setStatus(getA11yRemovalMessage({
4324
- itemToString: itemToString,
4332
+ itemToString,
4325
4333
  resultCount: selectedItems.length,
4326
- removedSelectedItem: removedSelectedItem,
4327
- activeIndex: activeIndex,
4334
+ removedSelectedItem,
4335
+ activeIndex,
4328
4336
  activeSelectedItem: selectedItems[activeIndex]
4329
4337
  }), environment.document);
4330
4338
  }
@@ -4332,7 +4340,7 @@
4332
4340
  previousSelectedItemsRef.current = selectedItems; // eslint-disable-next-line react-hooks/exhaustive-deps
4333
4341
  }, [selectedItems.length]); // Sets focus on active item.
4334
4342
 
4335
- preact.useEffect(function () {
4343
+ preact.useEffect(() => {
4336
4344
  if (isInitialMountRef.current) {
4337
4345
  return;
4338
4346
  }
@@ -4345,181 +4353,191 @@
4345
4353
  }, [activeIndex]);
4346
4354
  useControlPropsValidator({
4347
4355
  isInitialMount: isInitialMountRef.current,
4348
- props: props,
4349
- state: state
4356
+ props,
4357
+ state
4350
4358
  });
4351
- var setGetterPropCallInfo = useGetterPropsCalledChecker('getDropdownProps'); // Make initial ref false.
4359
+ const setGetterPropCallInfo = useGetterPropsCalledChecker('getDropdownProps'); // Make initial ref false.
4352
4360
 
4353
- preact.useEffect(function () {
4361
+ preact.useEffect(() => {
4354
4362
  isInitialMountRef.current = false;
4355
4363
  }, []); // Event handler functions.
4356
4364
 
4357
- var selectedItemKeyDownHandlers = preact.useMemo(function () {
4358
- var _ref;
4359
-
4360
- return _ref = {}, _ref[keyNavigationPrevious] = function () {
4365
+ const selectedItemKeyDownHandlers = preact.useMemo(() => ({
4366
+ [keyNavigationPrevious]() {
4361
4367
  dispatch({
4362
4368
  type: SelectedItemKeyDownNavigationPrevious
4363
4369
  });
4364
- }, _ref[keyNavigationNext] = function () {
4370
+ },
4371
+
4372
+ [keyNavigationNext]() {
4365
4373
  dispatch({
4366
4374
  type: SelectedItemKeyDownNavigationNext
4367
4375
  });
4368
- }, _ref.Delete = function Delete() {
4376
+ },
4377
+
4378
+ Delete() {
4369
4379
  dispatch({
4370
4380
  type: SelectedItemKeyDownDelete
4371
4381
  });
4372
- }, _ref.Backspace = function Backspace() {
4382
+ },
4383
+
4384
+ Backspace() {
4373
4385
  dispatch({
4374
4386
  type: SelectedItemKeyDownBackspace
4375
4387
  });
4376
- }, _ref;
4377
- }, [dispatch, keyNavigationNext, keyNavigationPrevious]);
4378
- var dropdownKeyDownHandlers = preact.useMemo(function () {
4379
- var _ref2;
4388
+ }
4380
4389
 
4381
- return _ref2 = {}, _ref2[keyNavigationPrevious] = function (event) {
4390
+ }), [dispatch, keyNavigationNext, keyNavigationPrevious]);
4391
+ const dropdownKeyDownHandlers = preact.useMemo(() => ({
4392
+ [keyNavigationPrevious](event) {
4382
4393
  if (isKeyDownOperationPermitted(event)) {
4383
4394
  dispatch({
4384
4395
  type: DropdownKeyDownNavigationPrevious
4385
4396
  });
4386
4397
  }
4387
- }, _ref2.Backspace = function Backspace(event) {
4398
+ },
4399
+
4400
+ Backspace(event) {
4388
4401
  if (isKeyDownOperationPermitted(event)) {
4389
4402
  dispatch({
4390
4403
  type: DropdownKeyDownBackspace
4391
4404
  });
4392
4405
  }
4393
- }, _ref2;
4394
- }, [dispatch, keyNavigationPrevious]); // Getter props.
4395
-
4396
- var getSelectedItemProps = preact.useCallback(function (_temp) {
4397
- var _extends2;
4398
-
4399
- var _ref3 = _temp === void 0 ? {} : _temp,
4400
- _ref3$refKey = _ref3.refKey,
4401
- refKey = _ref3$refKey === void 0 ? 'ref' : _ref3$refKey,
4402
- ref = _ref3.ref,
4403
- onClick = _ref3.onClick,
4404
- onKeyDown = _ref3.onKeyDown,
4405
- selectedItem = _ref3.selectedItem,
4406
- index = _ref3.index,
4407
- rest = _objectWithoutPropertiesLoose(_ref3, _excluded);
4406
+ }
4408
4407
 
4409
- var latestState = latest.current.state;
4410
- var itemIndex = getItemIndex(index, selectedItem, latestState.selectedItems);
4408
+ }), [dispatch, keyNavigationPrevious]); // Getter props.
4409
+
4410
+ const getSelectedItemProps = preact.useCallback(function (_temp) {
4411
+ let {
4412
+ refKey = 'ref',
4413
+ ref,
4414
+ onClick,
4415
+ onKeyDown,
4416
+ selectedItem,
4417
+ index,
4418
+ ...rest
4419
+ } = _temp === void 0 ? {} : _temp;
4420
+ const {
4421
+ state: latestState
4422
+ } = latest.current;
4423
+ const itemIndex = getItemIndex(index, selectedItem, latestState.selectedItems);
4411
4424
 
4412
4425
  if (itemIndex < 0) {
4413
4426
  throw new Error('Pass either selectedItem or index in getSelectedItemProps!');
4414
4427
  }
4415
4428
 
4416
- var selectedItemHandleClick = function selectedItemHandleClick() {
4429
+ const selectedItemHandleClick = () => {
4417
4430
  dispatch({
4418
4431
  type: SelectedItemClick,
4419
- index: index
4432
+ index
4420
4433
  });
4421
4434
  };
4422
4435
 
4423
- var selectedItemHandleKeyDown = function selectedItemHandleKeyDown(event) {
4424
- var key = normalizeArrowKey(event);
4436
+ const selectedItemHandleKeyDown = event => {
4437
+ const key = normalizeArrowKey(event);
4425
4438
 
4426
4439
  if (key && selectedItemKeyDownHandlers[key]) {
4427
4440
  selectedItemKeyDownHandlers[key](event);
4428
4441
  }
4429
4442
  };
4430
4443
 
4431
- return _extends((_extends2 = {}, _extends2[refKey] = handleRefs(ref, function (selectedItemNode) {
4432
- if (selectedItemNode) {
4433
- selectedItemRefs.current.push(selectedItemNode);
4434
- }
4435
- }), _extends2.tabIndex = index === latestState.activeIndex ? 0 : -1, _extends2.onClick = callAllEventHandlers(onClick, selectedItemHandleClick), _extends2.onKeyDown = callAllEventHandlers(onKeyDown, selectedItemHandleKeyDown), _extends2), rest);
4444
+ return {
4445
+ [refKey]: handleRefs(ref, selectedItemNode => {
4446
+ if (selectedItemNode) {
4447
+ selectedItemRefs.current.push(selectedItemNode);
4448
+ }
4449
+ }),
4450
+ tabIndex: index === latestState.activeIndex ? 0 : -1,
4451
+ onClick: callAllEventHandlers(onClick, selectedItemHandleClick),
4452
+ onKeyDown: callAllEventHandlers(onKeyDown, selectedItemHandleKeyDown),
4453
+ ...rest
4454
+ };
4436
4455
  }, [dispatch, latest, selectedItemKeyDownHandlers]);
4437
- var getDropdownProps = preact.useCallback(function (_temp2, _temp3) {
4438
- var _extends3;
4439
-
4440
- var _ref4 = _temp2 === void 0 ? {} : _temp2,
4441
- _ref4$refKey = _ref4.refKey,
4442
- refKey = _ref4$refKey === void 0 ? 'ref' : _ref4$refKey,
4443
- ref = _ref4.ref,
4444
- onKeyDown = _ref4.onKeyDown,
4445
- onClick = _ref4.onClick,
4446
- _ref4$preventKeyActio = _ref4.preventKeyAction,
4447
- preventKeyAction = _ref4$preventKeyActio === void 0 ? false : _ref4$preventKeyActio,
4448
- rest = _objectWithoutPropertiesLoose(_ref4, _excluded2);
4449
-
4450
- var _ref5 = _temp3 === void 0 ? {} : _temp3,
4451
- _ref5$suppressRefErro = _ref5.suppressRefError,
4452
- suppressRefError = _ref5$suppressRefErro === void 0 ? false : _ref5$suppressRefErro;
4453
-
4456
+ const getDropdownProps = preact.useCallback(function (_temp2, _temp3) {
4457
+ let {
4458
+ refKey = 'ref',
4459
+ ref,
4460
+ onKeyDown,
4461
+ onClick,
4462
+ preventKeyAction = false,
4463
+ ...rest
4464
+ } = _temp2 === void 0 ? {} : _temp2;
4465
+ let {
4466
+ suppressRefError = false
4467
+ } = _temp3 === void 0 ? {} : _temp3;
4454
4468
  setGetterPropCallInfo('getDropdownProps', suppressRefError, refKey, dropdownRef);
4455
4469
 
4456
- var dropdownHandleKeyDown = function dropdownHandleKeyDown(event) {
4457
- var key = normalizeArrowKey(event);
4470
+ const dropdownHandleKeyDown = event => {
4471
+ const key = normalizeArrowKey(event);
4458
4472
 
4459
4473
  if (key && dropdownKeyDownHandlers[key]) {
4460
4474
  dropdownKeyDownHandlers[key](event);
4461
4475
  }
4462
4476
  };
4463
4477
 
4464
- var dropdownHandleClick = function dropdownHandleClick() {
4478
+ const dropdownHandleClick = () => {
4465
4479
  dispatch({
4466
4480
  type: DropdownClick
4467
4481
  });
4468
4482
  };
4469
4483
 
4470
- return _extends((_extends3 = {}, _extends3[refKey] = handleRefs(ref, function (dropdownNode) {
4471
- if (dropdownNode) {
4472
- dropdownRef.current = dropdownNode;
4473
- }
4474
- }), _extends3), !preventKeyAction && {
4475
- onKeyDown: callAllEventHandlers(onKeyDown, dropdownHandleKeyDown),
4476
- onClick: callAllEventHandlers(onClick, dropdownHandleClick)
4477
- }, rest);
4484
+ return {
4485
+ [refKey]: handleRefs(ref, dropdownNode => {
4486
+ if (dropdownNode) {
4487
+ dropdownRef.current = dropdownNode;
4488
+ }
4489
+ }),
4490
+ ...(!preventKeyAction && {
4491
+ onKeyDown: callAllEventHandlers(onKeyDown, dropdownHandleKeyDown),
4492
+ onClick: callAllEventHandlers(onClick, dropdownHandleClick)
4493
+ }),
4494
+ ...rest
4495
+ };
4478
4496
  }, [dispatch, dropdownKeyDownHandlers, setGetterPropCallInfo]); // returns
4479
4497
 
4480
- var addSelectedItem = preact.useCallback(function (selectedItem) {
4498
+ const addSelectedItem = preact.useCallback(selectedItem => {
4481
4499
  dispatch({
4482
4500
  type: FunctionAddSelectedItem,
4483
- selectedItem: selectedItem
4501
+ selectedItem
4484
4502
  });
4485
4503
  }, [dispatch]);
4486
- var removeSelectedItem = preact.useCallback(function (selectedItem) {
4504
+ const removeSelectedItem = preact.useCallback(selectedItem => {
4487
4505
  dispatch({
4488
4506
  type: FunctionRemoveSelectedItem,
4489
- selectedItem: selectedItem
4507
+ selectedItem
4490
4508
  });
4491
4509
  }, [dispatch]);
4492
- var setSelectedItems = preact.useCallback(function (newSelectedItems) {
4510
+ const setSelectedItems = preact.useCallback(newSelectedItems => {
4493
4511
  dispatch({
4494
4512
  type: FunctionSetSelectedItems,
4495
4513
  selectedItems: newSelectedItems
4496
4514
  });
4497
4515
  }, [dispatch]);
4498
- var setActiveIndex = preact.useCallback(function (newActiveIndex) {
4516
+ const setActiveIndex = preact.useCallback(newActiveIndex => {
4499
4517
  dispatch({
4500
4518
  type: FunctionSetActiveIndex,
4501
4519
  activeIndex: newActiveIndex
4502
4520
  });
4503
4521
  }, [dispatch]);
4504
- var reset = preact.useCallback(function () {
4522
+ const reset = preact.useCallback(() => {
4505
4523
  dispatch({
4506
4524
  type: FunctionReset
4507
4525
  });
4508
4526
  }, [dispatch]);
4509
4527
  return {
4510
- getSelectedItemProps: getSelectedItemProps,
4511
- getDropdownProps: getDropdownProps,
4512
- addSelectedItem: addSelectedItem,
4513
- removeSelectedItem: removeSelectedItem,
4514
- setSelectedItems: setSelectedItems,
4515
- setActiveIndex: setActiveIndex,
4516
- reset: reset,
4517
- selectedItems: selectedItems,
4518
- activeIndex: activeIndex
4528
+ getSelectedItemProps,
4529
+ getDropdownProps,
4530
+ addSelectedItem,
4531
+ removeSelectedItem,
4532
+ setSelectedItems,
4533
+ setActiveIndex,
4534
+ reset,
4535
+ selectedItems,
4536
+ activeIndex
4519
4537
  };
4520
4538
  }
4521
4539
 
4522
- exports['default'] = Downshift$1;
4540
+ exports["default"] = Downshift$1;
4523
4541
  exports.resetIdCounter = resetIdCounter;
4524
4542
  exports.useCombobox = useCombobox;
4525
4543
  exports.useMultipleSelection = useMultipleSelection;
@@ -4527,5 +4545,5 @@
4527
4545
 
4528
4546
  Object.defineProperty(exports, '__esModule', { value: true });
4529
4547
 
4530
- })));
4548
+ }));
4531
4549
  //# sourceMappingURL=downshift.umd.js.map