downshift 6.1.5 → 6.1.8

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,7 +2101,7 @@
2162
2101
  defaultStateValues = dropdownDefaultStateValues;
2163
2102
  }
2164
2103
 
2165
- var defaultPropKey = "default" + capitalizeString(propKey);
2104
+ const defaultPropKey = "default" + capitalizeString(propKey);
2166
2105
 
2167
2106
  if (defaultPropKey in props) {
2168
2107
  return props[defaultPropKey];
@@ -2180,7 +2119,7 @@
2180
2119
  return props[propKey];
2181
2120
  }
2182
2121
 
2183
- var initialPropKey = "initial" + capitalizeString(propKey);
2122
+ const initialPropKey = "initial" + capitalizeString(propKey);
2184
2123
 
2185
2124
  if (initialPropKey in props) {
2186
2125
  return props[initialPropKey];
@@ -2190,24 +2129,28 @@
2190
2129
  }
2191
2130
 
2192
2131
  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');
2132
+ const selectedItem = getInitialValue$1(props, 'selectedItem');
2133
+ const isOpen = getInitialValue$1(props, 'isOpen');
2134
+ const highlightedIndex = getInitialValue$1(props, 'highlightedIndex');
2135
+ const inputValue = getInitialValue$1(props, 'inputValue');
2197
2136
  return {
2198
2137
  highlightedIndex: highlightedIndex < 0 && selectedItem && isOpen ? props.items.indexOf(selectedItem) : highlightedIndex,
2199
- isOpen: isOpen,
2200
- selectedItem: selectedItem,
2201
- inputValue: inputValue
2138
+ isOpen,
2139
+ selectedItem,
2140
+ inputValue
2202
2141
  };
2203
2142
  }
2204
2143
 
2205
2144
  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;
2145
+ const {
2146
+ items,
2147
+ initialHighlightedIndex,
2148
+ defaultHighlightedIndex
2149
+ } = props;
2150
+ const {
2151
+ selectedItem,
2152
+ highlightedIndex
2153
+ } = state;
2211
2154
 
2212
2155
  if (items.length === 0) {
2213
2156
  return -1;
@@ -2248,39 +2191,35 @@
2248
2191
 
2249
2192
 
2250
2193
  function useMouseAndTouchTracker(isOpen, downshiftElementRefs, environment, handleBlur) {
2251
- var mouseAndTouchTrackersRef = preact.useRef({
2194
+ const mouseAndTouchTrackersRef = preact.useRef({
2252
2195
  isMouseDown: false,
2253
2196
  isTouchMove: false
2254
2197
  });
2255
- preact.useEffect(function () {
2198
+ preact.useEffect(() => {
2256
2199
  // The same strategy for checking if a click occurred inside or outside downsift
2257
2200
  // as in downshift.js.
2258
- var onMouseDown = function onMouseDown() {
2201
+ const onMouseDown = () => {
2259
2202
  mouseAndTouchTrackersRef.current.isMouseDown = true;
2260
2203
  };
2261
2204
 
2262
- var onMouseUp = function onMouseUp(event) {
2205
+ const onMouseUp = event => {
2263
2206
  mouseAndTouchTrackersRef.current.isMouseDown = false;
2264
2207
 
2265
- if (isOpen && !targetWithinDownshift(event.target, downshiftElementRefs.map(function (ref) {
2266
- return ref.current;
2267
- }), environment)) {
2208
+ if (isOpen && !targetWithinDownshift(event.target, downshiftElementRefs.map(ref => ref.current), environment)) {
2268
2209
  handleBlur();
2269
2210
  }
2270
2211
  };
2271
2212
 
2272
- var onTouchStart = function onTouchStart() {
2213
+ const onTouchStart = () => {
2273
2214
  mouseAndTouchTrackersRef.current.isTouchMove = false;
2274
2215
  };
2275
2216
 
2276
- var onTouchMove = function onTouchMove() {
2217
+ const onTouchMove = () => {
2277
2218
  mouseAndTouchTrackersRef.current.isTouchMove = true;
2278
2219
  };
2279
2220
 
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)) {
2221
+ const onTouchEnd = event => {
2222
+ if (isOpen && !mouseAndTouchTrackersRef.current.isTouchMove && !targetWithinDownshift(event.target, downshiftElementRefs.map(ref => ref.current), environment, false)) {
2284
2223
  handleBlur();
2285
2224
  }
2286
2225
  };
@@ -2304,9 +2243,7 @@
2304
2243
  // eslint-disable-next-line import/no-mutable-exports
2305
2244
 
2306
2245
 
2307
- var useGetterPropsCalledChecker = function useGetterPropsCalledChecker() {
2308
- return noop;
2309
- };
2246
+ let useGetterPropsCalledChecker = () => noop;
2310
2247
  /**
2311
2248
  * Custom hook that checks if getter props are called correctly.
2312
2249
  *
@@ -2318,20 +2255,20 @@
2318
2255
 
2319
2256
 
2320
2257
  {
2321
- useGetterPropsCalledChecker = function useGetterPropsCalledChecker() {
2322
- var isInitialMountRef = preact.useRef(true);
2258
+ useGetterPropsCalledChecker = function () {
2259
+ const isInitialMountRef = preact.useRef(true);
2323
2260
 
2324
2261
  for (var _len = arguments.length, propKeys = new Array(_len), _key = 0; _key < _len; _key++) {
2325
2262
  propKeys[_key] = arguments[_key];
2326
2263
  }
2327
2264
 
2328
- var getterPropsCalledRef = preact.useRef(propKeys.reduce(function (acc, propKey) {
2265
+ const getterPropsCalledRef = preact.useRef(propKeys.reduce((acc, propKey) => {
2329
2266
  acc[propKey] = {};
2330
2267
  return acc;
2331
2268
  }, {}));
2332
- preact.useEffect(function () {
2333
- Object.keys(getterPropsCalledRef.current).forEach(function (propKey) {
2334
- var propCallInfo = getterPropsCalledRef.current[propKey];
2269
+ preact.useEffect(() => {
2270
+ Object.keys(getterPropsCalledRef.current).forEach(propKey => {
2271
+ const propCallInfo = getterPropsCalledRef.current[propKey];
2335
2272
 
2336
2273
  if (isInitialMountRef.current) {
2337
2274
  if (!Object.keys(propCallInfo).length) {
@@ -2341,9 +2278,11 @@
2341
2278
  }
2342
2279
  }
2343
2280
 
2344
- var suppressRefError = propCallInfo.suppressRefError,
2345
- refKey = propCallInfo.refKey,
2346
- elementRef = propCallInfo.elementRef;
2281
+ const {
2282
+ suppressRefError,
2283
+ refKey,
2284
+ elementRef
2285
+ } = propCallInfo;
2347
2286
 
2348
2287
  if ((!elementRef || !elementRef.current) && !suppressRefError) {
2349
2288
  // eslint-disable-next-line no-console
@@ -2352,11 +2291,11 @@
2352
2291
  });
2353
2292
  isInitialMountRef.current = false;
2354
2293
  });
2355
- var setGetterPropCallInfo = preact.useCallback(function (propKey, suppressRefError, refKey, elementRef) {
2294
+ const setGetterPropCallInfo = preact.useCallback((propKey, suppressRefError, refKey, elementRef) => {
2356
2295
  getterPropsCalledRef.current[propKey] = {
2357
- suppressRefError: suppressRefError,
2358
- refKey: refKey,
2359
- elementRef: elementRef
2296
+ suppressRefError,
2297
+ refKey,
2298
+ elementRef
2360
2299
  };
2361
2300
  }, []);
2362
2301
  return setGetterPropCallInfo;
@@ -2364,39 +2303,41 @@
2364
2303
  }
2365
2304
 
2366
2305
  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
-
2306
+ let {
2307
+ isInitialMount,
2308
+ highlightedIndex,
2309
+ items,
2310
+ environment,
2311
+ ...rest
2312
+ } = _ref2;
2373
2313
  // Sets a11y status message on changes in state.
2374
- preact.useEffect(function () {
2314
+ preact.useEffect(() => {
2375
2315
  if (isInitialMount || false) {
2376
2316
  return;
2377
2317
  }
2378
2318
 
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
2319
+ updateA11yStatus(() => getA11yMessage({
2320
+ highlightedIndex,
2321
+ highlightedItem: items[highlightedIndex],
2322
+ resultCount: items.length,
2323
+ ...rest
2324
+ }), environment.document); // eslint-disable-next-line react-hooks/exhaustive-deps
2386
2325
  }, dependencyArray);
2387
2326
  }
2388
2327
 
2389
2328
  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;
2329
+ let {
2330
+ highlightedIndex,
2331
+ isOpen,
2332
+ itemRefs,
2333
+ getItemNodeFromIndex,
2334
+ menuElement,
2335
+ scrollIntoView: scrollIntoViewProp
2336
+ } = _ref3;
2396
2337
  // used not to scroll on highlight by mouse.
2397
- var shouldScrollRef = preact.useRef(true); // Scroll on highlighted item if change comes from keyboard.
2338
+ const shouldScrollRef = preact.useRef(true); // Scroll on highlighted item if change comes from keyboard.
2398
2339
 
2399
- useIsomorphicLayoutEffect(function () {
2340
+ useIsomorphicLayoutEffect(() => {
2400
2341
  if (highlightedIndex < 0 || !isOpen || !Object.keys(itemRefs.current).length) {
2401
2342
  return;
2402
2343
  }
@@ -2412,17 +2353,19 @@
2412
2353
  } // eslint-disable-next-line import/no-mutable-exports
2413
2354
 
2414
2355
 
2415
- var useControlPropsValidator = noop;
2356
+ let useControlPropsValidator = noop;
2416
2357
  /* istanbul ignore next */
2417
2358
 
2418
2359
  {
2419
- useControlPropsValidator = function useControlPropsValidator(_ref4) {
2420
- var isInitialMount = _ref4.isInitialMount,
2421
- props = _ref4.props,
2422
- state = _ref4.state;
2360
+ useControlPropsValidator = _ref4 => {
2361
+ let {
2362
+ isInitialMount,
2363
+ props,
2364
+ state
2365
+ } = _ref4;
2423
2366
  // used for checking when props are moving from controlled to uncontrolled.
2424
- var prevPropsRef = preact.useRef(props);
2425
- preact.useEffect(function () {
2367
+ const prevPropsRef = preact.useRef(props);
2368
+ preact.useEffect(() => {
2426
2369
  if (isInitialMount) {
2427
2370
  return;
2428
2371
  }
@@ -2436,9 +2379,11 @@
2436
2379
  /* eslint-disable complexity */
2437
2380
 
2438
2381
  function downshiftCommonReducer(state, action, stateChangeTypes) {
2439
- var type = action.type,
2440
- props = action.props;
2441
- var changes;
2382
+ const {
2383
+ type,
2384
+ props
2385
+ } = action;
2386
+ let changes;
2442
2387
 
2443
2388
  switch (type) {
2444
2389
  case stateChangeTypes.ItemMouseMove:
@@ -2499,11 +2444,13 @@
2499
2444
  throw new Error('Reducer called without proper action type.');
2500
2445
  }
2501
2446
 
2502
- return _extends({}, state, changes);
2447
+ return { ...state,
2448
+ ...changes
2449
+ };
2503
2450
  }
2504
2451
  /* eslint-enable complexity */
2505
2452
 
2506
- /*! *****************************************************************************
2453
+ /******************************************************************************
2507
2454
  Copyright (c) Microsoft Corporation.
2508
2455
 
2509
2456
  Permission to use, copy, modify, and/or distribute this software for any
@@ -2548,37 +2495,37 @@
2548
2495
  return highlightedIndex;
2549
2496
  }
2550
2497
  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
2498
+ items: PropTypes__default["default"].array.isRequired,
2499
+ itemToString: PropTypes__default["default"].func,
2500
+ getA11yStatusMessage: PropTypes__default["default"].func,
2501
+ getA11ySelectionMessage: PropTypes__default["default"].func,
2502
+ circularNavigation: PropTypes__default["default"].bool,
2503
+ highlightedIndex: PropTypes__default["default"].number,
2504
+ defaultHighlightedIndex: PropTypes__default["default"].number,
2505
+ initialHighlightedIndex: PropTypes__default["default"].number,
2506
+ isOpen: PropTypes__default["default"].bool,
2507
+ defaultIsOpen: PropTypes__default["default"].bool,
2508
+ initialIsOpen: PropTypes__default["default"].bool,
2509
+ selectedItem: PropTypes__default["default"].any,
2510
+ initialSelectedItem: PropTypes__default["default"].any,
2511
+ defaultSelectedItem: PropTypes__default["default"].any,
2512
+ id: PropTypes__default["default"].string,
2513
+ labelId: PropTypes__default["default"].string,
2514
+ menuId: PropTypes__default["default"].string,
2515
+ getItemId: PropTypes__default["default"].func,
2516
+ toggleButtonId: PropTypes__default["default"].string,
2517
+ stateReducer: PropTypes__default["default"].func,
2518
+ onSelectedItemChange: PropTypes__default["default"].func,
2519
+ onHighlightedIndexChange: PropTypes__default["default"].func,
2520
+ onStateChange: PropTypes__default["default"].func,
2521
+ onIsOpenChange: PropTypes__default["default"].func,
2522
+ environment: PropTypes__default["default"].shape({
2523
+ addEventListener: PropTypes__default["default"].func,
2524
+ removeEventListener: PropTypes__default["default"].func,
2525
+ document: PropTypes__default["default"].shape({
2526
+ getElementById: PropTypes__default["default"].func,
2527
+ activeElement: PropTypes__default["default"].any,
2528
+ body: PropTypes__default["default"].any
2582
2529
  })
2583
2530
  })
2584
2531
  };
@@ -2599,7 +2546,7 @@
2599
2546
  return 'No results are available.';
2600
2547
  }
2601
2548
  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.";
2549
+ 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
2550
  }
2604
2551
  return '';
2605
2552
  }
@@ -2609,33 +2556,33 @@
2609
2556
  /* istanbul ignore next */
2610
2557
  {
2611
2558
  validatePropTypes$2 = function (options, caller) {
2612
- PropTypes__default['default'].checkPropTypes(propTypes$2, options, 'prop', caller.name);
2559
+ PropTypes__default["default"].checkPropTypes(propTypes$2, options, 'prop', caller.name);
2613
2560
  };
2614
2561
  }
2615
2562
 
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__' ;
2563
+ const MenuKeyDownArrowDown = '__menu_keydown_arrow_down__' ;
2564
+ const MenuKeyDownArrowUp = '__menu_keydown_arrow_up__' ;
2565
+ const MenuKeyDownEscape = '__menu_keydown_escape__' ;
2566
+ const MenuKeyDownHome = '__menu_keydown_home__' ;
2567
+ const MenuKeyDownEnd = '__menu_keydown_end__' ;
2568
+ const MenuKeyDownEnter = '__menu_keydown_enter__' ;
2569
+ const MenuKeyDownSpaceButton = '__menu_keydown_space_button__' ;
2570
+ const MenuKeyDownCharacter = '__menu_keydown_character__' ;
2571
+ const MenuBlur = '__menu_blur__' ;
2572
+ const MenuMouseLeave$1 = '__menu_mouse_leave__' ;
2573
+ const ItemMouseMove$1 = '__item_mouse_move__' ;
2574
+ const ItemClick$1 = '__item_click__' ;
2575
+ const ToggleButtonClick$1 = '__togglebutton_click__' ;
2576
+ const ToggleButtonKeyDownArrowDown = '__togglebutton_keydown_arrow_down__' ;
2577
+ const ToggleButtonKeyDownArrowUp = '__togglebutton_keydown_arrow_up__' ;
2578
+ const ToggleButtonKeyDownCharacter = '__togglebutton_keydown_character__' ;
2579
+ const FunctionToggleMenu$1 = '__function_toggle_menu__' ;
2580
+ const FunctionOpenMenu$1 = '__function_open_menu__' ;
2581
+ const FunctionCloseMenu$1 = '__function_close_menu__' ;
2582
+ const FunctionSetHighlightedIndex$1 = '__function_set_highlighted_index__' ;
2583
+ const FunctionSelectItem$1 = '__function_select_item__' ;
2584
+ const FunctionSetInputValue$1 = '__function_set_input_value__' ;
2585
+ const FunctionReset$2 = '__function_reset__' ;
2639
2586
 
2640
2587
  var stateChangeTypes$2 = /*#__PURE__*/Object.freeze({
2641
2588
  __proto__: null,
@@ -2667,10 +2614,12 @@
2667
2614
  /* eslint-disable complexity */
2668
2615
 
2669
2616
  function downshiftSelectReducer(state, action) {
2670
- var type = action.type,
2671
- props = action.props,
2672
- shiftKey = action.shiftKey;
2673
- var changes;
2617
+ const {
2618
+ type,
2619
+ props,
2620
+ shiftKey
2621
+ } = action;
2622
+ let changes;
2674
2623
 
2675
2624
  switch (type) {
2676
2625
  case ItemClick$1:
@@ -2683,20 +2632,21 @@
2683
2632
 
2684
2633
  case ToggleButtonKeyDownCharacter:
2685
2634
  {
2686
- var lowercasedKey = action.key;
2687
- var inputValue = "" + state.inputValue + lowercasedKey;
2688
- var itemIndex = getItemIndexByCharacterKey({
2635
+ const lowercasedKey = action.key;
2636
+ const inputValue = "" + state.inputValue + lowercasedKey;
2637
+ const itemIndex = getItemIndexByCharacterKey({
2689
2638
  keysSoFar: inputValue,
2690
2639
  highlightedIndex: state.selectedItem ? props.items.indexOf(state.selectedItem) : -1,
2691
2640
  items: props.items,
2692
2641
  itemToString: props.itemToString,
2693
2642
  getItemNodeFromIndex: action.getItemNodeFromIndex
2694
2643
  });
2695
- changes = _extends({
2696
- inputValue: inputValue
2697
- }, itemIndex >= 0 && {
2698
- selectedItem: props.items[itemIndex]
2699
- });
2644
+ changes = {
2645
+ inputValue,
2646
+ ...(itemIndex >= 0 && {
2647
+ selectedItem: props.items[itemIndex]
2648
+ })
2649
+ };
2700
2650
  }
2701
2651
  break;
2702
2652
 
@@ -2716,12 +2666,13 @@
2716
2666
 
2717
2667
  case MenuKeyDownEnter:
2718
2668
  case MenuKeyDownSpaceButton:
2719
- changes = _extends({
2669
+ changes = {
2720
2670
  isOpen: getDefaultValue$1(props, 'isOpen'),
2721
- highlightedIndex: getDefaultValue$1(props, 'highlightedIndex')
2722
- }, state.highlightedIndex >= 0 && {
2723
- selectedItem: props.items[state.highlightedIndex]
2724
- });
2671
+ highlightedIndex: getDefaultValue$1(props, 'highlightedIndex'),
2672
+ ...(state.highlightedIndex >= 0 && {
2673
+ selectedItem: props.items[state.highlightedIndex]
2674
+ })
2675
+ };
2725
2676
  break;
2726
2677
 
2727
2678
  case MenuKeyDownHome:
@@ -2752,22 +2703,21 @@
2752
2703
 
2753
2704
  case MenuKeyDownCharacter:
2754
2705
  {
2755
- var _lowercasedKey = action.key;
2756
-
2757
- var _inputValue = "" + state.inputValue + _lowercasedKey;
2758
-
2759
- var highlightedIndex = getItemIndexByCharacterKey({
2760
- keysSoFar: _inputValue,
2706
+ const lowercasedKey = action.key;
2707
+ const inputValue = "" + state.inputValue + lowercasedKey;
2708
+ const highlightedIndex = getItemIndexByCharacterKey({
2709
+ keysSoFar: inputValue,
2761
2710
  highlightedIndex: state.highlightedIndex,
2762
2711
  items: props.items,
2763
2712
  itemToString: props.itemToString,
2764
2713
  getItemNodeFromIndex: action.getItemNodeFromIndex
2765
2714
  });
2766
- changes = _extends({
2767
- inputValue: _inputValue
2768
- }, highlightedIndex >= 0 && {
2769
- highlightedIndex: highlightedIndex
2770
- });
2715
+ changes = {
2716
+ inputValue,
2717
+ ...(highlightedIndex >= 0 && {
2718
+ highlightedIndex
2719
+ })
2720
+ };
2771
2721
  }
2772
2722
  break;
2773
2723
 
@@ -2793,13 +2743,13 @@
2793
2743
  return downshiftCommonReducer(state, action, stateChangeTypes$2);
2794
2744
  }
2795
2745
 
2796
- return _extends({}, state, changes);
2746
+ return { ...state,
2747
+ ...changes
2748
+ };
2797
2749
  }
2798
2750
  /* eslint-enable complexity */
2799
2751
 
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"];
2752
+ /* eslint-disable max-statements */
2803
2753
  useSelect.stateChangeTypes = stateChangeTypes$2;
2804
2754
 
2805
2755
  function useSelect(userProps) {
@@ -2809,91 +2759,92 @@
2809
2759
 
2810
2760
  validatePropTypes$2(userProps, useSelect); // Props defaults and destructuring.
2811
2761
 
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
2762
+ const props = { ...defaultProps$2,
2763
+ ...userProps
2764
+ };
2765
+ const {
2766
+ items,
2767
+ scrollIntoView,
2768
+ environment,
2769
+ initialIsOpen,
2770
+ defaultIsOpen,
2771
+ itemToString,
2772
+ getA11ySelectionMessage,
2773
+ getA11yStatusMessage
2774
+ } = props; // Initial state depending on controlled props.
2775
+
2776
+ const initialState = getInitialState$2(props);
2777
+ const [state, dispatch] = useControlledReducer$1(downshiftSelectReducer, initialState, props);
2778
+ const {
2779
+ isOpen,
2780
+ highlightedIndex,
2781
+ selectedItem,
2782
+ inputValue
2783
+ } = state; // Element efs.
2784
+
2785
+ const toggleButtonRef = preact.useRef(null);
2786
+ const menuRef = preact.useRef(null);
2787
+ const itemRefs = preact.useRef({}); // used not to trigger menu blur action in some scenarios.
2788
+
2789
+ const shouldBlurRef = preact.useRef(true); // used to keep the inputValue clearTimeout object between renders.
2790
+
2791
+ const clearTimeoutRef = preact.useRef(null); // prevent id re-generation between renders.
2792
+
2793
+ const elementIds = useElementIds(props); // used to keep track of how many items we had on previous cycle.
2794
+
2795
+ const previousResultCountRef = preact.useRef();
2796
+ const isInitialMountRef = preact.useRef(true); // utility callback to get item element.
2797
+
2798
+ const latest = useLatestRef({
2799
+ state,
2800
+ props
2850
2801
  }); // Some utils.
2851
2802
 
2852
- var getItemNodeFromIndex = preact.useCallback(function (index) {
2853
- return itemRefs.current[elementIds.getItemId(index)];
2854
- }, [elementIds]); // Effects.
2803
+ const getItemNodeFromIndex = preact.useCallback(index => itemRefs.current[elementIds.getItemId(index)], [elementIds]); // Effects.
2855
2804
  // Sets a11y status message on changes in state.
2856
2805
 
2857
- useA11yMessageSetter(getA11yStatusMessage, [isOpen, highlightedIndex, inputValue, items], _extends({
2806
+ useA11yMessageSetter(getA11yStatusMessage, [isOpen, highlightedIndex, inputValue, items], {
2858
2807
  isInitialMount: isInitialMountRef.current,
2859
2808
  previousResultCount: previousResultCountRef.current,
2860
- items: items,
2861
- environment: environment,
2862
- itemToString: itemToString
2863
- }, state)); // Sets a11y status message on changes in selectedItem.
2809
+ items,
2810
+ environment,
2811
+ itemToString,
2812
+ ...state
2813
+ }); // Sets a11y status message on changes in selectedItem.
2864
2814
 
2865
- useA11yMessageSetter(getA11ySelectionMessage, [selectedItem], _extends({
2815
+ useA11yMessageSetter(getA11ySelectionMessage, [selectedItem], {
2866
2816
  isInitialMount: isInitialMountRef.current,
2867
2817
  previousResultCount: previousResultCountRef.current,
2868
- items: items,
2869
- environment: environment,
2870
- itemToString: itemToString
2871
- }, state)); // Scroll on highlighted item if change comes from keyboard.
2818
+ items,
2819
+ environment,
2820
+ itemToString,
2821
+ ...state
2822
+ }); // Scroll on highlighted item if change comes from keyboard.
2872
2823
 
2873
- var shouldScrollRef = useScrollIntoView({
2824
+ const shouldScrollRef = useScrollIntoView({
2874
2825
  menuElement: menuRef.current,
2875
- highlightedIndex: highlightedIndex,
2876
- isOpen: isOpen,
2877
- itemRefs: itemRefs,
2878
- scrollIntoView: scrollIntoView,
2879
- getItemNodeFromIndex: getItemNodeFromIndex
2826
+ highlightedIndex,
2827
+ isOpen,
2828
+ itemRefs,
2829
+ scrollIntoView,
2830
+ getItemNodeFromIndex
2880
2831
  }); // Sets cleanup for the keysSoFar callback, debounded after 500ms.
2881
2832
 
2882
- preact.useEffect(function () {
2833
+ preact.useEffect(() => {
2883
2834
  // init the clean function here as we need access to dispatch.
2884
- clearTimeoutRef.current = debounce(function (outerDispatch) {
2835
+ clearTimeoutRef.current = debounce(outerDispatch => {
2885
2836
  outerDispatch({
2886
2837
  type: FunctionSetInputValue$1,
2887
2838
  inputValue: ''
2888
2839
  });
2889
2840
  }, 500); // Cancel any pending debounced calls on mount
2890
2841
 
2891
- return function () {
2842
+ return () => {
2892
2843
  clearTimeoutRef.current.cancel();
2893
2844
  };
2894
2845
  }, []); // Invokes the keysSoFar callback set up above.
2895
2846
 
2896
- preact.useEffect(function () {
2847
+ preact.useEffect(() => {
2897
2848
  if (!inputValue) {
2898
2849
  return;
2899
2850
  }
@@ -2902,12 +2853,12 @@
2902
2853
  }, [dispatch, inputValue]);
2903
2854
  useControlPropsValidator({
2904
2855
  isInitialMount: isInitialMountRef.current,
2905
- props: props,
2906
- state: state
2856
+ props,
2857
+ state
2907
2858
  });
2908
2859
  /* Controls the focus on the menu or the toggle button. */
2909
2860
 
2910
- preact.useEffect(function () {
2861
+ preact.useEffect(() => {
2911
2862
  // Don't focus menu on first render.
2912
2863
  if (isInitialMountRef.current) {
2913
2864
  // Unless it was initialised as open.
@@ -2938,7 +2889,7 @@
2938
2889
  } // eslint-disable-next-line react-hooks/exhaustive-deps
2939
2890
 
2940
2891
  }, [isOpen]);
2941
- preact.useEffect(function () {
2892
+ preact.useEffect(() => {
2942
2893
  if (isInitialMountRef.current) {
2943
2894
  return;
2944
2895
  }
@@ -2946,180 +2897,180 @@
2946
2897
  previousResultCountRef.current = items.length;
2947
2898
  }); // Add mouse/touch events to document.
2948
2899
 
2949
- var mouseAndTouchTrackersRef = useMouseAndTouchTracker(isOpen, [menuRef, toggleButtonRef], environment, function () {
2900
+ const mouseAndTouchTrackersRef = useMouseAndTouchTracker(isOpen, [menuRef, toggleButtonRef], environment, () => {
2950
2901
  dispatch({
2951
2902
  type: MenuBlur
2952
2903
  });
2953
2904
  });
2954
- var setGetterPropCallInfo = useGetterPropsCalledChecker('getMenuProps', 'getToggleButtonProps'); // Make initial ref false.
2905
+ const setGetterPropCallInfo = useGetterPropsCalledChecker('getMenuProps', 'getToggleButtonProps'); // Make initial ref false.
2955
2906
 
2956
- preact.useEffect(function () {
2907
+ preact.useEffect(() => {
2957
2908
  isInitialMountRef.current = false;
2958
2909
  }, []); // Reset itemRefs on close.
2959
2910
 
2960
- preact.useEffect(function () {
2911
+ preact.useEffect(() => {
2961
2912
  if (!isOpen) {
2962
2913
  itemRefs.current = {};
2963
2914
  }
2964
2915
  }, [isOpen]); // Event handler functions.
2965
2916
 
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.
2917
+ const toggleButtonKeyDownHandlers = preact.useMemo(() => ({
2918
+ ArrowDown(event) {
2919
+ event.preventDefault();
2920
+ dispatch({
2921
+ type: ToggleButtonKeyDownArrowDown,
2922
+ getItemNodeFromIndex,
2923
+ shiftKey: event.shiftKey
2924
+ });
2925
+ },
2926
+
2927
+ ArrowUp(event) {
2928
+ event.preventDefault();
2929
+ dispatch({
2930
+ type: ToggleButtonKeyDownArrowUp,
2931
+ getItemNodeFromIndex,
2932
+ shiftKey: event.shiftKey
2933
+ });
2934
+ }
2935
+
2936
+ }), [dispatch, getItemNodeFromIndex]);
2937
+ const menuKeyDownHandlers = preact.useMemo(() => ({
2938
+ ArrowDown(event) {
2939
+ event.preventDefault();
2940
+ dispatch({
2941
+ type: MenuKeyDownArrowDown,
2942
+ getItemNodeFromIndex,
2943
+ shiftKey: event.shiftKey
2944
+ });
2945
+ },
2946
+
2947
+ ArrowUp(event) {
2948
+ event.preventDefault();
2949
+ dispatch({
2950
+ type: MenuKeyDownArrowUp,
2951
+ getItemNodeFromIndex,
2952
+ shiftKey: event.shiftKey
2953
+ });
2954
+ },
2955
+
2956
+ Home(event) {
2957
+ event.preventDefault();
2958
+ dispatch({
2959
+ type: MenuKeyDownHome,
2960
+ getItemNodeFromIndex
2961
+ });
2962
+ },
2963
+
2964
+ End(event) {
2965
+ event.preventDefault();
2966
+ dispatch({
2967
+ type: MenuKeyDownEnd,
2968
+ getItemNodeFromIndex
2969
+ });
2970
+ },
2971
+
2972
+ Escape() {
2973
+ dispatch({
2974
+ type: MenuKeyDownEscape
2975
+ });
2976
+ },
2977
+
2978
+ Enter(event) {
2979
+ event.preventDefault();
2980
+ dispatch({
2981
+ type: MenuKeyDownEnter
2982
+ });
2983
+ },
3037
2984
 
3038
- var toggleMenu = preact.useCallback(function () {
2985
+ ' '(event) {
2986
+ event.preventDefault();
2987
+ dispatch({
2988
+ type: MenuKeyDownSpaceButton
2989
+ });
2990
+ }
2991
+
2992
+ }), [dispatch, getItemNodeFromIndex]); // Action functions.
2993
+
2994
+ const toggleMenu = preact.useCallback(() => {
3039
2995
  dispatch({
3040
2996
  type: FunctionToggleMenu$1
3041
2997
  });
3042
2998
  }, [dispatch]);
3043
- var closeMenu = preact.useCallback(function () {
2999
+ const closeMenu = preact.useCallback(() => {
3044
3000
  dispatch({
3045
3001
  type: FunctionCloseMenu$1
3046
3002
  });
3047
3003
  }, [dispatch]);
3048
- var openMenu = preact.useCallback(function () {
3004
+ const openMenu = preact.useCallback(() => {
3049
3005
  dispatch({
3050
3006
  type: FunctionOpenMenu$1
3051
3007
  });
3052
3008
  }, [dispatch]);
3053
- var setHighlightedIndex = preact.useCallback(function (newHighlightedIndex) {
3009
+ const setHighlightedIndex = preact.useCallback(newHighlightedIndex => {
3054
3010
  dispatch({
3055
3011
  type: FunctionSetHighlightedIndex$1,
3056
3012
  highlightedIndex: newHighlightedIndex
3057
3013
  });
3058
3014
  }, [dispatch]);
3059
- var selectItem = preact.useCallback(function (newSelectedItem) {
3015
+ const selectItem = preact.useCallback(newSelectedItem => {
3060
3016
  dispatch({
3061
3017
  type: FunctionSelectItem$1,
3062
3018
  selectedItem: newSelectedItem
3063
3019
  });
3064
3020
  }, [dispatch]);
3065
- var reset = preact.useCallback(function () {
3021
+ const reset = preact.useCallback(() => {
3066
3022
  dispatch({
3067
3023
  type: FunctionReset$2
3068
3024
  });
3069
3025
  }, [dispatch]);
3070
- var setInputValue = preact.useCallback(function (newInputValue) {
3026
+ const setInputValue = preact.useCallback(newInputValue => {
3071
3027
  dispatch({
3072
3028
  type: FunctionSetInputValue$1,
3073
3029
  inputValue: newInputValue
3074
3030
  });
3075
3031
  }, [dispatch]); // Getter functions.
3076
3032
 
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);
3033
+ const getLabelProps = preact.useCallback(labelProps => ({
3034
+ id: elementIds.labelId,
3035
+ htmlFor: elementIds.toggleButtonId,
3036
+ ...labelProps
3037
+ }), [elementIds]);
3038
+ const getMenuProps = preact.useCallback(function (_temp, _temp2) {
3039
+ let {
3040
+ onMouseLeave,
3041
+ refKey = 'ref',
3042
+ onKeyDown,
3043
+ onBlur,
3044
+ ref,
3045
+ ...rest
3046
+ } = _temp === void 0 ? {} : _temp;
3047
+ let {
3048
+ suppressRefError = false
3049
+ } = _temp2 === void 0 ? {} : _temp2;
3050
+ const latestState = latest.current.state;
3051
+
3052
+ const menuHandleKeyDown = event => {
3053
+ const key = normalizeArrowKey(event);
3103
3054
 
3104
3055
  if (key && menuKeyDownHandlers[key]) {
3105
3056
  menuKeyDownHandlers[key](event);
3106
3057
  } else if (isAcceptedCharacterKey(key)) {
3107
3058
  dispatch({
3108
3059
  type: MenuKeyDownCharacter,
3109
- key: key,
3110
- getItemNodeFromIndex: getItemNodeFromIndex
3060
+ key,
3061
+ getItemNodeFromIndex
3111
3062
  });
3112
3063
  }
3113
3064
  };
3114
3065
 
3115
- var menuHandleBlur = function menuHandleBlur() {
3066
+ const menuHandleBlur = () => {
3116
3067
  // if the blur was a result of selection, we don't trigger this action.
3117
3068
  if (shouldBlurRef.current === false) {
3118
3069
  shouldBlurRef.current = true;
3119
3070
  return;
3120
3071
  }
3121
3072
 
3122
- var shouldBlur = !mouseAndTouchTrackersRef.current.isMouseDown;
3073
+ const shouldBlur = !mouseAndTouchTrackersRef.current.isMouseDown;
3123
3074
  /* istanbul ignore else */
3124
3075
 
3125
3076
  if (shouldBlur) {
@@ -3129,61 +3080,72 @@
3129
3080
  }
3130
3081
  };
3131
3082
 
3132
- var menuHandleMouseLeave = function menuHandleMouseLeave() {
3083
+ const menuHandleMouseLeave = () => {
3133
3084
  dispatch({
3134
3085
  type: MenuMouseLeave$1
3135
3086
  });
3136
3087
  };
3137
3088
 
3138
3089
  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
- }, {
3090
+ return {
3091
+ [refKey]: handleRefs(ref, menuNode => {
3092
+ menuRef.current = menuNode;
3093
+ }),
3094
+ id: elementIds.menuId,
3095
+ role: 'listbox',
3096
+ 'aria-labelledby': elementIds.labelId,
3097
+ tabIndex: -1,
3098
+ ...(latestState.isOpen && latestState.highlightedIndex > -1 && {
3099
+ 'aria-activedescendant': elementIds.getItemId(latestState.highlightedIndex)
3100
+ }),
3144
3101
  onMouseLeave: callAllEventHandlers(onMouseLeave, menuHandleMouseLeave),
3145
3102
  onKeyDown: callAllEventHandlers(onKeyDown, menuHandleKeyDown),
3146
- onBlur: callAllEventHandlers(onBlur, menuHandleBlur)
3147
- }, rest);
3103
+ onBlur: callAllEventHandlers(onBlur, menuHandleBlur),
3104
+ ...rest
3105
+ };
3148
3106
  }, [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() {
3107
+ const getToggleButtonProps = preact.useCallback(function (_temp3, _temp4) {
3108
+ let {
3109
+ onClick,
3110
+ onKeyDown,
3111
+ refKey = 'ref',
3112
+ ref,
3113
+ ...rest
3114
+ } = _temp3 === void 0 ? {} : _temp3;
3115
+ let {
3116
+ suppressRefError = false
3117
+ } = _temp4 === void 0 ? {} : _temp4;
3118
+
3119
+ const toggleButtonHandleClick = () => {
3165
3120
  dispatch({
3166
3121
  type: ToggleButtonClick$1
3167
3122
  });
3168
3123
  };
3169
3124
 
3170
- var toggleButtonHandleKeyDown = function toggleButtonHandleKeyDown(event) {
3171
- var key = normalizeArrowKey(event);
3125
+ const toggleButtonHandleKeyDown = event => {
3126
+ const key = normalizeArrowKey(event);
3172
3127
 
3173
3128
  if (key && toggleButtonKeyDownHandlers[key]) {
3174
3129
  toggleButtonKeyDownHandlers[key](event);
3175
3130
  } else if (isAcceptedCharacterKey(key)) {
3176
3131
  dispatch({
3177
3132
  type: ToggleButtonKeyDownCharacter,
3178
- key: key,
3179
- getItemNodeFromIndex: getItemNodeFromIndex
3133
+ key,
3134
+ getItemNodeFromIndex
3180
3135
  });
3181
3136
  }
3182
3137
  };
3183
3138
 
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);
3139
+ const toggleProps = {
3140
+ [refKey]: handleRefs(ref, toggleButtonNode => {
3141
+ toggleButtonRef.current = toggleButtonNode;
3142
+ }),
3143
+ id: elementIds.toggleButtonId,
3144
+ 'aria-haspopup': 'listbox',
3145
+ 'aria-expanded': latest.current.state.isOpen,
3146
+ 'aria-labelledby': elementIds.labelId + " " + elementIds.toggleButtonId,
3147
+ ...rest
3148
+ };
3187
3149
 
3188
3150
  if (!rest.disabled) {
3189
3151
  toggleProps.onClick = callAllEventHandlers(onClick, toggleButtonHandleClick);
@@ -3193,24 +3155,22 @@
3193
3155
  setGetterPropCallInfo('getToggleButtonProps', suppressRefError, refKey, toggleButtonRef);
3194
3156
  return toggleProps;
3195
3157
  }, [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() {
3158
+ const getItemProps = preact.useCallback(function (_temp5) {
3159
+ let {
3160
+ item,
3161
+ index,
3162
+ onMouseMove,
3163
+ onClick,
3164
+ refKey = 'ref',
3165
+ ref,
3166
+ ...rest
3167
+ } = _temp5 === void 0 ? {} : _temp5;
3168
+ const {
3169
+ state: latestState,
3170
+ props: latestProps
3171
+ } = latest.current;
3172
+
3173
+ const itemHandleMouseMove = () => {
3214
3174
  if (index === latestState.highlightedIndex) {
3215
3175
  return;
3216
3176
  }
@@ -3218,32 +3178,34 @@
3218
3178
  shouldScrollRef.current = false;
3219
3179
  dispatch({
3220
3180
  type: ItemMouseMove$1,
3221
- index: index
3181
+ index
3222
3182
  });
3223
3183
  };
3224
3184
 
3225
- var itemHandleClick = function itemHandleClick() {
3185
+ const itemHandleClick = () => {
3226
3186
  dispatch({
3227
3187
  type: ItemClick$1,
3228
- index: index
3188
+ index
3229
3189
  });
3230
3190
  };
3231
3191
 
3232
- var itemIndex = getItemIndex(index, item, latestProps.items);
3192
+ const itemIndex = getItemIndex(index, item, latestProps.items);
3233
3193
 
3234
3194
  if (itemIndex < 0) {
3235
3195
  throw new Error('Pass either item or item index in getItemProps!');
3236
3196
  }
3237
3197
 
3238
- var itemProps = _extends((_extends4 = {
3198
+ const itemProps = {
3239
3199
  role: 'option',
3240
3200
  '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);
3201
+ id: elementIds.getItemId(itemIndex),
3202
+ [refKey]: handleRefs(ref, itemNode => {
3203
+ if (itemNode) {
3204
+ itemRefs.current[elementIds.getItemId(itemIndex)] = itemNode;
3205
+ }
3206
+ }),
3207
+ ...rest
3208
+ };
3247
3209
 
3248
3210
  if (!rest.disabled) {
3249
3211
  itemProps.onMouseMove = callAllEventHandlers(onMouseMove, itemHandleMouseMove);
@@ -3254,46 +3216,46 @@
3254
3216
  }, [dispatch, latest, shouldScrollRef, elementIds]);
3255
3217
  return {
3256
3218
  // prop getters.
3257
- getToggleButtonProps: getToggleButtonProps,
3258
- getLabelProps: getLabelProps,
3259
- getMenuProps: getMenuProps,
3260
- getItemProps: getItemProps,
3219
+ getToggleButtonProps,
3220
+ getLabelProps,
3221
+ getMenuProps,
3222
+ getItemProps,
3261
3223
  // actions.
3262
- toggleMenu: toggleMenu,
3263
- openMenu: openMenu,
3264
- closeMenu: closeMenu,
3265
- setHighlightedIndex: setHighlightedIndex,
3266
- selectItem: selectItem,
3267
- reset: reset,
3268
- setInputValue: setInputValue,
3224
+ toggleMenu,
3225
+ openMenu,
3226
+ closeMenu,
3227
+ setHighlightedIndex,
3228
+ selectItem,
3229
+ reset,
3230
+ setInputValue,
3269
3231
  // state.
3270
- highlightedIndex: highlightedIndex,
3271
- isOpen: isOpen,
3272
- selectedItem: selectedItem,
3273
- inputValue: inputValue
3232
+ highlightedIndex,
3233
+ isOpen,
3234
+ selectedItem,
3235
+ inputValue
3274
3236
  };
3275
3237
  }
3276
3238
 
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__' ;
3239
+ const InputKeyDownArrowDown = '__input_keydown_arrow_down__' ;
3240
+ const InputKeyDownArrowUp = '__input_keydown_arrow_up__' ;
3241
+ const InputKeyDownEscape = '__input_keydown_escape__' ;
3242
+ const InputKeyDownHome = '__input_keydown_home__' ;
3243
+ const InputKeyDownEnd = '__input_keydown_end__' ;
3244
+ const InputKeyDownEnter = '__input_keydown_enter__' ;
3245
+ const InputChange = '__input_change__' ;
3246
+ const InputBlur = '__input_blur__' ;
3247
+ const MenuMouseLeave = '__menu_mouse_leave__' ;
3248
+ const ItemMouseMove = '__item_mouse_move__' ;
3249
+ const ItemClick = '__item_click__' ;
3250
+ const ToggleButtonClick = '__togglebutton_click__' ;
3251
+ const FunctionToggleMenu = '__function_toggle_menu__' ;
3252
+ const FunctionOpenMenu = '__function_open_menu__' ;
3253
+ const FunctionCloseMenu = '__function_close_menu__' ;
3254
+ const FunctionSetHighlightedIndex = '__function_set_highlighted_index__' ;
3255
+ const FunctionSelectItem = '__function_select_item__' ;
3256
+ const FunctionSetInputValue = '__function_set_input_value__' ;
3257
+ const FunctionReset$1 = '__function_reset__' ;
3258
+ const ControlledPropUpdatedSelectedItem = '__controlled_prop_updated_selected_item__' ;
3297
3259
 
3298
3260
  var stateChangeTypes$1 = /*#__PURE__*/Object.freeze({
3299
3261
  __proto__: null,
@@ -3320,56 +3282,60 @@
3320
3282
  });
3321
3283
 
3322
3284
  function getInitialState$1(props) {
3323
- var initialState = getInitialState$2(props);
3324
- var selectedItem = initialState.selectedItem;
3325
- var inputValue = initialState.inputValue;
3285
+ const initialState = getInitialState$2(props);
3286
+ const {
3287
+ selectedItem
3288
+ } = initialState;
3289
+ let {
3290
+ inputValue
3291
+ } = initialState;
3326
3292
 
3327
3293
  if (inputValue === '' && selectedItem && props.defaultInputValue === undefined && props.initialInputValue === undefined && props.inputValue === undefined) {
3328
3294
  inputValue = props.itemToString(selectedItem);
3329
3295
  }
3330
3296
 
3331
- return _extends({}, initialState, {
3332
- inputValue: inputValue
3333
- });
3297
+ return { ...initialState,
3298
+ inputValue
3299
+ };
3334
3300
  }
3335
3301
 
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
3302
+ const propTypes$1 = {
3303
+ items: PropTypes__default["default"].array.isRequired,
3304
+ itemToString: PropTypes__default["default"].func,
3305
+ getA11yStatusMessage: PropTypes__default["default"].func,
3306
+ getA11ySelectionMessage: PropTypes__default["default"].func,
3307
+ circularNavigation: PropTypes__default["default"].bool,
3308
+ highlightedIndex: PropTypes__default["default"].number,
3309
+ defaultHighlightedIndex: PropTypes__default["default"].number,
3310
+ initialHighlightedIndex: PropTypes__default["default"].number,
3311
+ isOpen: PropTypes__default["default"].bool,
3312
+ defaultIsOpen: PropTypes__default["default"].bool,
3313
+ initialIsOpen: PropTypes__default["default"].bool,
3314
+ selectedItem: PropTypes__default["default"].any,
3315
+ initialSelectedItem: PropTypes__default["default"].any,
3316
+ defaultSelectedItem: PropTypes__default["default"].any,
3317
+ inputValue: PropTypes__default["default"].string,
3318
+ defaultInputValue: PropTypes__default["default"].string,
3319
+ initialInputValue: PropTypes__default["default"].string,
3320
+ id: PropTypes__default["default"].string,
3321
+ labelId: PropTypes__default["default"].string,
3322
+ menuId: PropTypes__default["default"].string,
3323
+ getItemId: PropTypes__default["default"].func,
3324
+ inputId: PropTypes__default["default"].string,
3325
+ toggleButtonId: PropTypes__default["default"].string,
3326
+ stateReducer: PropTypes__default["default"].func,
3327
+ onSelectedItemChange: PropTypes__default["default"].func,
3328
+ onHighlightedIndexChange: PropTypes__default["default"].func,
3329
+ onStateChange: PropTypes__default["default"].func,
3330
+ onIsOpenChange: PropTypes__default["default"].func,
3331
+ onInputValueChange: PropTypes__default["default"].func,
3332
+ environment: PropTypes__default["default"].shape({
3333
+ addEventListener: PropTypes__default["default"].func,
3334
+ removeEventListener: PropTypes__default["default"].func,
3335
+ document: PropTypes__default["default"].shape({
3336
+ getElementById: PropTypes__default["default"].func,
3337
+ activeElement: PropTypes__default["default"].any,
3338
+ body: PropTypes__default["default"].any
3373
3339
  })
3374
3340
  })
3375
3341
  };
@@ -3387,14 +3353,10 @@
3387
3353
  */
3388
3354
 
3389
3355
  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.
3395
-
3356
+ const previousSelectedItemRef = preact.useRef();
3357
+ const [state, dispatch] = useEnhancedReducer(reducer, initialState, props); // ToDo: if needed, make same approach as selectedItemChanged from Downshift.
3396
3358
 
3397
- preact.useEffect(function () {
3359
+ preact.useEffect(() => {
3398
3360
  if (isControlledProp(props, 'selectedItem')) {
3399
3361
  if (previousSelectedItemRef.current !== props.selectedItem) {
3400
3362
  dispatch({
@@ -3410,27 +3372,29 @@
3410
3372
  } // eslint-disable-next-line import/no-mutable-exports
3411
3373
 
3412
3374
 
3413
- var validatePropTypes$1 = noop;
3375
+ let validatePropTypes$1 = noop;
3414
3376
  /* istanbul ignore next */
3415
3377
 
3416
3378
  {
3417
- validatePropTypes$1 = function validatePropTypes(options, caller) {
3418
- PropTypes__default['default'].checkPropTypes(propTypes$1, options, 'prop', caller.name);
3379
+ validatePropTypes$1 = (options, caller) => {
3380
+ PropTypes__default["default"].checkPropTypes(propTypes$1, options, 'prop', caller.name);
3419
3381
  };
3420
3382
  }
3421
3383
 
3422
- var defaultProps$1 = _extends({}, defaultProps$3, {
3384
+ const defaultProps$1 = { ...defaultProps$3,
3423
3385
  getA11yStatusMessage: getA11yStatusMessage$1,
3424
3386
  circularNavigation: true
3425
- });
3387
+ };
3426
3388
 
3427
3389
  /* eslint-disable complexity */
3428
3390
 
3429
3391
  function downshiftUseComboboxReducer(state, action) {
3430
- var type = action.type,
3431
- props = action.props,
3432
- shiftKey = action.shiftKey;
3433
- var changes;
3392
+ const {
3393
+ type,
3394
+ props,
3395
+ shiftKey
3396
+ } = action;
3397
+ let changes;
3434
3398
 
3435
3399
  switch (type) {
3436
3400
  case ItemClick:
@@ -3471,22 +3435,24 @@
3471
3435
  break;
3472
3436
 
3473
3437
  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
- });
3438
+ changes = { ...(state.isOpen && state.highlightedIndex >= 0 && {
3439
+ selectedItem: props.items[state.highlightedIndex],
3440
+ isOpen: getDefaultValue$1(props, 'isOpen'),
3441
+ highlightedIndex: getDefaultValue$1(props, 'highlightedIndex'),
3442
+ inputValue: props.itemToString(props.items[state.highlightedIndex])
3443
+ })
3444
+ };
3480
3445
  break;
3481
3446
 
3482
3447
  case InputKeyDownEscape:
3483
- changes = _extends({
3448
+ changes = {
3484
3449
  isOpen: false,
3485
- highlightedIndex: -1
3486
- }, !state.isOpen && {
3487
- selectedItem: null,
3488
- inputValue: ''
3489
- });
3450
+ highlightedIndex: -1,
3451
+ ...(!state.isOpen && {
3452
+ selectedItem: null,
3453
+ inputValue: ''
3454
+ })
3455
+ };
3490
3456
  break;
3491
3457
 
3492
3458
  case InputKeyDownHome:
@@ -3502,13 +3468,14 @@
3502
3468
  break;
3503
3469
 
3504
3470
  case InputBlur:
3505
- changes = _extends({
3471
+ changes = {
3506
3472
  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
- });
3473
+ highlightedIndex: -1,
3474
+ ...(state.highlightedIndex >= 0 && action.selectItem && {
3475
+ selectedItem: props.items[state.highlightedIndex],
3476
+ inputValue: props.itemToString(props.items[state.highlightedIndex])
3477
+ })
3478
+ };
3512
3479
  break;
3513
3480
 
3514
3481
  case InputChange:
@@ -3536,15 +3503,13 @@
3536
3503
  return downshiftCommonReducer(state, action, stateChangeTypes$1);
3537
3504
  }
3538
3505
 
3539
- return _extends({}, state, changes);
3506
+ return { ...state,
3507
+ ...changes
3508
+ };
3540
3509
  }
3541
3510
  /* eslint-enable complexity */
3542
3511
 
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"];
3512
+ /* eslint-disable max-statements */
3548
3513
  useCombobox.stateChangeTypes = stateChangeTypes$1;
3549
3514
 
3550
3515
  function useCombobox(userProps) {
@@ -3554,87 +3519,88 @@
3554
3519
 
3555
3520
  validatePropTypes$1(userProps, useCombobox); // Props defaults and destructuring.
3556
3521
 
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
3522
+ const props = { ...defaultProps$1,
3523
+ ...userProps
3524
+ };
3525
+ const {
3526
+ initialIsOpen,
3527
+ defaultIsOpen,
3528
+ items,
3529
+ scrollIntoView,
3530
+ environment,
3531
+ getA11yStatusMessage,
3532
+ getA11ySelectionMessage,
3533
+ itemToString
3534
+ } = props; // Initial state depending on controlled props.
3535
+
3536
+ const initialState = getInitialState$1(props);
3537
+ const [state, dispatch] = useControlledReducer(downshiftUseComboboxReducer, initialState, props);
3538
+ const {
3539
+ isOpen,
3540
+ highlightedIndex,
3541
+ selectedItem,
3542
+ inputValue
3543
+ } = state; // Element refs.
3544
+
3545
+ const menuRef = preact.useRef(null);
3546
+ const itemRefs = preact.useRef({});
3547
+ const inputRef = preact.useRef(null);
3548
+ const toggleButtonRef = preact.useRef(null);
3549
+ const comboboxRef = preact.useRef(null);
3550
+ const isInitialMountRef = preact.useRef(true); // prevent id re-generation between renders.
3551
+
3552
+ const elementIds = useElementIds(props); // used to keep track of how many items we had on previous cycle.
3553
+
3554
+ const previousResultCountRef = preact.useRef(); // utility callback to get item element.
3555
+
3556
+ const latest = useLatestRef({
3557
+ state,
3558
+ props
3593
3559
  });
3594
- var getItemNodeFromIndex = preact.useCallback(function (index) {
3595
- return itemRefs.current[elementIds.getItemId(index)];
3596
- }, [elementIds]); // Effects.
3560
+ const getItemNodeFromIndex = preact.useCallback(index => itemRefs.current[elementIds.getItemId(index)], [elementIds]); // Effects.
3597
3561
  // Sets a11y status message on changes in state.
3598
3562
 
3599
- useA11yMessageSetter(getA11yStatusMessage, [isOpen, highlightedIndex, inputValue, items], _extends({
3563
+ useA11yMessageSetter(getA11yStatusMessage, [isOpen, highlightedIndex, inputValue, items], {
3600
3564
  isInitialMount: isInitialMountRef.current,
3601
3565
  previousResultCount: previousResultCountRef.current,
3602
- items: items,
3603
- environment: environment,
3604
- itemToString: itemToString
3605
- }, state)); // Sets a11y status message on changes in selectedItem.
3566
+ items,
3567
+ environment,
3568
+ itemToString,
3569
+ ...state
3570
+ }); // Sets a11y status message on changes in selectedItem.
3606
3571
 
3607
- useA11yMessageSetter(getA11ySelectionMessage, [selectedItem], _extends({
3572
+ useA11yMessageSetter(getA11ySelectionMessage, [selectedItem], {
3608
3573
  isInitialMount: isInitialMountRef.current,
3609
3574
  previousResultCount: previousResultCountRef.current,
3610
- items: items,
3611
- environment: environment,
3612
- itemToString: itemToString
3613
- }, state)); // Scroll on highlighted item if change comes from keyboard.
3575
+ items,
3576
+ environment,
3577
+ itemToString,
3578
+ ...state
3579
+ }); // Scroll on highlighted item if change comes from keyboard.
3614
3580
 
3615
- var shouldScrollRef = useScrollIntoView({
3581
+ const shouldScrollRef = useScrollIntoView({
3616
3582
  menuElement: menuRef.current,
3617
- highlightedIndex: highlightedIndex,
3618
- isOpen: isOpen,
3619
- itemRefs: itemRefs,
3620
- scrollIntoView: scrollIntoView,
3621
- getItemNodeFromIndex: getItemNodeFromIndex
3583
+ highlightedIndex,
3584
+ isOpen,
3585
+ itemRefs,
3586
+ scrollIntoView,
3587
+ getItemNodeFromIndex
3622
3588
  });
3623
3589
  useControlPropsValidator({
3624
3590
  isInitialMount: isInitialMountRef.current,
3625
- props: props,
3626
- state: state
3591
+ props,
3592
+ state
3627
3593
  }); // Focus the input on first render if required.
3628
3594
 
3629
- preact.useEffect(function () {
3630
- var focusOnOpen = initialIsOpen || defaultIsOpen || isOpen;
3595
+ preact.useEffect(() => {
3596
+ const focusOnOpen = initialIsOpen || defaultIsOpen || isOpen;
3631
3597
 
3632
3598
  if (focusOnOpen && inputRef.current) {
3633
3599
  inputRef.current.focus();
3634
3600
  } // eslint-disable-next-line react-hooks/exhaustive-deps
3635
3601
 
3636
3602
  }, []);
3637
- preact.useEffect(function () {
3603
+ preact.useEffect(() => {
3638
3604
  if (isInitialMountRef.current) {
3639
3605
  return;
3640
3606
  }
@@ -3642,147 +3608,151 @@
3642
3608
  previousResultCountRef.current = items.length;
3643
3609
  }); // Add mouse/touch events to document.
3644
3610
 
3645
- var mouseAndTouchTrackersRef = useMouseAndTouchTracker(isOpen, [comboboxRef, menuRef, toggleButtonRef], environment, function () {
3611
+ const mouseAndTouchTrackersRef = useMouseAndTouchTracker(isOpen, [comboboxRef, menuRef, toggleButtonRef], environment, () => {
3646
3612
  dispatch({
3647
3613
  type: InputBlur,
3648
3614
  selectItem: false
3649
3615
  });
3650
3616
  });
3651
- var setGetterPropCallInfo = useGetterPropsCalledChecker('getInputProps', 'getComboboxProps', 'getMenuProps'); // Make initial ref false.
3617
+ const setGetterPropCallInfo = useGetterPropsCalledChecker('getInputProps', 'getComboboxProps', 'getMenuProps'); // Make initial ref false.
3652
3618
 
3653
- preact.useEffect(function () {
3619
+ preact.useEffect(() => {
3654
3620
  isInitialMountRef.current = false;
3655
3621
  }, []); // Reset itemRefs on close.
3656
3622
 
3657
- preact.useEffect(function () {
3623
+ preact.useEffect(() => {
3658
3624
  if (!isOpen) {
3659
3625
  itemRefs.current = {};
3660
3626
  }
3661
3627
  }, [isOpen]);
3662
3628
  /* Event handler functions */
3663
3629
 
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
- }
3630
+ const inputKeyDownHandlers = preact.useMemo(() => ({
3631
+ ArrowDown(event) {
3632
+ event.preventDefault();
3633
+ dispatch({
3634
+ type: InputKeyDownArrowDown,
3635
+ shiftKey: event.shiftKey,
3636
+ getItemNodeFromIndex
3637
+ });
3638
+ },
3686
3639
 
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
- }
3640
+ ArrowUp(event) {
3641
+ event.preventDefault();
3642
+ dispatch({
3643
+ type: InputKeyDownArrowUp,
3644
+ shiftKey: event.shiftKey,
3645
+ getItemNodeFromIndex
3646
+ });
3647
+ },
3697
3648
 
3698
- event.preventDefault();
3699
- dispatch({
3700
- type: InputKeyDownEnd,
3701
- getItemNodeFromIndex: getItemNodeFromIndex
3702
- });
3703
- },
3704
- Escape: function Escape() {
3705
- var latestState = latest.current.state;
3649
+ Home(event) {
3650
+ if (!latest.current.state.isOpen) {
3651
+ return;
3652
+ }
3706
3653
 
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.
3654
+ event.preventDefault();
3655
+ dispatch({
3656
+ type: InputKeyDownHome,
3657
+ getItemNodeFromIndex
3658
+ });
3659
+ },
3715
3660
 
3716
- if (!latestState.isOpen || latestState.highlightedIndex < 0 || event.which === 229 // if IME composing, wait for next Enter keydown event.
3717
- ) {
3718
- return;
3719
- }
3661
+ End(event) {
3662
+ if (!latest.current.state.isOpen) {
3663
+ return;
3664
+ }
3720
3665
 
3721
- event.preventDefault();
3666
+ event.preventDefault();
3667
+ dispatch({
3668
+ type: InputKeyDownEnd,
3669
+ getItemNodeFromIndex
3670
+ });
3671
+ },
3672
+
3673
+ Escape() {
3674
+ const latestState = latest.current.state;
3675
+
3676
+ if (latestState.isOpen || latestState.inputValue || latestState.selectedItem || latestState.highlightedIndex > -1) {
3722
3677
  dispatch({
3723
- type: InputKeyDownEnter,
3724
- getItemNodeFromIndex: getItemNodeFromIndex
3678
+ type: InputKeyDownEscape
3725
3679
  });
3726
3680
  }
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;
3681
+ },
3749
3682
 
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 () {
3683
+ Enter(event) {
3684
+ const latestState = latest.current.state; // if closed or no highlighted index, do nothing.
3685
+
3686
+ if (!latestState.isOpen || latestState.highlightedIndex < 0 || event.which === 229 // if IME composing, wait for next Enter keydown event.
3687
+ ) {
3688
+ return;
3689
+ }
3690
+
3691
+ event.preventDefault();
3754
3692
  dispatch({
3755
- type: MenuMouseLeave
3693
+ type: InputKeyDownEnter,
3694
+ getItemNodeFromIndex
3756
3695
  });
3757
- }), _extends2), rest);
3696
+ }
3697
+
3698
+ }), [dispatch, latest, getItemNodeFromIndex]); // Getter props.
3699
+
3700
+ const getLabelProps = preact.useCallback(labelProps => ({
3701
+ id: elementIds.labelId,
3702
+ htmlFor: elementIds.inputId,
3703
+ ...labelProps
3704
+ }), [elementIds]);
3705
+ const getMenuProps = preact.useCallback(function (_temp, _temp2) {
3706
+ let {
3707
+ onMouseLeave,
3708
+ refKey = 'ref',
3709
+ ref,
3710
+ ...rest
3711
+ } = _temp === void 0 ? {} : _temp;
3712
+ let {
3713
+ suppressRefError = false
3714
+ } = _temp2 === void 0 ? {} : _temp2;
3715
+ setGetterPropCallInfo('getMenuProps', suppressRefError, refKey, menuRef);
3716
+ return {
3717
+ [refKey]: handleRefs(ref, menuNode => {
3718
+ menuRef.current = menuNode;
3719
+ }),
3720
+ id: elementIds.menuId,
3721
+ role: 'listbox',
3722
+ 'aria-labelledby': elementIds.labelId,
3723
+ onMouseLeave: callAllEventHandlers(onMouseLeave, () => {
3724
+ dispatch({
3725
+ type: MenuMouseLeave
3726
+ });
3727
+ }),
3728
+ ...rest
3729
+ };
3758
3730
  }, [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);
3731
+ const getItemProps = preact.useCallback(function (_temp3) {
3732
+ let {
3733
+ item,
3734
+ index,
3735
+ refKey = 'ref',
3736
+ ref,
3737
+ onMouseMove,
3738
+ onClick,
3739
+ onPress,
3740
+ ...rest
3741
+ } = _temp3 === void 0 ? {} : _temp3;
3742
+ const {
3743
+ props: latestProps,
3744
+ state: latestState
3745
+ } = latest.current;
3746
+ const itemIndex = getItemIndex(index, item, latestProps.items);
3777
3747
 
3778
3748
  if (itemIndex < 0) {
3779
3749
  throw new Error('Pass either item or item index in getItemProps!');
3780
3750
  }
3781
3751
 
3782
- var onSelectKey = 'onClick';
3783
- var customClickHandler = onClick;
3752
+ const onSelectKey = 'onClick';
3753
+ const customClickHandler = onClick;
3784
3754
 
3785
- var itemHandleMouseMove = function itemHandleMouseMove() {
3755
+ const itemHandleMouseMove = () => {
3786
3756
  if (index === latestState.highlightedIndex) {
3787
3757
  return;
3788
3758
  }
@@ -3790,14 +3760,14 @@
3790
3760
  shouldScrollRef.current = false;
3791
3761
  dispatch({
3792
3762
  type: ItemMouseMove,
3793
- index: index
3763
+ index
3794
3764
  });
3795
3765
  };
3796
3766
 
3797
- var itemHandleClick = function itemHandleClick() {
3767
+ const itemHandleClick = () => {
3798
3768
  dispatch({
3799
3769
  type: ItemClick,
3800
- index: index
3770
+ index
3801
3771
  });
3802
3772
 
3803
3773
  if (inputRef.current) {
@@ -3805,26 +3775,32 @@
3805
3775
  }
3806
3776
  };
3807
3777
 
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);
3778
+ return {
3779
+ [refKey]: handleRefs(ref, itemNode => {
3780
+ if (itemNode) {
3781
+ itemRefs.current[elementIds.getItemId(itemIndex)] = itemNode;
3782
+ }
3783
+ }),
3784
+ role: 'option',
3785
+ 'aria-selected': "" + (itemIndex === latestState.highlightedIndex),
3786
+ id: elementIds.getItemId(itemIndex),
3787
+ ...(!rest.disabled && {
3788
+ onMouseMove: callAllEventHandlers(onMouseMove, itemHandleMouseMove),
3789
+ [onSelectKey]: callAllEventHandlers(customClickHandler, itemHandleClick)
3790
+ }),
3791
+ ...rest
3792
+ };
3815
3793
  }, [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() {
3794
+ const getToggleButtonProps = preact.useCallback(function (_temp4) {
3795
+ let {
3796
+ onClick,
3797
+ onPress,
3798
+ refKey = 'ref',
3799
+ ref,
3800
+ ...rest
3801
+ } = _temp4 === void 0 ? {} : _temp4;
3802
+
3803
+ const toggleButtonHandleClick = () => {
3828
3804
  dispatch({
3829
3805
  type: ToggleButtonClick
3830
3806
  });
@@ -3834,49 +3810,52 @@
3834
3810
  }
3835
3811
  };
3836
3812
 
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);
3813
+ return {
3814
+ [refKey]: handleRefs(ref, toggleButtonNode => {
3815
+ toggleButtonRef.current = toggleButtonNode;
3816
+ }),
3817
+ id: elementIds.toggleButtonId,
3818
+ tabIndex: -1,
3819
+ ...(!rest.disabled && { ...({
3820
+ onClick: callAllEventHandlers(onClick, toggleButtonHandleClick)
3821
+ })
3822
+ }),
3823
+ ...rest
3824
+ };
3842
3825
  }, [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
-
3826
+ const getInputProps = preact.useCallback(function (_temp5, _temp6) {
3827
+ let {
3828
+ onKeyDown,
3829
+ onChange,
3830
+ onInput,
3831
+ onBlur,
3832
+ onChangeText,
3833
+ refKey = 'ref',
3834
+ ref,
3835
+ ...rest
3836
+ } = _temp5 === void 0 ? {} : _temp5;
3837
+ let {
3838
+ suppressRefError = false
3839
+ } = _temp6 === void 0 ? {} : _temp6;
3861
3840
  setGetterPropCallInfo('getInputProps', suppressRefError, refKey, inputRef);
3862
- var latestState = latest.current.state;
3841
+ const latestState = latest.current.state;
3863
3842
 
3864
- var inputHandleKeyDown = function inputHandleKeyDown(event) {
3865
- var key = normalizeArrowKey(event);
3843
+ const inputHandleKeyDown = event => {
3844
+ const key = normalizeArrowKey(event);
3866
3845
 
3867
3846
  if (key && inputKeyDownHandlers[key]) {
3868
3847
  inputKeyDownHandlers[key](event);
3869
3848
  }
3870
3849
  };
3871
3850
 
3872
- var inputHandleChange = function inputHandleChange(event) {
3851
+ const inputHandleChange = event => {
3873
3852
  dispatch({
3874
3853
  type: InputChange,
3875
3854
  inputValue: event.target.value
3876
3855
  });
3877
3856
  };
3878
3857
 
3879
- var inputHandleBlur = function inputHandleBlur() {
3858
+ const inputHandleBlur = () => {
3880
3859
  /* istanbul ignore else */
3881
3860
  if (latestState.isOpen && !mouseAndTouchTrackersRef.current.isMouseDown) {
3882
3861
  dispatch({
@@ -3888,109 +3867,121 @@
3888
3867
  /* istanbul ignore next (preact) */
3889
3868
 
3890
3869
 
3891
- var onChangeKey = 'onInput' ;
3892
- var eventHandlers = {};
3870
+ const onChangeKey = 'onInput' ;
3871
+ let eventHandlers = {};
3893
3872
 
3894
3873
  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);
3874
+ eventHandlers = {
3875
+ [onChangeKey]: callAllEventHandlers(onChange, onInput, inputHandleChange),
3876
+ onKeyDown: callAllEventHandlers(onKeyDown, inputHandleKeyDown),
3877
+ onBlur: callAllEventHandlers(onBlur, inputHandleBlur)
3878
+ };
3898
3879
  }
3899
3880
 
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
- }, {
3881
+ return {
3882
+ [refKey]: handleRefs(ref, inputNode => {
3883
+ inputRef.current = inputNode;
3884
+ }),
3885
+ id: elementIds.inputId,
3886
+ 'aria-autocomplete': 'list',
3887
+ 'aria-controls': elementIds.menuId,
3888
+ ...(latestState.isOpen && latestState.highlightedIndex > -1 && {
3889
+ 'aria-activedescendant': elementIds.getItemId(latestState.highlightedIndex)
3890
+ }),
3905
3891
  'aria-labelledby': elementIds.labelId,
3906
3892
  // https://developer.mozilla.org/en-US/docs/Web/Security/Securing_your_site/Turning_off_form_autocompletion
3907
3893
  // revert back since autocomplete="nope" is ignored on latest Chrome and Opera
3908
3894
  autoComplete: 'off',
3909
- value: latestState.inputValue
3910
- }, eventHandlers, rest);
3895
+ value: latestState.inputValue,
3896
+ ...eventHandlers,
3897
+ ...rest
3898
+ };
3911
3899
  }, [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
-
3900
+ const getComboboxProps = preact.useCallback(function (_temp7, _temp8) {
3901
+ let {
3902
+ refKey = 'ref',
3903
+ ref,
3904
+ ...rest
3905
+ } = _temp7 === void 0 ? {} : _temp7;
3906
+ let {
3907
+ suppressRefError = false
3908
+ } = _temp8 === void 0 ? {} : _temp8;
3925
3909
  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);
3910
+ return {
3911
+ [refKey]: handleRefs(ref, comboboxNode => {
3912
+ comboboxRef.current = comboboxNode;
3913
+ }),
3914
+ role: 'combobox',
3915
+ 'aria-haspopup': 'listbox',
3916
+ 'aria-owns': elementIds.menuId,
3917
+ 'aria-expanded': latest.current.state.isOpen,
3918
+ ...rest
3919
+ };
3929
3920
  }, [latest, setGetterPropCallInfo, elementIds]); // returns
3930
3921
 
3931
- var toggleMenu = preact.useCallback(function () {
3922
+ const toggleMenu = preact.useCallback(() => {
3932
3923
  dispatch({
3933
3924
  type: FunctionToggleMenu
3934
3925
  });
3935
3926
  }, [dispatch]);
3936
- var closeMenu = preact.useCallback(function () {
3927
+ const closeMenu = preact.useCallback(() => {
3937
3928
  dispatch({
3938
3929
  type: FunctionCloseMenu
3939
3930
  });
3940
3931
  }, [dispatch]);
3941
- var openMenu = preact.useCallback(function () {
3932
+ const openMenu = preact.useCallback(() => {
3942
3933
  dispatch({
3943
3934
  type: FunctionOpenMenu
3944
3935
  });
3945
3936
  }, [dispatch]);
3946
- var setHighlightedIndex = preact.useCallback(function (newHighlightedIndex) {
3937
+ const setHighlightedIndex = preact.useCallback(newHighlightedIndex => {
3947
3938
  dispatch({
3948
3939
  type: FunctionSetHighlightedIndex,
3949
3940
  highlightedIndex: newHighlightedIndex
3950
3941
  });
3951
3942
  }, [dispatch]);
3952
- var selectItem = preact.useCallback(function (newSelectedItem) {
3943
+ const selectItem = preact.useCallback(newSelectedItem => {
3953
3944
  dispatch({
3954
3945
  type: FunctionSelectItem,
3955
3946
  selectedItem: newSelectedItem
3956
3947
  });
3957
3948
  }, [dispatch]);
3958
- var setInputValue = preact.useCallback(function (newInputValue) {
3949
+ const setInputValue = preact.useCallback(newInputValue => {
3959
3950
  dispatch({
3960
3951
  type: FunctionSetInputValue,
3961
3952
  inputValue: newInputValue
3962
3953
  });
3963
3954
  }, [dispatch]);
3964
- var reset = preact.useCallback(function () {
3955
+ const reset = preact.useCallback(() => {
3965
3956
  dispatch({
3966
3957
  type: FunctionReset$1
3967
3958
  });
3968
3959
  }, [dispatch]);
3969
3960
  return {
3970
3961
  // prop getters.
3971
- getItemProps: getItemProps,
3972
- getLabelProps: getLabelProps,
3973
- getMenuProps: getMenuProps,
3974
- getInputProps: getInputProps,
3975
- getComboboxProps: getComboboxProps,
3976
- getToggleButtonProps: getToggleButtonProps,
3962
+ getItemProps,
3963
+ getLabelProps,
3964
+ getMenuProps,
3965
+ getInputProps,
3966
+ getComboboxProps,
3967
+ getToggleButtonProps,
3977
3968
  // actions.
3978
- toggleMenu: toggleMenu,
3979
- openMenu: openMenu,
3980
- closeMenu: closeMenu,
3981
- setHighlightedIndex: setHighlightedIndex,
3982
- setInputValue: setInputValue,
3983
- selectItem: selectItem,
3984
- reset: reset,
3969
+ toggleMenu,
3970
+ openMenu,
3971
+ closeMenu,
3972
+ setHighlightedIndex,
3973
+ setInputValue,
3974
+ selectItem,
3975
+ reset,
3985
3976
  // state.
3986
- highlightedIndex: highlightedIndex,
3987
- isOpen: isOpen,
3988
- selectedItem: selectedItem,
3989
- inputValue: inputValue
3977
+ highlightedIndex,
3978
+ isOpen,
3979
+ selectedItem,
3980
+ inputValue
3990
3981
  };
3991
3982
  }
3992
3983
 
3993
- var defaultStateValues = {
3984
+ const defaultStateValues = {
3994
3985
  activeIndex: -1,
3995
3986
  selectedItems: []
3996
3987
  };
@@ -4030,11 +4021,11 @@
4030
4021
 
4031
4022
 
4032
4023
  function getInitialState(props) {
4033
- var activeIndex = getInitialValue(props, 'activeIndex');
4034
- var selectedItems = getInitialValue(props, 'selectedItems');
4024
+ const activeIndex = getInitialValue(props, 'activeIndex');
4025
+ const selectedItems = getInitialValue(props, 'selectedItems');
4035
4026
  return {
4036
- activeIndex: activeIndex,
4037
- selectedItems: selectedItems
4027
+ activeIndex,
4028
+ selectedItems
4038
4029
  };
4039
4030
  }
4040
4031
  /**
@@ -4053,10 +4044,12 @@
4053
4044
  return false;
4054
4045
  }
4055
4046
 
4056
- var element = event.target;
4047
+ const element = event.target;
4057
4048
 
4058
4049
  if (element instanceof HTMLInputElement && // if element is a text input
4059
- element.value !== '' && (element.selectionStart !== 0 || element.selectionEnd !== 0)) {
4050
+ element.value !== '' && ( // and we have text in it
4051
+ // and cursor is either not at the start or is currently highlighting text.
4052
+ element.selectionStart !== 0 || element.selectionEnd !== 0)) {
4060
4053
  return false;
4061
4054
  }
4062
4055
 
@@ -4071,66 +4064,68 @@
4071
4064
 
4072
4065
 
4073
4066
  function getA11yRemovalMessage(selectionParameters) {
4074
- var removedSelectedItem = selectionParameters.removedSelectedItem,
4075
- itemToStringLocal = selectionParameters.itemToString;
4067
+ const {
4068
+ removedSelectedItem,
4069
+ itemToString: itemToStringLocal
4070
+ } = selectionParameters;
4076
4071
  return itemToStringLocal(removedSelectedItem) + " has been removed.";
4077
4072
  }
4078
4073
 
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
4074
+ const propTypes = {
4075
+ selectedItems: PropTypes__default["default"].array,
4076
+ initialSelectedItems: PropTypes__default["default"].array,
4077
+ defaultSelectedItems: PropTypes__default["default"].array,
4078
+ itemToString: PropTypes__default["default"].func,
4079
+ getA11yRemovalMessage: PropTypes__default["default"].func,
4080
+ stateReducer: PropTypes__default["default"].func,
4081
+ activeIndex: PropTypes__default["default"].number,
4082
+ initialActiveIndex: PropTypes__default["default"].number,
4083
+ defaultActiveIndex: PropTypes__default["default"].number,
4084
+ onActiveIndexChange: PropTypes__default["default"].func,
4085
+ onSelectedItemsChange: PropTypes__default["default"].func,
4086
+ keyNavigationNext: PropTypes__default["default"].string,
4087
+ keyNavigationPrevious: PropTypes__default["default"].string,
4088
+ environment: PropTypes__default["default"].shape({
4089
+ addEventListener: PropTypes__default["default"].func,
4090
+ removeEventListener: PropTypes__default["default"].func,
4091
+ document: PropTypes__default["default"].shape({
4092
+ getElementById: PropTypes__default["default"].func,
4093
+ activeElement: PropTypes__default["default"].any,
4094
+ body: PropTypes__default["default"].any
4100
4095
  })
4101
4096
  })
4102
4097
  };
4103
- var defaultProps = {
4098
+ const defaultProps = {
4104
4099
  itemToString: defaultProps$3.itemToString,
4105
4100
  stateReducer: defaultProps$3.stateReducer,
4106
4101
  environment: defaultProps$3.environment,
4107
- getA11yRemovalMessage: getA11yRemovalMessage,
4102
+ getA11yRemovalMessage,
4108
4103
  keyNavigationNext: 'ArrowRight',
4109
4104
  keyNavigationPrevious: 'ArrowLeft'
4110
4105
  }; // eslint-disable-next-line import/no-mutable-exports
4111
4106
 
4112
- var validatePropTypes = noop;
4107
+ let validatePropTypes = noop;
4113
4108
  /* istanbul ignore next */
4114
4109
 
4115
4110
  {
4116
- validatePropTypes = function validatePropTypes(options, caller) {
4117
- PropTypes__default['default'].checkPropTypes(propTypes, options, 'prop', caller.name);
4111
+ validatePropTypes = (options, caller) => {
4112
+ PropTypes__default["default"].checkPropTypes(propTypes, options, 'prop', caller.name);
4118
4113
  };
4119
4114
  }
4120
4115
 
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__' ;
4116
+ const SelectedItemClick = '__selected_item_click__' ;
4117
+ const SelectedItemKeyDownDelete = '__selected_item_keydown_delete__' ;
4118
+ const SelectedItemKeyDownBackspace = '__selected_item_keydown_backspace__' ;
4119
+ const SelectedItemKeyDownNavigationNext = '__selected_item_keydown_navigation_next__' ;
4120
+ const SelectedItemKeyDownNavigationPrevious = '__selected_item_keydown_navigation_previous__' ;
4121
+ const DropdownKeyDownNavigationPrevious = '__dropdown_keydown_navigation_previous__' ;
4122
+ const DropdownKeyDownBackspace = '__dropdown_keydown_backspace__' ;
4123
+ const DropdownClick = '__dropdown_click__' ;
4124
+ const FunctionAddSelectedItem = '__function_add_selected_item__' ;
4125
+ const FunctionRemoveSelectedItem = '__function_remove_selected_item__' ;
4126
+ const FunctionSetSelectedItems = '__function_set_selected_items__' ;
4127
+ const FunctionSetActiveIndex = '__function_set_active_index__' ;
4128
+ const FunctionReset = '__function_reset__' ;
4134
4129
 
4135
4130
  var stateChangeTypes = /*#__PURE__*/Object.freeze({
4136
4131
  __proto__: null,
@@ -4152,13 +4147,17 @@
4152
4147
  /* eslint-disable complexity */
4153
4148
 
4154
4149
  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;
4150
+ const {
4151
+ type,
4152
+ index,
4153
+ props,
4154
+ selectedItem
4155
+ } = action;
4156
+ const {
4157
+ activeIndex,
4158
+ selectedItems
4159
+ } = state;
4160
+ let changes;
4162
4161
 
4163
4162
  switch (type) {
4164
4163
  case SelectedItemClick:
@@ -4182,7 +4181,7 @@
4182
4181
  case SelectedItemKeyDownBackspace:
4183
4182
  case SelectedItemKeyDownDelete:
4184
4183
  {
4185
- var newActiveIndex = activeIndex;
4184
+ let newActiveIndex = activeIndex;
4186
4185
 
4187
4186
  if (selectedItems.length === 1) {
4188
4187
  newActiveIndex = -1;
@@ -4190,11 +4189,12 @@
4190
4189
  newActiveIndex = selectedItems.length - 2;
4191
4190
  }
4192
4191
 
4193
- changes = _extends({
4194
- selectedItems: [].concat(selectedItems.slice(0, activeIndex), selectedItems.slice(activeIndex + 1))
4195
- }, {
4196
- activeIndex: newActiveIndex
4197
- });
4192
+ changes = {
4193
+ selectedItems: [...selectedItems.slice(0, activeIndex), ...selectedItems.slice(activeIndex + 1)],
4194
+ ...{
4195
+ activeIndex: newActiveIndex
4196
+ }
4197
+ };
4198
4198
  break;
4199
4199
  }
4200
4200
 
@@ -4212,7 +4212,7 @@
4212
4212
 
4213
4213
  case FunctionAddSelectedItem:
4214
4214
  changes = {
4215
- selectedItems: [].concat(selectedItems, [selectedItem])
4215
+ selectedItems: [...selectedItems, selectedItem]
4216
4216
  };
4217
4217
  break;
4218
4218
 
@@ -4224,26 +4224,30 @@
4224
4224
 
4225
4225
  case FunctionRemoveSelectedItem:
4226
4226
  {
4227
- var _newActiveIndex = activeIndex;
4228
- var selectedItemIndex = selectedItems.indexOf(selectedItem);
4227
+ let newActiveIndex = activeIndex;
4228
+ const selectedItemIndex = selectedItems.indexOf(selectedItem);
4229
+
4230
+ if (selectedItemIndex >= 0) {
4231
+ if (selectedItems.length === 1) {
4232
+ newActiveIndex = -1;
4233
+ } else if (selectedItemIndex === selectedItems.length - 1) {
4234
+ newActiveIndex = selectedItems.length - 2;
4235
+ }
4229
4236
 
4230
- if (selectedItems.length === 1) {
4231
- _newActiveIndex = -1;
4232
- } else if (selectedItemIndex === selectedItems.length - 1) {
4233
- _newActiveIndex = selectedItems.length - 2;
4237
+ changes = {
4238
+ selectedItems: [...selectedItems.slice(0, selectedItemIndex), ...selectedItems.slice(selectedItemIndex + 1)],
4239
+ activeIndex: newActiveIndex
4240
+ };
4234
4241
  }
4235
4242
 
4236
- changes = _extends({
4237
- selectedItems: [].concat(selectedItems.slice(0, selectedItemIndex), selectedItems.slice(selectedItemIndex + 1))
4238
- }, {
4239
- activeIndex: _newActiveIndex
4240
- });
4241
4243
  break;
4242
4244
  }
4243
4245
 
4244
4246
  case FunctionSetSelectedItems:
4245
4247
  {
4246
- var newSelectedItems = action.selectedItems;
4248
+ const {
4249
+ selectedItems: newSelectedItems
4250
+ } = action;
4247
4251
  changes = {
4248
4252
  selectedItems: newSelectedItems
4249
4253
  };
@@ -4252,9 +4256,11 @@
4252
4256
 
4253
4257
  case FunctionSetActiveIndex:
4254
4258
  {
4255
- var _newActiveIndex2 = action.activeIndex;
4259
+ const {
4260
+ activeIndex: newActiveIndex
4261
+ } = action;
4256
4262
  changes = {
4257
- activeIndex: _newActiveIndex2
4263
+ activeIndex: newActiveIndex
4258
4264
  };
4259
4265
  break;
4260
4266
  }
@@ -4270,11 +4276,11 @@
4270
4276
  throw new Error('Reducer called without proper action type.');
4271
4277
  }
4272
4278
 
4273
- return _extends({}, state, changes);
4279
+ return { ...state,
4280
+ ...changes
4281
+ };
4274
4282
  }
4275
4283
 
4276
- var _excluded = ["refKey", "ref", "onClick", "onKeyDown", "selectedItem", "index"],
4277
- _excluded2 = ["refKey", "ref", "onKeyDown", "onClick", "preventKeyAction"];
4278
4284
  useMultipleSelection.stateChangeTypes = stateChangeTypes;
4279
4285
 
4280
4286
  function useMultipleSelection(userProps) {
@@ -4284,47 +4290,47 @@
4284
4290
 
4285
4291
  validatePropTypes(userProps, useMultipleSelection); // Props defaults and destructuring.
4286
4292
 
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();
4293
+ const props = { ...defaultProps,
4294
+ ...userProps
4295
+ };
4296
+ const {
4297
+ getA11yRemovalMessage,
4298
+ itemToString,
4299
+ environment,
4300
+ keyNavigationNext,
4301
+ keyNavigationPrevious
4302
+ } = props; // Reducer init.
4303
+
4304
+ const [state, dispatch] = useControlledReducer$1(downshiftMultipleSelectionReducer, getInitialState(props), props);
4305
+ const {
4306
+ activeIndex,
4307
+ selectedItems
4308
+ } = state; // Refs.
4309
+
4310
+ const isInitialMountRef = preact.useRef(true);
4311
+ const dropdownRef = preact.useRef(null);
4312
+ const previousSelectedItemsRef = preact.useRef(selectedItems);
4313
+ const selectedItemRefs = preact.useRef();
4306
4314
  selectedItemRefs.current = [];
4307
- var latest = useLatestRef({
4308
- state: state,
4309
- props: props
4315
+ const latest = useLatestRef({
4316
+ state,
4317
+ props
4310
4318
  }); // Effects.
4311
4319
 
4312
4320
  /* Sets a11y status message on changes in selectedItem. */
4313
4321
 
4314
- preact.useEffect(function () {
4322
+ preact.useEffect(() => {
4315
4323
  if (isInitialMountRef.current) {
4316
4324
  return;
4317
4325
  }
4318
4326
 
4319
4327
  if (selectedItems.length < previousSelectedItemsRef.current.length) {
4320
- var removedSelectedItem = previousSelectedItemsRef.current.find(function (item) {
4321
- return selectedItems.indexOf(item) < 0;
4322
- });
4328
+ const removedSelectedItem = previousSelectedItemsRef.current.find(item => selectedItems.indexOf(item) < 0);
4323
4329
  setStatus(getA11yRemovalMessage({
4324
- itemToString: itemToString,
4330
+ itemToString,
4325
4331
  resultCount: selectedItems.length,
4326
- removedSelectedItem: removedSelectedItem,
4327
- activeIndex: activeIndex,
4332
+ removedSelectedItem,
4333
+ activeIndex,
4328
4334
  activeSelectedItem: selectedItems[activeIndex]
4329
4335
  }), environment.document);
4330
4336
  }
@@ -4332,7 +4338,7 @@
4332
4338
  previousSelectedItemsRef.current = selectedItems; // eslint-disable-next-line react-hooks/exhaustive-deps
4333
4339
  }, [selectedItems.length]); // Sets focus on active item.
4334
4340
 
4335
- preact.useEffect(function () {
4341
+ preact.useEffect(() => {
4336
4342
  if (isInitialMountRef.current) {
4337
4343
  return;
4338
4344
  }
@@ -4345,181 +4351,191 @@
4345
4351
  }, [activeIndex]);
4346
4352
  useControlPropsValidator({
4347
4353
  isInitialMount: isInitialMountRef.current,
4348
- props: props,
4349
- state: state
4354
+ props,
4355
+ state
4350
4356
  });
4351
- var setGetterPropCallInfo = useGetterPropsCalledChecker('getDropdownProps'); // Make initial ref false.
4357
+ const setGetterPropCallInfo = useGetterPropsCalledChecker('getDropdownProps'); // Make initial ref false.
4352
4358
 
4353
- preact.useEffect(function () {
4359
+ preact.useEffect(() => {
4354
4360
  isInitialMountRef.current = false;
4355
4361
  }, []); // Event handler functions.
4356
4362
 
4357
- var selectedItemKeyDownHandlers = preact.useMemo(function () {
4358
- var _ref;
4359
-
4360
- return _ref = {}, _ref[keyNavigationPrevious] = function () {
4363
+ const selectedItemKeyDownHandlers = preact.useMemo(() => ({
4364
+ [keyNavigationPrevious]() {
4361
4365
  dispatch({
4362
4366
  type: SelectedItemKeyDownNavigationPrevious
4363
4367
  });
4364
- }, _ref[keyNavigationNext] = function () {
4368
+ },
4369
+
4370
+ [keyNavigationNext]() {
4365
4371
  dispatch({
4366
4372
  type: SelectedItemKeyDownNavigationNext
4367
4373
  });
4368
- }, _ref.Delete = function Delete() {
4374
+ },
4375
+
4376
+ Delete() {
4369
4377
  dispatch({
4370
4378
  type: SelectedItemKeyDownDelete
4371
4379
  });
4372
- }, _ref.Backspace = function Backspace() {
4380
+ },
4381
+
4382
+ Backspace() {
4373
4383
  dispatch({
4374
4384
  type: SelectedItemKeyDownBackspace
4375
4385
  });
4376
- }, _ref;
4377
- }, [dispatch, keyNavigationNext, keyNavigationPrevious]);
4378
- var dropdownKeyDownHandlers = preact.useMemo(function () {
4379
- var _ref2;
4386
+ }
4380
4387
 
4381
- return _ref2 = {}, _ref2[keyNavigationPrevious] = function (event) {
4388
+ }), [dispatch, keyNavigationNext, keyNavigationPrevious]);
4389
+ const dropdownKeyDownHandlers = preact.useMemo(() => ({
4390
+ [keyNavigationPrevious](event) {
4382
4391
  if (isKeyDownOperationPermitted(event)) {
4383
4392
  dispatch({
4384
4393
  type: DropdownKeyDownNavigationPrevious
4385
4394
  });
4386
4395
  }
4387
- }, _ref2.Backspace = function Backspace(event) {
4396
+ },
4397
+
4398
+ Backspace(event) {
4388
4399
  if (isKeyDownOperationPermitted(event)) {
4389
4400
  dispatch({
4390
4401
  type: DropdownKeyDownBackspace
4391
4402
  });
4392
4403
  }
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);
4404
+ }
4408
4405
 
4409
- var latestState = latest.current.state;
4410
- var itemIndex = getItemIndex(index, selectedItem, latestState.selectedItems);
4406
+ }), [dispatch, keyNavigationPrevious]); // Getter props.
4407
+
4408
+ const getSelectedItemProps = preact.useCallback(function (_temp) {
4409
+ let {
4410
+ refKey = 'ref',
4411
+ ref,
4412
+ onClick,
4413
+ onKeyDown,
4414
+ selectedItem,
4415
+ index,
4416
+ ...rest
4417
+ } = _temp === void 0 ? {} : _temp;
4418
+ const {
4419
+ state: latestState
4420
+ } = latest.current;
4421
+ const itemIndex = getItemIndex(index, selectedItem, latestState.selectedItems);
4411
4422
 
4412
4423
  if (itemIndex < 0) {
4413
4424
  throw new Error('Pass either selectedItem or index in getSelectedItemProps!');
4414
4425
  }
4415
4426
 
4416
- var selectedItemHandleClick = function selectedItemHandleClick() {
4427
+ const selectedItemHandleClick = () => {
4417
4428
  dispatch({
4418
4429
  type: SelectedItemClick,
4419
- index: index
4430
+ index
4420
4431
  });
4421
4432
  };
4422
4433
 
4423
- var selectedItemHandleKeyDown = function selectedItemHandleKeyDown(event) {
4424
- var key = normalizeArrowKey(event);
4434
+ const selectedItemHandleKeyDown = event => {
4435
+ const key = normalizeArrowKey(event);
4425
4436
 
4426
4437
  if (key && selectedItemKeyDownHandlers[key]) {
4427
4438
  selectedItemKeyDownHandlers[key](event);
4428
4439
  }
4429
4440
  };
4430
4441
 
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);
4442
+ return {
4443
+ [refKey]: handleRefs(ref, selectedItemNode => {
4444
+ if (selectedItemNode) {
4445
+ selectedItemRefs.current.push(selectedItemNode);
4446
+ }
4447
+ }),
4448
+ tabIndex: index === latestState.activeIndex ? 0 : -1,
4449
+ onClick: callAllEventHandlers(onClick, selectedItemHandleClick),
4450
+ onKeyDown: callAllEventHandlers(onKeyDown, selectedItemHandleKeyDown),
4451
+ ...rest
4452
+ };
4436
4453
  }, [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
-
4454
+ const getDropdownProps = preact.useCallback(function (_temp2, _temp3) {
4455
+ let {
4456
+ refKey = 'ref',
4457
+ ref,
4458
+ onKeyDown,
4459
+ onClick,
4460
+ preventKeyAction = false,
4461
+ ...rest
4462
+ } = _temp2 === void 0 ? {} : _temp2;
4463
+ let {
4464
+ suppressRefError = false
4465
+ } = _temp3 === void 0 ? {} : _temp3;
4454
4466
  setGetterPropCallInfo('getDropdownProps', suppressRefError, refKey, dropdownRef);
4455
4467
 
4456
- var dropdownHandleKeyDown = function dropdownHandleKeyDown(event) {
4457
- var key = normalizeArrowKey(event);
4468
+ const dropdownHandleKeyDown = event => {
4469
+ const key = normalizeArrowKey(event);
4458
4470
 
4459
4471
  if (key && dropdownKeyDownHandlers[key]) {
4460
4472
  dropdownKeyDownHandlers[key](event);
4461
4473
  }
4462
4474
  };
4463
4475
 
4464
- var dropdownHandleClick = function dropdownHandleClick() {
4476
+ const dropdownHandleClick = () => {
4465
4477
  dispatch({
4466
4478
  type: DropdownClick
4467
4479
  });
4468
4480
  };
4469
4481
 
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);
4482
+ return {
4483
+ [refKey]: handleRefs(ref, dropdownNode => {
4484
+ if (dropdownNode) {
4485
+ dropdownRef.current = dropdownNode;
4486
+ }
4487
+ }),
4488
+ ...(!preventKeyAction && {
4489
+ onKeyDown: callAllEventHandlers(onKeyDown, dropdownHandleKeyDown),
4490
+ onClick: callAllEventHandlers(onClick, dropdownHandleClick)
4491
+ }),
4492
+ ...rest
4493
+ };
4478
4494
  }, [dispatch, dropdownKeyDownHandlers, setGetterPropCallInfo]); // returns
4479
4495
 
4480
- var addSelectedItem = preact.useCallback(function (selectedItem) {
4496
+ const addSelectedItem = preact.useCallback(selectedItem => {
4481
4497
  dispatch({
4482
4498
  type: FunctionAddSelectedItem,
4483
- selectedItem: selectedItem
4499
+ selectedItem
4484
4500
  });
4485
4501
  }, [dispatch]);
4486
- var removeSelectedItem = preact.useCallback(function (selectedItem) {
4502
+ const removeSelectedItem = preact.useCallback(selectedItem => {
4487
4503
  dispatch({
4488
4504
  type: FunctionRemoveSelectedItem,
4489
- selectedItem: selectedItem
4505
+ selectedItem
4490
4506
  });
4491
4507
  }, [dispatch]);
4492
- var setSelectedItems = preact.useCallback(function (newSelectedItems) {
4508
+ const setSelectedItems = preact.useCallback(newSelectedItems => {
4493
4509
  dispatch({
4494
4510
  type: FunctionSetSelectedItems,
4495
4511
  selectedItems: newSelectedItems
4496
4512
  });
4497
4513
  }, [dispatch]);
4498
- var setActiveIndex = preact.useCallback(function (newActiveIndex) {
4514
+ const setActiveIndex = preact.useCallback(newActiveIndex => {
4499
4515
  dispatch({
4500
4516
  type: FunctionSetActiveIndex,
4501
4517
  activeIndex: newActiveIndex
4502
4518
  });
4503
4519
  }, [dispatch]);
4504
- var reset = preact.useCallback(function () {
4520
+ const reset = preact.useCallback(() => {
4505
4521
  dispatch({
4506
4522
  type: FunctionReset
4507
4523
  });
4508
4524
  }, [dispatch]);
4509
4525
  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
4526
+ getSelectedItemProps,
4527
+ getDropdownProps,
4528
+ addSelectedItem,
4529
+ removeSelectedItem,
4530
+ setSelectedItems,
4531
+ setActiveIndex,
4532
+ reset,
4533
+ selectedItems,
4534
+ activeIndex
4519
4535
  };
4520
4536
  }
4521
4537
 
4522
- exports['default'] = Downshift$1;
4538
+ exports["default"] = Downshift$1;
4523
4539
  exports.resetIdCounter = resetIdCounter;
4524
4540
  exports.useCombobox = useCombobox;
4525
4541
  exports.useMultipleSelection = useMultipleSelection;
@@ -4527,5 +4543,5 @@
4527
4543
 
4528
4544
  Object.defineProperty(exports, '__esModule', { value: true });
4529
4545
 
4530
- })));
4546
+ }));
4531
4547
  //# sourceMappingURL=downshift.umd.js.map