downshift 7.1.2 → 7.1.3-alpha.0

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