downshift 7.1.2 → 7.1.3-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,14 +1,10 @@
1
- import _objectWithoutPropertiesLoose from '@babel/runtime/helpers/esm/objectWithoutPropertiesLoose';
2
- import _extends from '@babel/runtime/helpers/esm/extends';
3
- import _assertThisInitialized from '@babel/runtime/helpers/esm/assertThisInitialized';
4
- import _inheritsLoose from '@babel/runtime/helpers/esm/inheritsLoose';
5
1
  import PropTypes from 'prop-types';
6
- import { cloneElement, Component, useRef, useEffect, useCallback, useLayoutEffect, useReducer, useMemo } from 'react';
2
+ import { Component, cloneElement, useRef, useEffect, useCallback, useLayoutEffect, useReducer, useMemo } from 'react';
7
3
  import { isForwardRef } from 'react-is';
8
- import computeScrollIntoView from 'compute-scroll-into-view';
4
+ import compute from 'compute-scroll-into-view';
9
5
  import { __assign } from 'tslib';
10
6
 
11
- var idCounter = 0;
7
+ let idCounter = 0;
12
8
 
13
9
  /**
14
10
  * Accepts a parameter and returns it if it's a function
@@ -32,15 +28,17 @@ function scrollIntoView(node, menuNode) {
32
28
  if (!node) {
33
29
  return;
34
30
  }
35
- var actions = computeScrollIntoView(node, {
31
+ const actions = compute(node, {
36
32
  boundary: menuNode,
37
33
  block: 'nearest',
38
34
  scrollMode: 'if-needed'
39
35
  });
40
- actions.forEach(function (_ref) {
41
- var el = _ref.el,
42
- top = _ref.top,
43
- left = _ref.left;
36
+ actions.forEach(_ref => {
37
+ let {
38
+ el,
39
+ top,
40
+ left
41
+ } = _ref;
44
42
  el.scrollTop = top;
45
43
  el.scrollLeft = left;
46
44
  });
@@ -53,7 +51,7 @@ function scrollIntoView(node, menuNode) {
53
51
  * @return {Boolean} whether the parent is the child or the child is in the parent
54
52
  */
55
53
  function isOrContainsNode(parent, child, environment) {
56
- var result = parent === child || child instanceof environment.Node && parent.contains && parent.contains(child);
54
+ const result = parent === child || child instanceof environment.Node && parent.contains && parent.contains(child);
57
55
  return result;
58
56
  }
59
57
 
@@ -66,7 +64,7 @@ function isOrContainsNode(parent, child, environment) {
66
64
  * @return {Function} the debounced function
67
65
  */
68
66
  function debounce(fn, time) {
69
- var timeoutId;
67
+ let timeoutId;
70
68
  function cancel() {
71
69
  if (timeoutId) {
72
70
  clearTimeout(timeoutId);
@@ -77,9 +75,9 @@ function debounce(fn, time) {
77
75
  args[_key] = arguments[_key];
78
76
  }
79
77
  cancel();
80
- timeoutId = setTimeout(function () {
78
+ timeoutId = setTimeout(() => {
81
79
  timeoutId = null;
82
- fn.apply(void 0, args);
80
+ fn(...args);
83
81
  }, time);
84
82
  }
85
83
  wrapper.cancel = cancel;
@@ -101,9 +99,9 @@ function callAllEventHandlers() {
101
99
  for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
102
100
  args[_key3 - 1] = arguments[_key3];
103
101
  }
104
- return fns.some(function (fn) {
102
+ return fns.some(fn => {
105
103
  if (fn) {
106
- fn.apply(void 0, [event].concat(args));
104
+ fn(event, ...args);
107
105
  }
108
106
  return event.preventDownshiftDefault || event.hasOwnProperty('nativeEvent') && event.nativeEvent.preventDownshiftDefault;
109
107
  });
@@ -113,8 +111,8 @@ function handleRefs() {
113
111
  for (var _len4 = arguments.length, refs = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
114
112
  refs[_key4] = arguments[_key4];
115
113
  }
116
- return function (node) {
117
- refs.forEach(function (ref) {
114
+ return node => {
115
+ refs.forEach(ref => {
118
116
  if (typeof ref === 'function') {
119
117
  ref(node);
120
118
  } else if (ref) {
@@ -148,9 +146,11 @@ function resetIdCounter() {
148
146
  * @return {String} the a11y status message
149
147
  */
150
148
  function getA11yStatusMessage$1(_ref2) {
151
- var isOpen = _ref2.isOpen,
152
- resultCount = _ref2.resultCount,
153
- previousResultCount = _ref2.previousResultCount;
149
+ let {
150
+ isOpen,
151
+ resultCount,
152
+ previousResultCount
153
+ } = _ref2;
154
154
  if (!isOpen) {
155
155
  return '';
156
156
  }
@@ -158,7 +158,7 @@ function getA11yStatusMessage$1(_ref2) {
158
158
  return 'No results are available.';
159
159
  }
160
160
  if (resultCount !== previousResultCount) {
161
- return resultCount + " result" + (resultCount === 1 ? ' is' : 's are') + " available, use up and down arrow keys to navigate. Press Enter key to select.";
161
+ return `${resultCount} result${resultCount === 1 ? ' is' : 's are'} available, use up and down arrow keys to navigate. Press Enter key to select.`;
162
162
  }
163
163
  return '';
164
164
  }
@@ -205,9 +205,9 @@ function getElementProps(element) {
205
205
  */
206
206
  function requiredProp(fnName, propName) {
207
207
  // eslint-disable-next-line no-console
208
- console.error("The property \"" + propName + "\" is required in \"" + fnName + "\"");
208
+ console.error(`The property "${propName}" is required in "${fnName}"`);
209
209
  }
210
- var stateKeys = ['highlightedIndex', 'inputValue', 'isOpen', 'selectedItem', 'type'];
210
+ const stateKeys = ['highlightedIndex', 'inputValue', 'isOpen', 'selectedItem', 'type'];
211
211
  /**
212
212
  * @param {Object} state the state object
213
213
  * @return {Object} state that is relevant to downshift
@@ -216,8 +216,8 @@ function pickState(state) {
216
216
  if (state === void 0) {
217
217
  state = {};
218
218
  }
219
- var result = {};
220
- stateKeys.forEach(function (k) {
219
+ const result = {};
220
+ stateKeys.forEach(k => {
221
221
  if (state.hasOwnProperty(k)) {
222
222
  result[k] = state[k];
223
223
  }
@@ -237,7 +237,7 @@ function pickState(state) {
237
237
  * @returns {Object} The merged controlled state.
238
238
  */
239
239
  function getState(state, props) {
240
- return Object.keys(state).reduce(function (prevState, key) {
240
+ return Object.keys(state).reduce((prevState, key) => {
241
241
  prevState[key] = isControlledProp(props, key) ? props[key] : state[key];
242
242
  return prevState;
243
243
  }, {});
@@ -262,11 +262,13 @@ function isControlledProp(props, key) {
262
262
  * @return {String} keyboard key
263
263
  */
264
264
  function normalizeArrowKey(event) {
265
- var key = event.key,
266
- keyCode = event.keyCode;
265
+ const {
266
+ key,
267
+ keyCode
268
+ } = event;
267
269
  /* istanbul ignore next (ie) */
268
270
  if (keyCode >= 37 && keyCode <= 40 && key.indexOf('Arrow') !== 0) {
269
- return "Arrow" + key;
271
+ return `Arrow${key}`;
270
272
  }
271
273
  return key;
272
274
  }
@@ -298,17 +300,17 @@ function getNextWrappingIndex(moveAmount, baseIndex, itemCount, getItemNodeFromI
298
300
  if (itemCount === 0) {
299
301
  return -1;
300
302
  }
301
- var itemsLastIndex = itemCount - 1;
303
+ const itemsLastIndex = itemCount - 1;
302
304
  if (typeof baseIndex !== 'number' || baseIndex < 0 || baseIndex >= itemCount) {
303
305
  baseIndex = moveAmount > 0 ? -1 : itemsLastIndex + 1;
304
306
  }
305
- var newIndex = baseIndex + moveAmount;
307
+ let newIndex = baseIndex + moveAmount;
306
308
  if (newIndex < 0) {
307
309
  newIndex = circular ? itemsLastIndex : 0;
308
310
  } else if (newIndex > itemsLastIndex) {
309
311
  newIndex = circular ? 0 : itemsLastIndex;
310
312
  }
311
- var nonDisabledNewIndex = getNextNonDisabledIndex(moveAmount, newIndex, itemCount, getItemNodeFromIndex, circular);
313
+ const nonDisabledNewIndex = getNextNonDisabledIndex(moveAmount, newIndex, itemCount, getItemNodeFromIndex, circular);
312
314
  if (nonDisabledNewIndex === -1) {
313
315
  return baseIndex >= itemCount ? -1 : baseIndex;
314
316
  }
@@ -326,20 +328,20 @@ function getNextWrappingIndex(moveAmount, baseIndex, itemCount, getItemNodeFromI
326
328
  * @returns {number} The new index. Returns baseIndex if item is not disabled. Returns next non-disabled item otherwise. If no non-disabled found it will return -1.
327
329
  */
328
330
  function getNextNonDisabledIndex(moveAmount, baseIndex, itemCount, getItemNodeFromIndex, circular) {
329
- var currentElementNode = getItemNodeFromIndex(baseIndex);
331
+ const currentElementNode = getItemNodeFromIndex(baseIndex);
330
332
  if (!currentElementNode || !currentElementNode.hasAttribute('disabled')) {
331
333
  return baseIndex;
332
334
  }
333
335
  if (moveAmount > 0) {
334
- for (var index = baseIndex + 1; index < itemCount; index++) {
336
+ for (let index = baseIndex + 1; index < itemCount; index++) {
335
337
  if (!getItemNodeFromIndex(index).hasAttribute('disabled')) {
336
338
  return index;
337
339
  }
338
340
  }
339
341
  } else {
340
- for (var _index = baseIndex - 1; _index >= 0; _index--) {
341
- if (!getItemNodeFromIndex(_index).hasAttribute('disabled')) {
342
- return _index;
342
+ for (let index = baseIndex - 1; index >= 0; index--) {
343
+ if (!getItemNodeFromIndex(index).hasAttribute('disabled')) {
344
+ return index;
343
345
  }
344
346
  }
345
347
  }
@@ -363,30 +365,28 @@ function targetWithinDownshift(target, downshiftElements, environment, checkActi
363
365
  if (checkActiveElement === void 0) {
364
366
  checkActiveElement = true;
365
367
  }
366
- return downshiftElements.some(function (contextNode) {
367
- return contextNode && (isOrContainsNode(contextNode, target, environment) || checkActiveElement && isOrContainsNode(contextNode, environment.document.activeElement, environment));
368
- });
368
+ return downshiftElements.some(contextNode => contextNode && (isOrContainsNode(contextNode, target, environment) || checkActiveElement && isOrContainsNode(contextNode, environment.document.activeElement, environment)));
369
369
  }
370
370
 
371
371
  // eslint-disable-next-line import/no-mutable-exports
372
- var validateControlledUnchanged = noop;
372
+ let validateControlledUnchanged = noop;
373
373
  /* istanbul ignore next */
374
374
  if (process.env.NODE_ENV !== 'production') {
375
- validateControlledUnchanged = function validateControlledUnchanged(state, prevProps, nextProps) {
376
- 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";
377
- Object.keys(state).forEach(function (propKey) {
375
+ validateControlledUnchanged = (state, prevProps, nextProps) => {
376
+ 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`;
377
+ Object.keys(state).forEach(propKey => {
378
378
  if (prevProps[propKey] !== undefined && nextProps[propKey] === undefined) {
379
379
  // eslint-disable-next-line no-console
380
- console.error("downshift: A component has changed the controlled prop \"" + propKey + "\" to be uncontrolled. " + warningDescription);
380
+ console.error(`downshift: A component has changed the controlled prop "${propKey}" to be uncontrolled. ${warningDescription}`);
381
381
  } else if (prevProps[propKey] === undefined && nextProps[propKey] !== undefined) {
382
382
  // eslint-disable-next-line no-console
383
- console.error("downshift: A component has changed the uncontrolled prop \"" + propKey + "\" to be controlled. " + warningDescription);
383
+ console.error(`downshift: A component has changed the uncontrolled prop "${propKey}" to be controlled. ${warningDescription}`);
384
384
  }
385
385
  });
386
386
  };
387
387
  }
388
388
 
389
- var cleanupStatus = debounce(function (documentProp) {
389
+ const cleanupStatus = debounce(documentProp => {
390
390
  getStatusDiv(documentProp).textContent = '';
391
391
  }, 500);
392
392
 
@@ -395,7 +395,7 @@ var cleanupStatus = debounce(function (documentProp) {
395
395
  * @param {Object} documentProp document passed by the user.
396
396
  */
397
397
  function setStatus(status, documentProp) {
398
- var div = getStatusDiv(documentProp);
398
+ const div = getStatusDiv(documentProp);
399
399
  if (!status) {
400
400
  return;
401
401
  }
@@ -412,7 +412,7 @@ function getStatusDiv(documentProp) {
412
412
  if (documentProp === void 0) {
413
413
  documentProp = document;
414
414
  }
415
- var statusDiv = documentProp.getElementById('a11y-status-message');
415
+ let statusDiv = documentProp.getElementById('a11y-status-message');
416
416
  if (statusDiv) {
417
417
  return statusDiv;
418
418
  }
@@ -435,23 +435,23 @@ function getStatusDiv(documentProp) {
435
435
  return statusDiv;
436
436
  }
437
437
 
438
- var unknown = process.env.NODE_ENV !== "production" ? '__autocomplete_unknown__' : 0;
439
- var mouseUp = process.env.NODE_ENV !== "production" ? '__autocomplete_mouseup__' : 1;
440
- var itemMouseEnter = process.env.NODE_ENV !== "production" ? '__autocomplete_item_mouseenter__' : 2;
441
- var keyDownArrowUp = process.env.NODE_ENV !== "production" ? '__autocomplete_keydown_arrow_up__' : 3;
442
- var keyDownArrowDown = process.env.NODE_ENV !== "production" ? '__autocomplete_keydown_arrow_down__' : 4;
443
- var keyDownEscape = process.env.NODE_ENV !== "production" ? '__autocomplete_keydown_escape__' : 5;
444
- var keyDownEnter = process.env.NODE_ENV !== "production" ? '__autocomplete_keydown_enter__' : 6;
445
- var keyDownHome = process.env.NODE_ENV !== "production" ? '__autocomplete_keydown_home__' : 7;
446
- var keyDownEnd = process.env.NODE_ENV !== "production" ? '__autocomplete_keydown_end__' : 8;
447
- var clickItem = process.env.NODE_ENV !== "production" ? '__autocomplete_click_item__' : 9;
448
- var blurInput = process.env.NODE_ENV !== "production" ? '__autocomplete_blur_input__' : 10;
449
- var changeInput = process.env.NODE_ENV !== "production" ? '__autocomplete_change_input__' : 11;
450
- var keyDownSpaceButton = process.env.NODE_ENV !== "production" ? '__autocomplete_keydown_space_button__' : 12;
451
- var clickButton = process.env.NODE_ENV !== "production" ? '__autocomplete_click_button__' : 13;
452
- var blurButton = process.env.NODE_ENV !== "production" ? '__autocomplete_blur_button__' : 14;
453
- var controlledPropUpdatedSelectedItem = process.env.NODE_ENV !== "production" ? '__autocomplete_controlled_prop_updated_selected_item__' : 15;
454
- var touchEnd = process.env.NODE_ENV !== "production" ? '__autocomplete_touchend__' : 16;
438
+ const unknown = process.env.NODE_ENV !== "production" ? '__autocomplete_unknown__' : 0;
439
+ const mouseUp = process.env.NODE_ENV !== "production" ? '__autocomplete_mouseup__' : 1;
440
+ const itemMouseEnter = process.env.NODE_ENV !== "production" ? '__autocomplete_item_mouseenter__' : 2;
441
+ const keyDownArrowUp = process.env.NODE_ENV !== "production" ? '__autocomplete_keydown_arrow_up__' : 3;
442
+ const keyDownArrowDown = process.env.NODE_ENV !== "production" ? '__autocomplete_keydown_arrow_down__' : 4;
443
+ const keyDownEscape = process.env.NODE_ENV !== "production" ? '__autocomplete_keydown_escape__' : 5;
444
+ const keyDownEnter = process.env.NODE_ENV !== "production" ? '__autocomplete_keydown_enter__' : 6;
445
+ const keyDownHome = process.env.NODE_ENV !== "production" ? '__autocomplete_keydown_home__' : 7;
446
+ const keyDownEnd = process.env.NODE_ENV !== "production" ? '__autocomplete_keydown_end__' : 8;
447
+ const clickItem = process.env.NODE_ENV !== "production" ? '__autocomplete_click_item__' : 9;
448
+ const blurInput = process.env.NODE_ENV !== "production" ? '__autocomplete_blur_input__' : 10;
449
+ const changeInput = process.env.NODE_ENV !== "production" ? '__autocomplete_change_input__' : 11;
450
+ const keyDownSpaceButton = process.env.NODE_ENV !== "production" ? '__autocomplete_keydown_space_button__' : 12;
451
+ const clickButton = process.env.NODE_ENV !== "production" ? '__autocomplete_click_button__' : 13;
452
+ const blurButton = process.env.NODE_ENV !== "production" ? '__autocomplete_blur_button__' : 14;
453
+ const controlledPropUpdatedSelectedItem = process.env.NODE_ENV !== "production" ? '__autocomplete_controlled_prop_updated_selected_item__' : 15;
454
+ const touchEnd = process.env.NODE_ENV !== "production" ? '__autocomplete_touchend__' : 16;
455
455
 
456
456
  var stateChangeTypes$3 = /*#__PURE__*/Object.freeze({
457
457
  __proto__: null,
@@ -474,48 +474,37 @@ var stateChangeTypes$3 = /*#__PURE__*/Object.freeze({
474
474
  touchEnd: touchEnd
475
475
  });
476
476
 
477
- var _excluded$4 = ["refKey", "ref"],
478
- _excluded2$3 = ["onClick", "onPress", "onKeyDown", "onKeyUp", "onBlur"],
479
- _excluded3$2 = ["onKeyDown", "onBlur", "onChange", "onInput", "onChangeText"],
480
- _excluded4$1 = ["refKey", "ref"],
481
- _excluded5 = ["onMouseMove", "onMouseDown", "onClick", "onPress", "index", "item"];
482
- var Downshift = /*#__PURE__*/function () {
483
- var Downshift = /*#__PURE__*/function (_Component) {
484
- _inheritsLoose(Downshift, _Component);
485
- function Downshift(_props) {
477
+ /* eslint camelcase:0 */
478
+ const Downshift = /*#__PURE__*/(() => {
479
+ class Downshift extends Component {
480
+ constructor(_props) {
486
481
  var _this;
487
- _this = _Component.call(this, _props) || this;
488
- // fancy destructuring + defaults + aliases
489
- // this basically says each value of state should either be set to
490
- // the initial value or the default value if the initial value is not provided
491
- _this.id = _this.props.id || "downshift-" + generateId();
492
- _this.menuId = _this.props.menuId || _this.id + "-menu";
493
- _this.labelId = _this.props.labelId || _this.id + "-label";
494
- _this.inputId = _this.props.inputId || _this.id + "-input";
495
- _this.getItemId = _this.props.getItemId || function (index) {
496
- return _this.id + "-item-" + index;
497
- };
498
- _this.input = null;
499
- _this.items = [];
500
- _this.itemCount = null;
501
- _this.previousResultCount = 0;
502
- _this.timeoutIds = [];
503
- _this.internalSetTimeout = function (fn, time) {
504
- var id = setTimeout(function () {
505
- _this.timeoutIds = _this.timeoutIds.filter(function (i) {
506
- return i !== id;
507
- });
482
+ super(_props);
483
+ _this = this;
484
+ this.id = this.props.id || `downshift-${generateId()}`;
485
+ this.menuId = this.props.menuId || `${this.id}-menu`;
486
+ this.labelId = this.props.labelId || `${this.id}-label`;
487
+ this.inputId = this.props.inputId || `${this.id}-input`;
488
+ this.getItemId = this.props.getItemId || (index => `${this.id}-item-${index}`);
489
+ this.input = null;
490
+ this.items = [];
491
+ this.itemCount = null;
492
+ this.previousResultCount = 0;
493
+ this.timeoutIds = [];
494
+ this.internalSetTimeout = (fn, time) => {
495
+ const id = setTimeout(() => {
496
+ this.timeoutIds = this.timeoutIds.filter(i => i !== id);
508
497
  fn();
509
498
  }, time);
510
- _this.timeoutIds.push(id);
499
+ this.timeoutIds.push(id);
511
500
  };
512
- _this.setItemCount = function (count) {
513
- _this.itemCount = count;
501
+ this.setItemCount = count => {
502
+ this.itemCount = count;
514
503
  };
515
- _this.unsetItemCount = function () {
516
- _this.itemCount = null;
504
+ this.unsetItemCount = () => {
505
+ this.itemCount = null;
517
506
  };
518
- _this.setHighlightedIndex = function (highlightedIndex, otherStateToSet) {
507
+ this.setHighlightedIndex = function (highlightedIndex, otherStateToSet) {
519
508
  if (highlightedIndex === void 0) {
520
509
  highlightedIndex = _this.props.defaultHighlightedIndex;
521
510
  }
@@ -523,41 +512,43 @@ var Downshift = /*#__PURE__*/function () {
523
512
  otherStateToSet = {};
524
513
  }
525
514
  otherStateToSet = pickState(otherStateToSet);
526
- _this.internalSetState(_extends({
527
- highlightedIndex: highlightedIndex
528
- }, otherStateToSet));
529
- };
530
- _this.clearSelection = function (cb) {
531
515
  _this.internalSetState({
516
+ highlightedIndex,
517
+ ...otherStateToSet
518
+ });
519
+ };
520
+ this.clearSelection = cb => {
521
+ this.internalSetState({
532
522
  selectedItem: null,
533
523
  inputValue: '',
534
- highlightedIndex: _this.props.defaultHighlightedIndex,
535
- isOpen: _this.props.defaultIsOpen
524
+ highlightedIndex: this.props.defaultHighlightedIndex,
525
+ isOpen: this.props.defaultIsOpen
536
526
  }, cb);
537
527
  };
538
- _this.selectItem = function (item, otherStateToSet, cb) {
528
+ this.selectItem = (item, otherStateToSet, cb) => {
539
529
  otherStateToSet = pickState(otherStateToSet);
540
- _this.internalSetState(_extends({
541
- isOpen: _this.props.defaultIsOpen,
542
- highlightedIndex: _this.props.defaultHighlightedIndex,
530
+ this.internalSetState({
531
+ isOpen: this.props.defaultIsOpen,
532
+ highlightedIndex: this.props.defaultHighlightedIndex,
543
533
  selectedItem: item,
544
- inputValue: _this.props.itemToString(item)
545
- }, otherStateToSet), cb);
534
+ inputValue: this.props.itemToString(item),
535
+ ...otherStateToSet
536
+ }, cb);
546
537
  };
547
- _this.selectItemAtIndex = function (itemIndex, otherStateToSet, cb) {
548
- var item = _this.items[itemIndex];
538
+ this.selectItemAtIndex = (itemIndex, otherStateToSet, cb) => {
539
+ const item = this.items[itemIndex];
549
540
  if (item == null) {
550
541
  return;
551
542
  }
552
- _this.selectItem(item, otherStateToSet, cb);
543
+ this.selectItem(item, otherStateToSet, cb);
553
544
  };
554
- _this.selectHighlightedItem = function (otherStateToSet, cb) {
555
- return _this.selectItemAtIndex(_this.getState().highlightedIndex, otherStateToSet, cb);
545
+ this.selectHighlightedItem = (otherStateToSet, cb) => {
546
+ return this.selectItemAtIndex(this.getState().highlightedIndex, otherStateToSet, cb);
556
547
  };
557
- _this.internalSetState = function (stateToSet, cb) {
558
- var isItemSelected, onChangeArg;
559
- var onStateChangeArg = {};
560
- var isStateToSetFunction = typeof stateToSet === 'function';
548
+ this.internalSetState = (stateToSet, cb) => {
549
+ let isItemSelected, onChangeArg;
550
+ const onStateChangeArg = {};
551
+ const isStateToSetFunction = typeof stateToSet === 'function';
561
552
 
562
553
  // we want to call `onInputValueChange` before the `setState` call
563
554
  // so someone controlling the `inputValue` state gets notified of
@@ -565,21 +556,24 @@ var Downshift = /*#__PURE__*/function () {
565
556
  // preserving the cursor position.
566
557
  // See https://github.com/downshift-js/downshift/issues/217 for more info.
567
558
  if (!isStateToSetFunction && stateToSet.hasOwnProperty('inputValue')) {
568
- _this.props.onInputValueChange(stateToSet.inputValue, _extends({}, _this.getStateAndHelpers(), stateToSet));
559
+ this.props.onInputValueChange(stateToSet.inputValue, {
560
+ ...this.getStateAndHelpers(),
561
+ ...stateToSet
562
+ });
569
563
  }
570
- return _this.setState(function (state) {
571
- state = _this.getState(state);
572
- var newStateToSet = isStateToSetFunction ? stateToSet(state) : stateToSet;
564
+ return this.setState(state => {
565
+ state = this.getState(state);
566
+ let newStateToSet = isStateToSetFunction ? stateToSet(state) : stateToSet;
573
567
 
574
568
  // Your own function that could modify the state that will be set.
575
- newStateToSet = _this.props.stateReducer(state, newStateToSet);
569
+ newStateToSet = this.props.stateReducer(state, newStateToSet);
576
570
 
577
571
  // checks if an item is selected, regardless of if it's different from
578
572
  // what was selected before
579
573
  // used to determine if onSelect and onChange callbacks should be called
580
574
  isItemSelected = newStateToSet.hasOwnProperty('selectedItem');
581
575
  // this keeps track of the object we want to call with setState
582
- var nextState = {};
576
+ const nextState = {};
583
577
  // we need to call on change if the outside world is controlling any of our state
584
578
  // and we're trying to update that state. OR if the selection has changed and we're
585
579
  // trying to update the selection
@@ -587,7 +581,7 @@ var Downshift = /*#__PURE__*/function () {
587
581
  onChangeArg = newStateToSet.selectedItem;
588
582
  }
589
583
  newStateToSet.type = newStateToSet.type || unknown;
590
- Object.keys(newStateToSet).forEach(function (key) {
584
+ Object.keys(newStateToSet).forEach(key => {
591
585
  // onStateChangeArg should only have the state that is
592
586
  // actually changing
593
587
  if (state[key] !== newStateToSet[key]) {
@@ -604,7 +598,7 @@ var Downshift = /*#__PURE__*/function () {
604
598
  }
605
599
  newStateToSet[key];
606
600
  // if it's coming from props, then we don't care to set it internally
607
- if (!isControlledProp(_this.props, key)) {
601
+ if (!isControlledProp(this.props, key)) {
608
602
  nextState[key] = newStateToSet[key];
609
603
  }
610
604
  });
@@ -612,58 +606,66 @@ var Downshift = /*#__PURE__*/function () {
612
606
  // if stateToSet is a function, then we weren't able to call onInputValueChange
613
607
  // earlier, so we'll call it now that we know what the inputValue state will be.
614
608
  if (isStateToSetFunction && newStateToSet.hasOwnProperty('inputValue')) {
615
- _this.props.onInputValueChange(newStateToSet.inputValue, _extends({}, _this.getStateAndHelpers(), newStateToSet));
609
+ this.props.onInputValueChange(newStateToSet.inputValue, {
610
+ ...this.getStateAndHelpers(),
611
+ ...newStateToSet
612
+ });
616
613
  }
617
614
  return nextState;
618
- }, function () {
615
+ }, () => {
619
616
  // call the provided callback if it's a function
620
617
  cbToCb(cb)();
621
618
 
622
619
  // only call the onStateChange and onChange callbacks if
623
620
  // we have relevant information to pass them.
624
- var hasMoreStateThanType = Object.keys(onStateChangeArg).length > 1;
621
+ const hasMoreStateThanType = Object.keys(onStateChangeArg).length > 1;
625
622
  if (hasMoreStateThanType) {
626
- _this.props.onStateChange(onStateChangeArg, _this.getStateAndHelpers());
623
+ this.props.onStateChange(onStateChangeArg, this.getStateAndHelpers());
627
624
  }
628
625
  if (isItemSelected) {
629
- _this.props.onSelect(stateToSet.selectedItem, _this.getStateAndHelpers());
626
+ this.props.onSelect(stateToSet.selectedItem, this.getStateAndHelpers());
630
627
  }
631
628
  if (onChangeArg !== undefined) {
632
- _this.props.onChange(onChangeArg, _this.getStateAndHelpers());
629
+ this.props.onChange(onChangeArg, this.getStateAndHelpers());
633
630
  }
634
631
  // this is currently undocumented and therefore subject to change
635
632
  // We'll try to not break it, but just be warned.
636
- _this.props.onUserAction(onStateChangeArg, _this.getStateAndHelpers());
633
+ this.props.onUserAction(onStateChangeArg, this.getStateAndHelpers());
637
634
  });
638
635
  };
639
- _this.rootRef = function (node) {
640
- return _this._rootNode = node;
641
- };
642
- _this.getRootProps = function (_temp, _temp2) {
643
- var _extends2;
644
- var _ref = _temp === void 0 ? {} : _temp,
645
- _ref$refKey = _ref.refKey,
646
- refKey = _ref$refKey === void 0 ? 'ref' : _ref$refKey,
647
- ref = _ref.ref,
648
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$4);
649
- var _ref2 = _temp2 === void 0 ? {} : _temp2,
650
- _ref2$suppressRefErro = _ref2.suppressRefError,
651
- suppressRefError = _ref2$suppressRefErro === void 0 ? false : _ref2$suppressRefErro;
636
+ this.rootRef = node => this._rootNode = node;
637
+ this.getRootProps = function (_temp, _temp2) {
638
+ let {
639
+ refKey = 'ref',
640
+ ref,
641
+ ...rest
642
+ } = _temp === void 0 ? {} : _temp;
643
+ let {
644
+ suppressRefError = false
645
+ } = _temp2 === void 0 ? {} : _temp2;
652
646
  // this is used in the render to know whether the user has called getRootProps.
653
647
  // It uses that to know whether to apply the props automatically
654
648
  _this.getRootProps.called = true;
655
649
  _this.getRootProps.refKey = refKey;
656
650
  _this.getRootProps.suppressRefError = suppressRefError;
657
- var _this$getState = _this.getState(),
658
- isOpen = _this$getState.isOpen;
659
- 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);
651
+ const {
652
+ isOpen
653
+ } = _this.getState();
654
+ return {
655
+ [refKey]: handleRefs(ref, _this.rootRef),
656
+ role: 'combobox',
657
+ 'aria-expanded': isOpen,
658
+ 'aria-haspopup': 'listbox',
659
+ 'aria-owns': isOpen ? _this.menuId : null,
660
+ 'aria-labelledby': _this.labelId,
661
+ ...rest
662
+ };
660
663
  };
661
- _this.keyDownHandlers = {
662
- ArrowDown: function ArrowDown(event) {
663
- var _this2 = this;
664
+ this.keyDownHandlers = {
665
+ ArrowDown(event) {
664
666
  event.preventDefault();
665
667
  if (this.getState().isOpen) {
666
- var amount = event.shiftKey ? 5 : 1;
668
+ const amount = event.shiftKey ? 5 : 1;
667
669
  this.moveHighlightedIndex(amount, {
668
670
  type: keyDownArrowDown
669
671
  });
@@ -671,26 +673,24 @@ var Downshift = /*#__PURE__*/function () {
671
673
  this.internalSetState({
672
674
  isOpen: true,
673
675
  type: keyDownArrowDown
674
- }, function () {
675
- var itemCount = _this2.getItemCount();
676
+ }, () => {
677
+ const itemCount = this.getItemCount();
676
678
  if (itemCount > 0) {
677
- var _this2$getState = _this2.getState(),
678
- highlightedIndex = _this2$getState.highlightedIndex;
679
- var nextHighlightedIndex = getNextWrappingIndex(1, highlightedIndex, itemCount, function (index) {
680
- return _this2.getItemNodeFromIndex(index);
681
- });
682
- _this2.setHighlightedIndex(nextHighlightedIndex, {
679
+ const {
680
+ highlightedIndex
681
+ } = this.getState();
682
+ const nextHighlightedIndex = getNextWrappingIndex(1, highlightedIndex, itemCount, index => this.getItemNodeFromIndex(index));
683
+ this.setHighlightedIndex(nextHighlightedIndex, {
683
684
  type: keyDownArrowDown
684
685
  });
685
686
  }
686
687
  });
687
688
  }
688
689
  },
689
- ArrowUp: function ArrowUp(event) {
690
- var _this3 = this;
690
+ ArrowUp(event) {
691
691
  event.preventDefault();
692
692
  if (this.getState().isOpen) {
693
- var amount = event.shiftKey ? -5 : -1;
693
+ const amount = event.shiftKey ? -5 : -1;
694
694
  this.moveHighlightedIndex(amount, {
695
695
  type: keyDownArrowUp
696
696
  });
@@ -698,32 +698,32 @@ var Downshift = /*#__PURE__*/function () {
698
698
  this.internalSetState({
699
699
  isOpen: true,
700
700
  type: keyDownArrowUp
701
- }, function () {
702
- var itemCount = _this3.getItemCount();
701
+ }, () => {
702
+ const itemCount = this.getItemCount();
703
703
  if (itemCount > 0) {
704
- var _this3$getState = _this3.getState(),
705
- highlightedIndex = _this3$getState.highlightedIndex;
706
- var nextHighlightedIndex = getNextWrappingIndex(-1, highlightedIndex, itemCount, function (index) {
707
- return _this3.getItemNodeFromIndex(index);
708
- });
709
- _this3.setHighlightedIndex(nextHighlightedIndex, {
704
+ const {
705
+ highlightedIndex
706
+ } = this.getState();
707
+ const nextHighlightedIndex = getNextWrappingIndex(-1, highlightedIndex, itemCount, index => this.getItemNodeFromIndex(index));
708
+ this.setHighlightedIndex(nextHighlightedIndex, {
710
709
  type: keyDownArrowUp
711
710
  });
712
711
  }
713
712
  });
714
713
  }
715
714
  },
716
- Enter: function Enter(event) {
715
+ Enter(event) {
717
716
  if (event.which === 229) {
718
717
  return;
719
718
  }
720
- var _this$getState2 = this.getState(),
721
- isOpen = _this$getState2.isOpen,
722
- highlightedIndex = _this$getState2.highlightedIndex;
719
+ const {
720
+ isOpen,
721
+ highlightedIndex
722
+ } = this.getState();
723
723
  if (isOpen && highlightedIndex != null) {
724
724
  event.preventDefault();
725
- var item = this.items[highlightedIndex];
726
- var itemNode = this.getItemNodeFromIndex(highlightedIndex);
725
+ const item = this.items[highlightedIndex];
726
+ const itemNode = this.getItemNodeFromIndex(highlightedIndex);
727
727
  if (item == null || itemNode && itemNode.hasAttribute('disabled')) {
728
728
  return;
729
729
  }
@@ -732,169 +732,176 @@ var Downshift = /*#__PURE__*/function () {
732
732
  });
733
733
  }
734
734
  },
735
- Escape: function Escape(event) {
735
+ Escape(event) {
736
736
  event.preventDefault();
737
- this.reset(_extends({
738
- type: keyDownEscape
739
- }, !this.state.isOpen && {
740
- selectedItem: null,
741
- inputValue: ''
742
- }));
737
+ this.reset({
738
+ type: keyDownEscape,
739
+ ...(!this.state.isOpen && {
740
+ selectedItem: null,
741
+ inputValue: ''
742
+ })
743
+ });
743
744
  }
744
745
  };
745
- _this.buttonKeyDownHandlers = _extends({}, _this.keyDownHandlers, {
746
- ' ': function _(event) {
746
+ this.buttonKeyDownHandlers = {
747
+ ...this.keyDownHandlers,
748
+ ' '(event) {
747
749
  event.preventDefault();
748
750
  this.toggleMenu({
749
751
  type: keyDownSpaceButton
750
752
  });
751
753
  }
752
- });
753
- _this.inputKeyDownHandlers = _extends({}, _this.keyDownHandlers, {
754
- Home: function Home(event) {
755
- var _this4 = this;
756
- var _this$getState3 = this.getState(),
757
- isOpen = _this$getState3.isOpen;
754
+ };
755
+ this.inputKeyDownHandlers = {
756
+ ...this.keyDownHandlers,
757
+ Home(event) {
758
+ const {
759
+ isOpen
760
+ } = this.getState();
758
761
  if (!isOpen) {
759
762
  return;
760
763
  }
761
764
  event.preventDefault();
762
- var itemCount = this.getItemCount();
765
+ const itemCount = this.getItemCount();
763
766
  if (itemCount <= 0 || !isOpen) {
764
767
  return;
765
768
  }
766
769
 
767
770
  // get next non-disabled starting downwards from 0 if that's disabled.
768
- var newHighlightedIndex = getNextNonDisabledIndex(1, 0, itemCount, function (index) {
769
- return _this4.getItemNodeFromIndex(index);
770
- }, false);
771
+ const newHighlightedIndex = getNextNonDisabledIndex(1, 0, itemCount, index => this.getItemNodeFromIndex(index), false);
771
772
  this.setHighlightedIndex(newHighlightedIndex, {
772
773
  type: keyDownHome
773
774
  });
774
775
  },
775
- End: function End(event) {
776
- var _this5 = this;
777
- var _this$getState4 = this.getState(),
778
- isOpen = _this$getState4.isOpen;
776
+ End(event) {
777
+ const {
778
+ isOpen
779
+ } = this.getState();
779
780
  if (!isOpen) {
780
781
  return;
781
782
  }
782
783
  event.preventDefault();
783
- var itemCount = this.getItemCount();
784
+ const itemCount = this.getItemCount();
784
785
  if (itemCount <= 0 || !isOpen) {
785
786
  return;
786
787
  }
787
788
 
788
789
  // get next non-disabled starting upwards from last index if that's disabled.
789
- var newHighlightedIndex = getNextNonDisabledIndex(-1, itemCount - 1, itemCount, function (index) {
790
- return _this5.getItemNodeFromIndex(index);
791
- }, false);
790
+ const newHighlightedIndex = getNextNonDisabledIndex(-1, itemCount - 1, itemCount, index => this.getItemNodeFromIndex(index), false);
792
791
  this.setHighlightedIndex(newHighlightedIndex, {
793
792
  type: keyDownEnd
794
793
  });
795
794
  }
796
- });
797
- _this.getToggleButtonProps = function (_temp3) {
798
- var _ref3 = _temp3 === void 0 ? {} : _temp3,
799
- onClick = _ref3.onClick;
800
- _ref3.onPress;
801
- var onKeyDown = _ref3.onKeyDown,
802
- onKeyUp = _ref3.onKeyUp,
803
- onBlur = _ref3.onBlur,
804
- rest = _objectWithoutPropertiesLoose(_ref3, _excluded2$3);
805
- var _this$getState5 = _this.getState(),
806
- isOpen = _this$getState5.isOpen;
807
- var enabledEventHandlers = {
795
+ };
796
+ this.getToggleButtonProps = function (_temp3) {
797
+ let {
798
+ onClick,
799
+ onPress,
800
+ onKeyDown,
801
+ onKeyUp,
802
+ onBlur,
803
+ ...rest
804
+ } = _temp3 === void 0 ? {} : _temp3;
805
+ const {
806
+ isOpen
807
+ } = _this.getState();
808
+ const enabledEventHandlers = {
808
809
  onClick: callAllEventHandlers(onClick, _this.buttonHandleClick),
809
810
  onKeyDown: callAllEventHandlers(onKeyDown, _this.buttonHandleKeyDown),
810
811
  onKeyUp: callAllEventHandlers(onKeyUp, _this.buttonHandleKeyUp),
811
812
  onBlur: callAllEventHandlers(onBlur, _this.buttonHandleBlur)
812
813
  };
813
- var eventHandlers = rest.disabled ? {} : enabledEventHandlers;
814
- return _extends({
814
+ const eventHandlers = rest.disabled ? {} : enabledEventHandlers;
815
+ return {
815
816
  type: 'button',
816
817
  role: 'button',
817
818
  'aria-label': isOpen ? 'close menu' : 'open menu',
818
819
  'aria-haspopup': true,
819
- 'data-toggle': true
820
- }, eventHandlers, rest);
820
+ 'data-toggle': true,
821
+ ...eventHandlers,
822
+ ...rest
823
+ };
821
824
  };
822
- _this.buttonHandleKeyUp = function (event) {
825
+ this.buttonHandleKeyUp = event => {
823
826
  // Prevent click event from emitting in Firefox
824
827
  event.preventDefault();
825
828
  };
826
- _this.buttonHandleKeyDown = function (event) {
827
- var key = normalizeArrowKey(event);
828
- if (_this.buttonKeyDownHandlers[key]) {
829
- _this.buttonKeyDownHandlers[key].call(_assertThisInitialized(_this), event);
829
+ this.buttonHandleKeyDown = event => {
830
+ const key = normalizeArrowKey(event);
831
+ if (this.buttonKeyDownHandlers[key]) {
832
+ this.buttonKeyDownHandlers[key].call(this, event);
830
833
  }
831
834
  };
832
- _this.buttonHandleClick = function (event) {
835
+ this.buttonHandleClick = event => {
833
836
  event.preventDefault();
834
837
  // handle odd case for Safari and Firefox which
835
838
  // don't give the button the focus properly.
836
839
  /* istanbul ignore if (can't reasonably test this) */
837
- if (_this.props.environment.document.activeElement === _this.props.environment.document.body) {
840
+ if (this.props.environment.document.activeElement === this.props.environment.document.body) {
838
841
  event.target.focus();
839
842
  }
840
843
  // to simplify testing components that use downshift, we'll not wrap this in a setTimeout
841
844
  // if the NODE_ENV is test. With the proper build system, this should be dead code eliminated
842
845
  // when building for production and should therefore have no impact on production code.
843
846
  if (process.env.NODE_ENV === 'test') {
844
- _this.toggleMenu({
847
+ this.toggleMenu({
845
848
  type: clickButton
846
849
  });
847
850
  } else {
848
851
  // Ensure that toggle of menu occurs after the potential blur event in iOS
849
- _this.internalSetTimeout(function () {
850
- return _this.toggleMenu({
851
- type: clickButton
852
- });
853
- });
852
+ this.internalSetTimeout(() => this.toggleMenu({
853
+ type: clickButton
854
+ }));
854
855
  }
855
856
  };
856
- _this.buttonHandleBlur = function (event) {
857
- var blurTarget = event.target; // Save blur target for comparison with activeElement later
857
+ this.buttonHandleBlur = event => {
858
+ const blurTarget = event.target; // Save blur target for comparison with activeElement later
858
859
  // Need setTimeout, so that when the user presses Tab, the activeElement is the next focused element, not body element
859
- _this.internalSetTimeout(function () {
860
- 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)
860
+ this.internalSetTimeout(() => {
861
+ 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)
861
862
  ) {
862
- _this.reset({
863
+ this.reset({
863
864
  type: blurButton
864
865
  });
865
866
  }
866
867
  });
867
868
  };
868
- _this.getLabelProps = function (props) {
869
- return _extends({
870
- htmlFor: _this.inputId,
871
- id: _this.labelId
872
- }, props);
873
- };
874
- _this.getInputProps = function (_temp4) {
875
- var _ref4 = _temp4 === void 0 ? {} : _temp4,
876
- onKeyDown = _ref4.onKeyDown,
877
- onBlur = _ref4.onBlur,
878
- onChange = _ref4.onChange,
879
- onInput = _ref4.onInput;
880
- _ref4.onChangeText;
881
- var rest = _objectWithoutPropertiesLoose(_ref4, _excluded3$2);
882
- var onChangeKey;
883
- var eventHandlers = {};
869
+ this.getLabelProps = props => {
870
+ return {
871
+ htmlFor: this.inputId,
872
+ id: this.labelId,
873
+ ...props
874
+ };
875
+ };
876
+ this.getInputProps = function (_temp4) {
877
+ let {
878
+ onKeyDown,
879
+ onBlur,
880
+ onChange,
881
+ onInput,
882
+ onChangeText,
883
+ ...rest
884
+ } = _temp4 === void 0 ? {} : _temp4;
885
+ let onChangeKey;
886
+ let eventHandlers = {};
884
887
 
885
888
  /* istanbul ignore next (preact) */
886
889
  {
887
890
  onChangeKey = 'onChange';
888
891
  }
889
- var _this$getState6 = _this.getState(),
890
- inputValue = _this$getState6.inputValue,
891
- isOpen = _this$getState6.isOpen,
892
- highlightedIndex = _this$getState6.highlightedIndex;
892
+ const {
893
+ inputValue,
894
+ isOpen,
895
+ highlightedIndex
896
+ } = _this.getState();
893
897
  if (!rest.disabled) {
894
- var _eventHandlers;
895
- eventHandlers = (_eventHandlers = {}, _eventHandlers[onChangeKey] = callAllEventHandlers(onChange, onInput, _this.inputHandleChange), _eventHandlers.onKeyDown = callAllEventHandlers(onKeyDown, _this.inputHandleKeyDown), _eventHandlers.onBlur = callAllEventHandlers(onBlur, _this.inputHandleBlur), _eventHandlers);
898
+ eventHandlers = {
899
+ [onChangeKey]: callAllEventHandlers(onChange, onInput, _this.inputHandleChange),
900
+ onKeyDown: callAllEventHandlers(onKeyDown, _this.inputHandleKeyDown),
901
+ onBlur: callAllEventHandlers(onBlur, _this.inputHandleBlur)
902
+ };
896
903
  }
897
- return _extends({
904
+ return {
898
905
  'aria-autocomplete': 'list',
899
906
  'aria-activedescendant': isOpen && typeof highlightedIndex === 'number' && highlightedIndex >= 0 ? _this.getItemId(highlightedIndex) : null,
900
907
  'aria-controls': isOpen ? _this.menuId : null,
@@ -903,76 +910,82 @@ var Downshift = /*#__PURE__*/function () {
903
910
  // revert back since autocomplete="nope" is ignored on latest Chrome and Opera
904
911
  autoComplete: 'off',
905
912
  value: inputValue,
906
- id: _this.inputId
907
- }, eventHandlers, rest);
913
+ id: _this.inputId,
914
+ ...eventHandlers,
915
+ ...rest
916
+ };
908
917
  };
909
- _this.inputHandleKeyDown = function (event) {
910
- var key = normalizeArrowKey(event);
911
- if (key && _this.inputKeyDownHandlers[key]) {
912
- _this.inputKeyDownHandlers[key].call(_assertThisInitialized(_this), event);
918
+ this.inputHandleKeyDown = event => {
919
+ const key = normalizeArrowKey(event);
920
+ if (key && this.inputKeyDownHandlers[key]) {
921
+ this.inputKeyDownHandlers[key].call(this, event);
913
922
  }
914
923
  };
915
- _this.inputHandleChange = function (event) {
916
- _this.internalSetState({
924
+ this.inputHandleChange = event => {
925
+ this.internalSetState({
917
926
  type: changeInput,
918
927
  isOpen: true,
919
928
  inputValue: event.target.value,
920
- highlightedIndex: _this.props.defaultHighlightedIndex
929
+ highlightedIndex: this.props.defaultHighlightedIndex
921
930
  });
922
931
  };
923
- _this.inputHandleBlur = function () {
932
+ this.inputHandleBlur = () => {
924
933
  // Need setTimeout, so that when the user presses Tab, the activeElement is the next focused element, not the body element
925
- _this.internalSetTimeout(function () {
926
- 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);
927
- if (!_this.isMouseDown && !downshiftButtonIsActive) {
928
- _this.reset({
934
+ this.internalSetTimeout(() => {
935
+ 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);
936
+ if (!this.isMouseDown && !downshiftButtonIsActive) {
937
+ this.reset({
929
938
  type: blurInput
930
939
  });
931
940
  }
932
941
  });
933
942
  };
934
- _this.menuRef = function (node) {
935
- _this._menuNode = node;
936
- };
937
- _this.getMenuProps = function (_temp5, _temp6) {
938
- var _extends3;
939
- var _ref5 = _temp5 === void 0 ? {} : _temp5,
940
- _ref5$refKey = _ref5.refKey,
941
- refKey = _ref5$refKey === void 0 ? 'ref' : _ref5$refKey,
942
- ref = _ref5.ref,
943
- props = _objectWithoutPropertiesLoose(_ref5, _excluded4$1);
944
- var _ref6 = _temp6 === void 0 ? {} : _temp6,
945
- _ref6$suppressRefErro = _ref6.suppressRefError,
946
- suppressRefError = _ref6$suppressRefErro === void 0 ? false : _ref6$suppressRefErro;
943
+ this.menuRef = node => {
944
+ this._menuNode = node;
945
+ };
946
+ this.getMenuProps = function (_temp5, _temp6) {
947
+ let {
948
+ refKey = 'ref',
949
+ ref,
950
+ ...props
951
+ } = _temp5 === void 0 ? {} : _temp5;
952
+ let {
953
+ suppressRefError = false
954
+ } = _temp6 === void 0 ? {} : _temp6;
947
955
  _this.getMenuProps.called = true;
948
956
  _this.getMenuProps.refKey = refKey;
949
957
  _this.getMenuProps.suppressRefError = suppressRefError;
950
- 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);
951
- };
952
- _this.getItemProps = function (_temp7) {
953
- var _enabledEventHandlers;
954
- var _ref7 = _temp7 === void 0 ? {} : _temp7,
955
- onMouseMove = _ref7.onMouseMove,
956
- onMouseDown = _ref7.onMouseDown,
957
- onClick = _ref7.onClick;
958
- _ref7.onPress;
959
- var index = _ref7.index,
960
- _ref7$item = _ref7.item,
961
- item = _ref7$item === void 0 ? process.env.NODE_ENV === 'production' ? /* istanbul ignore next */undefined : requiredProp('getItemProps', 'item') : _ref7$item,
962
- rest = _objectWithoutPropertiesLoose(_ref7, _excluded5);
958
+ return {
959
+ [refKey]: handleRefs(ref, _this.menuRef),
960
+ role: 'listbox',
961
+ 'aria-labelledby': props && props['aria-label'] ? null : _this.labelId,
962
+ id: _this.menuId,
963
+ ...props
964
+ };
965
+ };
966
+ this.getItemProps = function (_temp7) {
967
+ let {
968
+ onMouseMove,
969
+ onMouseDown,
970
+ onClick,
971
+ onPress,
972
+ index,
973
+ item = process.env.NODE_ENV === 'production' ? /* istanbul ignore next */undefined : requiredProp('getItemProps', 'item'),
974
+ ...rest
975
+ } = _temp7 === void 0 ? {} : _temp7;
963
976
  if (index === undefined) {
964
977
  _this.items.push(item);
965
978
  index = _this.items.indexOf(item);
966
979
  } else {
967
980
  _this.items[index] = item;
968
981
  }
969
- var onSelectKey = 'onClick';
970
- var customClickHandler = onClick;
971
- var enabledEventHandlers = (_enabledEventHandlers = {
982
+ const onSelectKey = 'onClick';
983
+ const customClickHandler = onClick;
984
+ const enabledEventHandlers = {
972
985
  // onMouseMove is used over onMouseEnter here. onMouseMove
973
986
  // is only triggered on actual mouse movement while onMouseEnter
974
987
  // can fire on DOM changes, interrupting keyboard navigation
975
- onMouseMove: callAllEventHandlers(onMouseMove, function () {
988
+ onMouseMove: callAllEventHandlers(onMouseMove, () => {
976
989
  if (index === _this.getState().highlightedIndex) {
977
990
  return;
978
991
  }
@@ -985,66 +998,75 @@ var Downshift = /*#__PURE__*/function () {
985
998
  // from under the user which is currently scrolling/moving the
986
999
  // cursor
987
1000
  _this.avoidScrolling = true;
988
- _this.internalSetTimeout(function () {
989
- return _this.avoidScrolling = false;
990
- }, 250);
1001
+ _this.internalSetTimeout(() => _this.avoidScrolling = false, 250);
991
1002
  }),
992
- onMouseDown: callAllEventHandlers(onMouseDown, function (event) {
1003
+ onMouseDown: callAllEventHandlers(onMouseDown, event => {
993
1004
  // This prevents the activeElement from being changed
994
1005
  // to the item so it can remain with the current activeElement
995
1006
  // which is a more common use case.
996
1007
  event.preventDefault();
1008
+ }),
1009
+ [onSelectKey]: callAllEventHandlers(customClickHandler, () => {
1010
+ _this.selectItemAtIndex(index, {
1011
+ type: clickItem
1012
+ });
997
1013
  })
998
- }, _enabledEventHandlers[onSelectKey] = callAllEventHandlers(customClickHandler, function () {
999
- _this.selectItemAtIndex(index, {
1000
- type: clickItem
1001
- });
1002
- }), _enabledEventHandlers);
1014
+ };
1003
1015
 
1004
1016
  // Passing down the onMouseDown handler to prevent redirect
1005
1017
  // of the activeElement if clicking on disabled items
1006
- var eventHandlers = rest.disabled ? {
1018
+ const eventHandlers = rest.disabled ? {
1007
1019
  onMouseDown: enabledEventHandlers.onMouseDown
1008
1020
  } : enabledEventHandlers;
1009
- return _extends({
1021
+ return {
1010
1022
  id: _this.getItemId(index),
1011
1023
  role: 'option',
1012
- 'aria-selected': _this.getState().highlightedIndex === index
1013
- }, eventHandlers, rest);
1024
+ 'aria-selected': _this.getState().highlightedIndex === index,
1025
+ ...eventHandlers,
1026
+ ...rest
1027
+ };
1014
1028
  };
1015
- _this.clearItems = function () {
1016
- _this.items = [];
1029
+ this.clearItems = () => {
1030
+ this.items = [];
1017
1031
  };
1018
- _this.reset = function (otherStateToSet, cb) {
1032
+ this.reset = function (otherStateToSet, cb) {
1019
1033
  if (otherStateToSet === void 0) {
1020
1034
  otherStateToSet = {};
1021
1035
  }
1022
1036
  otherStateToSet = pickState(otherStateToSet);
1023
- _this.internalSetState(function (_ref8) {
1024
- var selectedItem = _ref8.selectedItem;
1025
- return _extends({
1037
+ _this.internalSetState(_ref => {
1038
+ let {
1039
+ selectedItem
1040
+ } = _ref;
1041
+ return {
1026
1042
  isOpen: _this.props.defaultIsOpen,
1027
1043
  highlightedIndex: _this.props.defaultHighlightedIndex,
1028
- inputValue: _this.props.itemToString(selectedItem)
1029
- }, otherStateToSet);
1044
+ inputValue: _this.props.itemToString(selectedItem),
1045
+ ...otherStateToSet
1046
+ };
1030
1047
  }, cb);
1031
1048
  };
1032
- _this.toggleMenu = function (otherStateToSet, cb) {
1049
+ this.toggleMenu = function (otherStateToSet, cb) {
1033
1050
  if (otherStateToSet === void 0) {
1034
1051
  otherStateToSet = {};
1035
1052
  }
1036
1053
  otherStateToSet = pickState(otherStateToSet);
1037
- _this.internalSetState(function (_ref9) {
1038
- var isOpen = _ref9.isOpen;
1039
- return _extends({
1040
- isOpen: !isOpen
1041
- }, isOpen && {
1042
- highlightedIndex: _this.props.defaultHighlightedIndex
1043
- }, otherStateToSet);
1044
- }, function () {
1045
- var _this$getState7 = _this.getState(),
1046
- isOpen = _this$getState7.isOpen,
1047
- highlightedIndex = _this$getState7.highlightedIndex;
1054
+ _this.internalSetState(_ref2 => {
1055
+ let {
1056
+ isOpen
1057
+ } = _ref2;
1058
+ return {
1059
+ isOpen: !isOpen,
1060
+ ...(isOpen && {
1061
+ highlightedIndex: _this.props.defaultHighlightedIndex
1062
+ }),
1063
+ ...otherStateToSet
1064
+ };
1065
+ }, () => {
1066
+ const {
1067
+ isOpen,
1068
+ highlightedIndex
1069
+ } = _this.getState();
1048
1070
  if (isOpen) {
1049
1071
  if (_this.getItemCount() > 0 && typeof highlightedIndex === 'number') {
1050
1072
  _this.setHighlightedIndex(highlightedIndex, otherStateToSet);
@@ -1053,58 +1075,57 @@ var Downshift = /*#__PURE__*/function () {
1053
1075
  cbToCb(cb)();
1054
1076
  });
1055
1077
  };
1056
- _this.openMenu = function (cb) {
1057
- _this.internalSetState({
1078
+ this.openMenu = cb => {
1079
+ this.internalSetState({
1058
1080
  isOpen: true
1059
1081
  }, cb);
1060
1082
  };
1061
- _this.closeMenu = function (cb) {
1062
- _this.internalSetState({
1083
+ this.closeMenu = cb => {
1084
+ this.internalSetState({
1063
1085
  isOpen: false
1064
1086
  }, cb);
1065
1087
  };
1066
- _this.updateStatus = debounce(function () {
1067
- var state = _this.getState();
1068
- var item = _this.items[state.highlightedIndex];
1069
- var resultCount = _this.getItemCount();
1070
- var status = _this.props.getA11yStatusMessage(_extends({
1071
- itemToString: _this.props.itemToString,
1072
- previousResultCount: _this.previousResultCount,
1073
- resultCount: resultCount,
1074
- highlightedItem: item
1075
- }, state));
1076
- _this.previousResultCount = resultCount;
1077
- setStatus(status, _this.props.environment.document);
1088
+ this.updateStatus = debounce(() => {
1089
+ const state = this.getState();
1090
+ const item = this.items[state.highlightedIndex];
1091
+ const resultCount = this.getItemCount();
1092
+ const status = this.props.getA11yStatusMessage({
1093
+ itemToString: this.props.itemToString,
1094
+ previousResultCount: this.previousResultCount,
1095
+ resultCount,
1096
+ highlightedItem: item,
1097
+ ...state
1098
+ });
1099
+ this.previousResultCount = resultCount;
1100
+ setStatus(status, this.props.environment.document);
1078
1101
  }, 200);
1079
- var _this$props = _this.props,
1080
- defaultHighlightedIndex = _this$props.defaultHighlightedIndex,
1081
- _this$props$initialHi = _this$props.initialHighlightedIndex,
1082
- _highlightedIndex = _this$props$initialHi === void 0 ? defaultHighlightedIndex : _this$props$initialHi,
1083
- defaultIsOpen = _this$props.defaultIsOpen,
1084
- _this$props$initialIs = _this$props.initialIsOpen,
1085
- _isOpen = _this$props$initialIs === void 0 ? defaultIsOpen : _this$props$initialIs,
1086
- _this$props$initialIn = _this$props.initialInputValue,
1087
- _inputValue = _this$props$initialIn === void 0 ? '' : _this$props$initialIn,
1088
- _this$props$initialSe = _this$props.initialSelectedItem,
1089
- _selectedItem = _this$props$initialSe === void 0 ? null : _this$props$initialSe;
1090
- var _state = _this.getState({
1102
+ // fancy destructuring + defaults + aliases
1103
+ // this basically says each value of state should either be set to
1104
+ // the initial value or the default value if the initial value is not provided
1105
+ const {
1106
+ defaultHighlightedIndex,
1107
+ initialHighlightedIndex: _highlightedIndex = defaultHighlightedIndex,
1108
+ defaultIsOpen,
1109
+ initialIsOpen: _isOpen = defaultIsOpen,
1110
+ initialInputValue: _inputValue = '',
1111
+ initialSelectedItem: _selectedItem = null
1112
+ } = this.props;
1113
+ const _state = this.getState({
1091
1114
  highlightedIndex: _highlightedIndex,
1092
1115
  isOpen: _isOpen,
1093
1116
  inputValue: _inputValue,
1094
1117
  selectedItem: _selectedItem
1095
1118
  });
1096
- if (_state.selectedItem != null && _this.props.initialInputValue === undefined) {
1097
- _state.inputValue = _this.props.itemToString(_state.selectedItem);
1119
+ if (_state.selectedItem != null && this.props.initialInputValue === undefined) {
1120
+ _state.inputValue = this.props.itemToString(_state.selectedItem);
1098
1121
  }
1099
- _this.state = _state;
1100
- return _this;
1122
+ this.state = _state;
1101
1123
  }
1102
- var _proto = Downshift.prototype;
1103
1124
  /**
1104
1125
  * Clear all running timeouts
1105
1126
  */
1106
- _proto.internalClearTimeouts = function internalClearTimeouts() {
1107
- this.timeoutIds.forEach(function (id) {
1127
+ internalClearTimeouts() {
1128
+ this.timeoutIds.forEach(id => {
1108
1129
  clearTimeout(id);
1109
1130
  });
1110
1131
  this.timeoutIds = [];
@@ -1118,113 +1139,117 @@ var Downshift = /*#__PURE__*/function () {
1118
1139
  *
1119
1140
  * @param {Object} stateToMerge defaults to this.state
1120
1141
  * @return {Object} the state
1121
- */;
1122
- _proto.getState = function getState$1(stateToMerge) {
1142
+ */
1143
+ getState(stateToMerge) {
1123
1144
  if (stateToMerge === void 0) {
1124
1145
  stateToMerge = this.state;
1125
1146
  }
1126
1147
  return getState(stateToMerge, this.props);
1127
- };
1128
- _proto.getItemCount = function getItemCount() {
1148
+ }
1149
+ getItemCount() {
1129
1150
  // things read better this way. They're in priority order:
1130
1151
  // 1. `this.itemCount`
1131
1152
  // 2. `this.props.itemCount`
1132
1153
  // 3. `this.items.length`
1133
- var itemCount = this.items.length;
1154
+ let itemCount = this.items.length;
1134
1155
  if (this.itemCount != null) {
1135
1156
  itemCount = this.itemCount;
1136
1157
  } else if (this.props.itemCount !== undefined) {
1137
1158
  itemCount = this.props.itemCount;
1138
1159
  }
1139
1160
  return itemCount;
1140
- };
1141
- _proto.getItemNodeFromIndex = function getItemNodeFromIndex(index) {
1161
+ }
1162
+ getItemNodeFromIndex(index) {
1142
1163
  return this.props.environment.document.getElementById(this.getItemId(index));
1143
- };
1144
- _proto.scrollHighlightedItemIntoView = function scrollHighlightedItemIntoView() {
1164
+ }
1165
+ scrollHighlightedItemIntoView() {
1145
1166
  /* istanbul ignore else (react-native) */
1146
1167
  {
1147
- var node = this.getItemNodeFromIndex(this.getState().highlightedIndex);
1168
+ const node = this.getItemNodeFromIndex(this.getState().highlightedIndex);
1148
1169
  this.props.scrollIntoView(node, this._menuNode);
1149
1170
  }
1150
- };
1151
- _proto.moveHighlightedIndex = function moveHighlightedIndex(amount, otherStateToSet) {
1152
- var _this6 = this;
1153
- var itemCount = this.getItemCount();
1154
- var _this$getState8 = this.getState(),
1155
- highlightedIndex = _this$getState8.highlightedIndex;
1171
+ }
1172
+ moveHighlightedIndex(amount, otherStateToSet) {
1173
+ const itemCount = this.getItemCount();
1174
+ const {
1175
+ highlightedIndex
1176
+ } = this.getState();
1156
1177
  if (itemCount > 0) {
1157
- var nextHighlightedIndex = getNextWrappingIndex(amount, highlightedIndex, itemCount, function (index) {
1158
- return _this6.getItemNodeFromIndex(index);
1159
- });
1178
+ const nextHighlightedIndex = getNextWrappingIndex(amount, highlightedIndex, itemCount, index => this.getItemNodeFromIndex(index));
1160
1179
  this.setHighlightedIndex(nextHighlightedIndex, otherStateToSet);
1161
1180
  }
1162
- };
1163
- _proto.getStateAndHelpers = function getStateAndHelpers() {
1164
- var _this$getState9 = this.getState(),
1165
- highlightedIndex = _this$getState9.highlightedIndex,
1166
- inputValue = _this$getState9.inputValue,
1167
- selectedItem = _this$getState9.selectedItem,
1168
- isOpen = _this$getState9.isOpen;
1169
- var itemToString = this.props.itemToString;
1170
- var id = this.id;
1171
- var getRootProps = this.getRootProps,
1172
- getToggleButtonProps = this.getToggleButtonProps,
1173
- getLabelProps = this.getLabelProps,
1174
- getMenuProps = this.getMenuProps,
1175
- getInputProps = this.getInputProps,
1176
- getItemProps = this.getItemProps,
1177
- openMenu = this.openMenu,
1178
- closeMenu = this.closeMenu,
1179
- toggleMenu = this.toggleMenu,
1180
- selectItem = this.selectItem,
1181
- selectItemAtIndex = this.selectItemAtIndex,
1182
- selectHighlightedItem = this.selectHighlightedItem,
1183
- setHighlightedIndex = this.setHighlightedIndex,
1184
- clearSelection = this.clearSelection,
1185
- clearItems = this.clearItems,
1186
- reset = this.reset,
1187
- setItemCount = this.setItemCount,
1188
- unsetItemCount = this.unsetItemCount,
1189
- setState = this.internalSetState;
1181
+ }
1182
+ getStateAndHelpers() {
1183
+ const {
1184
+ highlightedIndex,
1185
+ inputValue,
1186
+ selectedItem,
1187
+ isOpen
1188
+ } = this.getState();
1189
+ const {
1190
+ itemToString
1191
+ } = this.props;
1192
+ const {
1193
+ id
1194
+ } = this;
1195
+ const {
1196
+ getRootProps,
1197
+ getToggleButtonProps,
1198
+ getLabelProps,
1199
+ getMenuProps,
1200
+ getInputProps,
1201
+ getItemProps,
1202
+ openMenu,
1203
+ closeMenu,
1204
+ toggleMenu,
1205
+ selectItem,
1206
+ selectItemAtIndex,
1207
+ selectHighlightedItem,
1208
+ setHighlightedIndex,
1209
+ clearSelection,
1210
+ clearItems,
1211
+ reset,
1212
+ setItemCount,
1213
+ unsetItemCount,
1214
+ internalSetState: setState
1215
+ } = this;
1190
1216
  return {
1191
1217
  // prop getters
1192
- getRootProps: getRootProps,
1193
- getToggleButtonProps: getToggleButtonProps,
1194
- getLabelProps: getLabelProps,
1195
- getMenuProps: getMenuProps,
1196
- getInputProps: getInputProps,
1197
- getItemProps: getItemProps,
1218
+ getRootProps,
1219
+ getToggleButtonProps,
1220
+ getLabelProps,
1221
+ getMenuProps,
1222
+ getInputProps,
1223
+ getItemProps,
1198
1224
  // actions
1199
- reset: reset,
1200
- openMenu: openMenu,
1201
- closeMenu: closeMenu,
1202
- toggleMenu: toggleMenu,
1203
- selectItem: selectItem,
1204
- selectItemAtIndex: selectItemAtIndex,
1205
- selectHighlightedItem: selectHighlightedItem,
1206
- setHighlightedIndex: setHighlightedIndex,
1207
- clearSelection: clearSelection,
1208
- clearItems: clearItems,
1209
- setItemCount: setItemCount,
1210
- unsetItemCount: unsetItemCount,
1211
- setState: setState,
1225
+ reset,
1226
+ openMenu,
1227
+ closeMenu,
1228
+ toggleMenu,
1229
+ selectItem,
1230
+ selectItemAtIndex,
1231
+ selectHighlightedItem,
1232
+ setHighlightedIndex,
1233
+ clearSelection,
1234
+ clearItems,
1235
+ setItemCount,
1236
+ unsetItemCount,
1237
+ setState,
1212
1238
  // props
1213
- itemToString: itemToString,
1239
+ itemToString,
1214
1240
  // derived
1215
- id: id,
1241
+ id,
1216
1242
  // state
1217
- highlightedIndex: highlightedIndex,
1218
- inputValue: inputValue,
1219
- isOpen: isOpen,
1220
- selectedItem: selectedItem
1243
+ highlightedIndex,
1244
+ inputValue,
1245
+ isOpen,
1246
+ selectedItem
1221
1247
  };
1222
1248
  }
1223
1249
 
1224
1250
  //////////////////////////// ROOT
1225
- ;
1226
- _proto.componentDidMount = function componentDidMount() {
1227
- var _this7 = this;
1251
+
1252
+ componentDidMount() {
1228
1253
  /* istanbul ignore if (react-native) */
1229
1254
  if (process.env.NODE_ENV !== 'production' && !false && this.getMenuProps.called && !this.getMenuProps.suppressRefError) {
1230
1255
  validateGetMenuPropsCalledCorrectly(this._menuNode, this.getMenuProps);
@@ -1237,20 +1262,18 @@ var Downshift = /*#__PURE__*/function () {
1237
1262
  // down long enough for the list to disappear (because the blur event fires on the input)
1238
1263
  // this.isMouseDown is used in the blur handler on the input to determine whether the blur event should
1239
1264
  // trigger hiding the menu.
1240
- var onMouseDown = function onMouseDown() {
1241
- _this7.isMouseDown = true;
1265
+ const onMouseDown = () => {
1266
+ this.isMouseDown = true;
1242
1267
  };
1243
- var onMouseUp = function onMouseUp(event) {
1244
- _this7.isMouseDown = false;
1268
+ const onMouseUp = event => {
1269
+ this.isMouseDown = false;
1245
1270
  // if the target element or the activeElement is within a downshift node
1246
1271
  // then we don't want to reset downshift
1247
- var contextWithinDownshift = targetWithinDownshift(event.target, [_this7._rootNode, _this7._menuNode], _this7.props.environment);
1248
- if (!contextWithinDownshift && _this7.getState().isOpen) {
1249
- _this7.reset({
1272
+ const contextWithinDownshift = targetWithinDownshift(event.target, [this._rootNode, this._menuNode], this.props.environment);
1273
+ if (!contextWithinDownshift && this.getState().isOpen) {
1274
+ this.reset({
1250
1275
  type: mouseUp
1251
- }, function () {
1252
- return _this7.props.onOuterClick(_this7.getStateAndHelpers());
1253
- });
1276
+ }, () => this.props.onOuterClick(this.getStateAndHelpers()));
1254
1277
  }
1255
1278
  };
1256
1279
  // Touching an element in iOS gives focus and hover states, but touching out of
@@ -1259,31 +1282,31 @@ var Downshift = /*#__PURE__*/function () {
1259
1282
  // this.isTouchMove helps us track whether the user is tapping or swiping on a touch screen.
1260
1283
  // If the user taps outside of Downshift, the component should be reset,
1261
1284
  // but not if the user is swiping
1262
- var onTouchStart = function onTouchStart() {
1263
- _this7.isTouchMove = false;
1285
+ const onTouchStart = () => {
1286
+ this.isTouchMove = false;
1264
1287
  };
1265
- var onTouchMove = function onTouchMove() {
1266
- _this7.isTouchMove = true;
1288
+ const onTouchMove = () => {
1289
+ this.isTouchMove = true;
1267
1290
  };
1268
- var onTouchEnd = function onTouchEnd(event) {
1269
- var contextWithinDownshift = targetWithinDownshift(event.target, [_this7._rootNode, _this7._menuNode], _this7.props.environment, false);
1270
- if (!_this7.isTouchMove && !contextWithinDownshift && _this7.getState().isOpen) {
1271
- _this7.reset({
1291
+ const onTouchEnd = event => {
1292
+ const contextWithinDownshift = targetWithinDownshift(event.target, [this._rootNode, this._menuNode], this.props.environment, false);
1293
+ if (!this.isTouchMove && !contextWithinDownshift && this.getState().isOpen) {
1294
+ this.reset({
1272
1295
  type: touchEnd
1273
- }, function () {
1274
- return _this7.props.onOuterClick(_this7.getStateAndHelpers());
1275
- });
1296
+ }, () => this.props.onOuterClick(this.getStateAndHelpers()));
1276
1297
  }
1277
1298
  };
1278
- var environment = this.props.environment;
1299
+ const {
1300
+ environment
1301
+ } = this.props;
1279
1302
  environment.addEventListener('mousedown', onMouseDown);
1280
1303
  environment.addEventListener('mouseup', onMouseUp);
1281
1304
  environment.addEventListener('touchstart', onTouchStart);
1282
1305
  environment.addEventListener('touchmove', onTouchMove);
1283
1306
  environment.addEventListener('touchend', onTouchEnd);
1284
- this.cleanup = function () {
1285
- _this7.internalClearTimeouts();
1286
- _this7.updateStatus.cancel();
1307
+ this.cleanup = () => {
1308
+ this.internalClearTimeouts();
1309
+ this.updateStatus.cancel();
1287
1310
  environment.removeEventListener('mousedown', onMouseDown);
1288
1311
  environment.removeEventListener('mouseup', onMouseUp);
1289
1312
  environment.removeEventListener('touchstart', onTouchStart);
@@ -1291,17 +1314,19 @@ var Downshift = /*#__PURE__*/function () {
1291
1314
  environment.removeEventListener('touchend', onTouchEnd);
1292
1315
  };
1293
1316
  }
1294
- };
1295
- _proto.shouldScroll = function shouldScroll(prevState, prevProps) {
1296
- var _ref10 = this.props.highlightedIndex === undefined ? this.getState() : this.props,
1297
- currentHighlightedIndex = _ref10.highlightedIndex;
1298
- var _ref11 = prevProps.highlightedIndex === undefined ? prevState : prevProps,
1299
- prevHighlightedIndex = _ref11.highlightedIndex;
1300
- var scrollWhenOpen = currentHighlightedIndex && this.getState().isOpen && !prevState.isOpen;
1301
- var scrollWhenNavigating = currentHighlightedIndex !== prevHighlightedIndex;
1317
+ }
1318
+ shouldScroll(prevState, prevProps) {
1319
+ const {
1320
+ highlightedIndex: currentHighlightedIndex
1321
+ } = this.props.highlightedIndex === undefined ? this.getState() : this.props;
1322
+ const {
1323
+ highlightedIndex: prevHighlightedIndex
1324
+ } = prevProps.highlightedIndex === undefined ? prevState : prevProps;
1325
+ const scrollWhenOpen = currentHighlightedIndex && this.getState().isOpen && !prevState.isOpen;
1326
+ const scrollWhenNavigating = currentHighlightedIndex !== prevHighlightedIndex;
1302
1327
  return scrollWhenOpen || scrollWhenNavigating;
1303
- };
1304
- _proto.componentDidUpdate = function componentDidUpdate(prevProps, prevState) {
1328
+ }
1329
+ componentDidUpdate(prevProps, prevState) {
1305
1330
  if (process.env.NODE_ENV !== 'production') {
1306
1331
  validateControlledUnchanged(this.state, prevProps, this.props);
1307
1332
  /* istanbul ignore if (react-native) */
@@ -1323,12 +1348,13 @@ var Downshift = /*#__PURE__*/function () {
1323
1348
  {
1324
1349
  this.updateStatus();
1325
1350
  }
1326
- };
1327
- _proto.componentWillUnmount = function componentWillUnmount() {
1351
+ }
1352
+ componentWillUnmount() {
1328
1353
  this.cleanup(); // avoids memory leak
1329
- };
1330
- _proto.render = function render() {
1331
- var children = unwrapArray(this.props.children, noop);
1354
+ }
1355
+
1356
+ render() {
1357
+ const children = unwrapArray(this.props.children, noop);
1332
1358
  // because the items are rerendered every time we call the children
1333
1359
  // we clear this out each render and it will be populated again as
1334
1360
  // getItemProps is called.
@@ -1348,7 +1374,7 @@ var Downshift = /*#__PURE__*/function () {
1348
1374
  this.getLabelProps.called = false;
1349
1375
  // and something similar for getInputProps
1350
1376
  this.getInputProps.called = false;
1351
- var element = unwrapArray(children(this.getStateAndHelpers()));
1377
+ const element = unwrapArray(children(this.getStateAndHelpers()));
1352
1378
  if (!element) {
1353
1379
  return null;
1354
1380
  }
@@ -1373,14 +1399,13 @@ var Downshift = /*#__PURE__*/function () {
1373
1399
 
1374
1400
  /* istanbul ignore next */
1375
1401
  return undefined;
1376
- };
1377
- return Downshift;
1378
- }(Component);
1402
+ }
1403
+ }
1379
1404
  Downshift.defaultProps = {
1380
1405
  defaultHighlightedIndex: null,
1381
1406
  defaultIsOpen: false,
1382
1407
  getA11yStatusMessage: getA11yStatusMessage$1,
1383
- itemToString: function itemToString(i) {
1408
+ itemToString: i => {
1384
1409
  if (i == null) {
1385
1410
  return '';
1386
1411
  }
@@ -1396,20 +1421,16 @@ var Downshift = /*#__PURE__*/function () {
1396
1421
  onChange: noop,
1397
1422
  onSelect: noop,
1398
1423
  onOuterClick: noop,
1399
- selectedItemChanged: function selectedItemChanged(prevItem, item) {
1400
- return prevItem !== item;
1401
- },
1424
+ selectedItemChanged: (prevItem, item) => prevItem !== item,
1402
1425
  environment: /* istanbul ignore next (ssr) */
1403
1426
  typeof window === 'undefined' ? {} : window,
1404
- stateReducer: function stateReducer(state, stateToSet) {
1405
- return stateToSet;
1406
- },
1427
+ stateReducer: (state, stateToSet) => stateToSet,
1407
1428
  suppressRefError: false,
1408
- scrollIntoView: scrollIntoView
1429
+ scrollIntoView
1409
1430
  };
1410
1431
  Downshift.stateChangeTypes = stateChangeTypes$3;
1411
1432
  return Downshift;
1412
- }();
1433
+ })();
1413
1434
  process.env.NODE_ENV !== "production" ? Downshift.propTypes = {
1414
1435
  children: PropTypes.func,
1415
1436
  defaultHighlightedIndex: PropTypes.number,
@@ -1455,61 +1476,70 @@ process.env.NODE_ENV !== "production" ? Downshift.propTypes = {
1455
1476
  /* eslint-enable react/no-unused-prop-types */
1456
1477
  } : void 0;
1457
1478
  var Downshift$1 = Downshift;
1458
- function validateGetMenuPropsCalledCorrectly(node, _ref12) {
1459
- var refKey = _ref12.refKey;
1479
+ function validateGetMenuPropsCalledCorrectly(node, _ref3) {
1480
+ let {
1481
+ refKey
1482
+ } = _ref3;
1460
1483
  if (!node) {
1461
1484
  // eslint-disable-next-line no-console
1462
- console.error("downshift: The ref prop \"" + refKey + "\" from getMenuProps was not applied correctly on your menu element.");
1485
+ console.error(`downshift: The ref prop "${refKey}" from getMenuProps was not applied correctly on your menu element.`);
1463
1486
  }
1464
1487
  }
1465
- function validateGetRootPropsCalledCorrectly(element, _ref13) {
1466
- var refKey = _ref13.refKey;
1467
- var refKeySpecified = refKey !== 'ref';
1468
- var isComposite = !isDOMElement(element);
1488
+ function validateGetRootPropsCalledCorrectly(element, _ref4) {
1489
+ let {
1490
+ refKey
1491
+ } = _ref4;
1492
+ const refKeySpecified = refKey !== 'ref';
1493
+ const isComposite = !isDOMElement(element);
1469
1494
  if (isComposite && !refKeySpecified && !isForwardRef(element)) {
1470
1495
  // eslint-disable-next-line no-console
1471
1496
  console.error('downshift: You returned a non-DOM element. You must specify a refKey in getRootProps');
1472
1497
  } else if (!isComposite && refKeySpecified) {
1473
1498
  // eslint-disable-next-line no-console
1474
- console.error("downshift: You returned a DOM element. You should not specify a refKey in getRootProps. You specified \"" + refKey + "\"");
1499
+ console.error(`downshift: You returned a DOM element. You should not specify a refKey in getRootProps. You specified "${refKey}"`);
1475
1500
  }
1476
1501
  if (!isForwardRef(element) && !getElementProps(element)[refKey]) {
1477
1502
  // eslint-disable-next-line no-console
1478
- console.error("downshift: You must apply the ref prop \"" + refKey + "\" from getRootProps onto your root element.");
1503
+ console.error(`downshift: You must apply the ref prop "${refKey}" from getRootProps onto your root element.`);
1479
1504
  }
1480
1505
  }
1481
1506
 
1482
- var _excluded$3 = ["isInitialMount", "highlightedIndex", "items", "environment"];
1483
- var dropdownDefaultStateValues = {
1507
+ const dropdownDefaultStateValues = {
1484
1508
  highlightedIndex: -1,
1485
1509
  isOpen: false,
1486
1510
  selectedItem: null,
1487
1511
  inputValue: ''
1488
1512
  };
1489
1513
  function callOnChangeProps(action, state, newState) {
1490
- var props = action.props,
1491
- type = action.type;
1492
- var changes = {};
1493
- Object.keys(state).forEach(function (key) {
1514
+ const {
1515
+ props,
1516
+ type
1517
+ } = action;
1518
+ const changes = {};
1519
+ Object.keys(state).forEach(key => {
1494
1520
  invokeOnChangeHandler(key, action, state, newState);
1495
1521
  if (newState[key] !== state[key]) {
1496
1522
  changes[key] = newState[key];
1497
1523
  }
1498
1524
  });
1499
1525
  if (props.onStateChange && Object.keys(changes).length) {
1500
- props.onStateChange(_extends({
1501
- type: type
1502
- }, changes));
1526
+ props.onStateChange({
1527
+ type,
1528
+ ...changes
1529
+ });
1503
1530
  }
1504
1531
  }
1505
1532
  function invokeOnChangeHandler(key, action, state, newState) {
1506
- var props = action.props,
1507
- type = action.type;
1508
- var handler = "on" + capitalizeString(key) + "Change";
1533
+ const {
1534
+ props,
1535
+ type
1536
+ } = action;
1537
+ const handler = `on${capitalizeString(key)}Change`;
1509
1538
  if (props[handler] && newState[key] !== undefined && newState[key] !== state[key]) {
1510
- props[handler](_extends({
1511
- type: type
1512
- }, newState));
1539
+ props[handler]({
1540
+ type,
1541
+ ...newState
1542
+ });
1513
1543
  }
1514
1544
  }
1515
1545
 
@@ -1531,36 +1561,37 @@ function stateReducer(s, a) {
1531
1561
  * @returns {string} The a11y message.
1532
1562
  */
1533
1563
  function getA11ySelectionMessage(selectionParameters) {
1534
- var selectedItem = selectionParameters.selectedItem,
1535
- itemToStringLocal = selectionParameters.itemToString;
1536
- return selectedItem ? itemToStringLocal(selectedItem) + " has been selected." : '';
1564
+ const {
1565
+ selectedItem,
1566
+ itemToString: itemToStringLocal
1567
+ } = selectionParameters;
1568
+ return selectedItem ? `${itemToStringLocal(selectedItem)} has been selected.` : '';
1537
1569
  }
1538
1570
 
1539
1571
  /**
1540
1572
  * Debounced call for updating the a11y message.
1541
1573
  */
1542
- var updateA11yStatus = debounce(function (getA11yMessage, document) {
1574
+ const updateA11yStatus = debounce((getA11yMessage, document) => {
1543
1575
  setStatus(getA11yMessage(), document);
1544
1576
  }, 200);
1545
1577
 
1546
1578
  // istanbul ignore next
1547
- var useIsomorphicLayoutEffect = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined' ? useLayoutEffect : useEffect;
1579
+ const useIsomorphicLayoutEffect = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined' ? useLayoutEffect : useEffect;
1548
1580
  function useElementIds(_ref) {
1549
- var _ref$id = _ref.id,
1550
- id = _ref$id === void 0 ? "downshift-" + generateId() : _ref$id,
1551
- labelId = _ref.labelId,
1552
- menuId = _ref.menuId,
1553
- getItemId = _ref.getItemId,
1554
- toggleButtonId = _ref.toggleButtonId,
1555
- inputId = _ref.inputId;
1556
- var elementIdsRef = useRef({
1557
- labelId: labelId || id + "-label",
1558
- menuId: menuId || id + "-menu",
1559
- getItemId: getItemId || function (index) {
1560
- return id + "-item-" + index;
1561
- },
1562
- toggleButtonId: toggleButtonId || id + "-toggle-button",
1563
- inputId: inputId || id + "-input"
1581
+ let {
1582
+ id = `downshift-${generateId()}`,
1583
+ labelId,
1584
+ menuId,
1585
+ getItemId,
1586
+ toggleButtonId,
1587
+ inputId
1588
+ } = _ref;
1589
+ const elementIdsRef = useRef({
1590
+ labelId: labelId || `${id}-label`,
1591
+ menuId: menuId || `${id}-menu`,
1592
+ getItemId: getItemId || (index => `${id}-item-${index}`),
1593
+ toggleButtonId: toggleButtonId || `${id}-toggle-button`,
1594
+ inputId: inputId || `${id}-input`
1564
1595
  });
1565
1596
  return elementIdsRef.current;
1566
1597
  }
@@ -1580,10 +1611,10 @@ function isAcceptedCharacterKey(key) {
1580
1611
  return /^\S{1}$/.test(key);
1581
1612
  }
1582
1613
  function capitalizeString(string) {
1583
- return "" + string.slice(0, 1).toUpperCase() + string.slice(1);
1614
+ return `${string.slice(0, 1).toUpperCase()}${string.slice(1)}`;
1584
1615
  }
1585
1616
  function useLatestRef(val) {
1586
- var ref = useRef(val);
1617
+ const ref = useRef(val);
1587
1618
  // technically this is not "concurrent mode safe" because we're manipulating
1588
1619
  // the value during render (so it's not idempotent). However, the places this
1589
1620
  // hook is used is to support memoizing callbacks which will be called
@@ -1604,28 +1635,26 @@ function useLatestRef(val) {
1604
1635
  * @returns {Array} An array with the state and an action dispatcher.
1605
1636
  */
1606
1637
  function useEnhancedReducer(reducer, initialState, props) {
1607
- var prevStateRef = useRef();
1608
- var actionRef = useRef();
1609
- var enhancedReducer = useCallback(function (state, action) {
1638
+ const prevStateRef = useRef();
1639
+ const actionRef = useRef();
1640
+ const enhancedReducer = useCallback((state, action) => {
1610
1641
  actionRef.current = action;
1611
1642
  state = getState(state, action.props);
1612
- var changes = reducer(state, action);
1613
- var newState = action.props.stateReducer(state, _extends({}, action, {
1614
- changes: changes
1615
- }));
1643
+ const changes = reducer(state, action);
1644
+ const newState = action.props.stateReducer(state, {
1645
+ ...action,
1646
+ changes
1647
+ });
1616
1648
  return newState;
1617
1649
  }, [reducer]);
1618
- var _useReducer = useReducer(enhancedReducer, initialState),
1619
- state = _useReducer[0],
1620
- dispatch = _useReducer[1];
1621
- var propsRef = useLatestRef(props);
1622
- var dispatchWithProps = useCallback(function (action) {
1623
- return dispatch(_extends({
1624
- props: propsRef.current
1625
- }, action));
1626
- }, [propsRef]);
1627
- var action = actionRef.current;
1628
- useEffect(function () {
1650
+ const [state, dispatch] = useReducer(enhancedReducer, initialState);
1651
+ const propsRef = useLatestRef(props);
1652
+ const dispatchWithProps = useCallback(action => dispatch({
1653
+ props: propsRef.current,
1654
+ ...action
1655
+ }), [propsRef]);
1656
+ const action = actionRef.current;
1657
+ useEffect(() => {
1629
1658
  if (action && prevStateRef.current && prevStateRef.current !== state) {
1630
1659
  callOnChangeProps(action, getState(prevStateRef.current, action.props), state);
1631
1660
  }
@@ -1644,16 +1673,14 @@ function useEnhancedReducer(reducer, initialState, props) {
1644
1673
  * @returns {Array} An array with the state and an action dispatcher.
1645
1674
  */
1646
1675
  function useControlledReducer$1(reducer, initialState, props) {
1647
- var _useEnhancedReducer = useEnhancedReducer(reducer, initialState, props),
1648
- state = _useEnhancedReducer[0],
1649
- dispatch = _useEnhancedReducer[1];
1676
+ const [state, dispatch] = useEnhancedReducer(reducer, initialState, props);
1650
1677
  return [getState(state, props), dispatch];
1651
1678
  }
1652
- var defaultProps$3 = {
1653
- itemToString: itemToString,
1654
- stateReducer: stateReducer,
1655
- getA11ySelectionMessage: getA11ySelectionMessage,
1656
- scrollIntoView: scrollIntoView,
1679
+ const defaultProps$3 = {
1680
+ itemToString,
1681
+ stateReducer,
1682
+ getA11ySelectionMessage,
1683
+ scrollIntoView,
1657
1684
  environment: /* istanbul ignore next (ssr) */
1658
1685
  typeof window === 'undefined' ? {} : window
1659
1686
  };
@@ -1661,7 +1688,7 @@ function getDefaultValue$1(props, propKey, defaultStateValues) {
1661
1688
  if (defaultStateValues === void 0) {
1662
1689
  defaultStateValues = dropdownDefaultStateValues;
1663
1690
  }
1664
- var defaultValue = props["default" + capitalizeString(propKey)];
1691
+ const defaultValue = props[`default${capitalizeString(propKey)}`];
1665
1692
  if (defaultValue !== undefined) {
1666
1693
  return defaultValue;
1667
1694
  }
@@ -1671,34 +1698,38 @@ function getInitialValue$1(props, propKey, defaultStateValues) {
1671
1698
  if (defaultStateValues === void 0) {
1672
1699
  defaultStateValues = dropdownDefaultStateValues;
1673
1700
  }
1674
- var value = props[propKey];
1701
+ const value = props[propKey];
1675
1702
  if (value !== undefined) {
1676
1703
  return value;
1677
1704
  }
1678
- var initialValue = props["initial" + capitalizeString(propKey)];
1705
+ const initialValue = props[`initial${capitalizeString(propKey)}`];
1679
1706
  if (initialValue !== undefined) {
1680
1707
  return initialValue;
1681
1708
  }
1682
1709
  return getDefaultValue$1(props, propKey, defaultStateValues);
1683
1710
  }
1684
1711
  function getInitialState$2(props) {
1685
- var selectedItem = getInitialValue$1(props, 'selectedItem');
1686
- var isOpen = getInitialValue$1(props, 'isOpen');
1687
- var highlightedIndex = getInitialValue$1(props, 'highlightedIndex');
1688
- var inputValue = getInitialValue$1(props, 'inputValue');
1712
+ const selectedItem = getInitialValue$1(props, 'selectedItem');
1713
+ const isOpen = getInitialValue$1(props, 'isOpen');
1714
+ const highlightedIndex = getInitialValue$1(props, 'highlightedIndex');
1715
+ const inputValue = getInitialValue$1(props, 'inputValue');
1689
1716
  return {
1690
1717
  highlightedIndex: highlightedIndex < 0 && selectedItem && isOpen ? props.items.indexOf(selectedItem) : highlightedIndex,
1691
- isOpen: isOpen,
1692
- selectedItem: selectedItem,
1693
- inputValue: inputValue
1718
+ isOpen,
1719
+ selectedItem,
1720
+ inputValue
1694
1721
  };
1695
1722
  }
1696
1723
  function getHighlightedIndexOnOpen(props, state, offset) {
1697
- var items = props.items,
1698
- initialHighlightedIndex = props.initialHighlightedIndex,
1699
- defaultHighlightedIndex = props.defaultHighlightedIndex;
1700
- var selectedItem = state.selectedItem,
1701
- highlightedIndex = state.highlightedIndex;
1724
+ const {
1725
+ items,
1726
+ initialHighlightedIndex,
1727
+ defaultHighlightedIndex
1728
+ } = props;
1729
+ const {
1730
+ selectedItem,
1731
+ highlightedIndex
1732
+ } = state;
1702
1733
  if (items.length === 0) {
1703
1734
  return -1;
1704
1735
  }
@@ -1729,34 +1760,30 @@ function getHighlightedIndexOnOpen(props, state, offset) {
1729
1760
  * @returns {Object} Ref containing whether mouseDown or touchMove event is happening
1730
1761
  */
1731
1762
  function useMouseAndTouchTracker(isOpen, downshiftElementRefs, environment, handleBlur) {
1732
- var mouseAndTouchTrackersRef = useRef({
1763
+ const mouseAndTouchTrackersRef = useRef({
1733
1764
  isMouseDown: false,
1734
1765
  isTouchMove: false
1735
1766
  });
1736
- useEffect(function () {
1767
+ useEffect(() => {
1737
1768
  // The same strategy for checking if a click occurred inside or outside downsift
1738
1769
  // as in downshift.js.
1739
- var onMouseDown = function onMouseDown() {
1770
+ const onMouseDown = () => {
1740
1771
  mouseAndTouchTrackersRef.current.isMouseDown = true;
1741
1772
  };
1742
- var onMouseUp = function onMouseUp(event) {
1773
+ const onMouseUp = event => {
1743
1774
  mouseAndTouchTrackersRef.current.isMouseDown = false;
1744
- if (isOpen && !targetWithinDownshift(event.target, downshiftElementRefs.map(function (ref) {
1745
- return ref.current;
1746
- }), environment)) {
1775
+ if (isOpen && !targetWithinDownshift(event.target, downshiftElementRefs.map(ref => ref.current), environment)) {
1747
1776
  handleBlur();
1748
1777
  }
1749
1778
  };
1750
- var onTouchStart = function onTouchStart() {
1779
+ const onTouchStart = () => {
1751
1780
  mouseAndTouchTrackersRef.current.isTouchMove = false;
1752
1781
  };
1753
- var onTouchMove = function onTouchMove() {
1782
+ const onTouchMove = () => {
1754
1783
  mouseAndTouchTrackersRef.current.isTouchMove = true;
1755
1784
  };
1756
- var onTouchEnd = function onTouchEnd(event) {
1757
- if (isOpen && !mouseAndTouchTrackersRef.current.isTouchMove && !targetWithinDownshift(event.target, downshiftElementRefs.map(function (ref) {
1758
- return ref.current;
1759
- }), environment, false)) {
1785
+ const onTouchEnd = event => {
1786
+ if (isOpen && !mouseAndTouchTrackersRef.current.isTouchMove && !targetWithinDownshift(event.target, downshiftElementRefs.map(ref => ref.current), environment, false)) {
1760
1787
  handleBlur();
1761
1788
  }
1762
1789
  };
@@ -1779,9 +1806,7 @@ function useMouseAndTouchTracker(isOpen, downshiftElementRefs, environment, hand
1779
1806
 
1780
1807
  /* istanbul ignore next */
1781
1808
  // eslint-disable-next-line import/no-mutable-exports
1782
- var useGetterPropsCalledChecker = function useGetterPropsCalledChecker() {
1783
- return noop;
1784
- };
1809
+ let useGetterPropsCalledChecker = () => noop;
1785
1810
  /**
1786
1811
  * Custom hook that checks if getter props are called correctly.
1787
1812
  *
@@ -1790,77 +1815,82 @@ var useGetterPropsCalledChecker = function useGetterPropsCalledChecker() {
1790
1815
  */
1791
1816
  /* istanbul ignore next */
1792
1817
  if (process.env.NODE_ENV !== 'production') {
1793
- useGetterPropsCalledChecker = function useGetterPropsCalledChecker() {
1794
- var isInitialMountRef = useRef(true);
1818
+ useGetterPropsCalledChecker = function () {
1819
+ const isInitialMountRef = useRef(true);
1795
1820
  for (var _len = arguments.length, propKeys = new Array(_len), _key = 0; _key < _len; _key++) {
1796
1821
  propKeys[_key] = arguments[_key];
1797
1822
  }
1798
- var getterPropsCalledRef = useRef(propKeys.reduce(function (acc, propKey) {
1823
+ const getterPropsCalledRef = useRef(propKeys.reduce((acc, propKey) => {
1799
1824
  acc[propKey] = {};
1800
1825
  return acc;
1801
1826
  }, {}));
1802
- useEffect(function () {
1803
- Object.keys(getterPropsCalledRef.current).forEach(function (propKey) {
1804
- var propCallInfo = getterPropsCalledRef.current[propKey];
1827
+ useEffect(() => {
1828
+ Object.keys(getterPropsCalledRef.current).forEach(propKey => {
1829
+ const propCallInfo = getterPropsCalledRef.current[propKey];
1805
1830
  if (isInitialMountRef.current) {
1806
1831
  if (!Object.keys(propCallInfo).length) {
1807
1832
  // eslint-disable-next-line no-console
1808
- console.error("downshift: You forgot to call the " + propKey + " getter function on your component / element.");
1833
+ console.error(`downshift: You forgot to call the ${propKey} getter function on your component / element.`);
1809
1834
  return;
1810
1835
  }
1811
1836
  }
1812
- var suppressRefError = propCallInfo.suppressRefError,
1813
- refKey = propCallInfo.refKey,
1814
- elementRef = propCallInfo.elementRef;
1837
+ const {
1838
+ suppressRefError,
1839
+ refKey,
1840
+ elementRef
1841
+ } = propCallInfo;
1815
1842
  if ((!elementRef || !elementRef.current) && !suppressRefError) {
1816
1843
  // eslint-disable-next-line no-console
1817
- console.error("downshift: The ref prop \"" + refKey + "\" from " + propKey + " was not applied correctly on your element.");
1844
+ console.error(`downshift: The ref prop "${refKey}" from ${propKey} was not applied correctly on your element.`);
1818
1845
  }
1819
1846
  });
1820
1847
  isInitialMountRef.current = false;
1821
1848
  });
1822
- var setGetterPropCallInfo = useCallback(function (propKey, suppressRefError, refKey, elementRef) {
1849
+ const setGetterPropCallInfo = useCallback((propKey, suppressRefError, refKey, elementRef) => {
1823
1850
  getterPropsCalledRef.current[propKey] = {
1824
- suppressRefError: suppressRefError,
1825
- refKey: refKey,
1826
- elementRef: elementRef
1851
+ suppressRefError,
1852
+ refKey,
1853
+ elementRef
1827
1854
  };
1828
1855
  }, []);
1829
1856
  return setGetterPropCallInfo;
1830
1857
  };
1831
1858
  }
1832
1859
  function useA11yMessageSetter(getA11yMessage, dependencyArray, _ref2) {
1833
- var isInitialMount = _ref2.isInitialMount,
1834
- highlightedIndex = _ref2.highlightedIndex,
1835
- items = _ref2.items,
1836
- environment = _ref2.environment,
1837
- rest = _objectWithoutPropertiesLoose(_ref2, _excluded$3);
1860
+ let {
1861
+ isInitialMount,
1862
+ highlightedIndex,
1863
+ items,
1864
+ environment,
1865
+ ...rest
1866
+ } = _ref2;
1838
1867
  // Sets a11y status message on changes in state.
1839
- useEffect(function () {
1868
+ useEffect(() => {
1840
1869
  if (isInitialMount || false) {
1841
1870
  return;
1842
1871
  }
1843
- updateA11yStatus(function () {
1844
- return getA11yMessage(_extends({
1845
- highlightedIndex: highlightedIndex,
1846
- highlightedItem: items[highlightedIndex],
1847
- resultCount: items.length
1848
- }, rest));
1849
- }, environment.document);
1872
+ updateA11yStatus(() => getA11yMessage({
1873
+ highlightedIndex,
1874
+ highlightedItem: items[highlightedIndex],
1875
+ resultCount: items.length,
1876
+ ...rest
1877
+ }), environment.document);
1850
1878
  // eslint-disable-next-line react-hooks/exhaustive-deps
1851
1879
  }, dependencyArray);
1852
1880
  }
1853
1881
  function useScrollIntoView(_ref3) {
1854
- var highlightedIndex = _ref3.highlightedIndex,
1855
- isOpen = _ref3.isOpen,
1856
- itemRefs = _ref3.itemRefs,
1857
- getItemNodeFromIndex = _ref3.getItemNodeFromIndex,
1858
- menuElement = _ref3.menuElement,
1859
- scrollIntoViewProp = _ref3.scrollIntoView;
1882
+ let {
1883
+ highlightedIndex,
1884
+ isOpen,
1885
+ itemRefs,
1886
+ getItemNodeFromIndex,
1887
+ menuElement,
1888
+ scrollIntoView: scrollIntoViewProp
1889
+ } = _ref3;
1860
1890
  // used not to scroll on highlight by mouse.
1861
- var shouldScrollRef = useRef(true);
1891
+ const shouldScrollRef = useRef(true);
1862
1892
  // Scroll on highlighted item if change comes from keyboard.
1863
- useIsomorphicLayoutEffect(function () {
1893
+ useIsomorphicLayoutEffect(() => {
1864
1894
  if (highlightedIndex < 0 || !isOpen || !Object.keys(itemRefs.current).length) {
1865
1895
  return;
1866
1896
  }
@@ -1875,16 +1905,18 @@ function useScrollIntoView(_ref3) {
1875
1905
  }
1876
1906
 
1877
1907
  // eslint-disable-next-line import/no-mutable-exports
1878
- var useControlPropsValidator = noop;
1908
+ let useControlPropsValidator = noop;
1879
1909
  /* istanbul ignore next */
1880
1910
  if (process.env.NODE_ENV !== 'production') {
1881
- useControlPropsValidator = function useControlPropsValidator(_ref4) {
1882
- var isInitialMount = _ref4.isInitialMount,
1883
- props = _ref4.props,
1884
- state = _ref4.state;
1911
+ useControlPropsValidator = _ref4 => {
1912
+ let {
1913
+ isInitialMount,
1914
+ props,
1915
+ state
1916
+ } = _ref4;
1885
1917
  // used for checking when props are moving from controlled to uncontrolled.
1886
- var prevPropsRef = useRef(props);
1887
- useEffect(function () {
1918
+ const prevPropsRef = useRef(props);
1919
+ useEffect(() => {
1888
1920
  if (isInitialMount) {
1889
1921
  return;
1890
1922
  }
@@ -1895,9 +1927,11 @@ if (process.env.NODE_ENV !== 'production') {
1895
1927
  }
1896
1928
 
1897
1929
  function downshiftCommonReducer(state, action, stateChangeTypes) {
1898
- var type = action.type,
1899
- props = action.props;
1900
- var changes;
1930
+ const {
1931
+ type,
1932
+ props
1933
+ } = action;
1934
+ let changes;
1901
1935
  switch (type) {
1902
1936
  case stateChangeTypes.ItemMouseMove:
1903
1937
  changes = {
@@ -1948,7 +1982,10 @@ function downshiftCommonReducer(state, action, stateChangeTypes) {
1948
1982
  default:
1949
1983
  throw new Error('Reducer called without proper action type.');
1950
1984
  }
1951
- return _extends({}, state, changes);
1985
+ return {
1986
+ ...state,
1987
+ ...changes
1988
+ };
1952
1989
  }
1953
1990
  /* eslint-enable complexity */
1954
1991
 
@@ -2034,28 +2071,28 @@ if (process.env.NODE_ENV !== 'production') {
2034
2071
  };
2035
2072
  }
2036
2073
 
2037
- var ToggleButtonClick$1 = process.env.NODE_ENV !== "production" ? '__togglebutton_click__' : 0;
2038
- var ToggleButtonKeyDownArrowDown = process.env.NODE_ENV !== "production" ? '__togglebutton_keydown_arrow_down__' : 1;
2039
- var ToggleButtonKeyDownArrowUp = process.env.NODE_ENV !== "production" ? '__togglebutton_keydown_arrow_up__' : 2;
2040
- var ToggleButtonKeyDownCharacter = process.env.NODE_ENV !== "production" ? '__togglebutton_keydown_character__' : 3;
2041
- var ToggleButtonKeyDownEscape = process.env.NODE_ENV !== "production" ? '__togglebutton_keydown_escape__' : 4;
2042
- var ToggleButtonKeyDownHome = process.env.NODE_ENV !== "production" ? '__togglebutton_keydown_home__' : 5;
2043
- var ToggleButtonKeyDownEnd = process.env.NODE_ENV !== "production" ? '__togglebutton_keydown_end__' : 6;
2044
- var ToggleButtonKeyDownEnter = process.env.NODE_ENV !== "production" ? '__togglebutton_keydown_enter__' : 7;
2045
- var ToggleButtonKeyDownSpaceButton = process.env.NODE_ENV !== "production" ? '__togglebutton_keydown_space_button__' : 8;
2046
- var ToggleButtonKeyDownPageUp = process.env.NODE_ENV !== "production" ? '__togglebutton_keydown_page_up__' : 9;
2047
- var ToggleButtonKeyDownPageDown = process.env.NODE_ENV !== "production" ? '__togglebutton_keydown_page_down__' : 10;
2048
- var ToggleButtonBlur = process.env.NODE_ENV !== "production" ? '__togglebutton_blur__' : 11;
2049
- var MenuMouseLeave$1 = process.env.NODE_ENV !== "production" ? '__menu_mouse_leave__' : 12;
2050
- var ItemMouseMove$1 = process.env.NODE_ENV !== "production" ? '__item_mouse_move__' : 13;
2051
- var ItemClick$1 = process.env.NODE_ENV !== "production" ? '__item_click__' : 14;
2052
- var FunctionToggleMenu$1 = process.env.NODE_ENV !== "production" ? '__function_toggle_menu__' : 15;
2053
- var FunctionOpenMenu$1 = process.env.NODE_ENV !== "production" ? '__function_open_menu__' : 16;
2054
- var FunctionCloseMenu$1 = process.env.NODE_ENV !== "production" ? '__function_close_menu__' : 17;
2055
- var FunctionSetHighlightedIndex$1 = process.env.NODE_ENV !== "production" ? '__function_set_highlighted_index__' : 18;
2056
- var FunctionSelectItem$1 = process.env.NODE_ENV !== "production" ? '__function_select_item__' : 19;
2057
- var FunctionSetInputValue$1 = process.env.NODE_ENV !== "production" ? '__function_set_input_value__' : 20;
2058
- var FunctionReset$2 = process.env.NODE_ENV !== "production" ? '__function_reset__' : 21;
2074
+ const ToggleButtonClick$1 = process.env.NODE_ENV !== "production" ? '__togglebutton_click__' : 0;
2075
+ const ToggleButtonKeyDownArrowDown = process.env.NODE_ENV !== "production" ? '__togglebutton_keydown_arrow_down__' : 1;
2076
+ const ToggleButtonKeyDownArrowUp = process.env.NODE_ENV !== "production" ? '__togglebutton_keydown_arrow_up__' : 2;
2077
+ const ToggleButtonKeyDownCharacter = process.env.NODE_ENV !== "production" ? '__togglebutton_keydown_character__' : 3;
2078
+ const ToggleButtonKeyDownEscape = process.env.NODE_ENV !== "production" ? '__togglebutton_keydown_escape__' : 4;
2079
+ const ToggleButtonKeyDownHome = process.env.NODE_ENV !== "production" ? '__togglebutton_keydown_home__' : 5;
2080
+ const ToggleButtonKeyDownEnd = process.env.NODE_ENV !== "production" ? '__togglebutton_keydown_end__' : 6;
2081
+ const ToggleButtonKeyDownEnter = process.env.NODE_ENV !== "production" ? '__togglebutton_keydown_enter__' : 7;
2082
+ const ToggleButtonKeyDownSpaceButton = process.env.NODE_ENV !== "production" ? '__togglebutton_keydown_space_button__' : 8;
2083
+ const ToggleButtonKeyDownPageUp = process.env.NODE_ENV !== "production" ? '__togglebutton_keydown_page_up__' : 9;
2084
+ const ToggleButtonKeyDownPageDown = process.env.NODE_ENV !== "production" ? '__togglebutton_keydown_page_down__' : 10;
2085
+ const ToggleButtonBlur = process.env.NODE_ENV !== "production" ? '__togglebutton_blur__' : 11;
2086
+ const MenuMouseLeave$1 = process.env.NODE_ENV !== "production" ? '__menu_mouse_leave__' : 12;
2087
+ const ItemMouseMove$1 = process.env.NODE_ENV !== "production" ? '__item_mouse_move__' : 13;
2088
+ const ItemClick$1 = process.env.NODE_ENV !== "production" ? '__item_click__' : 14;
2089
+ const FunctionToggleMenu$1 = process.env.NODE_ENV !== "production" ? '__function_toggle_menu__' : 15;
2090
+ const FunctionOpenMenu$1 = process.env.NODE_ENV !== "production" ? '__function_open_menu__' : 16;
2091
+ const FunctionCloseMenu$1 = process.env.NODE_ENV !== "production" ? '__function_close_menu__' : 17;
2092
+ const FunctionSetHighlightedIndex$1 = process.env.NODE_ENV !== "production" ? '__function_set_highlighted_index__' : 18;
2093
+ const FunctionSelectItem$1 = process.env.NODE_ENV !== "production" ? '__function_select_item__' : 19;
2094
+ const FunctionSetInputValue$1 = process.env.NODE_ENV !== "production" ? '__function_set_input_value__' : 20;
2095
+ const FunctionReset$2 = process.env.NODE_ENV !== "production" ? '__function_reset__' : 21;
2059
2096
 
2060
2097
  var stateChangeTypes$2 = /*#__PURE__*/Object.freeze({
2061
2098
  __proto__: null,
@@ -2085,10 +2122,12 @@ var stateChangeTypes$2 = /*#__PURE__*/Object.freeze({
2085
2122
 
2086
2123
  /* eslint-disable complexity */
2087
2124
  function downshiftSelectReducer(state, action) {
2088
- var type = action.type,
2089
- props = action.props,
2090
- altKey = action.altKey;
2091
- var changes;
2125
+ const {
2126
+ type,
2127
+ props,
2128
+ altKey
2129
+ } = action;
2130
+ let changes;
2092
2131
  switch (type) {
2093
2132
  case ItemClick$1:
2094
2133
  changes = {
@@ -2099,10 +2138,10 @@ function downshiftSelectReducer(state, action) {
2099
2138
  break;
2100
2139
  case ToggleButtonKeyDownCharacter:
2101
2140
  {
2102
- var lowercasedKey = action.key;
2103
- var inputValue = "" + state.inputValue + lowercasedKey;
2104
- var prevHighlightedIndex = !state.isOpen && state.selectedItem ? props.items.indexOf(state.selectedItem) : state.highlightedIndex;
2105
- var highlightedIndex = getItemIndexByCharacterKey({
2141
+ const lowercasedKey = action.key;
2142
+ const inputValue = `${state.inputValue}${lowercasedKey}`;
2143
+ const prevHighlightedIndex = !state.isOpen && state.selectedItem ? props.items.indexOf(state.selectedItem) : state.highlightedIndex;
2144
+ const highlightedIndex = getItemIndexByCharacterKey({
2106
2145
  keysSoFar: inputValue,
2107
2146
  highlightedIndex: prevHighlightedIndex,
2108
2147
  items: props.items,
@@ -2110,33 +2149,34 @@ function downshiftSelectReducer(state, action) {
2110
2149
  getItemNodeFromIndex: action.getItemNodeFromIndex
2111
2150
  });
2112
2151
  changes = {
2113
- inputValue: inputValue,
2114
- highlightedIndex: highlightedIndex,
2152
+ inputValue,
2153
+ highlightedIndex,
2115
2154
  isOpen: true
2116
2155
  };
2117
2156
  }
2118
2157
  break;
2119
2158
  case ToggleButtonKeyDownArrowDown:
2120
2159
  {
2121
- var _highlightedIndex = state.isOpen ? getNextWrappingIndex(1, state.highlightedIndex, props.items.length, action.getItemNodeFromIndex, false) : altKey && state.selectedItem == null ? -1 : getHighlightedIndexOnOpen(props, state, 1);
2160
+ const highlightedIndex = state.isOpen ? getNextWrappingIndex(1, state.highlightedIndex, props.items.length, action.getItemNodeFromIndex, false) : altKey && state.selectedItem == null ? -1 : getHighlightedIndexOnOpen(props, state, 1);
2122
2161
  changes = {
2123
- highlightedIndex: _highlightedIndex,
2162
+ highlightedIndex,
2124
2163
  isOpen: true
2125
2164
  };
2126
2165
  }
2127
2166
  break;
2128
2167
  case ToggleButtonKeyDownArrowUp:
2129
2168
  if (state.isOpen && altKey) {
2130
- changes = _extends({
2169
+ changes = {
2131
2170
  isOpen: getDefaultValue$1(props, 'isOpen'),
2132
- highlightedIndex: getDefaultValue$1(props, 'highlightedIndex')
2133
- }, state.highlightedIndex >= 0 && {
2134
- selectedItem: props.items[state.highlightedIndex]
2135
- });
2171
+ highlightedIndex: getDefaultValue$1(props, 'highlightedIndex'),
2172
+ ...(state.highlightedIndex >= 0 && {
2173
+ selectedItem: props.items[state.highlightedIndex]
2174
+ })
2175
+ };
2136
2176
  } else {
2137
- var _highlightedIndex2 = state.isOpen ? getNextWrappingIndex(-1, state.highlightedIndex, props.items.length, action.getItemNodeFromIndex, false) : getHighlightedIndexOnOpen(props, state, -1);
2177
+ const highlightedIndex = state.isOpen ? getNextWrappingIndex(-1, state.highlightedIndex, props.items.length, action.getItemNodeFromIndex, false) : getHighlightedIndexOnOpen(props, state, -1);
2138
2178
  changes = {
2139
- highlightedIndex: _highlightedIndex2,
2179
+ highlightedIndex,
2140
2180
  isOpen: true
2141
2181
  };
2142
2182
  }
@@ -2144,12 +2184,13 @@ function downshiftSelectReducer(state, action) {
2144
2184
  // only triggered when menu is open.
2145
2185
  case ToggleButtonKeyDownEnter:
2146
2186
  case ToggleButtonKeyDownSpaceButton:
2147
- changes = _extends({
2187
+ changes = {
2148
2188
  isOpen: getDefaultValue$1(props, 'isOpen'),
2149
- highlightedIndex: getDefaultValue$1(props, 'highlightedIndex')
2150
- }, state.highlightedIndex >= 0 && {
2151
- selectedItem: props.items[state.highlightedIndex]
2152
- });
2189
+ highlightedIndex: getDefaultValue$1(props, 'highlightedIndex'),
2190
+ ...(state.highlightedIndex >= 0 && {
2191
+ selectedItem: props.items[state.highlightedIndex]
2192
+ })
2193
+ };
2153
2194
  break;
2154
2195
  case ToggleButtonKeyDownHome:
2155
2196
  changes = {
@@ -2180,12 +2221,13 @@ function downshiftSelectReducer(state, action) {
2180
2221
  };
2181
2222
  break;
2182
2223
  case ToggleButtonBlur:
2183
- changes = _extends({
2224
+ changes = {
2184
2225
  isOpen: false,
2185
- highlightedIndex: -1
2186
- }, state.highlightedIndex >= 0 && {
2187
- selectedItem: props.items[state.highlightedIndex]
2188
- });
2226
+ highlightedIndex: -1,
2227
+ ...(state.highlightedIndex >= 0 && {
2228
+ selectedItem: props.items[state.highlightedIndex]
2229
+ })
2230
+ };
2189
2231
  break;
2190
2232
  case FunctionSelectItem$1:
2191
2233
  changes = {
@@ -2195,13 +2237,13 @@ function downshiftSelectReducer(state, action) {
2195
2237
  default:
2196
2238
  return downshiftCommonReducer(state, action, stateChangeTypes$2);
2197
2239
  }
2198
- return _extends({}, state, changes);
2240
+ return {
2241
+ ...state,
2242
+ ...changes
2243
+ };
2199
2244
  }
2200
2245
  /* eslint-enable complexity */
2201
2246
 
2202
- var _excluded$2 = ["onMouseLeave", "refKey", "onKeyDown", "onBlur", "ref"],
2203
- _excluded2$2 = ["onBlur", "onClick", "onKeyDown", "refKey", "ref"],
2204
- _excluded3$1 = ["item", "index", "onMouseMove", "onClick", "refKey", "ref", "disabled"];
2205
2247
  useSelect.stateChangeTypes = stateChangeTypes$2;
2206
2248
  function useSelect(userProps) {
2207
2249
  if (userProps === void 0) {
@@ -2209,76 +2251,81 @@ function useSelect(userProps) {
2209
2251
  }
2210
2252
  validatePropTypes$2(userProps, useSelect);
2211
2253
  // Props defaults and destructuring.
2212
- var props = _extends({}, defaultProps$2, userProps);
2213
- var items = props.items,
2214
- scrollIntoView = props.scrollIntoView,
2215
- environment = props.environment,
2216
- itemToString = props.itemToString,
2217
- getA11ySelectionMessage = props.getA11ySelectionMessage,
2218
- getA11yStatusMessage = props.getA11yStatusMessage;
2254
+ const props = {
2255
+ ...defaultProps$2,
2256
+ ...userProps
2257
+ };
2258
+ const {
2259
+ items,
2260
+ scrollIntoView,
2261
+ environment,
2262
+ itemToString,
2263
+ getA11ySelectionMessage,
2264
+ getA11yStatusMessage
2265
+ } = props;
2219
2266
  // Initial state depending on controlled props.
2220
- var initialState = getInitialState$2(props);
2221
- var _useControlledReducer = useControlledReducer$1(downshiftSelectReducer, initialState, props),
2222
- state = _useControlledReducer[0],
2223
- dispatch = _useControlledReducer[1];
2224
- var isOpen = state.isOpen,
2225
- highlightedIndex = state.highlightedIndex,
2226
- selectedItem = state.selectedItem,
2227
- inputValue = state.inputValue;
2267
+ const initialState = getInitialState$2(props);
2268
+ const [state, dispatch] = useControlledReducer$1(downshiftSelectReducer, initialState, props);
2269
+ const {
2270
+ isOpen,
2271
+ highlightedIndex,
2272
+ selectedItem,
2273
+ inputValue
2274
+ } = state;
2228
2275
 
2229
2276
  // Element efs.
2230
- var toggleButtonRef = useRef(null);
2231
- var menuRef = useRef(null);
2232
- var itemRefs = useRef({});
2277
+ const toggleButtonRef = useRef(null);
2278
+ const menuRef = useRef(null);
2279
+ const itemRefs = useRef({});
2233
2280
  // used to keep the inputValue clearTimeout object between renders.
2234
- var clearTimeoutRef = useRef(null);
2281
+ const clearTimeoutRef = useRef(null);
2235
2282
  // prevent id re-generation between renders.
2236
- var elementIds = useElementIds(props);
2283
+ const elementIds = useElementIds(props);
2237
2284
  // used to keep track of how many items we had on previous cycle.
2238
- var previousResultCountRef = useRef();
2239
- var isInitialMountRef = useRef(true);
2285
+ const previousResultCountRef = useRef();
2286
+ const isInitialMountRef = useRef(true);
2240
2287
  // utility callback to get item element.
2241
- var latest = useLatestRef({
2242
- state: state,
2243
- props: props
2288
+ const latest = useLatestRef({
2289
+ state,
2290
+ props
2244
2291
  });
2245
2292
 
2246
2293
  // Some utils.
2247
- var getItemNodeFromIndex = useCallback(function (index) {
2248
- return itemRefs.current[elementIds.getItemId(index)];
2249
- }, [elementIds]);
2294
+ const getItemNodeFromIndex = useCallback(index => itemRefs.current[elementIds.getItemId(index)], [elementIds]);
2250
2295
 
2251
2296
  // Effects.
2252
2297
  // Sets a11y status message on changes in state.
2253
- useA11yMessageSetter(getA11yStatusMessage, [isOpen, highlightedIndex, inputValue, items], _extends({
2298
+ useA11yMessageSetter(getA11yStatusMessage, [isOpen, highlightedIndex, inputValue, items], {
2254
2299
  isInitialMount: isInitialMountRef.current,
2255
2300
  previousResultCount: previousResultCountRef.current,
2256
- items: items,
2257
- environment: environment,
2258
- itemToString: itemToString
2259
- }, state));
2301
+ items,
2302
+ environment,
2303
+ itemToString,
2304
+ ...state
2305
+ });
2260
2306
  // Sets a11y status message on changes in selectedItem.
2261
- useA11yMessageSetter(getA11ySelectionMessage, [selectedItem], _extends({
2307
+ useA11yMessageSetter(getA11ySelectionMessage, [selectedItem], {
2262
2308
  isInitialMount: isInitialMountRef.current,
2263
2309
  previousResultCount: previousResultCountRef.current,
2264
- items: items,
2265
- environment: environment,
2266
- itemToString: itemToString
2267
- }, state));
2310
+ items,
2311
+ environment,
2312
+ itemToString,
2313
+ ...state
2314
+ });
2268
2315
  // Scroll on highlighted item if change comes from keyboard.
2269
- var shouldScrollRef = useScrollIntoView({
2316
+ const shouldScrollRef = useScrollIntoView({
2270
2317
  menuElement: menuRef.current,
2271
- highlightedIndex: highlightedIndex,
2272
- isOpen: isOpen,
2273
- itemRefs: itemRefs,
2274
- scrollIntoView: scrollIntoView,
2275
- getItemNodeFromIndex: getItemNodeFromIndex
2318
+ highlightedIndex,
2319
+ isOpen,
2320
+ itemRefs,
2321
+ scrollIntoView,
2322
+ getItemNodeFromIndex
2276
2323
  });
2277
2324
 
2278
2325
  // Sets cleanup for the keysSoFar callback, debounded after 500ms.
2279
- useEffect(function () {
2326
+ useEffect(() => {
2280
2327
  // init the clean function here as we need access to dispatch.
2281
- clearTimeoutRef.current = debounce(function (outerDispatch) {
2328
+ clearTimeoutRef.current = debounce(outerDispatch => {
2282
2329
  outerDispatch({
2283
2330
  type: FunctionSetInputValue$1,
2284
2331
  inputValue: ''
@@ -2286,13 +2333,13 @@ function useSelect(userProps) {
2286
2333
  }, 500);
2287
2334
 
2288
2335
  // Cancel any pending debounced calls on mount
2289
- return function () {
2336
+ return () => {
2290
2337
  clearTimeoutRef.current.cancel();
2291
2338
  };
2292
2339
  }, []);
2293
2340
 
2294
2341
  // Invokes the keysSoFar callback set up above.
2295
- useEffect(function () {
2342
+ useEffect(() => {
2296
2343
  if (!inputValue) {
2297
2344
  return;
2298
2345
  }
@@ -2300,234 +2347,249 @@ function useSelect(userProps) {
2300
2347
  }, [dispatch, inputValue]);
2301
2348
  useControlPropsValidator({
2302
2349
  isInitialMount: isInitialMountRef.current,
2303
- props: props,
2304
- state: state
2350
+ props,
2351
+ state
2305
2352
  });
2306
- useEffect(function () {
2353
+ useEffect(() => {
2307
2354
  if (isInitialMountRef.current) {
2308
2355
  return;
2309
2356
  }
2310
2357
  previousResultCountRef.current = items.length;
2311
2358
  });
2312
2359
  // Add mouse/touch events to document.
2313
- var mouseAndTouchTrackersRef = useMouseAndTouchTracker(isOpen, [menuRef, toggleButtonRef], environment, function () {
2360
+ const mouseAndTouchTrackersRef = useMouseAndTouchTracker(isOpen, [menuRef, toggleButtonRef], environment, () => {
2314
2361
  dispatch({
2315
2362
  type: ToggleButtonBlur
2316
2363
  });
2317
2364
  });
2318
- var setGetterPropCallInfo = useGetterPropsCalledChecker('getMenuProps', 'getToggleButtonProps');
2365
+ const setGetterPropCallInfo = useGetterPropsCalledChecker('getMenuProps', 'getToggleButtonProps');
2319
2366
  // Make initial ref false.
2320
- useEffect(function () {
2367
+ useEffect(() => {
2321
2368
  isInitialMountRef.current = false;
2322
- return function () {
2369
+ return () => {
2323
2370
  isInitialMountRef.current = true;
2324
2371
  };
2325
2372
  }, []);
2326
2373
  // Reset itemRefs on close.
2327
- useEffect(function () {
2374
+ useEffect(() => {
2328
2375
  if (!isOpen) {
2329
2376
  itemRefs.current = {};
2330
2377
  }
2331
2378
  }, [isOpen]);
2332
2379
 
2333
2380
  // Event handler functions.
2334
- var toggleButtonKeyDownHandlers = useMemo(function () {
2335
- return {
2336
- ArrowDown: function ArrowDown(event) {
2337
- event.preventDefault();
2381
+ const toggleButtonKeyDownHandlers = useMemo(() => ({
2382
+ ArrowDown(event) {
2383
+ event.preventDefault();
2384
+ dispatch({
2385
+ type: ToggleButtonKeyDownArrowDown,
2386
+ getItemNodeFromIndex,
2387
+ altKey: event.altKey
2388
+ });
2389
+ },
2390
+ ArrowUp(event) {
2391
+ event.preventDefault();
2392
+ dispatch({
2393
+ type: ToggleButtonKeyDownArrowUp,
2394
+ getItemNodeFromIndex,
2395
+ altKey: event.altKey
2396
+ });
2397
+ },
2398
+ Home(event) {
2399
+ event.preventDefault();
2400
+ dispatch({
2401
+ type: ToggleButtonKeyDownHome,
2402
+ getItemNodeFromIndex
2403
+ });
2404
+ },
2405
+ End(event) {
2406
+ event.preventDefault();
2407
+ dispatch({
2408
+ type: ToggleButtonKeyDownEnd,
2409
+ getItemNodeFromIndex
2410
+ });
2411
+ },
2412
+ Escape() {
2413
+ if (latest.current.state.isOpen) {
2338
2414
  dispatch({
2339
- type: ToggleButtonKeyDownArrowDown,
2340
- getItemNodeFromIndex: getItemNodeFromIndex,
2341
- altKey: event.altKey
2415
+ type: ToggleButtonKeyDownEscape
2342
2416
  });
2343
- },
2344
- ArrowUp: function ArrowUp(event) {
2417
+ }
2418
+ },
2419
+ Enter(event) {
2420
+ event.preventDefault();
2421
+ dispatch({
2422
+ type: latest.current.state.isOpen ? ToggleButtonKeyDownEnter : ToggleButtonClick$1
2423
+ });
2424
+ },
2425
+ PageUp(event) {
2426
+ if (latest.current.state.isOpen) {
2345
2427
  event.preventDefault();
2346
2428
  dispatch({
2347
- type: ToggleButtonKeyDownArrowUp,
2348
- getItemNodeFromIndex: getItemNodeFromIndex,
2349
- altKey: event.altKey
2429
+ type: ToggleButtonKeyDownPageUp,
2430
+ getItemNodeFromIndex
2350
2431
  });
2351
- },
2352
- Home: function Home(event) {
2432
+ }
2433
+ },
2434
+ PageDown(event) {
2435
+ if (latest.current.state.isOpen) {
2353
2436
  event.preventDefault();
2354
2437
  dispatch({
2355
- type: ToggleButtonKeyDownHome,
2356
- getItemNodeFromIndex: getItemNodeFromIndex
2438
+ type: ToggleButtonKeyDownPageDown,
2439
+ getItemNodeFromIndex
2357
2440
  });
2358
- },
2359
- End: function End(event) {
2360
- event.preventDefault();
2441
+ }
2442
+ },
2443
+ ' '(event) {
2444
+ event.preventDefault();
2445
+ const currentState = latest.current.state;
2446
+ if (!currentState.isOpen) {
2361
2447
  dispatch({
2362
- type: ToggleButtonKeyDownEnd,
2363
- getItemNodeFromIndex: getItemNodeFromIndex
2448
+ type: ToggleButtonClick$1
2364
2449
  });
2365
- },
2366
- Escape: function Escape() {
2367
- if (latest.current.state.isOpen) {
2368
- dispatch({
2369
- type: ToggleButtonKeyDownEscape
2370
- });
2371
- }
2372
- },
2373
- Enter: function Enter(event) {
2374
- event.preventDefault();
2450
+ return;
2451
+ }
2452
+ if (currentState.inputValue) {
2375
2453
  dispatch({
2376
- type: latest.current.state.isOpen ? ToggleButtonKeyDownEnter : ToggleButtonClick$1
2454
+ type: ToggleButtonKeyDownCharacter,
2455
+ key: ' ',
2456
+ getItemNodeFromIndex
2457
+ });
2458
+ } else {
2459
+ dispatch({
2460
+ type: ToggleButtonKeyDownSpaceButton
2377
2461
  });
2378
- },
2379
- PageUp: function PageUp(event) {
2380
- if (latest.current.state.isOpen) {
2381
- event.preventDefault();
2382
- dispatch({
2383
- type: ToggleButtonKeyDownPageUp,
2384
- getItemNodeFromIndex: getItemNodeFromIndex
2385
- });
2386
- }
2387
- },
2388
- PageDown: function PageDown(event) {
2389
- if (latest.current.state.isOpen) {
2390
- event.preventDefault();
2391
- dispatch({
2392
- type: ToggleButtonKeyDownPageDown,
2393
- getItemNodeFromIndex: getItemNodeFromIndex
2394
- });
2395
- }
2396
- },
2397
- ' ': function _(event) {
2398
- event.preventDefault();
2399
- var currentState = latest.current.state;
2400
- if (!currentState.isOpen) {
2401
- dispatch({
2402
- type: ToggleButtonClick$1
2403
- });
2404
- return;
2405
- }
2406
- if (currentState.inputValue) {
2407
- dispatch({
2408
- type: ToggleButtonKeyDownCharacter,
2409
- key: ' ',
2410
- getItemNodeFromIndex: getItemNodeFromIndex
2411
- });
2412
- } else {
2413
- dispatch({
2414
- type: ToggleButtonKeyDownSpaceButton
2415
- });
2416
- }
2417
2462
  }
2418
- };
2419
- }, [dispatch, getItemNodeFromIndex, latest]);
2463
+ }
2464
+ }), [dispatch, getItemNodeFromIndex, latest]);
2420
2465
 
2421
2466
  // Action functions.
2422
- var toggleMenu = useCallback(function () {
2467
+ const toggleMenu = useCallback(() => {
2423
2468
  dispatch({
2424
2469
  type: FunctionToggleMenu$1
2425
2470
  });
2426
2471
  }, [dispatch]);
2427
- var closeMenu = useCallback(function () {
2472
+ const closeMenu = useCallback(() => {
2428
2473
  dispatch({
2429
2474
  type: FunctionCloseMenu$1
2430
2475
  });
2431
2476
  }, [dispatch]);
2432
- var openMenu = useCallback(function () {
2477
+ const openMenu = useCallback(() => {
2433
2478
  dispatch({
2434
2479
  type: FunctionOpenMenu$1
2435
2480
  });
2436
2481
  }, [dispatch]);
2437
- var setHighlightedIndex = useCallback(function (newHighlightedIndex) {
2482
+ const setHighlightedIndex = useCallback(newHighlightedIndex => {
2438
2483
  dispatch({
2439
2484
  type: FunctionSetHighlightedIndex$1,
2440
2485
  highlightedIndex: newHighlightedIndex
2441
2486
  });
2442
2487
  }, [dispatch]);
2443
- var selectItem = useCallback(function (newSelectedItem) {
2488
+ const selectItem = useCallback(newSelectedItem => {
2444
2489
  dispatch({
2445
2490
  type: FunctionSelectItem$1,
2446
2491
  selectedItem: newSelectedItem
2447
2492
  });
2448
2493
  }, [dispatch]);
2449
- var reset = useCallback(function () {
2494
+ const reset = useCallback(() => {
2450
2495
  dispatch({
2451
2496
  type: FunctionReset$2
2452
2497
  });
2453
2498
  }, [dispatch]);
2454
- var setInputValue = useCallback(function (newInputValue) {
2499
+ const setInputValue = useCallback(newInputValue => {
2455
2500
  dispatch({
2456
2501
  type: FunctionSetInputValue$1,
2457
2502
  inputValue: newInputValue
2458
2503
  });
2459
2504
  }, [dispatch]);
2460
2505
  // Getter functions.
2461
- var getLabelProps = useCallback(function (labelProps) {
2462
- return _extends({
2463
- id: elementIds.labelId,
2464
- htmlFor: elementIds.toggleButtonId
2465
- }, labelProps);
2466
- }, [elementIds]);
2467
- var getMenuProps = useCallback(function (_temp, _temp2) {
2468
- var _extends2;
2469
- var _ref = _temp === void 0 ? {} : _temp,
2470
- onMouseLeave = _ref.onMouseLeave,
2471
- _ref$refKey = _ref.refKey,
2472
- refKey = _ref$refKey === void 0 ? 'ref' : _ref$refKey;
2473
- _ref.onKeyDown;
2474
- _ref.onBlur;
2475
- var ref = _ref.ref,
2476
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$2);
2477
- var _ref2 = _temp2 === void 0 ? {} : _temp2,
2478
- _ref2$suppressRefErro = _ref2.suppressRefError,
2479
- suppressRefError = _ref2$suppressRefErro === void 0 ? false : _ref2$suppressRefErro;
2480
- var menuHandleMouseLeave = function menuHandleMouseLeave() {
2506
+ const getLabelProps = useCallback(labelProps => ({
2507
+ id: elementIds.labelId,
2508
+ htmlFor: elementIds.toggleButtonId,
2509
+ ...labelProps
2510
+ }), [elementIds]);
2511
+ const getMenuProps = useCallback(function (_temp, _temp2) {
2512
+ let {
2513
+ onMouseLeave,
2514
+ refKey = 'ref',
2515
+ onKeyDown,
2516
+ onBlur,
2517
+ ref,
2518
+ ...rest
2519
+ } = _temp === void 0 ? {} : _temp;
2520
+ let {
2521
+ suppressRefError = false
2522
+ } = _temp2 === void 0 ? {} : _temp2;
2523
+ const menuHandleMouseLeave = () => {
2481
2524
  dispatch({
2482
2525
  type: MenuMouseLeave$1
2483
2526
  });
2484
2527
  };
2485
2528
  setGetterPropCallInfo('getMenuProps', suppressRefError, refKey, menuRef);
2486
- return _extends((_extends2 = {}, _extends2[refKey] = handleRefs(ref, function (menuNode) {
2487
- menuRef.current = menuNode;
2488
- }), _extends2.id = elementIds.menuId, _extends2.role = 'listbox', _extends2['aria-labelledby'] = elementIds.labelId, _extends2.tabIndex = -1, _extends2.onMouseLeave = callAllEventHandlers(onMouseLeave, menuHandleMouseLeave), _extends2), rest);
2529
+ return {
2530
+ [refKey]: handleRefs(ref, menuNode => {
2531
+ menuRef.current = menuNode;
2532
+ }),
2533
+ id: elementIds.menuId,
2534
+ role: 'listbox',
2535
+ 'aria-labelledby': elementIds.labelId,
2536
+ tabIndex: -1,
2537
+ onMouseLeave: callAllEventHandlers(onMouseLeave, menuHandleMouseLeave),
2538
+ ...rest
2539
+ };
2489
2540
  }, [dispatch, setGetterPropCallInfo, elementIds]);
2490
- var getToggleButtonProps = useCallback(function (_temp3, _temp4) {
2491
- var _extends3;
2492
- var _ref3 = _temp3 === void 0 ? {} : _temp3,
2493
- onBlur = _ref3.onBlur,
2494
- onClick = _ref3.onClick,
2495
- onKeyDown = _ref3.onKeyDown,
2496
- _ref3$refKey = _ref3.refKey,
2497
- refKey = _ref3$refKey === void 0 ? 'ref' : _ref3$refKey,
2498
- ref = _ref3.ref,
2499
- rest = _objectWithoutPropertiesLoose(_ref3, _excluded2$2);
2500
- var _ref4 = _temp4 === void 0 ? {} : _temp4,
2501
- _ref4$suppressRefErro = _ref4.suppressRefError,
2502
- suppressRefError = _ref4$suppressRefErro === void 0 ? false : _ref4$suppressRefErro;
2503
- var latestState = latest.current.state;
2504
- var toggleButtonHandleClick = function toggleButtonHandleClick() {
2541
+ const getToggleButtonProps = useCallback(function (_temp3, _temp4) {
2542
+ let {
2543
+ onBlur,
2544
+ onClick,
2545
+ onKeyDown,
2546
+ refKey = 'ref',
2547
+ ref,
2548
+ ...rest
2549
+ } = _temp3 === void 0 ? {} : _temp3;
2550
+ let {
2551
+ suppressRefError = false
2552
+ } = _temp4 === void 0 ? {} : _temp4;
2553
+ const latestState = latest.current.state;
2554
+ const toggleButtonHandleClick = () => {
2505
2555
  dispatch({
2506
2556
  type: ToggleButtonClick$1
2507
2557
  });
2508
2558
  };
2509
- var toggleButtonHandleBlur = function toggleButtonHandleBlur() {
2559
+ const toggleButtonHandleBlur = () => {
2510
2560
  if (latestState.isOpen && !mouseAndTouchTrackersRef.current.isMouseDown) {
2511
2561
  dispatch({
2512
2562
  type: ToggleButtonBlur
2513
2563
  });
2514
2564
  }
2515
2565
  };
2516
- var toggleButtonHandleKeyDown = function toggleButtonHandleKeyDown(event) {
2517
- var key = normalizeArrowKey(event);
2566
+ const toggleButtonHandleKeyDown = event => {
2567
+ const key = normalizeArrowKey(event);
2518
2568
  if (key && toggleButtonKeyDownHandlers[key]) {
2519
2569
  toggleButtonKeyDownHandlers[key](event);
2520
2570
  } else if (isAcceptedCharacterKey(key)) {
2521
2571
  dispatch({
2522
2572
  type: ToggleButtonKeyDownCharacter,
2523
- key: key,
2524
- getItemNodeFromIndex: getItemNodeFromIndex
2573
+ key,
2574
+ getItemNodeFromIndex
2525
2575
  });
2526
2576
  }
2527
2577
  };
2528
- var toggleProps = _extends((_extends3 = {}, _extends3[refKey] = handleRefs(ref, function (toggleButtonNode) {
2529
- toggleButtonRef.current = toggleButtonNode;
2530
- }), _extends3['aria-activedescendant'] = latestState.isOpen && latestState.highlightedIndex > -1 ? elementIds.getItemId(latestState.highlightedIndex) : '', _extends3['aria-controls'] = elementIds.menuId, _extends3['aria-expanded'] = latest.current.state.isOpen, _extends3['aria-haspopup'] = 'listbox', _extends3['aria-labelledby'] = "" + elementIds.labelId, _extends3.id = elementIds.toggleButtonId, _extends3.role = 'combobox', _extends3.tabIndex = 0, _extends3.onBlur = callAllEventHandlers(onBlur, toggleButtonHandleBlur), _extends3), rest);
2578
+ const toggleProps = {
2579
+ [refKey]: handleRefs(ref, toggleButtonNode => {
2580
+ toggleButtonRef.current = toggleButtonNode;
2581
+ }),
2582
+ 'aria-activedescendant': latestState.isOpen && latestState.highlightedIndex > -1 ? elementIds.getItemId(latestState.highlightedIndex) : '',
2583
+ 'aria-controls': elementIds.menuId,
2584
+ 'aria-expanded': latest.current.state.isOpen,
2585
+ 'aria-haspopup': 'listbox',
2586
+ 'aria-labelledby': `${elementIds.labelId}`,
2587
+ id: elementIds.toggleButtonId,
2588
+ role: 'combobox',
2589
+ tabIndex: 0,
2590
+ onBlur: callAllEventHandlers(onBlur, toggleButtonHandleBlur),
2591
+ ...rest
2592
+ };
2531
2593
  if (!rest.disabled) {
2532
2594
  toggleProps.onClick = callAllEventHandlers(onClick, toggleButtonHandleClick);
2533
2595
  toggleProps.onKeyDown = callAllEventHandlers(onKeyDown, toggleButtonHandleKeyDown);
@@ -2535,54 +2597,56 @@ function useSelect(userProps) {
2535
2597
  setGetterPropCallInfo('getToggleButtonProps', suppressRefError, refKey, toggleButtonRef);
2536
2598
  return toggleProps;
2537
2599
  }, [latest, elementIds, setGetterPropCallInfo, dispatch, mouseAndTouchTrackersRef, toggleButtonKeyDownHandlers, getItemNodeFromIndex]);
2538
- var getItemProps = useCallback(function (_temp5) {
2539
- var _extends4;
2540
- var _ref5 = _temp5 === void 0 ? {} : _temp5,
2541
- itemProp = _ref5.item,
2542
- indexProp = _ref5.index,
2543
- onMouseMove = _ref5.onMouseMove,
2544
- onClick = _ref5.onClick,
2545
- _ref5$refKey = _ref5.refKey,
2546
- refKey = _ref5$refKey === void 0 ? 'ref' : _ref5$refKey,
2547
- ref = _ref5.ref,
2548
- disabled = _ref5.disabled,
2549
- rest = _objectWithoutPropertiesLoose(_ref5, _excluded3$1);
2550
- var _latest$current = latest.current,
2551
- latestState = _latest$current.state,
2552
- latestProps = _latest$current.props;
2553
- var item = itemProp != null ? itemProp : items[indexProp];
2554
- var index = getItemIndex(indexProp, item, latestProps.items);
2555
- var itemHandleMouseMove = function itemHandleMouseMove() {
2600
+ const getItemProps = useCallback(function (_temp5) {
2601
+ let {
2602
+ item: itemProp,
2603
+ index: indexProp,
2604
+ onMouseMove,
2605
+ onClick,
2606
+ refKey = 'ref',
2607
+ ref,
2608
+ disabled,
2609
+ ...rest
2610
+ } = _temp5 === void 0 ? {} : _temp5;
2611
+ const {
2612
+ state: latestState,
2613
+ props: latestProps
2614
+ } = latest.current;
2615
+ const item = itemProp ?? items[indexProp];
2616
+ const index = getItemIndex(indexProp, item, latestProps.items);
2617
+ const itemHandleMouseMove = () => {
2556
2618
  if (index === latestState.highlightedIndex) {
2557
2619
  return;
2558
2620
  }
2559
2621
  shouldScrollRef.current = false;
2560
2622
  dispatch({
2561
2623
  type: ItemMouseMove$1,
2562
- index: index,
2563
- disabled: disabled
2624
+ index,
2625
+ disabled
2564
2626
  });
2565
2627
  };
2566
- var itemHandleClick = function itemHandleClick() {
2628
+ const itemHandleClick = () => {
2567
2629
  dispatch({
2568
2630
  type: ItemClick$1,
2569
- index: index
2631
+ index
2570
2632
  });
2571
2633
  };
2572
- var itemIndex = getItemIndex(index, item, latestProps.items);
2634
+ const itemIndex = getItemIndex(index, item, latestProps.items);
2573
2635
  if (itemIndex < 0) {
2574
2636
  throw new Error('Pass either item or item index in getItemProps!');
2575
2637
  }
2576
- var itemProps = _extends((_extends4 = {
2577
- disabled: disabled,
2638
+ const itemProps = {
2639
+ disabled,
2578
2640
  role: 'option',
2579
- 'aria-selected': "" + (item === selectedItem),
2580
- id: elementIds.getItemId(itemIndex)
2581
- }, _extends4[refKey] = handleRefs(ref, function (itemNode) {
2582
- if (itemNode) {
2583
- itemRefs.current[elementIds.getItemId(itemIndex)] = itemNode;
2584
- }
2585
- }), _extends4), rest);
2641
+ 'aria-selected': `${item === selectedItem}`,
2642
+ id: elementIds.getItemId(itemIndex),
2643
+ [refKey]: handleRefs(ref, itemNode => {
2644
+ if (itemNode) {
2645
+ itemRefs.current[elementIds.getItemId(itemIndex)] = itemNode;
2646
+ }
2647
+ }),
2648
+ ...rest
2649
+ };
2586
2650
  if (!disabled) {
2587
2651
  itemProps.onClick = callAllEventHandlers(onClick, itemHandleClick);
2588
2652
  }
@@ -2591,49 +2655,49 @@ function useSelect(userProps) {
2591
2655
  }, [latest, items, selectedItem, elementIds, shouldScrollRef, dispatch]);
2592
2656
  return {
2593
2657
  // prop getters.
2594
- getToggleButtonProps: getToggleButtonProps,
2595
- getLabelProps: getLabelProps,
2596
- getMenuProps: getMenuProps,
2597
- getItemProps: getItemProps,
2658
+ getToggleButtonProps,
2659
+ getLabelProps,
2660
+ getMenuProps,
2661
+ getItemProps,
2598
2662
  // actions.
2599
- toggleMenu: toggleMenu,
2600
- openMenu: openMenu,
2601
- closeMenu: closeMenu,
2602
- setHighlightedIndex: setHighlightedIndex,
2603
- selectItem: selectItem,
2604
- reset: reset,
2605
- setInputValue: setInputValue,
2663
+ toggleMenu,
2664
+ openMenu,
2665
+ closeMenu,
2666
+ setHighlightedIndex,
2667
+ selectItem,
2668
+ reset,
2669
+ setInputValue,
2606
2670
  // state.
2607
- highlightedIndex: highlightedIndex,
2608
- isOpen: isOpen,
2609
- selectedItem: selectedItem,
2610
- inputValue: inputValue
2671
+ highlightedIndex,
2672
+ isOpen,
2673
+ selectedItem,
2674
+ inputValue
2611
2675
  };
2612
2676
  }
2613
2677
 
2614
- var InputKeyDownArrowDown = process.env.NODE_ENV !== "production" ? '__input_keydown_arrow_down__' : 0;
2615
- var InputKeyDownArrowUp = process.env.NODE_ENV !== "production" ? '__input_keydown_arrow_up__' : 1;
2616
- var InputKeyDownEscape = process.env.NODE_ENV !== "production" ? '__input_keydown_escape__' : 2;
2617
- var InputKeyDownHome = process.env.NODE_ENV !== "production" ? '__input_keydown_home__' : 3;
2618
- var InputKeyDownEnd = process.env.NODE_ENV !== "production" ? '__input_keydown_end__' : 4;
2619
- var InputKeyDownPageUp = process.env.NODE_ENV !== "production" ? '__input_keydown_page_up__' : 5;
2620
- var InputKeyDownPageDown = process.env.NODE_ENV !== "production" ? '__input_keydown_page_down__' : 6;
2621
- var InputKeyDownEnter = process.env.NODE_ENV !== "production" ? '__input_keydown_enter__' : 7;
2622
- var InputChange = process.env.NODE_ENV !== "production" ? '__input_change__' : 8;
2623
- var InputBlur = process.env.NODE_ENV !== "production" ? '__input_blur__' : 9;
2624
- var InputFocus = process.env.NODE_ENV !== "production" ? '__input_focus__' : 10;
2625
- var MenuMouseLeave = process.env.NODE_ENV !== "production" ? '__menu_mouse_leave__' : 11;
2626
- var ItemMouseMove = process.env.NODE_ENV !== "production" ? '__item_mouse_move__' : 12;
2627
- var ItemClick = process.env.NODE_ENV !== "production" ? '__item_click__' : 13;
2628
- var ToggleButtonClick = process.env.NODE_ENV !== "production" ? '__togglebutton_click__' : 14;
2629
- var FunctionToggleMenu = process.env.NODE_ENV !== "production" ? '__function_toggle_menu__' : 15;
2630
- var FunctionOpenMenu = process.env.NODE_ENV !== "production" ? '__function_open_menu__' : 16;
2631
- var FunctionCloseMenu = process.env.NODE_ENV !== "production" ? '__function_close_menu__' : 17;
2632
- var FunctionSetHighlightedIndex = process.env.NODE_ENV !== "production" ? '__function_set_highlighted_index__' : 18;
2633
- var FunctionSelectItem = process.env.NODE_ENV !== "production" ? '__function_select_item__' : 19;
2634
- var FunctionSetInputValue = process.env.NODE_ENV !== "production" ? '__function_set_input_value__' : 20;
2635
- var FunctionReset$1 = process.env.NODE_ENV !== "production" ? '__function_reset__' : 21;
2636
- var ControlledPropUpdatedSelectedItem = process.env.NODE_ENV !== "production" ? '__controlled_prop_updated_selected_item__' : 22;
2678
+ const InputKeyDownArrowDown = process.env.NODE_ENV !== "production" ? '__input_keydown_arrow_down__' : 0;
2679
+ const InputKeyDownArrowUp = process.env.NODE_ENV !== "production" ? '__input_keydown_arrow_up__' : 1;
2680
+ const InputKeyDownEscape = process.env.NODE_ENV !== "production" ? '__input_keydown_escape__' : 2;
2681
+ const InputKeyDownHome = process.env.NODE_ENV !== "production" ? '__input_keydown_home__' : 3;
2682
+ const InputKeyDownEnd = process.env.NODE_ENV !== "production" ? '__input_keydown_end__' : 4;
2683
+ const InputKeyDownPageUp = process.env.NODE_ENV !== "production" ? '__input_keydown_page_up__' : 5;
2684
+ const InputKeyDownPageDown = process.env.NODE_ENV !== "production" ? '__input_keydown_page_down__' : 6;
2685
+ const InputKeyDownEnter = process.env.NODE_ENV !== "production" ? '__input_keydown_enter__' : 7;
2686
+ const InputChange = process.env.NODE_ENV !== "production" ? '__input_change__' : 8;
2687
+ const InputBlur = process.env.NODE_ENV !== "production" ? '__input_blur__' : 9;
2688
+ const InputFocus = process.env.NODE_ENV !== "production" ? '__input_focus__' : 10;
2689
+ const MenuMouseLeave = process.env.NODE_ENV !== "production" ? '__menu_mouse_leave__' : 11;
2690
+ const ItemMouseMove = process.env.NODE_ENV !== "production" ? '__item_mouse_move__' : 12;
2691
+ const ItemClick = process.env.NODE_ENV !== "production" ? '__item_click__' : 13;
2692
+ const ToggleButtonClick = process.env.NODE_ENV !== "production" ? '__togglebutton_click__' : 14;
2693
+ const FunctionToggleMenu = process.env.NODE_ENV !== "production" ? '__function_toggle_menu__' : 15;
2694
+ const FunctionOpenMenu = process.env.NODE_ENV !== "production" ? '__function_open_menu__' : 16;
2695
+ const FunctionCloseMenu = process.env.NODE_ENV !== "production" ? '__function_close_menu__' : 17;
2696
+ const FunctionSetHighlightedIndex = process.env.NODE_ENV !== "production" ? '__function_set_highlighted_index__' : 18;
2697
+ const FunctionSelectItem = process.env.NODE_ENV !== "production" ? '__function_select_item__' : 19;
2698
+ const FunctionSetInputValue = process.env.NODE_ENV !== "production" ? '__function_set_input_value__' : 20;
2699
+ const FunctionReset$1 = process.env.NODE_ENV !== "production" ? '__function_reset__' : 21;
2700
+ const ControlledPropUpdatedSelectedItem = process.env.NODE_ENV !== "production" ? '__controlled_prop_updated_selected_item__' : 22;
2637
2701
 
2638
2702
  var stateChangeTypes$1 = /*#__PURE__*/Object.freeze({
2639
2703
  __proto__: null,
@@ -2663,17 +2727,22 @@ var stateChangeTypes$1 = /*#__PURE__*/Object.freeze({
2663
2727
  });
2664
2728
 
2665
2729
  function getInitialState$1(props) {
2666
- var initialState = getInitialState$2(props);
2667
- var selectedItem = initialState.selectedItem;
2668
- var inputValue = initialState.inputValue;
2730
+ const initialState = getInitialState$2(props);
2731
+ const {
2732
+ selectedItem
2733
+ } = initialState;
2734
+ let {
2735
+ inputValue
2736
+ } = initialState;
2669
2737
  if (inputValue === '' && selectedItem && props.defaultInputValue === undefined && props.initialInputValue === undefined && props.inputValue === undefined) {
2670
2738
  inputValue = props.itemToString(selectedItem);
2671
2739
  }
2672
- return _extends({}, initialState, {
2673
- inputValue: inputValue
2674
- });
2740
+ return {
2741
+ ...initialState,
2742
+ inputValue
2743
+ };
2675
2744
  }
2676
- var propTypes$1 = {
2745
+ const propTypes$1 = {
2677
2746
  items: PropTypes.array.isRequired,
2678
2747
  itemToString: PropTypes.func,
2679
2748
  getA11yStatusMessage: PropTypes.func,
@@ -2726,13 +2795,11 @@ var propTypes$1 = {
2726
2795
  * @returns {Array} An array with the state and an action dispatcher.
2727
2796
  */
2728
2797
  function useControlledReducer(reducer, initialState, props) {
2729
- var previousSelectedItemRef = useRef();
2730
- var _useEnhancedReducer = useEnhancedReducer(reducer, initialState, props),
2731
- state = _useEnhancedReducer[0],
2732
- dispatch = _useEnhancedReducer[1];
2798
+ const previousSelectedItemRef = useRef();
2799
+ const [state, dispatch] = useEnhancedReducer(reducer, initialState, props);
2733
2800
 
2734
2801
  // ToDo: if needed, make same approach as selectedItemChanged from Downshift.
2735
- useEffect(function () {
2802
+ useEffect(() => {
2736
2803
  if (isControlledProp(props, 'selectedItem')) {
2737
2804
  if (previousSelectedItemRef.current !== props.selectedItem) {
2738
2805
  dispatch({
@@ -2747,23 +2814,26 @@ function useControlledReducer(reducer, initialState, props) {
2747
2814
  }
2748
2815
 
2749
2816
  // eslint-disable-next-line import/no-mutable-exports
2750
- var validatePropTypes$1 = noop;
2817
+ let validatePropTypes$1 = noop;
2751
2818
  /* istanbul ignore next */
2752
2819
  if (process.env.NODE_ENV !== 'production') {
2753
- validatePropTypes$1 = function validatePropTypes(options, caller) {
2820
+ validatePropTypes$1 = (options, caller) => {
2754
2821
  PropTypes.checkPropTypes(propTypes$1, options, 'prop', caller.name);
2755
2822
  };
2756
2823
  }
2757
- var defaultProps$1 = _extends({}, defaultProps$3, {
2824
+ const defaultProps$1 = {
2825
+ ...defaultProps$3,
2758
2826
  getA11yStatusMessage: getA11yStatusMessage$1
2759
- });
2827
+ };
2760
2828
 
2761
2829
  /* eslint-disable complexity */
2762
2830
  function downshiftUseComboboxReducer(state, action) {
2763
- var type = action.type,
2764
- props = action.props,
2765
- altKey = action.altKey;
2766
- var changes;
2831
+ const {
2832
+ type,
2833
+ props,
2834
+ altKey
2835
+ } = action;
2836
+ let changes;
2767
2837
  switch (type) {
2768
2838
  case ItemClick:
2769
2839
  changes = {
@@ -2788,13 +2858,14 @@ function downshiftUseComboboxReducer(state, action) {
2788
2858
  case InputKeyDownArrowUp:
2789
2859
  if (state.isOpen) {
2790
2860
  if (altKey) {
2791
- changes = _extends({
2861
+ changes = {
2792
2862
  isOpen: getDefaultValue$1(props, 'isOpen'),
2793
- highlightedIndex: getDefaultValue$1(props, 'highlightedIndex')
2794
- }, state.highlightedIndex >= 0 && {
2795
- selectedItem: props.items[state.highlightedIndex],
2796
- inputValue: props.itemToString(props.items[state.highlightedIndex])
2797
- });
2863
+ highlightedIndex: getDefaultValue$1(props, 'highlightedIndex'),
2864
+ ...(state.highlightedIndex >= 0 && {
2865
+ selectedItem: props.items[state.highlightedIndex],
2866
+ inputValue: props.itemToString(props.items[state.highlightedIndex])
2867
+ })
2868
+ };
2798
2869
  } else {
2799
2870
  changes = {
2800
2871
  highlightedIndex: getNextWrappingIndex(-1, state.highlightedIndex, props.items.length, action.getItemNodeFromIndex, true)
@@ -2808,22 +2879,24 @@ function downshiftUseComboboxReducer(state, action) {
2808
2879
  }
2809
2880
  break;
2810
2881
  case InputKeyDownEnter:
2811
- changes = _extends({
2882
+ changes = {
2812
2883
  isOpen: getDefaultValue$1(props, 'isOpen'),
2813
- highlightedIndex: getDefaultValue$1(props, 'highlightedIndex')
2814
- }, state.highlightedIndex >= 0 && {
2815
- selectedItem: props.items[state.highlightedIndex],
2816
- inputValue: props.itemToString(props.items[state.highlightedIndex])
2817
- });
2884
+ highlightedIndex: getDefaultValue$1(props, 'highlightedIndex'),
2885
+ ...(state.highlightedIndex >= 0 && {
2886
+ selectedItem: props.items[state.highlightedIndex],
2887
+ inputValue: props.itemToString(props.items[state.highlightedIndex])
2888
+ })
2889
+ };
2818
2890
  break;
2819
2891
  case InputKeyDownEscape:
2820
- changes = _extends({
2892
+ changes = {
2821
2893
  isOpen: false,
2822
- highlightedIndex: -1
2823
- }, !state.isOpen && {
2824
- selectedItem: null,
2825
- inputValue: ''
2826
- });
2894
+ highlightedIndex: -1,
2895
+ ...(!state.isOpen && {
2896
+ selectedItem: null,
2897
+ inputValue: ''
2898
+ })
2899
+ };
2827
2900
  break;
2828
2901
  case InputKeyDownPageUp:
2829
2902
  changes = {
@@ -2846,13 +2919,14 @@ function downshiftUseComboboxReducer(state, action) {
2846
2919
  };
2847
2920
  break;
2848
2921
  case InputBlur:
2849
- changes = _extends({
2922
+ changes = {
2850
2923
  isOpen: false,
2851
- highlightedIndex: -1
2852
- }, state.highlightedIndex >= 0 && action.selectItem && {
2853
- selectedItem: props.items[state.highlightedIndex],
2854
- inputValue: props.itemToString(props.items[state.highlightedIndex])
2855
- });
2924
+ highlightedIndex: -1,
2925
+ ...(state.highlightedIndex >= 0 && action.selectItem && {
2926
+ selectedItem: props.items[state.highlightedIndex],
2927
+ inputValue: props.itemToString(props.items[state.highlightedIndex])
2928
+ })
2929
+ };
2856
2930
  break;
2857
2931
  case InputChange:
2858
2932
  changes = {
@@ -2881,14 +2955,14 @@ function downshiftUseComboboxReducer(state, action) {
2881
2955
  default:
2882
2956
  return downshiftCommonReducer(state, action, stateChangeTypes$1);
2883
2957
  }
2884
- return _extends({}, state, changes);
2958
+ return {
2959
+ ...state,
2960
+ ...changes
2961
+ };
2885
2962
  }
2886
2963
  /* eslint-enable complexity */
2887
2964
 
2888
- var _excluded$1 = ["onMouseLeave", "refKey", "ref"],
2889
- _excluded2$1 = ["item", "index", "refKey", "ref", "onMouseMove", "onMouseDown", "onClick", "onPress", "disabled"],
2890
- _excluded3 = ["onClick", "onPress", "refKey", "ref"],
2891
- _excluded4 = ["onKeyDown", "onChange", "onInput", "onFocus", "onBlur", "onChangeText", "refKey", "ref"];
2965
+ /* eslint-disable max-statements */
2892
2966
  useCombobox.stateChangeTypes = stateChangeTypes$1;
2893
2967
  function useCombobox(userProps) {
2894
2968
  if (userProps === void 0) {
@@ -2896,327 +2970,349 @@ function useCombobox(userProps) {
2896
2970
  }
2897
2971
  validatePropTypes$1(userProps, useCombobox);
2898
2972
  // Props defaults and destructuring.
2899
- var props = _extends({}, defaultProps$1, userProps);
2900
- var initialIsOpen = props.initialIsOpen,
2901
- defaultIsOpen = props.defaultIsOpen,
2902
- items = props.items,
2903
- scrollIntoView = props.scrollIntoView,
2904
- environment = props.environment,
2905
- getA11yStatusMessage = props.getA11yStatusMessage,
2906
- getA11ySelectionMessage = props.getA11ySelectionMessage,
2907
- itemToString = props.itemToString;
2973
+ const props = {
2974
+ ...defaultProps$1,
2975
+ ...userProps
2976
+ };
2977
+ const {
2978
+ initialIsOpen,
2979
+ defaultIsOpen,
2980
+ items,
2981
+ scrollIntoView,
2982
+ environment,
2983
+ getA11yStatusMessage,
2984
+ getA11ySelectionMessage,
2985
+ itemToString
2986
+ } = props;
2908
2987
  // Initial state depending on controlled props.
2909
- var initialState = getInitialState$1(props);
2910
- var _useControlledReducer = useControlledReducer(downshiftUseComboboxReducer, initialState, props),
2911
- state = _useControlledReducer[0],
2912
- dispatch = _useControlledReducer[1];
2913
- var isOpen = state.isOpen,
2914
- highlightedIndex = state.highlightedIndex,
2915
- selectedItem = state.selectedItem,
2916
- inputValue = state.inputValue;
2988
+ const initialState = getInitialState$1(props);
2989
+ const [state, dispatch] = useControlledReducer(downshiftUseComboboxReducer, initialState, props);
2990
+ const {
2991
+ isOpen,
2992
+ highlightedIndex,
2993
+ selectedItem,
2994
+ inputValue
2995
+ } = state;
2917
2996
 
2918
2997
  // Element refs.
2919
- var menuRef = useRef(null);
2920
- var itemRefs = useRef({});
2921
- var inputRef = useRef(null);
2922
- var toggleButtonRef = useRef(null);
2923
- var isInitialMountRef = useRef(true);
2998
+ const menuRef = useRef(null);
2999
+ const itemRefs = useRef({});
3000
+ const inputRef = useRef(null);
3001
+ const toggleButtonRef = useRef(null);
3002
+ const isInitialMountRef = useRef(true);
2924
3003
  // prevent id re-generation between renders.
2925
- var elementIds = useElementIds(props);
3004
+ const elementIds = useElementIds(props);
2926
3005
  // used to keep track of how many items we had on previous cycle.
2927
- var previousResultCountRef = useRef();
3006
+ const previousResultCountRef = useRef();
2928
3007
  // utility callback to get item element.
2929
- var latest = useLatestRef({
2930
- state: state,
2931
- props: props
3008
+ const latest = useLatestRef({
3009
+ state,
3010
+ props
2932
3011
  });
2933
- var getItemNodeFromIndex = useCallback(function (index) {
2934
- return itemRefs.current[elementIds.getItemId(index)];
2935
- }, [elementIds]);
3012
+ const getItemNodeFromIndex = useCallback(index => itemRefs.current[elementIds.getItemId(index)], [elementIds]);
2936
3013
 
2937
3014
  // Effects.
2938
3015
  // Sets a11y status message on changes in state.
2939
- useA11yMessageSetter(getA11yStatusMessage, [isOpen, highlightedIndex, inputValue, items], _extends({
3016
+ useA11yMessageSetter(getA11yStatusMessage, [isOpen, highlightedIndex, inputValue, items], {
2940
3017
  isInitialMount: isInitialMountRef.current,
2941
3018
  previousResultCount: previousResultCountRef.current,
2942
- items: items,
2943
- environment: environment,
2944
- itemToString: itemToString
2945
- }, state));
3019
+ items,
3020
+ environment,
3021
+ itemToString,
3022
+ ...state
3023
+ });
2946
3024
  // Sets a11y status message on changes in selectedItem.
2947
- useA11yMessageSetter(getA11ySelectionMessage, [selectedItem], _extends({
3025
+ useA11yMessageSetter(getA11ySelectionMessage, [selectedItem], {
2948
3026
  isInitialMount: isInitialMountRef.current,
2949
3027
  previousResultCount: previousResultCountRef.current,
2950
- items: items,
2951
- environment: environment,
2952
- itemToString: itemToString
2953
- }, state));
3028
+ items,
3029
+ environment,
3030
+ itemToString,
3031
+ ...state
3032
+ });
2954
3033
  // Scroll on highlighted item if change comes from keyboard.
2955
- var shouldScrollRef = useScrollIntoView({
3034
+ const shouldScrollRef = useScrollIntoView({
2956
3035
  menuElement: menuRef.current,
2957
- highlightedIndex: highlightedIndex,
2958
- isOpen: isOpen,
2959
- itemRefs: itemRefs,
2960
- scrollIntoView: scrollIntoView,
2961
- getItemNodeFromIndex: getItemNodeFromIndex
3036
+ highlightedIndex,
3037
+ isOpen,
3038
+ itemRefs,
3039
+ scrollIntoView,
3040
+ getItemNodeFromIndex
2962
3041
  });
2963
3042
  useControlPropsValidator({
2964
3043
  isInitialMount: isInitialMountRef.current,
2965
- props: props,
2966
- state: state
3044
+ props,
3045
+ state
2967
3046
  });
2968
3047
  // Focus the input on first render if required.
2969
- useEffect(function () {
2970
- var focusOnOpen = initialIsOpen || defaultIsOpen || isOpen;
3048
+ useEffect(() => {
3049
+ const focusOnOpen = initialIsOpen || defaultIsOpen || isOpen;
2971
3050
  if (focusOnOpen && inputRef.current) {
2972
3051
  inputRef.current.focus();
2973
3052
  }
2974
3053
  // eslint-disable-next-line react-hooks/exhaustive-deps
2975
3054
  }, []);
2976
- useEffect(function () {
3055
+ useEffect(() => {
2977
3056
  if (isInitialMountRef.current) {
2978
3057
  return;
2979
3058
  }
2980
3059
  previousResultCountRef.current = items.length;
2981
3060
  });
2982
3061
  // Add mouse/touch events to document.
2983
- var mouseAndTouchTrackersRef = useMouseAndTouchTracker(isOpen, [inputRef, menuRef, toggleButtonRef], environment, function () {
3062
+ const mouseAndTouchTrackersRef = useMouseAndTouchTracker(isOpen, [inputRef, menuRef, toggleButtonRef], environment, () => {
2984
3063
  dispatch({
2985
3064
  type: InputBlur,
2986
3065
  selectItem: false
2987
3066
  });
2988
3067
  });
2989
- var setGetterPropCallInfo = useGetterPropsCalledChecker('getInputProps', 'getMenuProps');
3068
+ const setGetterPropCallInfo = useGetterPropsCalledChecker('getInputProps', 'getMenuProps');
2990
3069
  // Make initial ref false.
2991
- useEffect(function () {
3070
+ useEffect(() => {
2992
3071
  isInitialMountRef.current = false;
2993
- return function () {
3072
+ return () => {
2994
3073
  isInitialMountRef.current = true;
2995
3074
  };
2996
3075
  }, []);
2997
3076
  // Reset itemRefs on close.
2998
- useEffect(function () {
3077
+ useEffect(() => {
2999
3078
  if (!isOpen) {
3000
3079
  itemRefs.current = {};
3001
3080
  } else if (document.activeElement !== inputRef.current) {
3002
- var _inputRef$current;
3003
- inputRef == null ? void 0 : (_inputRef$current = inputRef.current) == null ? void 0 : _inputRef$current.focus();
3081
+ inputRef?.current?.focus();
3004
3082
  }
3005
3083
  }, [isOpen]);
3006
3084
 
3007
3085
  /* Event handler functions */
3008
- var inputKeyDownHandlers = useMemo(function () {
3009
- return {
3010
- ArrowDown: function ArrowDown(event) {
3011
- event.preventDefault();
3012
- dispatch({
3013
- type: InputKeyDownArrowDown,
3014
- altKey: event.altKey,
3015
- getItemNodeFromIndex: getItemNodeFromIndex
3016
- });
3017
- },
3018
- ArrowUp: function ArrowUp(event) {
3019
- event.preventDefault();
3020
- dispatch({
3021
- type: InputKeyDownArrowUp,
3022
- altKey: event.altKey,
3023
- getItemNodeFromIndex: getItemNodeFromIndex
3024
- });
3025
- },
3026
- Home: function Home(event) {
3027
- if (!latest.current.state.isOpen) {
3028
- return;
3029
- }
3086
+ const inputKeyDownHandlers = useMemo(() => ({
3087
+ ArrowDown(event) {
3088
+ event.preventDefault();
3089
+ dispatch({
3090
+ type: InputKeyDownArrowDown,
3091
+ altKey: event.altKey,
3092
+ getItemNodeFromIndex
3093
+ });
3094
+ },
3095
+ ArrowUp(event) {
3096
+ event.preventDefault();
3097
+ dispatch({
3098
+ type: InputKeyDownArrowUp,
3099
+ altKey: event.altKey,
3100
+ getItemNodeFromIndex
3101
+ });
3102
+ },
3103
+ Home(event) {
3104
+ if (!latest.current.state.isOpen) {
3105
+ return;
3106
+ }
3107
+ event.preventDefault();
3108
+ dispatch({
3109
+ type: InputKeyDownHome,
3110
+ getItemNodeFromIndex
3111
+ });
3112
+ },
3113
+ End(event) {
3114
+ if (!latest.current.state.isOpen) {
3115
+ return;
3116
+ }
3117
+ event.preventDefault();
3118
+ dispatch({
3119
+ type: InputKeyDownEnd,
3120
+ getItemNodeFromIndex
3121
+ });
3122
+ },
3123
+ Escape(event) {
3124
+ const latestState = latest.current.state;
3125
+ if (latestState.isOpen || latestState.inputValue || latestState.selectedItem || latestState.highlightedIndex > -1) {
3030
3126
  event.preventDefault();
3031
3127
  dispatch({
3032
- type: InputKeyDownHome,
3033
- getItemNodeFromIndex: getItemNodeFromIndex
3128
+ type: InputKeyDownEscape
3034
3129
  });
3035
- },
3036
- End: function End(event) {
3037
- if (!latest.current.state.isOpen) {
3038
- return;
3039
- }
3130
+ }
3131
+ },
3132
+ Enter(event) {
3133
+ const latestState = latest.current.state;
3134
+ // if closed or no highlighted index, do nothing.
3135
+ if (!latestState.isOpen || event.which === 229 // if IME composing, wait for next Enter keydown event.
3136
+ ) {
3137
+ return;
3138
+ }
3139
+ event.preventDefault();
3140
+ dispatch({
3141
+ type: InputKeyDownEnter,
3142
+ getItemNodeFromIndex
3143
+ });
3144
+ },
3145
+ PageUp(event) {
3146
+ if (latest.current.state.isOpen) {
3040
3147
  event.preventDefault();
3041
3148
  dispatch({
3042
- type: InputKeyDownEnd,
3043
- getItemNodeFromIndex: getItemNodeFromIndex
3149
+ type: InputKeyDownPageUp,
3150
+ getItemNodeFromIndex
3044
3151
  });
3045
- },
3046
- Escape: function Escape(event) {
3047
- var latestState = latest.current.state;
3048
- if (latestState.isOpen || latestState.inputValue || latestState.selectedItem || latestState.highlightedIndex > -1) {
3049
- event.preventDefault();
3050
- dispatch({
3051
- type: InputKeyDownEscape
3052
- });
3053
- }
3054
- },
3055
- Enter: function Enter(event) {
3056
- var latestState = latest.current.state;
3057
- // if closed or no highlighted index, do nothing.
3058
- if (!latestState.isOpen || event.which === 229 // if IME composing, wait for next Enter keydown event.
3059
- ) {
3060
- return;
3061
- }
3152
+ }
3153
+ },
3154
+ PageDown(event) {
3155
+ if (latest.current.state.isOpen) {
3062
3156
  event.preventDefault();
3063
3157
  dispatch({
3064
- type: InputKeyDownEnter,
3065
- getItemNodeFromIndex: getItemNodeFromIndex
3158
+ type: InputKeyDownPageDown,
3159
+ getItemNodeFromIndex
3066
3160
  });
3067
- },
3068
- PageUp: function PageUp(event) {
3069
- if (latest.current.state.isOpen) {
3070
- event.preventDefault();
3071
- dispatch({
3072
- type: InputKeyDownPageUp,
3073
- getItemNodeFromIndex: getItemNodeFromIndex
3074
- });
3075
- }
3076
- },
3077
- PageDown: function PageDown(event) {
3078
- if (latest.current.state.isOpen) {
3079
- event.preventDefault();
3080
- dispatch({
3081
- type: InputKeyDownPageDown,
3082
- getItemNodeFromIndex: getItemNodeFromIndex
3083
- });
3084
- }
3085
3161
  }
3086
- };
3087
- }, [dispatch, latest, getItemNodeFromIndex]);
3162
+ }
3163
+ }), [dispatch, latest, getItemNodeFromIndex]);
3088
3164
 
3089
3165
  // Getter props.
3090
- var getLabelProps = useCallback(function (labelProps) {
3091
- return _extends({
3092
- id: elementIds.labelId,
3093
- htmlFor: elementIds.inputId
3094
- }, labelProps);
3095
- }, [elementIds]);
3096
- var getMenuProps = useCallback(function (_temp, _temp2) {
3097
- var _extends2;
3098
- var _ref = _temp === void 0 ? {} : _temp,
3099
- onMouseLeave = _ref.onMouseLeave,
3100
- _ref$refKey = _ref.refKey,
3101
- refKey = _ref$refKey === void 0 ? 'ref' : _ref$refKey,
3102
- ref = _ref.ref,
3103
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$1);
3104
- var _ref2 = _temp2 === void 0 ? {} : _temp2,
3105
- _ref2$suppressRefErro = _ref2.suppressRefError,
3106
- suppressRefError = _ref2$suppressRefErro === void 0 ? false : _ref2$suppressRefErro;
3166
+ const getLabelProps = useCallback(labelProps => ({
3167
+ id: elementIds.labelId,
3168
+ htmlFor: elementIds.inputId,
3169
+ ...labelProps
3170
+ }), [elementIds]);
3171
+ const getMenuProps = useCallback(function (_temp, _temp2) {
3172
+ let {
3173
+ onMouseLeave,
3174
+ refKey = 'ref',
3175
+ ref,
3176
+ ...rest
3177
+ } = _temp === void 0 ? {} : _temp;
3178
+ let {
3179
+ suppressRefError = false
3180
+ } = _temp2 === void 0 ? {} : _temp2;
3107
3181
  setGetterPropCallInfo('getMenuProps', suppressRefError, refKey, menuRef);
3108
- return _extends((_extends2 = {}, _extends2[refKey] = handleRefs(ref, function (menuNode) {
3109
- menuRef.current = menuNode;
3110
- }), _extends2.id = elementIds.menuId, _extends2.role = 'listbox', _extends2['aria-labelledby'] = elementIds.labelId, _extends2.onMouseLeave = callAllEventHandlers(onMouseLeave, function () {
3111
- dispatch({
3112
- type: MenuMouseLeave
3113
- });
3114
- }), _extends2), rest);
3182
+ return {
3183
+ [refKey]: handleRefs(ref, menuNode => {
3184
+ menuRef.current = menuNode;
3185
+ }),
3186
+ id: elementIds.menuId,
3187
+ role: 'listbox',
3188
+ 'aria-labelledby': elementIds.labelId,
3189
+ onMouseLeave: callAllEventHandlers(onMouseLeave, () => {
3190
+ dispatch({
3191
+ type: MenuMouseLeave
3192
+ });
3193
+ }),
3194
+ ...rest
3195
+ };
3115
3196
  }, [dispatch, setGetterPropCallInfo, elementIds]);
3116
- var getItemProps = useCallback(function (_temp3) {
3117
- var _extends3, _ref4;
3118
- var _ref3 = _temp3 === void 0 ? {} : _temp3,
3119
- item = _ref3.item,
3120
- index = _ref3.index,
3121
- _ref3$refKey = _ref3.refKey,
3122
- refKey = _ref3$refKey === void 0 ? 'ref' : _ref3$refKey,
3123
- ref = _ref3.ref,
3124
- onMouseMove = _ref3.onMouseMove,
3125
- onMouseDown = _ref3.onMouseDown,
3126
- onClick = _ref3.onClick;
3127
- _ref3.onPress;
3128
- var disabled = _ref3.disabled,
3129
- rest = _objectWithoutPropertiesLoose(_ref3, _excluded2$1);
3130
- var _latest$current = latest.current,
3131
- latestProps = _latest$current.props,
3132
- latestState = _latest$current.state;
3133
- var itemIndex = getItemIndex(index, item, latestProps.items);
3197
+ const getItemProps = useCallback(function (_temp3) {
3198
+ let {
3199
+ item,
3200
+ index,
3201
+ refKey = 'ref',
3202
+ ref,
3203
+ onMouseMove,
3204
+ onMouseDown,
3205
+ onClick,
3206
+ onPress,
3207
+ disabled,
3208
+ ...rest
3209
+ } = _temp3 === void 0 ? {} : _temp3;
3210
+ const {
3211
+ props: latestProps,
3212
+ state: latestState
3213
+ } = latest.current;
3214
+ const itemIndex = getItemIndex(index, item, latestProps.items);
3134
3215
  if (itemIndex < 0) {
3135
3216
  throw new Error('Pass either item or item index in getItemProps!');
3136
3217
  }
3137
- var onSelectKey = 'onClick';
3138
- var customClickHandler = onClick;
3139
- var itemHandleMouseMove = function itemHandleMouseMove() {
3218
+ const onSelectKey = 'onClick';
3219
+ const customClickHandler = onClick;
3220
+ const itemHandleMouseMove = () => {
3140
3221
  if (index === latestState.highlightedIndex) {
3141
3222
  return;
3142
3223
  }
3143
3224
  shouldScrollRef.current = false;
3144
3225
  dispatch({
3145
3226
  type: ItemMouseMove,
3146
- index: index,
3147
- disabled: disabled
3227
+ index,
3228
+ disabled
3148
3229
  });
3149
3230
  };
3150
- var itemHandleClick = function itemHandleClick() {
3231
+ const itemHandleClick = () => {
3151
3232
  dispatch({
3152
3233
  type: ItemClick,
3153
- index: index
3234
+ index
3154
3235
  });
3155
3236
  };
3156
- var itemHandleMouseDown = function itemHandleMouseDown(e) {
3157
- return e.preventDefault();
3158
- };
3159
- return _extends((_extends3 = {}, _extends3[refKey] = handleRefs(ref, function (itemNode) {
3160
- if (itemNode) {
3161
- itemRefs.current[elementIds.getItemId(itemIndex)] = itemNode;
3162
- }
3163
- }), _extends3.disabled = disabled, _extends3.role = 'option', _extends3['aria-selected'] = "" + (itemIndex === latestState.highlightedIndex), _extends3.id = elementIds.getItemId(itemIndex), _extends3), !disabled && (_ref4 = {}, _ref4[onSelectKey] = callAllEventHandlers(customClickHandler, itemHandleClick), _ref4), {
3237
+ const itemHandleMouseDown = e => e.preventDefault();
3238
+ return {
3239
+ [refKey]: handleRefs(ref, itemNode => {
3240
+ if (itemNode) {
3241
+ itemRefs.current[elementIds.getItemId(itemIndex)] = itemNode;
3242
+ }
3243
+ }),
3244
+ disabled,
3245
+ role: 'option',
3246
+ 'aria-selected': `${itemIndex === latestState.highlightedIndex}`,
3247
+ id: elementIds.getItemId(itemIndex),
3248
+ ...(!disabled && {
3249
+ [onSelectKey]: callAllEventHandlers(customClickHandler, itemHandleClick)
3250
+ }),
3164
3251
  onMouseMove: callAllEventHandlers(onMouseMove, itemHandleMouseMove),
3165
- onMouseDown: callAllEventHandlers(onMouseDown, itemHandleMouseDown)
3166
- }, rest);
3252
+ onMouseDown: callAllEventHandlers(onMouseDown, itemHandleMouseDown),
3253
+ ...rest
3254
+ };
3167
3255
  }, [dispatch, latest, shouldScrollRef, elementIds]);
3168
- var getToggleButtonProps = useCallback(function (_temp4) {
3169
- var _extends4;
3170
- var _ref5 = _temp4 === void 0 ? {} : _temp4,
3171
- onClick = _ref5.onClick;
3172
- _ref5.onPress;
3173
- var _ref5$refKey = _ref5.refKey,
3174
- refKey = _ref5$refKey === void 0 ? 'ref' : _ref5$refKey,
3175
- ref = _ref5.ref,
3176
- rest = _objectWithoutPropertiesLoose(_ref5, _excluded3);
3177
- var latestState = latest.current.state;
3178
- var toggleButtonHandleClick = function toggleButtonHandleClick() {
3256
+ const getToggleButtonProps = useCallback(function (_temp4) {
3257
+ let {
3258
+ onClick,
3259
+ onPress,
3260
+ refKey = 'ref',
3261
+ ref,
3262
+ ...rest
3263
+ } = _temp4 === void 0 ? {} : _temp4;
3264
+ const latestState = latest.current.state;
3265
+ const toggleButtonHandleClick = () => {
3179
3266
  dispatch({
3180
3267
  type: ToggleButtonClick
3181
3268
  });
3182
3269
  };
3183
- return _extends((_extends4 = {}, _extends4[refKey] = handleRefs(ref, function (toggleButtonNode) {
3184
- toggleButtonRef.current = toggleButtonNode;
3185
- }), _extends4['aria-controls'] = elementIds.menuId, _extends4['aria-expanded'] = latestState.isOpen, _extends4.id = elementIds.toggleButtonId, _extends4.tabIndex = -1, _extends4), !rest.disabled && _extends({}, {
3186
- onClick: callAllEventHandlers(onClick, toggleButtonHandleClick)
3187
- }), rest);
3270
+ return {
3271
+ [refKey]: handleRefs(ref, toggleButtonNode => {
3272
+ toggleButtonRef.current = toggleButtonNode;
3273
+ }),
3274
+ 'aria-controls': elementIds.menuId,
3275
+ 'aria-expanded': latestState.isOpen,
3276
+ id: elementIds.toggleButtonId,
3277
+ tabIndex: -1,
3278
+ ...(!rest.disabled && {
3279
+ ...({
3280
+ onClick: callAllEventHandlers(onClick, toggleButtonHandleClick)
3281
+ })
3282
+ }),
3283
+ ...rest
3284
+ };
3188
3285
  }, [dispatch, latest, elementIds]);
3189
- var getInputProps = useCallback(function (_temp5, _temp6) {
3190
- var _extends5;
3191
- var _ref6 = _temp5 === void 0 ? {} : _temp5,
3192
- onKeyDown = _ref6.onKeyDown,
3193
- onChange = _ref6.onChange,
3194
- onInput = _ref6.onInput,
3195
- onFocus = _ref6.onFocus,
3196
- onBlur = _ref6.onBlur;
3197
- _ref6.onChangeText;
3198
- var _ref6$refKey = _ref6.refKey,
3199
- refKey = _ref6$refKey === void 0 ? 'ref' : _ref6$refKey,
3200
- ref = _ref6.ref,
3201
- rest = _objectWithoutPropertiesLoose(_ref6, _excluded4);
3202
- var _ref7 = _temp6 === void 0 ? {} : _temp6,
3203
- _ref7$suppressRefErro = _ref7.suppressRefError,
3204
- suppressRefError = _ref7$suppressRefErro === void 0 ? false : _ref7$suppressRefErro;
3286
+ const getInputProps = useCallback(function (_temp5, _temp6) {
3287
+ let {
3288
+ onKeyDown,
3289
+ onChange,
3290
+ onInput,
3291
+ onFocus,
3292
+ onBlur,
3293
+ onChangeText,
3294
+ refKey = 'ref',
3295
+ ref,
3296
+ ...rest
3297
+ } = _temp5 === void 0 ? {} : _temp5;
3298
+ let {
3299
+ suppressRefError = false
3300
+ } = _temp6 === void 0 ? {} : _temp6;
3205
3301
  setGetterPropCallInfo('getInputProps', suppressRefError, refKey, inputRef);
3206
- var latestState = latest.current.state;
3207
- var inputHandleKeyDown = function inputHandleKeyDown(event) {
3208
- var key = normalizeArrowKey(event);
3302
+ const latestState = latest.current.state;
3303
+ const inputHandleKeyDown = event => {
3304
+ const key = normalizeArrowKey(event);
3209
3305
  if (key && inputKeyDownHandlers[key]) {
3210
3306
  inputKeyDownHandlers[key](event);
3211
3307
  }
3212
3308
  };
3213
- var inputHandleChange = function inputHandleChange(event) {
3309
+ const inputHandleChange = event => {
3214
3310
  dispatch({
3215
3311
  type: InputChange,
3216
3312
  inputValue: event.target.value
3217
3313
  });
3218
3314
  };
3219
- var inputHandleBlur = function inputHandleBlur() {
3315
+ const inputHandleBlur = () => {
3220
3316
  /* istanbul ignore else */
3221
3317
  if (latestState.isOpen && !mouseAndTouchTrackersRef.current.isMouseDown) {
3222
3318
  dispatch({
@@ -3225,7 +3321,7 @@ function useCombobox(userProps) {
3225
3321
  });
3226
3322
  }
3227
3323
  };
3228
- var inputHandleFocus = function inputHandleFocus() {
3324
+ const inputHandleFocus = () => {
3229
3325
  if (!latestState.isOpen) {
3230
3326
  dispatch({
3231
3327
  type: InputFocus
@@ -3234,80 +3330,99 @@ function useCombobox(userProps) {
3234
3330
  };
3235
3331
 
3236
3332
  /* istanbul ignore next (preact) */
3237
- var onChangeKey = 'onChange';
3238
- var eventHandlers = {};
3333
+ const onChangeKey = 'onChange';
3334
+ let eventHandlers = {};
3239
3335
  if (!rest.disabled) {
3240
- var _eventHandlers;
3241
- eventHandlers = (_eventHandlers = {}, _eventHandlers[onChangeKey] = callAllEventHandlers(onChange, onInput, inputHandleChange), _eventHandlers.onKeyDown = callAllEventHandlers(onKeyDown, inputHandleKeyDown), _eventHandlers.onBlur = callAllEventHandlers(onBlur, inputHandleBlur), _eventHandlers.onFocus = callAllEventHandlers(onFocus, inputHandleFocus), _eventHandlers);
3336
+ eventHandlers = {
3337
+ [onChangeKey]: callAllEventHandlers(onChange, onInput, inputHandleChange),
3338
+ onKeyDown: callAllEventHandlers(onKeyDown, inputHandleKeyDown),
3339
+ onBlur: callAllEventHandlers(onBlur, inputHandleBlur),
3340
+ onFocus: callAllEventHandlers(onFocus, inputHandleFocus)
3341
+ };
3242
3342
  }
3243
- return _extends((_extends5 = {}, _extends5[refKey] = handleRefs(ref, function (inputNode) {
3244
- inputRef.current = inputNode;
3245
- }), _extends5['aria-activedescendant'] = latestState.isOpen && latestState.highlightedIndex > -1 ? elementIds.getItemId(latestState.highlightedIndex) : '', _extends5['aria-autocomplete'] = 'list', _extends5['aria-controls'] = elementIds.menuId, _extends5['aria-expanded'] = latestState.isOpen, _extends5['aria-labelledby'] = elementIds.labelId, _extends5.autoComplete = 'off', _extends5.id = elementIds.inputId, _extends5.role = 'combobox', _extends5.value = latestState.inputValue, _extends5), eventHandlers, rest);
3343
+ return {
3344
+ [refKey]: handleRefs(ref, inputNode => {
3345
+ inputRef.current = inputNode;
3346
+ }),
3347
+ 'aria-activedescendant': latestState.isOpen && latestState.highlightedIndex > -1 ? elementIds.getItemId(latestState.highlightedIndex) : '',
3348
+ 'aria-autocomplete': 'list',
3349
+ 'aria-controls': elementIds.menuId,
3350
+ 'aria-expanded': latestState.isOpen,
3351
+ 'aria-labelledby': elementIds.labelId,
3352
+ // https://developer.mozilla.org/en-US/docs/Web/Security/Securing_your_site/Turning_off_form_autocompletion
3353
+ // revert back since autocomplete="nope" is ignored on latest Chrome and Opera
3354
+ autoComplete: 'off',
3355
+ id: elementIds.inputId,
3356
+ role: 'combobox',
3357
+ value: latestState.inputValue,
3358
+ ...eventHandlers,
3359
+ ...rest
3360
+ };
3246
3361
  }, [dispatch, inputKeyDownHandlers, latest, mouseAndTouchTrackersRef, setGetterPropCallInfo, elementIds]);
3247
3362
 
3248
3363
  // returns
3249
- var toggleMenu = useCallback(function () {
3364
+ const toggleMenu = useCallback(() => {
3250
3365
  dispatch({
3251
3366
  type: FunctionToggleMenu
3252
3367
  });
3253
3368
  }, [dispatch]);
3254
- var closeMenu = useCallback(function () {
3369
+ const closeMenu = useCallback(() => {
3255
3370
  dispatch({
3256
3371
  type: FunctionCloseMenu
3257
3372
  });
3258
3373
  }, [dispatch]);
3259
- var openMenu = useCallback(function () {
3374
+ const openMenu = useCallback(() => {
3260
3375
  dispatch({
3261
3376
  type: FunctionOpenMenu
3262
3377
  });
3263
3378
  }, [dispatch]);
3264
- var setHighlightedIndex = useCallback(function (newHighlightedIndex) {
3379
+ const setHighlightedIndex = useCallback(newHighlightedIndex => {
3265
3380
  dispatch({
3266
3381
  type: FunctionSetHighlightedIndex,
3267
3382
  highlightedIndex: newHighlightedIndex
3268
3383
  });
3269
3384
  }, [dispatch]);
3270
- var selectItem = useCallback(function (newSelectedItem) {
3385
+ const selectItem = useCallback(newSelectedItem => {
3271
3386
  dispatch({
3272
3387
  type: FunctionSelectItem,
3273
3388
  selectedItem: newSelectedItem
3274
3389
  });
3275
3390
  }, [dispatch]);
3276
- var setInputValue = useCallback(function (newInputValue) {
3391
+ const setInputValue = useCallback(newInputValue => {
3277
3392
  dispatch({
3278
3393
  type: FunctionSetInputValue,
3279
3394
  inputValue: newInputValue
3280
3395
  });
3281
3396
  }, [dispatch]);
3282
- var reset = useCallback(function () {
3397
+ const reset = useCallback(() => {
3283
3398
  dispatch({
3284
3399
  type: FunctionReset$1
3285
3400
  });
3286
3401
  }, [dispatch]);
3287
3402
  return {
3288
3403
  // prop getters.
3289
- getItemProps: getItemProps,
3290
- getLabelProps: getLabelProps,
3291
- getMenuProps: getMenuProps,
3292
- getInputProps: getInputProps,
3293
- getToggleButtonProps: getToggleButtonProps,
3404
+ getItemProps,
3405
+ getLabelProps,
3406
+ getMenuProps,
3407
+ getInputProps,
3408
+ getToggleButtonProps,
3294
3409
  // actions.
3295
- toggleMenu: toggleMenu,
3296
- openMenu: openMenu,
3297
- closeMenu: closeMenu,
3298
- setHighlightedIndex: setHighlightedIndex,
3299
- setInputValue: setInputValue,
3300
- selectItem: selectItem,
3301
- reset: reset,
3410
+ toggleMenu,
3411
+ openMenu,
3412
+ closeMenu,
3413
+ setHighlightedIndex,
3414
+ setInputValue,
3415
+ selectItem,
3416
+ reset,
3302
3417
  // state.
3303
- highlightedIndex: highlightedIndex,
3304
- isOpen: isOpen,
3305
- selectedItem: selectedItem,
3306
- inputValue: inputValue
3418
+ highlightedIndex,
3419
+ isOpen,
3420
+ selectedItem,
3421
+ inputValue
3307
3422
  };
3308
3423
  }
3309
3424
 
3310
- var defaultStateValues = {
3425
+ const defaultStateValues = {
3311
3426
  activeIndex: -1,
3312
3427
  selectedItems: []
3313
3428
  };
@@ -3345,11 +3460,11 @@ function getDefaultValue(props, propKey) {
3345
3460
  * @returns {Object} The initial state.
3346
3461
  */
3347
3462
  function getInitialState(props) {
3348
- var activeIndex = getInitialValue(props, 'activeIndex');
3349
- var selectedItems = getInitialValue(props, 'selectedItems');
3463
+ const activeIndex = getInitialValue(props, 'activeIndex');
3464
+ const selectedItems = getInitialValue(props, 'selectedItems');
3350
3465
  return {
3351
- activeIndex: activeIndex,
3352
- selectedItems: selectedItems
3466
+ activeIndex,
3467
+ selectedItems
3353
3468
  };
3354
3469
  }
3355
3470
 
@@ -3366,7 +3481,7 @@ function isKeyDownOperationPermitted(event) {
3366
3481
  if (event.shiftKey || event.metaKey || event.ctrlKey || event.altKey) {
3367
3482
  return false;
3368
3483
  }
3369
- var element = event.target;
3484
+ const element = event.target;
3370
3485
  if (element instanceof HTMLInputElement &&
3371
3486
  // if element is a text input
3372
3487
  element.value !== '' && (
@@ -3385,11 +3500,13 @@ function isKeyDownOperationPermitted(event) {
3385
3500
  * @returns {string} The a11y message.
3386
3501
  */
3387
3502
  function getA11yRemovalMessage(selectionParameters) {
3388
- var removedSelectedItem = selectionParameters.removedSelectedItem,
3389
- itemToStringLocal = selectionParameters.itemToString;
3390
- return itemToStringLocal(removedSelectedItem) + " has been removed.";
3503
+ const {
3504
+ removedSelectedItem,
3505
+ itemToString: itemToStringLocal
3506
+ } = selectionParameters;
3507
+ return `${itemToStringLocal(removedSelectedItem)} has been removed.`;
3391
3508
  }
3392
- var propTypes = {
3509
+ const propTypes = {
3393
3510
  selectedItems: PropTypes.array,
3394
3511
  initialSelectedItems: PropTypes.array,
3395
3512
  defaultSelectedItems: PropTypes.array,
@@ -3413,37 +3530,37 @@ var propTypes = {
3413
3530
  })
3414
3531
  })
3415
3532
  };
3416
- var defaultProps = {
3533
+ const defaultProps = {
3417
3534
  itemToString: defaultProps$3.itemToString,
3418
3535
  stateReducer: defaultProps$3.stateReducer,
3419
3536
  environment: defaultProps$3.environment,
3420
- getA11yRemovalMessage: getA11yRemovalMessage,
3537
+ getA11yRemovalMessage,
3421
3538
  keyNavigationNext: 'ArrowRight',
3422
3539
  keyNavigationPrevious: 'ArrowLeft'
3423
3540
  };
3424
3541
 
3425
3542
  // eslint-disable-next-line import/no-mutable-exports
3426
- var validatePropTypes = noop;
3543
+ let validatePropTypes = noop;
3427
3544
  /* istanbul ignore next */
3428
3545
  if (process.env.NODE_ENV !== 'production') {
3429
- validatePropTypes = function validatePropTypes(options, caller) {
3546
+ validatePropTypes = (options, caller) => {
3430
3547
  PropTypes.checkPropTypes(propTypes, options, 'prop', caller.name);
3431
3548
  };
3432
3549
  }
3433
3550
 
3434
- var SelectedItemClick = process.env.NODE_ENV !== "production" ? '__selected_item_click__' : 0;
3435
- var SelectedItemKeyDownDelete = process.env.NODE_ENV !== "production" ? '__selected_item_keydown_delete__' : 1;
3436
- var SelectedItemKeyDownBackspace = process.env.NODE_ENV !== "production" ? '__selected_item_keydown_backspace__' : 2;
3437
- var SelectedItemKeyDownNavigationNext = process.env.NODE_ENV !== "production" ? '__selected_item_keydown_navigation_next__' : 3;
3438
- var SelectedItemKeyDownNavigationPrevious = process.env.NODE_ENV !== "production" ? '__selected_item_keydown_navigation_previous__' : 4;
3439
- var DropdownKeyDownNavigationPrevious = process.env.NODE_ENV !== "production" ? '__dropdown_keydown_navigation_previous__' : 5;
3440
- var DropdownKeyDownBackspace = process.env.NODE_ENV !== "production" ? '__dropdown_keydown_backspace__' : 6;
3441
- var DropdownClick = process.env.NODE_ENV !== "production" ? '__dropdown_click__' : 7;
3442
- var FunctionAddSelectedItem = process.env.NODE_ENV !== "production" ? '__function_add_selected_item__' : 8;
3443
- var FunctionRemoveSelectedItem = process.env.NODE_ENV !== "production" ? '__function_remove_selected_item__' : 9;
3444
- var FunctionSetSelectedItems = process.env.NODE_ENV !== "production" ? '__function_set_selected_items__' : 10;
3445
- var FunctionSetActiveIndex = process.env.NODE_ENV !== "production" ? '__function_set_active_index__' : 11;
3446
- var FunctionReset = process.env.NODE_ENV !== "production" ? '__function_reset__' : 12;
3551
+ const SelectedItemClick = process.env.NODE_ENV !== "production" ? '__selected_item_click__' : 0;
3552
+ const SelectedItemKeyDownDelete = process.env.NODE_ENV !== "production" ? '__selected_item_keydown_delete__' : 1;
3553
+ const SelectedItemKeyDownBackspace = process.env.NODE_ENV !== "production" ? '__selected_item_keydown_backspace__' : 2;
3554
+ const SelectedItemKeyDownNavigationNext = process.env.NODE_ENV !== "production" ? '__selected_item_keydown_navigation_next__' : 3;
3555
+ const SelectedItemKeyDownNavigationPrevious = process.env.NODE_ENV !== "production" ? '__selected_item_keydown_navigation_previous__' : 4;
3556
+ const DropdownKeyDownNavigationPrevious = process.env.NODE_ENV !== "production" ? '__dropdown_keydown_navigation_previous__' : 5;
3557
+ const DropdownKeyDownBackspace = process.env.NODE_ENV !== "production" ? '__dropdown_keydown_backspace__' : 6;
3558
+ const DropdownClick = process.env.NODE_ENV !== "production" ? '__dropdown_click__' : 7;
3559
+ const FunctionAddSelectedItem = process.env.NODE_ENV !== "production" ? '__function_add_selected_item__' : 8;
3560
+ const FunctionRemoveSelectedItem = process.env.NODE_ENV !== "production" ? '__function_remove_selected_item__' : 9;
3561
+ const FunctionSetSelectedItems = process.env.NODE_ENV !== "production" ? '__function_set_selected_items__' : 10;
3562
+ const FunctionSetActiveIndex = process.env.NODE_ENV !== "production" ? '__function_set_active_index__' : 11;
3563
+ const FunctionReset = process.env.NODE_ENV !== "production" ? '__function_reset__' : 12;
3447
3564
 
3448
3565
  var stateChangeTypes = /*#__PURE__*/Object.freeze({
3449
3566
  __proto__: null,
@@ -3464,13 +3581,17 @@ var stateChangeTypes = /*#__PURE__*/Object.freeze({
3464
3581
 
3465
3582
  /* eslint-disable complexity */
3466
3583
  function downshiftMultipleSelectionReducer(state, action) {
3467
- var type = action.type,
3468
- index = action.index,
3469
- props = action.props,
3470
- selectedItem = action.selectedItem;
3471
- var activeIndex = state.activeIndex,
3472
- selectedItems = state.selectedItems;
3473
- var changes;
3584
+ const {
3585
+ type,
3586
+ index,
3587
+ props,
3588
+ selectedItem
3589
+ } = action;
3590
+ const {
3591
+ activeIndex,
3592
+ selectedItems
3593
+ } = state;
3594
+ let changes;
3474
3595
  switch (type) {
3475
3596
  case SelectedItemClick:
3476
3597
  changes = {
@@ -3493,17 +3614,18 @@ function downshiftMultipleSelectionReducer(state, action) {
3493
3614
  if (activeIndex < 0) {
3494
3615
  break;
3495
3616
  }
3496
- var newActiveIndex = activeIndex;
3617
+ let newActiveIndex = activeIndex;
3497
3618
  if (selectedItems.length === 1) {
3498
3619
  newActiveIndex = -1;
3499
3620
  } else if (activeIndex === selectedItems.length - 1) {
3500
3621
  newActiveIndex = selectedItems.length - 2;
3501
3622
  }
3502
- changes = _extends({
3503
- selectedItems: [].concat(selectedItems.slice(0, activeIndex), selectedItems.slice(activeIndex + 1))
3504
- }, {
3505
- activeIndex: newActiveIndex
3506
- });
3623
+ changes = {
3624
+ selectedItems: [...selectedItems.slice(0, activeIndex), ...selectedItems.slice(activeIndex + 1)],
3625
+ ...{
3626
+ activeIndex: newActiveIndex
3627
+ }
3628
+ };
3507
3629
  break;
3508
3630
  }
3509
3631
  case DropdownKeyDownNavigationPrevious:
@@ -3518,7 +3640,7 @@ function downshiftMultipleSelectionReducer(state, action) {
3518
3640
  break;
3519
3641
  case FunctionAddSelectedItem:
3520
3642
  changes = {
3521
- selectedItems: [].concat(selectedItems, [selectedItem])
3643
+ selectedItems: [...selectedItems, selectedItem]
3522
3644
  };
3523
3645
  break;
3524
3646
  case DropdownClick:
@@ -3528,25 +3650,27 @@ function downshiftMultipleSelectionReducer(state, action) {
3528
3650
  break;
3529
3651
  case FunctionRemoveSelectedItem:
3530
3652
  {
3531
- var _newActiveIndex = activeIndex;
3532
- var selectedItemIndex = selectedItems.indexOf(selectedItem);
3653
+ let newActiveIndex = activeIndex;
3654
+ const selectedItemIndex = selectedItems.indexOf(selectedItem);
3533
3655
  if (selectedItemIndex < 0) {
3534
3656
  break;
3535
3657
  }
3536
3658
  if (selectedItems.length === 1) {
3537
- _newActiveIndex = -1;
3659
+ newActiveIndex = -1;
3538
3660
  } else if (selectedItemIndex === selectedItems.length - 1) {
3539
- _newActiveIndex = selectedItems.length - 2;
3661
+ newActiveIndex = selectedItems.length - 2;
3540
3662
  }
3541
3663
  changes = {
3542
- selectedItems: [].concat(selectedItems.slice(0, selectedItemIndex), selectedItems.slice(selectedItemIndex + 1)),
3543
- activeIndex: _newActiveIndex
3664
+ selectedItems: [...selectedItems.slice(0, selectedItemIndex), ...selectedItems.slice(selectedItemIndex + 1)],
3665
+ activeIndex: newActiveIndex
3544
3666
  };
3545
3667
  break;
3546
3668
  }
3547
3669
  case FunctionSetSelectedItems:
3548
3670
  {
3549
- var newSelectedItems = action.selectedItems;
3671
+ const {
3672
+ selectedItems: newSelectedItems
3673
+ } = action;
3550
3674
  changes = {
3551
3675
  selectedItems: newSelectedItems
3552
3676
  };
@@ -3554,9 +3678,11 @@ function downshiftMultipleSelectionReducer(state, action) {
3554
3678
  }
3555
3679
  case FunctionSetActiveIndex:
3556
3680
  {
3557
- var _newActiveIndex2 = action.activeIndex;
3681
+ const {
3682
+ activeIndex: newActiveIndex
3683
+ } = action;
3558
3684
  changes = {
3559
- activeIndex: _newActiveIndex2
3685
+ activeIndex: newActiveIndex
3560
3686
  };
3561
3687
  break;
3562
3688
  }
@@ -3569,11 +3695,12 @@ function downshiftMultipleSelectionReducer(state, action) {
3569
3695
  default:
3570
3696
  throw new Error('Reducer called without proper action type.');
3571
3697
  }
3572
- return _extends({}, state, changes);
3698
+ return {
3699
+ ...state,
3700
+ ...changes
3701
+ };
3573
3702
  }
3574
3703
 
3575
- var _excluded = ["refKey", "ref", "onClick", "onKeyDown", "selectedItem", "index"],
3576
- _excluded2 = ["refKey", "ref", "onKeyDown", "onClick", "preventKeyAction"];
3577
3704
  useMultipleSelection.stateChangeTypes = stateChangeTypes;
3578
3705
  function useMultipleSelection(userProps) {
3579
3706
  if (userProps === void 0) {
@@ -3581,46 +3708,49 @@ function useMultipleSelection(userProps) {
3581
3708
  }
3582
3709
  validatePropTypes(userProps, useMultipleSelection);
3583
3710
  // Props defaults and destructuring.
3584
- var props = _extends({}, defaultProps, userProps);
3585
- var getA11yRemovalMessage = props.getA11yRemovalMessage,
3586
- itemToString = props.itemToString,
3587
- environment = props.environment,
3588
- keyNavigationNext = props.keyNavigationNext,
3589
- keyNavigationPrevious = props.keyNavigationPrevious;
3711
+ const props = {
3712
+ ...defaultProps,
3713
+ ...userProps
3714
+ };
3715
+ const {
3716
+ getA11yRemovalMessage,
3717
+ itemToString,
3718
+ environment,
3719
+ keyNavigationNext,
3720
+ keyNavigationPrevious
3721
+ } = props;
3590
3722
 
3591
3723
  // Reducer init.
3592
- var _useControlledReducer = useControlledReducer$1(downshiftMultipleSelectionReducer, getInitialState(props), props),
3593
- state = _useControlledReducer[0],
3594
- dispatch = _useControlledReducer[1];
3595
- var activeIndex = state.activeIndex,
3596
- selectedItems = state.selectedItems;
3724
+ const [state, dispatch] = useControlledReducer$1(downshiftMultipleSelectionReducer, getInitialState(props), props);
3725
+ const {
3726
+ activeIndex,
3727
+ selectedItems
3728
+ } = state;
3597
3729
 
3598
3730
  // Refs.
3599
- var isInitialMountRef = useRef(true);
3600
- var dropdownRef = useRef(null);
3601
- var previousSelectedItemsRef = useRef(selectedItems);
3602
- var selectedItemRefs = useRef();
3731
+ const isInitialMountRef = useRef(true);
3732
+ const dropdownRef = useRef(null);
3733
+ const previousSelectedItemsRef = useRef(selectedItems);
3734
+ const selectedItemRefs = useRef();
3603
3735
  selectedItemRefs.current = [];
3604
- var latest = useLatestRef({
3605
- state: state,
3606
- props: props
3736
+ const latest = useLatestRef({
3737
+ state,
3738
+ props
3607
3739
  });
3608
3740
 
3609
3741
  // Effects.
3610
3742
  /* Sets a11y status message on changes in selectedItem. */
3611
- useEffect(function () {
3743
+ useEffect(() => {
3612
3744
  if (isInitialMountRef.current) {
3613
3745
  return;
3614
3746
  }
3615
3747
  if (selectedItems.length < previousSelectedItemsRef.current.length) {
3616
- var removedSelectedItem = previousSelectedItemsRef.current.find(function (item) {
3617
- return selectedItems.indexOf(item) < 0;
3618
- });
3748
+ const removedSelectedItem = previousSelectedItemsRef.current.find(item => selectedItems.indexOf(item) < 0);
3619
3749
  setStatus(getA11yRemovalMessage({
3620
- itemToString: itemToString,
3750
+ itemToString,
3621
3751
  resultCount: selectedItems.length,
3622
- removedSelectedItem: removedSelectedItem,
3623
- activeIndex: activeIndex,
3752
+ removedSelectedItem,
3753
+ activeIndex,
3624
3754
  activeSelectedItem: selectedItems[activeIndex]
3625
3755
  }), environment.document);
3626
3756
  }
@@ -3629,7 +3759,7 @@ function useMultipleSelection(userProps) {
3629
3759
  // eslint-disable-next-line react-hooks/exhaustive-deps
3630
3760
  }, [selectedItems.length]);
3631
3761
  // Sets focus on active item.
3632
- useEffect(function () {
3762
+ useEffect(() => {
3633
3763
  if (isInitialMountRef.current) {
3634
3764
  return;
3635
3765
  }
@@ -3641,167 +3771,178 @@ function useMultipleSelection(userProps) {
3641
3771
  }, [activeIndex]);
3642
3772
  useControlPropsValidator({
3643
3773
  isInitialMount: isInitialMountRef.current,
3644
- props: props,
3645
- state: state
3774
+ props,
3775
+ state
3646
3776
  });
3647
- var setGetterPropCallInfo = useGetterPropsCalledChecker('getDropdownProps');
3777
+ const setGetterPropCallInfo = useGetterPropsCalledChecker('getDropdownProps');
3648
3778
  // Make initial ref false.
3649
- useEffect(function () {
3779
+ useEffect(() => {
3650
3780
  isInitialMountRef.current = false;
3651
- return function () {
3781
+ return () => {
3652
3782
  isInitialMountRef.current = true;
3653
3783
  };
3654
3784
  }, []);
3655
3785
 
3656
3786
  // Event handler functions.
3657
- var selectedItemKeyDownHandlers = useMemo(function () {
3658
- var _ref;
3659
- return _ref = {}, _ref[keyNavigationPrevious] = function () {
3787
+ const selectedItemKeyDownHandlers = useMemo(() => ({
3788
+ [keyNavigationPrevious]() {
3660
3789
  dispatch({
3661
3790
  type: SelectedItemKeyDownNavigationPrevious
3662
3791
  });
3663
- }, _ref[keyNavigationNext] = function () {
3792
+ },
3793
+ [keyNavigationNext]() {
3664
3794
  dispatch({
3665
3795
  type: SelectedItemKeyDownNavigationNext
3666
3796
  });
3667
- }, _ref.Delete = function Delete() {
3797
+ },
3798
+ Delete() {
3668
3799
  dispatch({
3669
3800
  type: SelectedItemKeyDownDelete
3670
3801
  });
3671
- }, _ref.Backspace = function Backspace() {
3802
+ },
3803
+ Backspace() {
3672
3804
  dispatch({
3673
3805
  type: SelectedItemKeyDownBackspace
3674
3806
  });
3675
- }, _ref;
3676
- }, [dispatch, keyNavigationNext, keyNavigationPrevious]);
3677
- var dropdownKeyDownHandlers = useMemo(function () {
3678
- var _ref2;
3679
- return _ref2 = {}, _ref2[keyNavigationPrevious] = function (event) {
3807
+ }
3808
+ }), [dispatch, keyNavigationNext, keyNavigationPrevious]);
3809
+ const dropdownKeyDownHandlers = useMemo(() => ({
3810
+ [keyNavigationPrevious](event) {
3680
3811
  if (isKeyDownOperationPermitted(event)) {
3681
3812
  dispatch({
3682
3813
  type: DropdownKeyDownNavigationPrevious
3683
3814
  });
3684
3815
  }
3685
- }, _ref2.Backspace = function Backspace(event) {
3816
+ },
3817
+ Backspace(event) {
3686
3818
  if (isKeyDownOperationPermitted(event)) {
3687
3819
  dispatch({
3688
3820
  type: DropdownKeyDownBackspace
3689
3821
  });
3690
3822
  }
3691
- }, _ref2;
3692
- }, [dispatch, keyNavigationPrevious]);
3823
+ }
3824
+ }), [dispatch, keyNavigationPrevious]);
3693
3825
 
3694
3826
  // Getter props.
3695
- var getSelectedItemProps = useCallback(function (_temp) {
3696
- var _extends2;
3697
- var _ref3 = _temp === void 0 ? {} : _temp,
3698
- _ref3$refKey = _ref3.refKey,
3699
- refKey = _ref3$refKey === void 0 ? 'ref' : _ref3$refKey,
3700
- ref = _ref3.ref,
3701
- onClick = _ref3.onClick,
3702
- onKeyDown = _ref3.onKeyDown,
3703
- selectedItem = _ref3.selectedItem,
3704
- index = _ref3.index,
3705
- rest = _objectWithoutPropertiesLoose(_ref3, _excluded);
3706
- var latestState = latest.current.state;
3707
- var itemIndex = getItemIndex(index, selectedItem, latestState.selectedItems);
3827
+ const getSelectedItemProps = useCallback(function (_temp) {
3828
+ let {
3829
+ refKey = 'ref',
3830
+ ref,
3831
+ onClick,
3832
+ onKeyDown,
3833
+ selectedItem,
3834
+ index,
3835
+ ...rest
3836
+ } = _temp === void 0 ? {} : _temp;
3837
+ const {
3838
+ state: latestState
3839
+ } = latest.current;
3840
+ const itemIndex = getItemIndex(index, selectedItem, latestState.selectedItems);
3708
3841
  if (itemIndex < 0) {
3709
3842
  throw new Error('Pass either selectedItem or index in getSelectedItemProps!');
3710
3843
  }
3711
- var selectedItemHandleClick = function selectedItemHandleClick() {
3844
+ const selectedItemHandleClick = () => {
3712
3845
  dispatch({
3713
3846
  type: SelectedItemClick,
3714
- index: index
3847
+ index
3715
3848
  });
3716
3849
  };
3717
- var selectedItemHandleKeyDown = function selectedItemHandleKeyDown(event) {
3718
- var key = normalizeArrowKey(event);
3850
+ const selectedItemHandleKeyDown = event => {
3851
+ const key = normalizeArrowKey(event);
3719
3852
  if (key && selectedItemKeyDownHandlers[key]) {
3720
3853
  selectedItemKeyDownHandlers[key](event);
3721
3854
  }
3722
3855
  };
3723
- return _extends((_extends2 = {}, _extends2[refKey] = handleRefs(ref, function (selectedItemNode) {
3724
- if (selectedItemNode) {
3725
- selectedItemRefs.current.push(selectedItemNode);
3726
- }
3727
- }), _extends2.tabIndex = index === latestState.activeIndex ? 0 : -1, _extends2.onClick = callAllEventHandlers(onClick, selectedItemHandleClick), _extends2.onKeyDown = callAllEventHandlers(onKeyDown, selectedItemHandleKeyDown), _extends2), rest);
3856
+ return {
3857
+ [refKey]: handleRefs(ref, selectedItemNode => {
3858
+ if (selectedItemNode) {
3859
+ selectedItemRefs.current.push(selectedItemNode);
3860
+ }
3861
+ }),
3862
+ tabIndex: index === latestState.activeIndex ? 0 : -1,
3863
+ onClick: callAllEventHandlers(onClick, selectedItemHandleClick),
3864
+ onKeyDown: callAllEventHandlers(onKeyDown, selectedItemHandleKeyDown),
3865
+ ...rest
3866
+ };
3728
3867
  }, [dispatch, latest, selectedItemKeyDownHandlers]);
3729
- var getDropdownProps = useCallback(function (_temp2, _temp3) {
3730
- var _extends3;
3731
- var _ref4 = _temp2 === void 0 ? {} : _temp2,
3732
- _ref4$refKey = _ref4.refKey,
3733
- refKey = _ref4$refKey === void 0 ? 'ref' : _ref4$refKey,
3734
- ref = _ref4.ref,
3735
- onKeyDown = _ref4.onKeyDown,
3736
- onClick = _ref4.onClick,
3737
- _ref4$preventKeyActio = _ref4.preventKeyAction,
3738
- preventKeyAction = _ref4$preventKeyActio === void 0 ? false : _ref4$preventKeyActio,
3739
- rest = _objectWithoutPropertiesLoose(_ref4, _excluded2);
3740
- var _ref5 = _temp3 === void 0 ? {} : _temp3,
3741
- _ref5$suppressRefErro = _ref5.suppressRefError,
3742
- suppressRefError = _ref5$suppressRefErro === void 0 ? false : _ref5$suppressRefErro;
3868
+ const getDropdownProps = useCallback(function (_temp2, _temp3) {
3869
+ let {
3870
+ refKey = 'ref',
3871
+ ref,
3872
+ onKeyDown,
3873
+ onClick,
3874
+ preventKeyAction = false,
3875
+ ...rest
3876
+ } = _temp2 === void 0 ? {} : _temp2;
3877
+ let {
3878
+ suppressRefError = false
3879
+ } = _temp3 === void 0 ? {} : _temp3;
3743
3880
  setGetterPropCallInfo('getDropdownProps', suppressRefError, refKey, dropdownRef);
3744
- var dropdownHandleKeyDown = function dropdownHandleKeyDown(event) {
3745
- var key = normalizeArrowKey(event);
3881
+ const dropdownHandleKeyDown = event => {
3882
+ const key = normalizeArrowKey(event);
3746
3883
  if (key && dropdownKeyDownHandlers[key]) {
3747
3884
  dropdownKeyDownHandlers[key](event);
3748
3885
  }
3749
3886
  };
3750
- var dropdownHandleClick = function dropdownHandleClick() {
3887
+ const dropdownHandleClick = () => {
3751
3888
  dispatch({
3752
3889
  type: DropdownClick
3753
3890
  });
3754
3891
  };
3755
- return _extends((_extends3 = {}, _extends3[refKey] = handleRefs(ref, function (dropdownNode) {
3756
- if (dropdownNode) {
3757
- dropdownRef.current = dropdownNode;
3758
- }
3759
- }), _extends3), !preventKeyAction && {
3760
- onKeyDown: callAllEventHandlers(onKeyDown, dropdownHandleKeyDown),
3761
- onClick: callAllEventHandlers(onClick, dropdownHandleClick)
3762
- }, rest);
3892
+ return {
3893
+ [refKey]: handleRefs(ref, dropdownNode => {
3894
+ if (dropdownNode) {
3895
+ dropdownRef.current = dropdownNode;
3896
+ }
3897
+ }),
3898
+ ...(!preventKeyAction && {
3899
+ onKeyDown: callAllEventHandlers(onKeyDown, dropdownHandleKeyDown),
3900
+ onClick: callAllEventHandlers(onClick, dropdownHandleClick)
3901
+ }),
3902
+ ...rest
3903
+ };
3763
3904
  }, [dispatch, dropdownKeyDownHandlers, setGetterPropCallInfo]);
3764
3905
 
3765
3906
  // returns
3766
- var addSelectedItem = useCallback(function (selectedItem) {
3907
+ const addSelectedItem = useCallback(selectedItem => {
3767
3908
  dispatch({
3768
3909
  type: FunctionAddSelectedItem,
3769
- selectedItem: selectedItem
3910
+ selectedItem
3770
3911
  });
3771
3912
  }, [dispatch]);
3772
- var removeSelectedItem = useCallback(function (selectedItem) {
3913
+ const removeSelectedItem = useCallback(selectedItem => {
3773
3914
  dispatch({
3774
3915
  type: FunctionRemoveSelectedItem,
3775
- selectedItem: selectedItem
3916
+ selectedItem
3776
3917
  });
3777
3918
  }, [dispatch]);
3778
- var setSelectedItems = useCallback(function (newSelectedItems) {
3919
+ const setSelectedItems = useCallback(newSelectedItems => {
3779
3920
  dispatch({
3780
3921
  type: FunctionSetSelectedItems,
3781
3922
  selectedItems: newSelectedItems
3782
3923
  });
3783
3924
  }, [dispatch]);
3784
- var setActiveIndex = useCallback(function (newActiveIndex) {
3925
+ const setActiveIndex = useCallback(newActiveIndex => {
3785
3926
  dispatch({
3786
3927
  type: FunctionSetActiveIndex,
3787
3928
  activeIndex: newActiveIndex
3788
3929
  });
3789
3930
  }, [dispatch]);
3790
- var reset = useCallback(function () {
3931
+ const reset = useCallback(() => {
3791
3932
  dispatch({
3792
3933
  type: FunctionReset
3793
3934
  });
3794
3935
  }, [dispatch]);
3795
3936
  return {
3796
- getSelectedItemProps: getSelectedItemProps,
3797
- getDropdownProps: getDropdownProps,
3798
- addSelectedItem: addSelectedItem,
3799
- removeSelectedItem: removeSelectedItem,
3800
- setSelectedItems: setSelectedItems,
3801
- setActiveIndex: setActiveIndex,
3802
- reset: reset,
3803
- selectedItems: selectedItems,
3804
- activeIndex: activeIndex
3937
+ getSelectedItemProps,
3938
+ getDropdownProps,
3939
+ addSelectedItem,
3940
+ removeSelectedItem,
3941
+ setSelectedItems,
3942
+ setActiveIndex,
3943
+ reset,
3944
+ selectedItems,
3945
+ activeIndex
3805
3946
  };
3806
3947
  }
3807
3948