downshift 9.3.2 → 9.4.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (155) hide show
  1. package/dist/downshift.cjs.cjs +617 -698
  2. package/dist/downshift.d.ts +49 -55
  3. package/dist/downshift.esm.mjs +618 -699
  4. package/dist/downshift.native.cjs.cjs +575 -653
  5. package/dist/downshift.nativeweb.cjs.cjs +615 -693
  6. package/dist/downshift.types.d.ts +205 -0
  7. package/dist/downshift.umd.js +621 -702
  8. package/dist/downshift.umd.js.map +1 -1
  9. package/dist/downshift.umd.min.js +1 -1
  10. package/dist/downshift.umd.min.js.map +1 -1
  11. package/dist/hooks/testUtils/MemoizedItem.d.ts +10 -0
  12. package/dist/hooks/testUtils/fixtures.d.ts +16 -0
  13. package/dist/hooks/testUtils/index.d.ts +4 -0
  14. package/dist/hooks/testUtils/interactions.d.ts +16 -0
  15. package/dist/hooks/testUtils/testCases.d.ts +2 -0
  16. package/dist/hooks/useCombobox/__tests__/utils/index.d.ts +5 -0
  17. package/dist/hooks/useCombobox/__tests__/utils/interactions.d.ts +6 -0
  18. package/dist/hooks/useCombobox/__tests__/utils/renderCombobox.d.ts +72 -0
  19. package/dist/hooks/useCombobox/__tests__/utils/renderUseCombobox.d.ts +2 -0
  20. package/dist/hooks/useCombobox/index.d.ts +4 -94
  21. package/dist/hooks/useCombobox/index.types.d.ts +302 -0
  22. package/dist/hooks/useCombobox/reducer.d.ts +4 -1
  23. package/dist/hooks/useCombobox/stateChangeTypes.d.ts +24 -23
  24. package/dist/hooks/useCombobox/utils/getInitialState.d.ts +10 -0
  25. package/dist/hooks/useCombobox/utils/index.d.ts +3 -0
  26. package/dist/hooks/useCombobox/{utils.d.ts → utils/propTypes.d.ts} +2 -30
  27. package/dist/hooks/useCombobox/utils/useControlledReducer.d.ts +16 -0
  28. package/dist/hooks/useMultipleSelection/index.d.ts +25 -13
  29. package/dist/hooks/useMultipleSelection/index.types.d.ts +117 -0
  30. package/dist/hooks/useMultipleSelection/reducer.d.ts +1 -1
  31. package/dist/hooks/useMultipleSelection/utils.d.ts +14 -15
  32. package/dist/hooks/useSelect/__tests__/utils/getItemIndexByCharacter.d.ts +7 -0
  33. package/dist/hooks/useSelect/__tests__/utils/index.d.ts +6 -0
  34. package/dist/hooks/useSelect/__tests__/utils/renderSelect.d.ts +71 -0
  35. package/dist/hooks/useSelect/__tests__/utils/renderUseSelect.d.ts +2 -0
  36. package/dist/hooks/useSelect/__tests__/utils/stateChangeTestCases.d.ts +182 -0
  37. package/dist/hooks/useSelect/index.d.ts +4 -71
  38. package/dist/hooks/useSelect/index.types.d.ts +266 -0
  39. package/dist/hooks/useSelect/reducer.d.ts +4 -1
  40. package/dist/hooks/useSelect/stateChangeTypes.d.ts +23 -22
  41. package/dist/hooks/useSelect/utils/index.d.ts +0 -1
  42. package/dist/hooks/useTagGroup/__tests__/utils/renderTagGroup.d.ts +1 -1
  43. package/dist/hooks/useTagGroup/index.types.d.ts +10 -13
  44. package/dist/hooks/useTagGroup/reducer.d.ts +4 -2
  45. package/dist/hooks/useTagGroup/utils/index.d.ts +3 -1
  46. package/dist/hooks/utils/__tests__/dropdownDefaultProps.test.d.ts +1 -0
  47. package/dist/hooks/utils/__tests__/getChangesOnSelection.test.d.ts +1 -0
  48. package/dist/hooks/utils/__tests__/getDefaultHighlightedIndex.test.d.ts +1 -0
  49. package/dist/hooks/utils/__tests__/getDefaultValue.test.d.ts +1 -0
  50. package/dist/hooks/utils/__tests__/getHighlightedIndexOnOpen.test.d.ts +1 -0
  51. package/dist/hooks/utils/__tests__/getInitialValue.test.d.ts +1 -0
  52. package/dist/hooks/utils/__tests__/getItemAndIndex.test.d.ts +1 -0
  53. package/dist/hooks/utils/__tests__/isDropdownStateEqual.test.d.ts +1 -0
  54. package/dist/hooks/utils/__tests__/useA11yMessageStatus.test.d.ts +1 -0
  55. package/dist/hooks/utils/__tests__/useControlPropsValidator.test.d.ts +1 -0
  56. package/dist/hooks/utils/__tests__/useControlledReducer.test.d.ts +1 -0
  57. package/dist/hooks/utils/__tests__/useElementIds.legacy.test.d.ts +1 -0
  58. package/dist/hooks/utils/__tests__/useElementIds.r18.test.d.ts +1 -0
  59. package/dist/hooks/utils/__tests__/useEnhancedReducer.test.d.ts +1 -0
  60. package/dist/hooks/utils/__tests__/useGetterPropsCalledChecker.test.d.ts +1 -0
  61. package/dist/hooks/utils/__tests__/useIsInitialMount.test.d.ts +1 -0
  62. package/dist/hooks/utils/__tests__/useMouseAndTouchTracker.test.d.ts +1 -0
  63. package/dist/hooks/utils/__tests__/useScrollIntoView.test.d.ts +1 -0
  64. package/dist/hooks/utils/callOnChangeProps.d.ts +4 -0
  65. package/dist/hooks/utils/dropdownDefaultProps.d.ts +13 -0
  66. package/dist/hooks/{utils.dropdown/defaultStateValues.d.ts → utils/dropdownDefaultStateValues.d.ts} +2 -2
  67. package/dist/hooks/{utils.dropdown/propTypes.d.ts → utils/dropdownPropTypes.d.ts} +1 -1
  68. package/dist/hooks/utils/getChangesOnSelection.d.ts +17 -0
  69. package/dist/hooks/utils/getDefaultHighlightedIndex.d.ts +7 -0
  70. package/dist/hooks/utils/getDefaultValue.d.ts +8 -0
  71. package/dist/hooks/utils/getHighlightedIndexOnOpen.d.ts +16 -0
  72. package/dist/hooks/utils/getInitialState.d.ts +23 -0
  73. package/dist/hooks/utils/getInitialValue.d.ts +14 -0
  74. package/dist/hooks/utils/index.d.ts +24 -0
  75. package/dist/hooks/utils/index.types.d.ts +26 -0
  76. package/dist/hooks/utils/isDropdownStateEqual.d.ts +16 -0
  77. package/dist/hooks/utils/reducer.d.ts +27 -0
  78. package/dist/hooks/utils/useControlPropsValidator.d.ts +6 -0
  79. package/dist/hooks/utils/useControlledReducer.d.ts +13 -0
  80. package/dist/hooks/utils/useEnhancedReducer.d.ts +15 -0
  81. package/dist/hooks/utils/useGetterPropsCalledChecker.d.ts +2 -0
  82. package/dist/hooks/utils/useMouseAndTouchTracker.d.ts +15 -0
  83. package/dist/hooks/utils/useScrollIntoView.d.ts +11 -0
  84. package/dist/index.d.ts +1 -1
  85. package/dist/utils/__tests__/callAllEventHandlers.test.d.ts +1 -0
  86. package/dist/utils/__tests__/debounce.test.d.ts +1 -0
  87. package/dist/utils/__tests__/generateId.r18.test.d.ts +1 -0
  88. package/dist/utils/__tests__/generateId.test.d.ts +1 -0
  89. package/dist/utils/__tests__/getHighlightedIndex.test.d.ts +1 -0
  90. package/dist/utils/__tests__/getNonDisabledIndex.test.d.ts +1 -0
  91. package/dist/utils/__tests__/getState.test.d.ts +1 -0
  92. package/dist/utils/__tests__/handleRefs.test.d.ts +1 -0
  93. package/dist/utils/__tests__/normalizeArrowKey.test.d.ts +1 -0
  94. package/dist/utils/__tests__/scrollIntoView.test.d.ts +1 -0
  95. package/dist/utils/__tests__/setA11yStatus.test.d.ts +1 -0
  96. package/dist/utils/__tests__/targetWithinDownshift.test.d.ts +1 -0
  97. package/dist/utils/__tests__/useLatestRef.test.d.ts +1 -0
  98. package/dist/utils/__tests__/validateControlledUnchanged.test.d.ts +1 -0
  99. package/dist/utils/__tests__/validatePropTypes.test.d.ts +1 -0
  100. package/dist/utils/getHighlightedIndex.d.ts +11 -0
  101. package/dist/utils/getNonDisabledIndex.d.ts +11 -0
  102. package/dist/utils/getState.d.ts +12 -0
  103. package/dist/utils/handleRefs.d.ts +2 -0
  104. package/dist/{utils-ts → utils}/index.d.ts +5 -1
  105. package/dist/utils/normalizeArrowKey.d.ts +6 -0
  106. package/dist/utils/targetWithinDownshift.d.ts +12 -0
  107. package/dist/utils/validateControlledUnchanged.d.ts +1 -0
  108. package/dist/utils/validatePropTypes.d.ts +2 -0
  109. package/dist/utils.legacy.d.ts +54 -0
  110. package/flow-typed/npm/downshift_v2.x.x.js.flow +87 -62
  111. package/package.json +2 -4
  112. package/preact/dist/downshift.cjs.cjs +617 -698
  113. package/preact/dist/downshift.cjs.js +4265 -0
  114. package/preact/dist/downshift.esm.js +4238 -0
  115. package/preact/dist/downshift.esm.mjs +618 -699
  116. package/preact/dist/downshift.umd.js +617 -698
  117. package/preact/dist/downshift.umd.js.map +1 -1
  118. package/preact/dist/downshift.umd.min.js +1 -1
  119. package/preact/dist/downshift.umd.min.js.map +1 -1
  120. package/typings/index.d.ts +13 -21
  121. package/dist/hooks/reducer.d.ts +0 -1
  122. package/dist/hooks/useSelect/utils/defaultProps.d.ts +0 -8
  123. package/dist/hooks/utils-ts/callOnChangeProps.d.ts +0 -2
  124. package/dist/hooks/utils-ts/getDefaultValue.d.ts +0 -2
  125. package/dist/hooks/utils-ts/getInitialValue.d.ts +0 -2
  126. package/dist/hooks/utils-ts/index.d.ts +0 -11
  127. package/dist/hooks/utils-ts/stateReducer.d.ts +0 -6
  128. package/dist/hooks/utils-ts/useControlledReducer.d.ts +0 -12
  129. package/dist/hooks/utils-ts/useEnhancedReducer.d.ts +0 -13
  130. package/dist/hooks/utils.d.ts +0 -58
  131. package/dist/hooks/utils.dropdown/defaultProps.d.ts +0 -9
  132. package/dist/hooks/utils.dropdown/index.d.ts +0 -3
  133. package/dist/utils-ts/getState.d.ts +0 -22
  134. package/dist/utils-ts/handleRefs.d.ts +0 -2
  135. package/dist/utils-ts/validatePropTypes.d.ts +0 -2
  136. package/dist/utils.d.ts +0 -123
  137. package/typings/index.legacy.d.ts +0 -888
  138. /package/dist/hooks/{utils-ts/__tests__/getItemAndIndex.test.d.ts → useCombobox/utils/__tests__/getInitialState.test.d.ts} +0 -0
  139. /package/dist/hooks/{utils.dropdown/__tests__/useElementIds.legacy.test.d.ts → useCombobox/utils/__tests__/useControlledReducer.test.d.ts} +0 -0
  140. /package/dist/hooks/{utils.dropdown/__tests__/useElementIds.r18.test.d.ts → useSelect/utils/__tests__/getItemIndexByCharacterKey.test.d.ts} +0 -0
  141. /package/dist/{utils-ts/__tests__/getState.test.d.ts → hooks/utils/__tests__/callOnChangeProps.test.d.ts} +0 -0
  142. /package/dist/{utils-ts/__tests__/handleRefs.test.d.ts → hooks/utils/__tests__/capitalizeString.test.d.ts} +0 -0
  143. /package/dist/hooks/{utils-ts → utils}/capitalizeString.d.ts +0 -0
  144. /package/dist/hooks/{utils-ts → utils}/getItemAndIndex.d.ts +0 -0
  145. /package/dist/hooks/{utils-ts → utils}/propTypes.d.ts +0 -0
  146. /package/dist/hooks/{utils-ts → utils}/useA11yMessageStatus.d.ts +0 -0
  147. /package/dist/hooks/{utils.dropdown → utils}/useElementIds.d.ts +0 -0
  148. /package/dist/hooks/{utils-ts → utils}/useIsInitialMount.d.ts +0 -0
  149. /package/dist/{utils-ts → utils}/callAllEventHandlers.d.ts +0 -0
  150. /package/dist/{utils-ts → utils}/debounce.d.ts +0 -0
  151. /package/dist/{utils-ts → utils}/generateId.d.ts +0 -0
  152. /package/dist/{utils-ts → utils}/noop.d.ts +0 -0
  153. /package/dist/{utils-ts → utils}/scrollIntoView.d.ts +0 -0
  154. /package/dist/{utils-ts → utils}/setA11yStatus.d.ts +0 -0
  155. /package/dist/{utils-ts → utils}/useLatestRef.d.ts +0 -0
@@ -101,7 +101,7 @@ function useLatestRef(val) {
101
101
  return ref;
102
102
  }
103
103
 
104
- function handleRefs$1() {
104
+ function handleRefs() {
105
105
  for (var _len = arguments.length, refs = new Array(_len), _key = 0; _key < _len; _key++) {
106
106
  refs[_key] = arguments[_key];
107
107
  }
@@ -123,7 +123,7 @@ function handleRefs$1() {
123
123
  * @param fns the event handler functions
124
124
  * @return the event handler to add to an element
125
125
  */
126
- function callAllEventHandlers$1() {
126
+ function callAllEventHandlers() {
127
127
  for (var _len = arguments.length, fns = new Array(_len), _key = 0; _key < _len; _key++) {
128
128
  fns[_key] = arguments[_key];
129
129
  }
@@ -145,7 +145,7 @@ function callAllEventHandlers$1() {
145
145
  * function once after the time given has passed since
146
146
  * it was last called.
147
147
  */
148
- function debounce$1(fn, time) {
148
+ function debounce(fn, time) {
149
149
  var timeoutId;
150
150
  function cancel() {
151
151
  if (timeoutId) {
@@ -166,7 +166,7 @@ function debounce$1(fn, time) {
166
166
  return wrapper;
167
167
  }
168
168
 
169
- var cleanupStatus = debounce$1(function (document) {
169
+ var cleanupStatus = debounce(function (document) {
170
170
  getStatusDiv(document).textContent = '';
171
171
  }, 500);
172
172
 
@@ -247,6 +247,8 @@ function getState(state, props) {
247
247
  }
248
248
  var keys = Object.keys(state);
249
249
  return keys.reduce(function (newState, key) {
250
+ // state keys could be in props, but with value undefined, which means they should be ignored.
251
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
250
252
  if (props[key] !== undefined) {
251
253
  newState[key] = props[key];
252
254
  }
@@ -278,84 +280,121 @@ function scrollIntoView(node, menuNode) {
278
280
  }
279
281
 
280
282
  /**
281
- * Accepts a parameter and returns it if it's a function
282
- * or a noop function if it's not. This allows us to
283
- * accept a callback, but not worry about it if it's not
284
- * passed.
285
- * @param {Function} cb the callback
286
- * @return {Function} a function
283
+ * Normalizes the 'key' property of a KeyboardEvent in IE/Edge
284
+ * @param event a keyboardEvent object
285
+ * @return keyboard key
287
286
  */
288
- function cbToCb(cb) {
289
- return typeof cb === 'function' ? cb : noop;
287
+ function normalizeArrowKey(event) {
288
+ var key = event.key,
289
+ keyCode = event.keyCode;
290
+ /* istanbul ignore next (ie) */
291
+ if (keyCode >= 37 && keyCode <= 40 && !key.startsWith('Arrow')) {
292
+ return "Arrow" + key;
293
+ }
294
+ return key;
290
295
  }
291
296
 
292
297
  /**
293
- * Simple debounce implementation. Will call the given
294
- * function once after the time given has passed since
295
- * it was last called.
296
- * @param {Function} fn the function to call after the time
297
- * @param {Number} time the time to wait
298
- * @return {Function} the debounced function
298
+ * Returns the next non-disabled highlightedIndex value.
299
+ *
300
+ * @param start The current highlightedIndex.
301
+ * @param backwards If true, it will search backwards from the start.
302
+ * @param items The items array.
303
+ * @param isItemDisabled Function that tells if an item is disabled or not.
304
+ * @param circular If the search reaches the end, if it can search again starting from the other end.
305
+ * @returns The next non-disabled index.
299
306
  */
300
- function debounce(fn, time) {
301
- var timeoutId;
302
- function cancel() {
303
- if (timeoutId) {
304
- clearTimeout(timeoutId);
305
- }
307
+ function getNonDisabledIndex(start, backwards, items, isItemDisabled, circular) {
308
+ if (circular === void 0) {
309
+ circular = false;
306
310
  }
307
- function wrapper() {
308
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
309
- args[_key] = arguments[_key];
311
+ var count = items.length;
312
+ if (backwards) {
313
+ for (var index = start; index >= 0; index--) {
314
+ if (!isItemDisabled(items[index], index)) {
315
+ return index;
316
+ }
317
+ }
318
+ } else {
319
+ for (var _index = start; _index < count; _index++) {
320
+ if (!isItemDisabled(items[_index], _index)) {
321
+ return _index;
322
+ }
310
323
  }
311
- cancel();
312
- timeoutId = setTimeout(function () {
313
- timeoutId = null;
314
- fn.apply(void 0, args);
315
- }, time);
316
324
  }
317
- wrapper.cancel = cancel;
318
- return wrapper;
325
+ if (circular) {
326
+ return getNonDisabledIndex(backwards ? count - 1 : 0, backwards, items, isItemDisabled);
327
+ }
328
+ return -1;
319
329
  }
320
330
 
321
331
  /**
322
- * This is intended to be used to compose event handlers.
323
- * They are executed in order until one of them sets
324
- * `event.preventDownshiftDefault = true`.
325
- * @param {...Function} fns the event handler functions
326
- * @return {Function} the event handler to add to an element
332
+ * Returns the next non-disabled highlightedIndex value.
333
+ *
334
+ * @param start The current highlightedIndex.
335
+ * @param offset The offset from the current highlightedIndex to start searching.
336
+ * @param items The items array.
337
+ * @param isItemDisabled Function that tells if an item is disabled or not.
338
+ * @param circular If the search reaches the end, if it can search again starting from the other end.
339
+ * @returns The next highlightedIndex.
327
340
  */
328
- function callAllEventHandlers() {
329
- for (var _len2 = arguments.length, fns = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
330
- fns[_key2] = arguments[_key2];
341
+ function getHighlightedIndex(start, offset, items, isItemDisabled, circular) {
342
+ if (circular === void 0) {
343
+ circular = false;
331
344
  }
332
- return function (event) {
333
- for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
334
- args[_key3 - 1] = arguments[_key3];
335
- }
336
- return fns.some(function (fn) {
337
- if (fn) {
338
- fn.apply(void 0, [event].concat(args));
339
- }
340
- return event.preventDownshiftDefault || event.hasOwnProperty('nativeEvent') && event.nativeEvent.preventDownshiftDefault;
341
- });
342
- };
343
- }
344
- function handleRefs() {
345
- for (var _len4 = arguments.length, refs = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
346
- refs[_key4] = arguments[_key4];
345
+ var count = items.length;
346
+ if (count === 0) {
347
+ return -1;
347
348
  }
348
- return function (node) {
349
- refs.forEach(function (ref) {
350
- if (typeof ref === 'function') {
351
- ref(node);
352
- } else if (ref) {
353
- ref.current = node;
349
+ var itemsLastIndex = count - 1;
350
+ if (typeof start !== 'number' || start < 0 || start > itemsLastIndex) {
351
+ start = offset > 0 ? -1 : itemsLastIndex + 1;
352
+ }
353
+ var current = start + offset;
354
+ if (current < 0) {
355
+ current = circular ? itemsLastIndex : 0;
356
+ } else if (current > itemsLastIndex) {
357
+ current = circular ? 0 : itemsLastIndex;
358
+ }
359
+ var highlightedIndex = getNonDisabledIndex(current, offset < 0, items, isItemDisabled, circular);
360
+ if (highlightedIndex === -1) {
361
+ return start >= count ? -1 : start;
362
+ }
363
+ return highlightedIndex;
364
+ }
365
+
366
+ /* eslint-disable @typescript-eslint/no-explicit-any */
367
+
368
+ // eslint-disable-next-line import/no-mutable-exports
369
+ var validateControlledUnchanged = noop;
370
+ /* istanbul ignore next */
371
+ if (process.env.NODE_ENV !== 'production') {
372
+ validateControlledUnchanged = function validateControlledUnchanged(state, prevProps, nextProps) {
373
+ 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";
374
+ Object.keys(state).forEach(function (propKey) {
375
+ if (prevProps[propKey] !== undefined && nextProps[propKey] === undefined) {
376
+ // eslint-disable-next-line no-console
377
+ console.error("downshift: A component has changed the controlled prop \"" + propKey + "\" to be uncontrolled. " + warningDescription);
378
+ } else if (prevProps[propKey] === undefined && nextProps[propKey] !== undefined) {
379
+ // eslint-disable-next-line no-console
380
+ console.error("downshift: A component has changed the uncontrolled prop \"" + propKey + "\" to be controlled. " + warningDescription);
354
381
  }
355
382
  });
356
383
  };
357
384
  }
358
385
 
386
+ /**
387
+ * Accepts a parameter and returns it if it's a function
388
+ * or a noop function if it's not. This allows us to
389
+ * accept a callback, but not worry about it if it's not
390
+ * passed.
391
+ * @param {Function} cb the callback
392
+ * @return {Function} a function
393
+ */
394
+ function cbToCb(cb) {
395
+ return typeof cb === 'function' ? cb : noop;
396
+ }
397
+
359
398
  /**
360
399
  * Default implementation for status message. Only added when menu is open.
361
400
  * Will specify if there are results in the list, and if so, how many,
@@ -442,34 +481,6 @@ function pickState(state) {
442
481
  return result;
443
482
  }
444
483
 
445
- /**
446
- * This determines whether a prop is a "controlled prop" meaning it is
447
- * state which is controlled by the outside of this component rather
448
- * than within this component.
449
- *
450
- * @param {Object} props The props that may contain controlled values.
451
- * @param {String} key the key to check
452
- * @return {Boolean} whether it is a controlled controlled prop
453
- */
454
- function isControlledProp(props, key) {
455
- return props[key] !== undefined;
456
- }
457
-
458
- /**
459
- * Normalizes the 'key' property of a KeyboardEvent in IE/Edge
460
- * @param {Object} event a keyboardEvent object
461
- * @return {String} keyboard key
462
- */
463
- function normalizeArrowKey(event) {
464
- var key = event.key,
465
- keyCode = event.keyCode;
466
- /* istanbul ignore next (ie) */
467
- if (keyCode >= 37 && keyCode <= 40 && key.indexOf('Arrow') !== 0) {
468
- return "Arrow" + key;
469
- }
470
- return key;
471
- }
472
-
473
484
  /**
474
485
  * Simple check if the value passed is object literal
475
486
  * @param {*} obj any things
@@ -479,93 +490,6 @@ function isPlainObject(obj) {
479
490
  return Object.prototype.toString.call(obj) === '[object Object]';
480
491
  }
481
492
 
482
- /**
483
- * Returns the next non-disabled highlightedIndex value.
484
- *
485
- * @param {number} start The current highlightedIndex.
486
- * @param {number} offset The offset from the current highlightedIndex to start searching.
487
- * @param {unknown[]} items The items array.
488
- * @param {(item: unknown, index: number) => boolean} isItemDisabled Function that tells if an item is disabled or not.
489
- * @param {boolean?} circular If the search reaches the end, if it can search again starting from the other end.
490
- * @returns {number} The next highlightedIndex.
491
- */
492
- function getHighlightedIndex(start, offset, items, isItemDisabled, circular) {
493
- if (circular === void 0) {
494
- circular = false;
495
- }
496
- var count = items.length;
497
- if (count === 0) {
498
- return -1;
499
- }
500
- var itemsLastIndex = count - 1;
501
- if (typeof start !== 'number' || start < 0 || start > itemsLastIndex) {
502
- start = offset > 0 ? -1 : itemsLastIndex + 1;
503
- }
504
- var current = start + offset;
505
- if (current < 0) {
506
- current = circular ? itemsLastIndex : 0;
507
- } else if (current > itemsLastIndex) {
508
- current = circular ? 0 : itemsLastIndex;
509
- }
510
- var highlightedIndex = getNonDisabledIndex(current, offset < 0, items, isItemDisabled, circular);
511
- if (highlightedIndex === -1) {
512
- return start >= count ? -1 : start;
513
- }
514
- return highlightedIndex;
515
- }
516
-
517
- /**
518
- * Returns the next non-disabled highlightedIndex value.
519
- *
520
- * @param {number} start The current highlightedIndex.
521
- * @param {boolean} backwards If true, it will search backwards from the start.
522
- * @param {unknown[]} items The items array.
523
- * @param {(item: unknown, index: number) => boolean} isItemDisabled Function that tells if an item is disabled or not.
524
- * @param {boolean} circular If the search reaches the end, if it can search again starting from the other end.
525
- * @returns {number} The next non-disabled index.
526
- */
527
- function getNonDisabledIndex(start, backwards, items, isItemDisabled, circular) {
528
- if (circular === void 0) {
529
- circular = false;
530
- }
531
- var count = items.length;
532
- if (backwards) {
533
- for (var index = start; index >= 0; index--) {
534
- if (!isItemDisabled(items[index], index)) {
535
- return index;
536
- }
537
- }
538
- } else {
539
- for (var _index = start; _index < count; _index++) {
540
- if (!isItemDisabled(items[_index], _index)) {
541
- return _index;
542
- }
543
- }
544
- }
545
- if (circular) {
546
- return getNonDisabledIndex(backwards ? count - 1 : 0, backwards, items, isItemDisabled);
547
- }
548
- return -1;
549
- }
550
-
551
- // eslint-disable-next-line import/no-mutable-exports
552
- var validateControlledUnchanged = noop;
553
- /* istanbul ignore next */
554
- if (process.env.NODE_ENV !== 'production') {
555
- validateControlledUnchanged = function validateControlledUnchanged(state, prevProps, nextProps) {
556
- 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";
557
- Object.keys(state).forEach(function (propKey) {
558
- if (prevProps[propKey] !== undefined && nextProps[propKey] === undefined) {
559
- // eslint-disable-next-line no-console
560
- console.error("downshift: A component has changed the controlled prop \"" + propKey + "\" to be uncontrolled. " + warningDescription);
561
- } else if (prevProps[propKey] === undefined && nextProps[propKey] !== undefined) {
562
- // eslint-disable-next-line no-console
563
- console.error("downshift: A component has changed the uncontrolled prop \"" + propKey + "\" to be controlled. " + warningDescription);
564
- }
565
- });
566
- };
567
- }
568
-
569
493
  var _excluded$4 = ["refKey", "ref"],
570
494
  _excluded2$4 = ["onClick", "onPress", "onKeyDown", "onKeyUp", "onBlur"],
571
495
  _excluded3$3 = ["onKeyDown", "onBlur", "onChange", "onInput", "onChangeText"],
@@ -716,7 +640,7 @@ var Downshift = /*#__PURE__*/function () {
716
640
  }
717
641
  newStateToSet[key];
718
642
  // if it's coming from props, then we don't care to set it internally
719
- if (!isControlledProp(_this.props, key)) {
643
+ if (_this.props[key] === undefined) {
720
644
  nextState[key] = newStateToSet[key];
721
645
  }
722
646
  });
@@ -1382,7 +1306,7 @@ var Downshift = /*#__PURE__*/function () {
1382
1306
  if (process.env.NODE_ENV !== 'production') {
1383
1307
  validateControlledUnchanged(this.state, prevProps, this.props);
1384
1308
  }
1385
- if (isControlledProp(this.props, 'selectedItem') && this.props.selectedItemChanged(prevProps.selectedItem, this.props.selectedItem)) {
1309
+ if (this.props.selectedItem !== undefined && this.props.selectedItemChanged(prevProps.selectedItem, this.props.selectedItem)) {
1386
1310
  this.internalSetState({
1387
1311
  type: controlledPropUpdatedSelectedItem,
1388
1312
  inputValue: this.props.itemToString(this.props.selectedItem)
@@ -1556,7 +1480,7 @@ function callOnChangeProps(action, props, state, newState) {
1556
1480
  changes[key] = newState[key];
1557
1481
  }
1558
1482
  }
1559
- if (props.onStateChange && Object.keys(changes).length) {
1483
+ if (typeof props.onStateChange === 'function' && Object.keys(changes).length) {
1560
1484
  props.onStateChange(_extends({
1561
1485
  type: type
1562
1486
  }, changes));
@@ -1582,50 +1506,53 @@ function invokeOnChangeHandler(key, action, props, state, newState) {
1582
1506
  * two reducers, one from downshift and an optional one from the user.
1583
1507
  * Also calls the onChange handlers for state values that have changed.
1584
1508
  *
1585
- * @param {Function} reducer Reducer function from downshift.
1586
- * @param {Object} props The hook props, also passed to createInitialState.
1587
- * @param {Function} createInitialState Function that returns the initial state.
1588
- * @param {Function} isStateEqual Function that checks if a previous state is equal to the next.
1589
- * @returns {Array} An array with the state and an action dispatcher.
1509
+ * @param reducer Reducer function from downshift.
1510
+ * @param props The hook props, also passed to createInitialState.
1511
+ * @param createInitialState Function that returns the initial state.
1512
+ * @param isStateEqual Function that checks if a previous state is equal to the next.
1513
+ * @returns An array with the state and an action dispatcher.
1590
1514
  */
1591
1515
  function useEnhancedReducer(reducer, props, createInitialState, isStateEqual) {
1592
- var prevStateRef = React__namespace.useRef(null);
1593
- var actionRef = React__namespace.useRef(undefined);
1594
- var propsRef = useLatestRef(props);
1516
+ var prevStateRef = React__namespace.useRef({});
1517
+ var actionRef = React__namespace.useRef();
1595
1518
  var enhancedReducer = React__namespace.useCallback(function (state, action) {
1596
1519
  actionRef.current = action;
1597
- state = getState(state, propsRef.current);
1598
- var changes = reducer(state, propsRef.current, action);
1599
- var newState = propsRef.current.stateReducer(state, _extends({}, action, {
1520
+ state = getState(state, action.props);
1521
+ var changes = reducer(state, action);
1522
+ var newState = action.props.stateReducer(state, _extends({}, action, {
1600
1523
  changes: changes
1601
1524
  }));
1602
1525
  return _extends({}, state, newState);
1603
- }, [propsRef, reducer]);
1526
+ }, [reducer]);
1604
1527
  var _React$useReducer = React__namespace.useReducer(enhancedReducer, props, createInitialState),
1605
1528
  state = _React$useReducer[0],
1606
1529
  dispatch = _React$useReducer[1];
1530
+ var propsRef = useLatestRef(props);
1531
+ var dispatchWithProps = React__namespace.useCallback(function (action) {
1532
+ return dispatch(_extends({}, action, {
1533
+ props: propsRef.current
1534
+ }));
1535
+ }, [propsRef]);
1607
1536
  var action = actionRef.current;
1608
1537
  React__namespace.useEffect(function () {
1609
- var _prevStateRef$current;
1610
- var prevState = getState((_prevStateRef$current = prevStateRef.current) != null ? _prevStateRef$current : {}, propsRef.current);
1611
- var shouldCallOnChangeProps = action && prevStateRef.current && !isStateEqual(prevState, state);
1538
+ var prevState = getState(prevStateRef.current, action == null ? void 0 : action.props);
1539
+ var shouldCallOnChangeProps = action && !isStateEqual(prevState, state);
1612
1540
  if (shouldCallOnChangeProps) {
1613
- callOnChangeProps(action, propsRef.current, prevState, state);
1541
+ callOnChangeProps(action, action.props, prevState, state);
1614
1542
  }
1615
1543
  prevStateRef.current = state;
1616
- }, [state, action, isStateEqual, propsRef]);
1617
- return [state, dispatch];
1544
+ }, [state, action, isStateEqual]);
1545
+ return [state, dispatchWithProps];
1618
1546
  }
1619
1547
 
1620
1548
  /**
1621
1549
  * Wraps the useEnhancedReducer and applies the controlled prop values before
1622
1550
  * returning the new state.
1623
- *
1624
- * @param {Function} reducer Reducer function from downshift.
1625
- * @param {Object} props The hook props, also passed to createInitialState.
1626
- * @param {Function} createInitialState Function that returns the initial state.
1627
- * @param {Function} isStateEqual Function that checks if a previous state is equal to the next.
1628
- * @returns {Array} An array with the state and an action dispatcher.
1551
+ * @param reducer Reducer function from downshift.
1552
+ * @param props The hook props, also passed to createInitialState.
1553
+ * @param createInitialState Function that returns the initial state.
1554
+ * @param isStateEqual Function that checks if a previous state is equal to the next.
1555
+ * @returns An array with the state and an action dispatcher.
1629
1556
  */
1630
1557
  function useControlledReducer$1(reducer, props, createInitialState, isStateEqual) {
1631
1558
  var _useEnhancedReducer = useEnhancedReducer(reducer, props, createInitialState, isStateEqual),
@@ -1678,16 +1605,8 @@ function useIsInitialMount() {
1678
1605
  return isInitialMountRef.current;
1679
1606
  }
1680
1607
 
1681
- /**
1682
- * Default state reducer that returns the changes.
1683
- *
1684
- */
1685
- function stateReducer(_s, a) {
1686
- return a.changes;
1687
- }
1688
-
1689
1608
  // Shared between all exports.
1690
- var propTypes$5 = {
1609
+ var propTypes$4 = {
1691
1610
  environment: PropTypes.shape({
1692
1611
  addEventListener: PropTypes.func.isRequired,
1693
1612
  removeEventListener: PropTypes.func.isRequired,
@@ -1703,30 +1622,47 @@ var propTypes$5 = {
1703
1622
  stateReducer: PropTypes.func
1704
1623
  };
1705
1624
 
1706
- function getDefaultValue$1(props, propKey, defaultStateValues) {
1707
- var defaultValue = props["default" + capitalizeString(propKey)];
1708
- if (defaultValue !== undefined) {
1709
- return defaultValue;
1710
- }
1711
- return defaultStateValues[propKey];
1625
+ /**
1626
+ * Returns the default value based on the defaultProp and defaultStateValue.
1627
+ *
1628
+ * @param defaultProp The default prop value.
1629
+ * @param defaultStateValue The default state value.
1630
+ * @returns The resolved default value.
1631
+ */
1632
+ function getDefaultValue(defaultProp, defaultStateValue) {
1633
+ return defaultProp === undefined ? defaultStateValue : defaultProp;
1712
1634
  }
1713
1635
 
1714
- function getInitialValue$1(props, propKey, defaultStateValues) {
1715
- var value = props[propKey];
1636
+ /**
1637
+ * Returns the initial value for a state variable, based on the following precedence:
1638
+ * 1. The controlled value (if it's not undefined)
1639
+ * 2. The initialValue (if it's not undefined)
1640
+ * 3. The defaultValue (if it's not undefined)
1641
+ * 4. The defaultStateValue
1642
+ *
1643
+ * @param value The controlled value of the state variable.
1644
+ * @param initialValue The initial value of the state variable.
1645
+ * @param defaultValue The default value of the state variable.
1646
+ * @param defaultStateValue The default state value to use if all other values are undefined.
1647
+ * @returns The initial value for the state variable.
1648
+ */
1649
+ function getInitialValue(value, initialValue, defaultValue, defaultStateValue) {
1716
1650
  if (value !== undefined) {
1717
1651
  return value;
1718
1652
  }
1719
- var initialValue = props["initial" + capitalizeString(propKey)];
1720
1653
  if (initialValue !== undefined) {
1721
1654
  return initialValue;
1722
1655
  }
1723
- return getDefaultValue$1(props, propKey, defaultStateValues);
1656
+ if (defaultValue !== undefined) {
1657
+ return defaultValue;
1658
+ }
1659
+ return defaultStateValue;
1724
1660
  }
1725
1661
 
1726
1662
  /**
1727
1663
  * Debounced call for updating the a11y message.
1728
1664
  */
1729
- var updateA11yStatus = debounce$1(function (status, document) {
1665
+ var updateA11yStatus = debounce(function (status, document) {
1730
1666
  setStatus(status, document);
1731
1667
  }, 200);
1732
1668
 
@@ -1760,7 +1696,7 @@ function useA11yMessageStatus(getA11yStatusMessage, options, dependencyArray, en
1760
1696
  }
1761
1697
 
1762
1698
  // Shared between useSelect, useCombobox, Downshift.
1763
- var propTypes$4 = _extends({}, propTypes$5, {
1699
+ var dropdownPropTypes = _extends({}, propTypes$4, {
1764
1700
  getA11yStatusMessage: PropTypes.func,
1765
1701
  highlightedIndex: PropTypes.number,
1766
1702
  defaultHighlightedIndex: PropTypes.number,
@@ -1783,59 +1719,145 @@ var propTypes$4 = _extends({}, propTypes$5, {
1783
1719
  scrollIntoView: PropTypes.func
1784
1720
  });
1785
1721
 
1786
- var defaultProps$3 = {
1722
+ var dropdownDefaultProps = {
1787
1723
  itemToString: function itemToString(item) {
1788
1724
  return item ? String(item) : '';
1789
1725
  },
1790
1726
  itemToKey: function itemToKey(item) {
1791
1727
  return item;
1792
1728
  },
1793
- stateReducer: stateReducer,
1729
+ isItemDisabled: function isItemDisabled(_item) {
1730
+ return false;
1731
+ },
1732
+ stateReducer: function stateReducer(_state, actionAndChanges) {
1733
+ return actionAndChanges.changes;
1734
+ },
1794
1735
  scrollIntoView: scrollIntoView,
1795
1736
  environment: /* istanbul ignore next (ssr) */
1796
1737
  undefined
1797
1738
  };
1798
1739
 
1799
- var defaultStateValues$1 = {
1740
+ var dropdownDefaultStateValues = {
1800
1741
  highlightedIndex: -1,
1801
1742
  isOpen: false,
1802
1743
  selectedItem: null,
1803
1744
  inputValue: ''
1804
1745
  };
1805
1746
 
1806
- // istanbul ignore next
1807
- var useIsomorphicLayoutEffect = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined' ? React__namespace.useLayoutEffect : React__namespace.useEffect;
1808
- function getInitialState$3(props) {
1809
- var selectedItem = getInitialValue$1(props, 'selectedItem', defaultStateValues$1);
1810
- var isOpen = getInitialValue$1(props, 'isOpen', defaultStateValues$1);
1811
- var highlightedIndex = getInitialHighlightedIndex(props);
1812
- var inputValue = getInitialValue$1(props, 'inputValue', defaultStateValues$1);
1813
- return {
1814
- highlightedIndex: highlightedIndex < 0 && selectedItem && isOpen ? props.items.findIndex(function (item) {
1815
- return props.itemToKey(item) === props.itemToKey(selectedItem);
1816
- }) : highlightedIndex,
1817
- isOpen: isOpen,
1818
- selectedItem: selectedItem,
1819
- inputValue: inputValue
1820
- };
1747
+ // https://github.com/downshift-js/downshift/issues/1674#issuecomment-3924320872
1748
+ var SafeReact$1 = _extends({}, React__namespace);
1749
+ var reactUseId$1 = SafeReact$1.useId;
1750
+ var useElementIds$1 = typeof reactUseId$1 === 'function' ? useElementIdsR18$1 : useElementIdsLegacy$1;
1751
+ function useElementIdsR18$1(_ref) {
1752
+ var id = _ref.id,
1753
+ labelId = _ref.labelId,
1754
+ menuId = _ref.menuId,
1755
+ getItemId = _ref.getItemId,
1756
+ toggleButtonId = _ref.toggleButtonId,
1757
+ inputId = _ref.inputId;
1758
+ var reactId = "downshift-" + reactUseId$1();
1759
+ if (!id) {
1760
+ id = reactId;
1761
+ }
1762
+ var elementIds = React__namespace.useMemo(function () {
1763
+ return {
1764
+ labelId: labelId != null ? labelId : id + "-label",
1765
+ menuId: menuId != null ? menuId : id + "-menu",
1766
+ getItemId: getItemId != null ? getItemId : function (index) {
1767
+ return id + "-item-" + index;
1768
+ },
1769
+ toggleButtonId: toggleButtonId != null ? toggleButtonId : id + "-toggle-button",
1770
+ inputId: inputId != null ? inputId : id + "-input"
1771
+ };
1772
+ }, [getItemId, id, inputId, labelId, menuId, toggleButtonId]);
1773
+ return elementIds;
1821
1774
  }
1822
- function getHighlightedIndexOnOpen(props, state, offset) {
1823
- var items = props.items,
1824
- initialHighlightedIndex = props.initialHighlightedIndex,
1825
- defaultHighlightedIndex = props.defaultHighlightedIndex,
1826
- isItemDisabled = props.isItemDisabled,
1827
- itemToKey = props.itemToKey;
1828
- var selectedItem = state.selectedItem,
1829
- highlightedIndex = state.highlightedIndex;
1775
+ function useElementIdsLegacy$1(_ref2) {
1776
+ var id = _ref2.id,
1777
+ labelId = _ref2.labelId,
1778
+ menuId = _ref2.menuId,
1779
+ getItemId = _ref2.getItemId,
1780
+ toggleButtonId = _ref2.toggleButtonId,
1781
+ inputId = _ref2.inputId;
1782
+ var baseIdRef = React__namespace.useRef(id != null ? id : "downshift-" + generateId());
1783
+ var baseId = baseIdRef.current;
1784
+ var elementIds = React__namespace.useMemo(function () {
1785
+ return {
1786
+ labelId: labelId != null ? labelId : baseId + "-label",
1787
+ menuId: menuId != null ? menuId : baseId + "-menu",
1788
+ getItemId: getItemId != null ? getItemId : function (index) {
1789
+ return baseId + "-item-" + index;
1790
+ },
1791
+ toggleButtonId: toggleButtonId != null ? toggleButtonId : baseId + "-toggle-button",
1792
+ inputId: inputId != null ? inputId : baseId + "-input"
1793
+ };
1794
+ }, [getItemId, inputId, labelId, menuId, toggleButtonId, baseId]);
1795
+ return elementIds;
1796
+ }
1797
+
1798
+ /**
1799
+ * Returns the new highlightedIndex based on the defaultHighlightedIndex prop, if it's not disabled.
1800
+ *
1801
+ * @param props Props passed to the hook.
1802
+ * @returns The highlighted index.
1803
+ */
1804
+ function getDefaultHighlightedIndex(items, isItemDisabled, defaultHighlightedIndex) {
1805
+ var highlightedIndex = getDefaultValue(defaultHighlightedIndex, dropdownDefaultStateValues.highlightedIndex);
1806
+ if (items[highlightedIndex] && isItemDisabled(items[highlightedIndex], highlightedIndex)) {
1807
+ return -1;
1808
+ }
1809
+ return highlightedIndex;
1810
+ }
1811
+
1812
+ /**
1813
+ * Handles selection on Enter / Alt + ArrowUp. Closes the menu and resets the highlighted index, unless there is a highlighted.
1814
+ * In that case, selects the item and resets to defaults for open state and highlighted idex.
1815
+ *
1816
+ * @param props The Dropdown props.
1817
+ * @param highlightedIndex The index from the state.
1818
+ * @param inputValue Also return the input value for state.
1819
+ * @returns The changes for the state.
1820
+ */
1821
+ function getChangesOnSelection(items, itemToString, defaultIsOpen, defaultHighlightedIndex, highlightedIndex, inputValue) {
1822
+ var shouldSelect = items.length && highlightedIndex >= 0;
1823
+ return _extends({
1824
+ isOpen: false,
1825
+ highlightedIndex: -1
1826
+ }, shouldSelect && _extends({
1827
+ selectedItem: items[highlightedIndex],
1828
+ isOpen: getDefaultValue(defaultIsOpen, dropdownDefaultStateValues.isOpen),
1829
+ highlightedIndex: getDefaultValue(defaultHighlightedIndex, dropdownDefaultStateValues.highlightedIndex)
1830
+ }, inputValue && {
1831
+ inputValue: itemToString(items[highlightedIndex])
1832
+ }));
1833
+ }
1834
+
1835
+ /* eslint-disable max-params */
1836
+ /**
1837
+ * Returns the highlighted index when the menu is opened.
1838
+ * Takes into account the initialHighlightedIndex, defaultHighlightedIndex,
1839
+ * selectedItem, and the open direction offset.
1840
+ *
1841
+ * @param items The list of items.
1842
+ * @param initialHighlightedIndex The initial highlighted index prop.
1843
+ * @param defaultHighlightedIndex The default highlighted index prop.
1844
+ * @param isItemDisabled Callback to determine if an item is disabled.
1845
+ * @param itemToKey Callback to get a unique key from an item.
1846
+ * @param selectedItem The currently selected item.
1847
+ * @param highlightedIndex The current highlighted index from state.
1848
+ * @param offset The direction of navigation: positive opens downward, negative opens upward.
1849
+ * @returns The new highlighted index.
1850
+ */
1851
+ function getHighlightedIndexOnOpen(items, initialHighlightedIndex, defaultHighlightedIndex, isItemDisabled, itemToKey, selectedItem, highlightedIndex, offset) {
1830
1852
  if (items.length === 0) {
1831
1853
  return -1;
1832
1854
  }
1833
1855
 
1834
1856
  // initialHighlightedIndex will give value to highlightedIndex on initial state only.
1835
- if (initialHighlightedIndex !== undefined && highlightedIndex === initialHighlightedIndex && !isItemDisabled(items[initialHighlightedIndex], initialHighlightedIndex)) {
1857
+ if (initialHighlightedIndex !== undefined && highlightedIndex === initialHighlightedIndex && items[initialHighlightedIndex] && !isItemDisabled(items[initialHighlightedIndex], initialHighlightedIndex)) {
1836
1858
  return initialHighlightedIndex;
1837
1859
  }
1838
- if (defaultHighlightedIndex !== undefined && !isItemDisabled(items[defaultHighlightedIndex], defaultHighlightedIndex)) {
1860
+ if (defaultHighlightedIndex !== undefined && items[defaultHighlightedIndex] && !isItemDisabled(items[defaultHighlightedIndex], defaultHighlightedIndex)) {
1839
1861
  return defaultHighlightedIndex;
1840
1862
  }
1841
1863
  if (selectedItem) {
@@ -1843,21 +1865,71 @@ function getHighlightedIndexOnOpen(props, state, offset) {
1843
1865
  return itemToKey(selectedItem) === itemToKey(item);
1844
1866
  });
1845
1867
  }
1846
- if (offset < 0 && !isItemDisabled(items[items.length - 1], items.length - 1)) {
1868
+ if (offset < 0 && items[items.length - 1] && !isItemDisabled(items[items.length - 1], items.length - 1)) {
1847
1869
  return items.length - 1;
1848
1870
  }
1849
- if (offset > 0 && !isItemDisabled(items[0], 0)) {
1871
+ if (offset > 0 && items[0] && !isItemDisabled(items[0], 0)) {
1850
1872
  return 0;
1851
1873
  }
1852
1874
  return -1;
1853
1875
  }
1876
+
1877
+ function getInitialState$3(props) {
1878
+ var selectedItem = getInitialValue(props.selectedItem, props.initialSelectedItem, props.defaultSelectedItem, dropdownDefaultStateValues.selectedItem);
1879
+ var isOpen = getInitialValue(props.isOpen, props.initialIsOpen, props.defaultIsOpen, dropdownDefaultStateValues.isOpen);
1880
+ var highlightedIndex = getInitialHighlightedIndex(props);
1881
+ var inputValue = getInitialValue(props.inputValue, props.initialInputValue, props.defaultInputValue, dropdownDefaultStateValues.inputValue);
1882
+ return {
1883
+ highlightedIndex: highlightedIndex < 0 && selectedItem && isOpen ? props.items.findIndex(function (item) {
1884
+ return props.itemToKey(item) === props.itemToKey(selectedItem);
1885
+ }) : highlightedIndex,
1886
+ isOpen: isOpen,
1887
+ selectedItem: selectedItem,
1888
+ inputValue: inputValue
1889
+ };
1890
+ }
1891
+
1892
+ /**
1893
+ * Returns the new highlightedIndex based on the initialHighlightedIndex prop, if not disabled.
1894
+ * @param props Props from useCombobox or useSelect.
1895
+ * @returns The highlighted index.
1896
+ */
1897
+ function getInitialHighlightedIndex(props) {
1898
+ var highlightedIndex = getInitialValue(props.highlightedIndex, props.initialHighlightedIndex, props.defaultHighlightedIndex, dropdownDefaultStateValues.highlightedIndex);
1899
+ if (highlightedIndex > -1 && props.items[highlightedIndex] && props.isItemDisabled(props.items[highlightedIndex], highlightedIndex)) {
1900
+ return -1;
1901
+ }
1902
+ return highlightedIndex;
1903
+ }
1904
+
1905
+ /* eslint-disable @typescript-eslint/no-explicit-any */
1906
+ // eslint-disable-next-line import/no-mutable-exports
1907
+ var useControlPropsValidator = noop;
1908
+ /* istanbul ignore next */
1909
+ if (process.env.NODE_ENV !== 'production') {
1910
+ useControlPropsValidator = function useControlPropsValidator(_ref) {
1911
+ var props = _ref.props,
1912
+ state = _ref.state;
1913
+ // used for checking when props are moving from controlled to uncontrolled.
1914
+ var prevPropsRef = React__namespace.useRef(props);
1915
+ var isInitialMount = useIsInitialMount();
1916
+ React__namespace.useEffect(function () {
1917
+ if (isInitialMount) {
1918
+ return;
1919
+ }
1920
+ validateControlledUnchanged(state, prevPropsRef.current, props);
1921
+ prevPropsRef.current = props;
1922
+ }, [state, props, isInitialMount]);
1923
+ };
1924
+ }
1925
+
1854
1926
  /**
1855
1927
  * Tracks mouse and touch events, such as mouseDown, touchMove and touchEnd.
1856
1928
  *
1857
- * @param {Window} environment The environment to add the event listeners to, for instance window.
1858
- * @param {() => void} handleBlur The function that is called if mouseDown or touchEnd occured outside the downshiftElements.
1859
- * @param {Array<{current: HTMLElement}>} downshiftElementsRefs The refs for the elements that should not trigger a blur action from mouseDown or touchEnd.
1860
- * @returns {{isMouseDown: boolean, isTouchMove: boolean, isTouchEnd: boolean}} The mouse and touch events information, if any of are happening.
1929
+ * @param environment The environment to add the event listeners to, for instance window.
1930
+ * @param handleBlur The function that is called if mouseDown or touchEnd occured outside the downshiftElements.
1931
+ * @param downshiftRefs The refs for the elements that should not trigger a blur action from mouseDown or touchEnd.
1932
+ * @returns The mouse and touch events information.
1861
1933
  */
1862
1934
  function useMouseAndTouchTracker(environment, handleBlur, downshiftRefs) {
1863
1935
  var mouseAndTouchTrackersRef = React__namespace.useRef({
@@ -1886,8 +1958,8 @@ var useGetterPropsCalledChecker = function useGetterPropsCalledChecker() {
1886
1958
  /**
1887
1959
  * Custom hook that checks if getter props are called correctly.
1888
1960
  *
1889
- * @param {...any} propKeys Getter prop names to be handled.
1890
- * @returns {Function} Setter function called inside getter props to set call information.
1961
+ * @param propKeys Getter prop names to be handled.
1962
+ * @returns Setter function called inside getter props to set call information.
1891
1963
  */
1892
1964
  /* istanbul ignore next */
1893
1965
  if (process.env.NODE_ENV !== 'production') {
@@ -1929,116 +2001,54 @@ if (process.env.NODE_ENV !== 'production') {
1929
2001
  return setGetterPropCallInfo;
1930
2002
  };
1931
2003
  }
1932
- function useScrollIntoView(_ref) {
1933
- var highlightedIndex = _ref.highlightedIndex,
1934
- isOpen = _ref.isOpen,
1935
- itemRefs = _ref.itemRefs,
1936
- getItemNodeFromIndex = _ref.getItemNodeFromIndex,
1937
- menuElement = _ref.menuElement,
1938
- scrollIntoViewProp = _ref.scrollIntoView;
2004
+
2005
+ // istanbul ignore next
2006
+ var useIsomorphicLayoutEffect = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined' ? React__namespace.useLayoutEffect : React__namespace.useEffect;
2007
+
2008
+ /**
2009
+ * Utility hook that scrolls an item from a menu into view.
2010
+ * @param scrollIntoView The function that does the scroll.
2011
+ * @param highlightedIndex The index of the item that should be scrolled.
2012
+ * @param isOpen If the menu is open or not.
2013
+ * @param menuElement The menu element.
2014
+ * @param itemElements The object containing item elements.
2015
+ * @param getItemId The function to get the item id from index.
2016
+ * @returns Function that when called prevents the scroll.
2017
+ */
2018
+ function useScrollIntoView(scrollIntoView, highlightedIndex, isOpen, menuElement, itemElements, getItemId) {
1939
2019
  // used not to scroll on highlight by mouse.
1940
2020
  var shouldScrollRef = React__namespace.useRef(true);
1941
2021
  // Scroll on highlighted item if change comes from keyboard.
1942
2022
  useIsomorphicLayoutEffect(function () {
1943
- if (highlightedIndex < 0 || !isOpen || !Object.keys(itemRefs.current).length) {
2023
+ if (highlightedIndex < 0 || !isOpen || !Object.keys(itemElements).length) {
1944
2024
  return;
1945
2025
  }
1946
- if (shouldScrollRef.current === false) {
1947
- shouldScrollRef.current = true;
2026
+ if (shouldScrollRef.current) {
2027
+ var itemElement = itemElements[getItemId(highlightedIndex)];
2028
+ if (itemElement && menuElement) {
2029
+ scrollIntoView(itemElement, menuElement);
2030
+ }
1948
2031
  } else {
1949
- scrollIntoViewProp(getItemNodeFromIndex(highlightedIndex), menuElement);
2032
+ shouldScrollRef.current = true;
1950
2033
  }
1951
- // eslint-disable-next-line react-hooks/exhaustive-deps
1952
2034
  }, [highlightedIndex]);
1953
- return shouldScrollRef;
1954
- }
1955
-
1956
- // eslint-disable-next-line import/no-mutable-exports
1957
- var useControlPropsValidator = noop;
1958
- /* istanbul ignore next */
1959
- if (process.env.NODE_ENV !== 'production') {
1960
- useControlPropsValidator = function useControlPropsValidator(_ref2) {
1961
- var props = _ref2.props,
1962
- state = _ref2.state;
1963
- // used for checking when props are moving from controlled to uncontrolled.
1964
- var prevPropsRef = React__namespace.useRef(props);
1965
- var isInitialMount = useIsInitialMount();
1966
- React__namespace.useEffect(function () {
1967
- if (isInitialMount) {
1968
- return;
1969
- }
1970
- validateControlledUnchanged(state, prevPropsRef.current, props);
1971
- prevPropsRef.current = props;
1972
- }, [state, props, isInitialMount]);
1973
- };
1974
- }
1975
-
1976
- /**
1977
- * Handles selection on Enter / Alt + ArrowUp. Closes the menu and resets the highlighted index, unless there is a highlighted.
1978
- * In that case, selects the item and resets to defaults for open state and highlighted idex.
1979
- * @param {Object} props The useCombobox props.
1980
- * @param {number} highlightedIndex The index from the state.
1981
- * @param {boolean} inputValue Also return the input value for state.
1982
- * @returns The changes for the state.
1983
- */
1984
- function getChangesOnSelection(props, highlightedIndex, inputValue) {
1985
- var _props$items;
1986
- if (inputValue === void 0) {
1987
- inputValue = true;
1988
- }
1989
- var shouldSelect = ((_props$items = props.items) == null ? void 0 : _props$items.length) && highlightedIndex >= 0;
1990
- return _extends({
1991
- isOpen: false,
1992
- highlightedIndex: -1
1993
- }, shouldSelect && _extends({
1994
- selectedItem: props.items[highlightedIndex],
1995
- isOpen: getDefaultValue$1(props, 'isOpen', defaultStateValues$1),
1996
- highlightedIndex: getDefaultValue$1(props, 'highlightedIndex', defaultStateValues$1)
1997
- }, inputValue && {
1998
- inputValue: props.itemToString(props.items[highlightedIndex])
1999
- }));
2035
+ return React__namespace.useCallback(function preventScroll() {
2036
+ shouldScrollRef.current = false;
2037
+ }, []);
2000
2038
  }
2001
2039
 
2002
2040
  /**
2003
2041
  * Check if a state is equal for dropdowns, by comparing isOpen, inputValue, highlightedIndex and selected item.
2004
2042
  * Used by useSelect and useCombobox.
2005
2043
  *
2006
- * @param {Object} prevState
2007
- * @param {Object} newState
2008
- * @returns {boolean} Wheather the states are deeply equal.
2044
+ * @param prevState The previous dropdown state.
2045
+ * @param newState The new dropdown state.
2046
+ * @returns Wheather the states are deeply equal.
2009
2047
  */
2010
- function isDropdownsStateEqual(prevState, newState) {
2048
+ function isDropdownStateEqual(prevState, newState) {
2011
2049
  return prevState.isOpen === newState.isOpen && prevState.inputValue === newState.inputValue && prevState.highlightedIndex === newState.highlightedIndex && prevState.selectedItem === newState.selectedItem;
2012
2050
  }
2013
2051
 
2014
- /**
2015
- * Returns the new highlightedIndex based on the defaultHighlightedIndex prop, if it's not disabled.
2016
- *
2017
- * @param {Object} props Props from useCombobox or useSelect.
2018
- * @returns {number} The highlighted index.
2019
- */
2020
- function getDefaultHighlightedIndex(props) {
2021
- var highlightedIndex = getDefaultValue$1(props, 'highlightedIndex', defaultStateValues$1);
2022
- if (highlightedIndex > -1 && props.isItemDisabled(props.items[highlightedIndex], highlightedIndex)) {
2023
- return -1;
2024
- }
2025
- return highlightedIndex;
2026
- }
2027
-
2028
- /**
2029
- * Returns the new highlightedIndex based on the initialHighlightedIndex prop, if not disabled.
2030
- *
2031
- * @param {Object} props Props from useCombobox or useSelect.
2032
- * @returns {number} The highlighted index.
2033
- */
2034
- function getInitialHighlightedIndex(props) {
2035
- var highlightedIndex = getInitialValue$1(props, 'highlightedIndex', defaultStateValues$1);
2036
- if (highlightedIndex > -1 && props.isItemDisabled(props.items[highlightedIndex], highlightedIndex)) {
2037
- return -1;
2038
- }
2039
- return highlightedIndex;
2040
- }
2041
-
2042
2052
  function downshiftCommonReducer(state, props, action, stateChangeTypes) {
2043
2053
  var type = action.type;
2044
2054
  var changes;
@@ -2057,13 +2067,13 @@ function downshiftCommonReducer(state, props, action, stateChangeTypes) {
2057
2067
  case stateChangeTypes.FunctionToggleMenu:
2058
2068
  changes = {
2059
2069
  isOpen: !state.isOpen,
2060
- highlightedIndex: state.isOpen ? -1 : getHighlightedIndexOnOpen(props, state, 0)
2070
+ highlightedIndex: state.isOpen ? -1 : getHighlightedIndexOnOpen(props.items, props.initialHighlightedIndex, props.defaultHighlightedIndex, props.isItemDisabled, props.itemToKey, state.selectedItem, state.highlightedIndex, 0)
2061
2071
  };
2062
2072
  break;
2063
2073
  case stateChangeTypes.FunctionOpenMenu:
2064
2074
  changes = {
2065
2075
  isOpen: true,
2066
- highlightedIndex: getHighlightedIndexOnOpen(props, state, 0)
2076
+ highlightedIndex: getHighlightedIndexOnOpen(props.items, props.initialHighlightedIndex, props.defaultHighlightedIndex, props.isItemDisabled, props.itemToKey, state.selectedItem, state.highlightedIndex, 0)
2067
2077
  };
2068
2078
  break;
2069
2079
  case stateChangeTypes.FunctionCloseMenu:
@@ -2072,9 +2082,12 @@ function downshiftCommonReducer(state, props, action, stateChangeTypes) {
2072
2082
  };
2073
2083
  break;
2074
2084
  case stateChangeTypes.FunctionSetHighlightedIndex:
2075
- changes = {
2076
- highlightedIndex: props.isItemDisabled(props.items[action.highlightedIndex], action.highlightedIndex) ? -1 : action.highlightedIndex
2077
- };
2085
+ {
2086
+ var highlightedIndex = action.highlightedIndex;
2087
+ changes = {
2088
+ highlightedIndex: props.isItemDisabled(props.items[highlightedIndex], highlightedIndex) ? -1 : highlightedIndex
2089
+ };
2090
+ }
2078
2091
  break;
2079
2092
  case stateChangeTypes.FunctionSetInputValue:
2080
2093
  changes = {
@@ -2083,10 +2096,10 @@ function downshiftCommonReducer(state, props, action, stateChangeTypes) {
2083
2096
  break;
2084
2097
  case stateChangeTypes.FunctionReset:
2085
2098
  changes = {
2086
- highlightedIndex: getDefaultHighlightedIndex(props),
2087
- isOpen: getDefaultValue$1(props, 'isOpen', defaultStateValues$1),
2088
- selectedItem: getDefaultValue$1(props, 'selectedItem', defaultStateValues$1),
2089
- inputValue: getDefaultValue$1(props, 'inputValue', defaultStateValues$1)
2099
+ highlightedIndex: getDefaultHighlightedIndex(props.items, props.isItemDisabled, props.defaultHighlightedIndex),
2100
+ isOpen: getDefaultValue(props.defaultIsOpen, dropdownDefaultStateValues.isOpen),
2101
+ selectedItem: getDefaultValue(props.defaultSelectedItem, dropdownDefaultStateValues.selectedItem),
2102
+ inputValue: getDefaultValue(props.defaultInputValue, dropdownDefaultStateValues.inputValue)
2090
2103
  };
2091
2104
  break;
2092
2105
  default:
@@ -2096,17 +2109,11 @@ function downshiftCommonReducer(state, props, action, stateChangeTypes) {
2096
2109
  }
2097
2110
  /* eslint-enable complexity */
2098
2111
 
2099
- var propTypes$3 = _extends({}, propTypes$4, {
2112
+ var propTypes$3 = _extends({}, dropdownPropTypes, {
2100
2113
  items: PropTypes.array.isRequired,
2101
2114
  isItemDisabled: PropTypes.func
2102
2115
  });
2103
2116
 
2104
- var defaultProps$2 = _extends({}, defaultProps$3, {
2105
- isItemDisabled: function isItemDisabled() {
2106
- return false;
2107
- }
2108
- });
2109
-
2110
2117
  function getItemIndexByCharacterKey(_ref) {
2111
2118
  var keysSoFar = _ref.keysSoFar,
2112
2119
  highlightedIndex = _ref.highlightedIndex,
@@ -2175,16 +2182,15 @@ var stateChangeTypes$3 = /*#__PURE__*/Object.freeze({
2175
2182
  });
2176
2183
 
2177
2184
  /* eslint-disable complexity */
2178
- function downshiftSelectReducer(state, props, action) {
2179
- var _props$items;
2185
+ function downshiftSelectReducer(state, action) {
2180
2186
  var type = action.type,
2181
- altKey = action.altKey;
2187
+ props = action.props;
2182
2188
  var changes;
2183
2189
  switch (type) {
2184
2190
  case ItemClick$1:
2185
2191
  changes = {
2186
- isOpen: getDefaultValue$1(props, 'isOpen', defaultStateValues$1),
2187
- highlightedIndex: getDefaultHighlightedIndex(props),
2192
+ isOpen: getDefaultValue(props.defaultIsOpen, dropdownDefaultStateValues.isOpen),
2193
+ highlightedIndex: getDefaultHighlightedIndex(props.items, props.isItemDisabled, props.defaultHighlightedIndex),
2188
2194
  selectedItem: props.items[action.index]
2189
2195
  };
2190
2196
  break;
@@ -2211,7 +2217,8 @@ function downshiftSelectReducer(state, props, action) {
2211
2217
  break;
2212
2218
  case ToggleButtonKeyDownArrowDown:
2213
2219
  {
2214
- var _highlightedIndex = state.isOpen ? getHighlightedIndex(state.highlightedIndex, 1, props.items, props.isItemDisabled) : altKey && state.selectedItem == null ? -1 : getHighlightedIndexOnOpen(props, state, 1);
2220
+ var altKey = action.altKey;
2221
+ var _highlightedIndex = state.isOpen ? getHighlightedIndex(state.highlightedIndex, 1, props.items, props.isItemDisabled) : altKey && state.selectedItem == null ? -1 : getHighlightedIndexOnOpen(props.items, props.initialHighlightedIndex, props.defaultHighlightedIndex, props.isItemDisabled, props.itemToKey, state.selectedItem, state.highlightedIndex, 1);
2215
2222
  changes = {
2216
2223
  highlightedIndex: _highlightedIndex,
2217
2224
  isOpen: true
@@ -2219,20 +2226,23 @@ function downshiftSelectReducer(state, props, action) {
2219
2226
  }
2220
2227
  break;
2221
2228
  case ToggleButtonKeyDownArrowUp:
2222
- if (state.isOpen && altKey) {
2223
- changes = getChangesOnSelection(props, state.highlightedIndex, false);
2224
- } else {
2225
- var _highlightedIndex2 = state.isOpen ? getHighlightedIndex(state.highlightedIndex, -1, props.items, props.isItemDisabled) : getHighlightedIndexOnOpen(props, state, -1);
2226
- changes = {
2227
- highlightedIndex: _highlightedIndex2,
2228
- isOpen: true
2229
- };
2229
+ {
2230
+ var _altKey = action.altKey;
2231
+ if (state.isOpen && _altKey) {
2232
+ changes = getChangesOnSelection(props.items, props.itemToString, props.defaultIsOpen, props.defaultHighlightedIndex, state.highlightedIndex, false);
2233
+ } else {
2234
+ var _highlightedIndex2 = state.isOpen ? getHighlightedIndex(state.highlightedIndex, -1, props.items, props.isItemDisabled) : getHighlightedIndexOnOpen(props.items, props.initialHighlightedIndex, props.defaultHighlightedIndex, props.isItemDisabled, props.itemToKey, state.selectedItem, state.highlightedIndex, -1);
2235
+ changes = {
2236
+ highlightedIndex: _highlightedIndex2,
2237
+ isOpen: true
2238
+ };
2239
+ }
2230
2240
  }
2231
2241
  break;
2232
2242
  // only triggered when menu is open.
2233
2243
  case ToggleButtonKeyDownEnter:
2234
2244
  case ToggleButtonKeyDownSpaceButton:
2235
- changes = getChangesOnSelection(props, state.highlightedIndex, false);
2245
+ changes = getChangesOnSelection(props.items, props.itemToString, props.defaultIsOpen, props.defaultHighlightedIndex, state.highlightedIndex, false);
2236
2246
  break;
2237
2247
  case ToggleButtonKeyDownHome:
2238
2248
  changes = {
@@ -2266,7 +2276,7 @@ function downshiftSelectReducer(state, props, action) {
2266
2276
  changes = _extends({
2267
2277
  isOpen: false,
2268
2278
  highlightedIndex: -1
2269
- }, state.highlightedIndex >= 0 && ((_props$items = props.items) == null ? void 0 : _props$items.length) && {
2279
+ }, state.highlightedIndex >= 0 && props.items.length && {
2270
2280
  selectedItem: props.items[state.highlightedIndex]
2271
2281
  });
2272
2282
  break;
@@ -2282,60 +2292,9 @@ function downshiftSelectReducer(state, props, action) {
2282
2292
  }
2283
2293
  /* eslint-enable complexity */
2284
2294
 
2285
- // https://github.com/downshift-js/downshift/issues/1674#issuecomment-3924320872
2286
- var SafeReact$1 = _extends({}, React__namespace);
2287
- var reactUseId$1 = SafeReact$1.useId;
2288
- var useElementIds$1 = typeof reactUseId$1 === 'function' ? useElementIdsR18$1 : useElementIdsLegacy$1;
2289
- function useElementIdsR18$1(_ref) {
2290
- var id = _ref.id,
2291
- labelId = _ref.labelId,
2292
- menuId = _ref.menuId,
2293
- getItemId = _ref.getItemId,
2294
- toggleButtonId = _ref.toggleButtonId,
2295
- inputId = _ref.inputId;
2296
- var reactId = "downshift-" + reactUseId$1();
2297
- if (!id) {
2298
- id = reactId;
2299
- }
2300
- var elementIds = React__namespace.useMemo(function () {
2301
- return {
2302
- labelId: labelId != null ? labelId : id + "-label",
2303
- menuId: menuId != null ? menuId : id + "-menu",
2304
- getItemId: getItemId != null ? getItemId : function (index) {
2305
- return id + "-item-" + index;
2306
- },
2307
- toggleButtonId: toggleButtonId != null ? toggleButtonId : id + "-toggle-button",
2308
- inputId: inputId != null ? inputId : id + "-input"
2309
- };
2310
- }, [getItemId, id, inputId, labelId, menuId, toggleButtonId]);
2311
- return elementIds;
2312
- }
2313
- function useElementIdsLegacy$1(_ref2) {
2314
- var id = _ref2.id,
2315
- labelId = _ref2.labelId,
2316
- menuId = _ref2.menuId,
2317
- getItemId = _ref2.getItemId,
2318
- toggleButtonId = _ref2.toggleButtonId,
2319
- inputId = _ref2.inputId;
2320
- var baseIdRef = React__namespace.useRef(id != null ? id : "downshift-" + generateId());
2321
- var baseId = baseIdRef.current;
2322
- var elementIds = React__namespace.useMemo(function () {
2323
- return {
2324
- labelId: labelId != null ? labelId : baseId + "-label",
2325
- menuId: menuId != null ? menuId : baseId + "-menu",
2326
- getItemId: getItemId != null ? getItemId : function (index) {
2327
- return baseId + "-item-" + index;
2328
- },
2329
- toggleButtonId: toggleButtonId != null ? toggleButtonId : baseId + "-toggle-button",
2330
- inputId: inputId != null ? inputId : baseId + "-input"
2331
- };
2332
- }, [getItemId, inputId, labelId, menuId, toggleButtonId, baseId]);
2333
- return elementIds;
2334
- }
2335
-
2336
2295
  var _excluded$3 = ["onClick"],
2337
- _excluded2$3 = ["onMouseLeave", "refKey", "ref"],
2338
- _excluded3$2 = ["onBlur", "onClick", "onPress", "onKeyDown", "refKey", "ref"],
2296
+ _excluded2$3 = ["onMouseLeave", "refKey", "ref", "aria-label"],
2297
+ _excluded3$2 = ["onBlur", "onClick", "onPress", "onKeyDown", "refKey", "ref", "disabled"],
2339
2298
  _excluded4$1 = ["item", "index", "onMouseMove", "onClick", "onMouseDown", "onPress", "refKey", "disabled", "ref"];
2340
2299
  useSelect.stateChangeTypes = stateChangeTypes$3;
2341
2300
  function useSelect(userProps) {
@@ -2344,22 +2303,23 @@ function useSelect(userProps) {
2344
2303
  }
2345
2304
  validatePropTypes$1(userProps, useSelect, propTypes$3);
2346
2305
  // Props defaults and destructuring.
2347
- var props = _extends({}, defaultProps$2, userProps);
2306
+ var props = _extends({}, dropdownDefaultProps, userProps);
2348
2307
  var scrollIntoView = props.scrollIntoView,
2349
2308
  environment = props.environment,
2350
2309
  getA11yStatusMessage = props.getA11yStatusMessage;
2351
2310
  // Initial state depending on controlled props.
2352
- var _useControlledReducer = useControlledReducer$1(downshiftSelectReducer, props, getInitialState$3, isDropdownsStateEqual),
2311
+ var _useControlledReducer = useControlledReducer$1(downshiftSelectReducer, props, getInitialState$3, isDropdownStateEqual),
2353
2312
  state = _useControlledReducer[0],
2354
2313
  dispatch = _useControlledReducer[1];
2355
2314
  var isOpen = state.isOpen,
2356
2315
  highlightedIndex = state.highlightedIndex,
2357
2316
  selectedItem = state.selectedItem,
2358
2317
  inputValue = state.inputValue;
2359
- // Element efs.
2318
+
2319
+ // Element refs.
2360
2320
  var toggleButtonRef = React.useRef(null);
2361
2321
  var menuRef = React.useRef(null);
2362
- var itemRefs = React.useRef({});
2322
+ var itemsRef = React.useRef({});
2363
2323
 
2364
2324
  // used to keep the inputValue clearTimeout object between renders.
2365
2325
  var clearTimeoutRef = React.useRef(null);
@@ -2371,24 +2331,12 @@ function useSelect(userProps) {
2371
2331
  props: props
2372
2332
  });
2373
2333
 
2374
- // Some utils.
2375
- var getItemNodeFromIndex = React.useCallback(function (index) {
2376
- return itemRefs.current[elementIds.getItemId(index)];
2377
- }, [elementIds]);
2378
-
2379
2334
  // Effects.
2380
2335
  // Adds an a11y aria live status message if getA11yStatusMessage is passed.
2381
2336
  useA11yMessageStatus(getA11yStatusMessage, state, [isOpen, highlightedIndex, selectedItem, inputValue], environment);
2382
2337
  // Scroll on highlighted item if change comes from keyboard.
2383
- var shouldScrollRef = useScrollIntoView({
2384
- menuElement: menuRef.current,
2385
- highlightedIndex: highlightedIndex,
2386
- isOpen: isOpen,
2387
- itemRefs: itemRefs,
2388
- scrollIntoView: scrollIntoView,
2389
- getItemNodeFromIndex: getItemNodeFromIndex
2390
- });
2391
- // Sets cleanup for the keysSoFar callback, debounded after 500ms.
2338
+ var preventScroll = useScrollIntoView(scrollIntoView, highlightedIndex, isOpen, menuRef.current, itemsRef.current, elementIds.getItemId);
2339
+ // Sets cleanup for the keysSoFar callback, debounced after 500ms.
2392
2340
  React.useEffect(function () {
2393
2341
  // init the clean function here as we need access to dispatch.
2394
2342
  clearTimeoutRef.current = debounce(function (outerDispatch) {
@@ -2400,7 +2348,8 @@ function useSelect(userProps) {
2400
2348
 
2401
2349
  // Cancel any pending debounced calls on mount
2402
2350
  return function () {
2403
- clearTimeoutRef.current.cancel();
2351
+ var _clearTimeoutRef$curr;
2352
+ (_clearTimeoutRef$curr = clearTimeoutRef.current) == null || _clearTimeoutRef$curr.cancel();
2404
2353
  };
2405
2354
  }, []);
2406
2355
  // Invokes the keysSoFar callback set up above.
@@ -2408,7 +2357,7 @@ function useSelect(userProps) {
2408
2357
  if (!inputValue) {
2409
2358
  return;
2410
2359
  }
2411
- clearTimeoutRef.current(dispatch);
2360
+ clearTimeoutRef.current == null || clearTimeoutRef.current(dispatch);
2412
2361
  }, [dispatch, inputValue]);
2413
2362
  useControlPropsValidator({
2414
2363
  props: props,
@@ -2416,7 +2365,7 @@ function useSelect(userProps) {
2416
2365
  });
2417
2366
  // Focus the toggle button on first render if required.
2418
2367
  React.useEffect(function () {
2419
- var focusOnOpen = getInitialValue$1(props, 'isOpen', defaultStateValues$1);
2368
+ var focusOnOpen = getInitialValue(props.isOpen, props.initialIsOpen, props.defaultIsOpen, dropdownDefaultStateValues.isOpen);
2420
2369
  if (focusOnOpen && toggleButtonRef.current) {
2421
2370
  toggleButtonRef.current.focus();
2422
2371
  }
@@ -2437,7 +2386,7 @@ function useSelect(userProps) {
2437
2386
  // Reset itemRefs on close.
2438
2387
  React.useEffect(function () {
2439
2388
  if (!isOpen) {
2440
- itemRefs.current = {};
2389
+ itemsRef.current = {};
2441
2390
  }
2442
2391
  }, [isOpen]);
2443
2392
 
@@ -2522,50 +2471,11 @@ function useSelect(userProps) {
2522
2471
  };
2523
2472
  }, [dispatch, latest]);
2524
2473
 
2525
- // Action functions.
2526
- var toggleMenu = React.useCallback(function () {
2527
- dispatch({
2528
- type: FunctionToggleMenu$1
2529
- });
2530
- }, [dispatch]);
2531
- var closeMenu = React.useCallback(function () {
2532
- dispatch({
2533
- type: FunctionCloseMenu$1
2534
- });
2535
- }, [dispatch]);
2536
- var openMenu = React.useCallback(function () {
2537
- dispatch({
2538
- type: FunctionOpenMenu$1
2539
- });
2540
- }, [dispatch]);
2541
- var setHighlightedIndex = React.useCallback(function (newHighlightedIndex) {
2542
- dispatch({
2543
- type: FunctionSetHighlightedIndex$1,
2544
- highlightedIndex: newHighlightedIndex
2545
- });
2546
- }, [dispatch]);
2547
- var selectItem = React.useCallback(function (newSelectedItem) {
2548
- dispatch({
2549
- type: FunctionSelectItem$1,
2550
- selectedItem: newSelectedItem
2551
- });
2552
- }, [dispatch]);
2553
- var reset = React.useCallback(function () {
2554
- dispatch({
2555
- type: FunctionReset$2
2556
- });
2557
- }, [dispatch]);
2558
- var setInputValue = React.useCallback(function (newInputValue) {
2559
- dispatch({
2560
- type: FunctionSetInputValue$1,
2561
- inputValue: newInputValue
2562
- });
2563
- }, [dispatch]);
2564
2474
  // Getter functions.
2565
- var getLabelProps = React.useCallback(function (_temp) {
2566
- var _ref = _temp === void 0 ? {} : _temp,
2475
+ var getLabelProps = React.useCallback(function (labelProps) {
2476
+ var _ref = labelProps != null ? labelProps : {},
2567
2477
  onClick = _ref.onClick,
2568
- labelProps = _objectWithoutPropertiesLoose(_ref, _excluded$3);
2478
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$3);
2569
2479
  var labelHandleClick = function labelHandleClick() {
2570
2480
  var _toggleButtonRef$curr;
2571
2481
  (_toggleButtonRef$curr = toggleButtonRef.current) == null || _toggleButtonRef$curr.focus();
@@ -2574,17 +2484,18 @@ function useSelect(userProps) {
2574
2484
  id: elementIds.labelId,
2575
2485
  htmlFor: elementIds.toggleButtonId,
2576
2486
  onClick: callAllEventHandlers(onClick, labelHandleClick)
2577
- }, labelProps);
2487
+ }, rest);
2578
2488
  }, [elementIds]);
2579
- var getMenuProps = React.useCallback(function (_temp2, _temp3) {
2489
+ var getMenuProps = React.useCallback(function (menuProps, otherProps) {
2580
2490
  var _extends2;
2581
- var _ref2 = _temp2 === void 0 ? {} : _temp2,
2491
+ var _ref2 = menuProps != null ? menuProps : {},
2582
2492
  onMouseLeave = _ref2.onMouseLeave,
2583
2493
  _ref2$refKey = _ref2.refKey,
2584
2494
  refKey = _ref2$refKey === void 0 ? 'ref' : _ref2$refKey,
2585
2495
  ref = _ref2.ref,
2496
+ ariaLabel = _ref2['aria-label'],
2586
2497
  rest = _objectWithoutPropertiesLoose(_ref2, _excluded2$3);
2587
- var _ref3 = _temp3 === void 0 ? {} : _temp3,
2498
+ var _ref3 = otherProps != null ? otherProps : {},
2588
2499
  _ref3$suppressRefErro = _ref3.suppressRefError,
2589
2500
  suppressRefError = _ref3$suppressRefErro === void 0 ? false : _ref3$suppressRefErro;
2590
2501
  var menuHandleMouseLeave = function menuHandleMouseLeave() {
@@ -2595,11 +2506,11 @@ function useSelect(userProps) {
2595
2506
  setGetterPropCallInfo('getMenuProps', suppressRefError, refKey, menuRef);
2596
2507
  return _extends((_extends2 = {}, _extends2[refKey] = handleRefs(ref, function (menuNode) {
2597
2508
  menuRef.current = menuNode;
2598
- }), _extends2.id = elementIds.menuId, _extends2.role = 'listbox', _extends2['aria-labelledby'] = rest && rest['aria-label'] ? undefined : "" + elementIds.labelId, _extends2.onMouseLeave = callAllEventHandlers(onMouseLeave, menuHandleMouseLeave), _extends2), rest);
2509
+ }), _extends2.id = elementIds.menuId, _extends2.role = 'listbox', _extends2['aria-label'] = ariaLabel, _extends2['aria-labelledby'] = ariaLabel ? undefined : "" + elementIds.labelId, _extends2.onMouseLeave = callAllEventHandlers(onMouseLeave, menuHandleMouseLeave), _extends2), rest);
2599
2510
  }, [dispatch, setGetterPropCallInfo, elementIds]);
2600
- var getToggleButtonProps = React.useCallback(function (_temp4, _temp5) {
2511
+ var getToggleButtonProps = React.useCallback(function (toggleButtonProps, otherProps) {
2601
2512
  var _extends3;
2602
- var _ref4 = _temp4 === void 0 ? {} : _temp4,
2513
+ var _ref4 = toggleButtonProps != null ? toggleButtonProps : {},
2603
2514
  onBlur = _ref4.onBlur;
2604
2515
  _ref4.onClick;
2605
2516
  var onPress = _ref4.onPress;
@@ -2607,8 +2518,9 @@ function useSelect(userProps) {
2607
2518
  var _ref4$refKey = _ref4.refKey,
2608
2519
  refKey = _ref4$refKey === void 0 ? 'ref' : _ref4$refKey,
2609
2520
  ref = _ref4.ref,
2521
+ disabled = _ref4.disabled,
2610
2522
  rest = _objectWithoutPropertiesLoose(_ref4, _excluded3$2);
2611
- var _ref5 = _temp5 === void 0 ? {} : _temp5,
2523
+ var _ref5 = otherProps != null ? otherProps : {},
2612
2524
  _ref5$suppressRefErro = _ref5.suppressRefError,
2613
2525
  suppressRefError = _ref5$suppressRefErro === void 0 ? false : _ref5$suppressRefErro;
2614
2526
  var latestState = latest.current.state;
@@ -2626,19 +2538,21 @@ function useSelect(userProps) {
2626
2538
  };
2627
2539
  var toggleProps = _extends((_extends3 = {}, _extends3[refKey] = handleRefs(ref, function (toggleButtonNode) {
2628
2540
  toggleButtonRef.current = toggleButtonNode;
2629
- }), _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'] = rest && rest['aria-label'] ? undefined : "" + elementIds.labelId, _extends3.id = elementIds.toggleButtonId, _extends3.role = 'combobox', _extends3.tabIndex = 0, _extends3.onBlur = callAllEventHandlers(onBlur, toggleButtonHandleBlur), _extends3), rest);
2630
- if (!rest.disabled) {
2541
+ }), _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'] = rest['aria-label'] ? undefined : "" + elementIds.labelId, _extends3.id = elementIds.toggleButtonId, _extends3.role = 'combobox', _extends3.tabIndex = 0, _extends3.onBlur = callAllEventHandlers(onBlur, toggleButtonHandleBlur), _extends3.disabled = disabled, _extends3), rest);
2542
+ if (!disabled) {
2631
2543
  /* istanbul ignore if (react-native) */
2632
2544
  {
2633
- toggleProps.onPress = callAllEventHandlers(onPress, toggleButtonHandleClick);
2545
+ Object.assign(toggleProps, {
2546
+ onPress: callAllEventHandlers(onPress, toggleButtonHandleClick)
2547
+ });
2634
2548
  }
2635
2549
  }
2636
2550
  setGetterPropCallInfo('getToggleButtonProps', suppressRefError, refKey, toggleButtonRef);
2637
2551
  return toggleProps;
2638
2552
  }, [dispatch, elementIds, latest, mouseAndTouchTrackers, setGetterPropCallInfo, toggleButtonKeyDownHandlers]);
2639
- var getItemProps = React.useCallback(function (_temp6) {
2553
+ var getItemProps = React.useCallback(function (itemProps) {
2640
2554
  var _extends4;
2641
- var _ref6 = _temp6 === void 0 ? {} : _temp6,
2555
+ var _ref6 = itemProps != null ? itemProps : {},
2642
2556
  itemProp = _ref6.item,
2643
2557
  indexProp = _ref6.index,
2644
2558
  onMouseMove = _ref6.onMouseMove;
@@ -2664,7 +2578,7 @@ function useSelect(userProps) {
2664
2578
  if (mouseAndTouchTrackers.isTouchEnd || index === latestState.highlightedIndex) {
2665
2579
  return;
2666
2580
  }
2667
- shouldScrollRef.current = false;
2581
+ preventScroll();
2668
2582
  dispatch({
2669
2583
  type: ItemMouseMove$1,
2670
2584
  index: index,
@@ -2681,21 +2595,61 @@ function useSelect(userProps) {
2681
2595
  return e.preventDefault();
2682
2596
  }; // keep focus on the toggle after item click select.
2683
2597
 
2684
- var itemProps = _extends((_extends4 = {}, _extends4[refKey] = handleRefs(ref, function (itemNode) {
2598
+ var resultItemProps = _extends((_extends4 = {}, _extends4[refKey] = handleRefs(ref, function (itemNode) {
2685
2599
  if (itemNode) {
2686
- itemRefs.current[elementIds.getItemId(index)] = itemNode;
2600
+ itemsRef.current[elementIds.getItemId(index)] = itemNode;
2687
2601
  }
2688
- }), _extends4['aria-disabled'] = disabled, _extends4['aria-selected'] = item === latestState.selectedItem, _extends4.id = elementIds.getItemId(index), _extends4.role = 'option', _extends4), rest);
2602
+ }), _extends4['aria-disabled'] = disabled, _extends4['aria-selected'] = item === latestState.selectedItem, _extends4.id = elementIds.getItemId(index), _extends4.role = 'option', _extends4.onMouseMove = callAllEventHandlers(onMouseMove, itemHandleMouseMove), _extends4.onMouseDown = callAllEventHandlers(onMouseDown, itemHandleMouseDown), _extends4), rest);
2689
2603
  if (!disabled) {
2690
2604
  /* istanbul ignore next (react-native) */
2691
2605
  {
2692
- itemProps.onPress = callAllEventHandlers(onPress, itemHandleClick);
2606
+ Object.assign(resultItemProps, {
2607
+ onPress: callAllEventHandlers(onPress, itemHandleClick)
2608
+ });
2693
2609
  }
2694
2610
  }
2695
- itemProps.onMouseMove = callAllEventHandlers(onMouseMove, itemHandleMouseMove);
2696
- itemProps.onMouseDown = callAllEventHandlers(onMouseDown, itemHandleMouseDown);
2697
- return itemProps;
2698
- }, [latest, elementIds, mouseAndTouchTrackers, shouldScrollRef, dispatch]);
2611
+ return resultItemProps;
2612
+ }, [latest, elementIds, mouseAndTouchTrackers, preventScroll, dispatch]);
2613
+
2614
+ // Action functions.
2615
+ var toggleMenu = React.useCallback(function () {
2616
+ dispatch({
2617
+ type: FunctionToggleMenu$1
2618
+ });
2619
+ }, [dispatch]);
2620
+ var closeMenu = React.useCallback(function () {
2621
+ dispatch({
2622
+ type: FunctionCloseMenu$1
2623
+ });
2624
+ }, [dispatch]);
2625
+ var openMenu = React.useCallback(function () {
2626
+ dispatch({
2627
+ type: FunctionOpenMenu$1
2628
+ });
2629
+ }, [dispatch]);
2630
+ var setHighlightedIndex = React.useCallback(function (newHighlightedIndex) {
2631
+ dispatch({
2632
+ type: FunctionSetHighlightedIndex$1,
2633
+ highlightedIndex: newHighlightedIndex
2634
+ });
2635
+ }, [dispatch]);
2636
+ var selectItem = React.useCallback(function (newSelectedItem) {
2637
+ dispatch({
2638
+ type: FunctionSelectItem$1,
2639
+ selectedItem: newSelectedItem
2640
+ });
2641
+ }, [dispatch]);
2642
+ var reset = React.useCallback(function () {
2643
+ dispatch({
2644
+ type: FunctionReset$2
2645
+ });
2646
+ }, [dispatch]);
2647
+ var setInputValue = React.useCallback(function (newInputValue) {
2648
+ dispatch({
2649
+ type: FunctionSetInputValue$1,
2650
+ inputValue: newInputValue
2651
+ });
2652
+ }, [dispatch]);
2699
2653
  return {
2700
2654
  // prop getters.
2701
2655
  getToggleButtonProps: getToggleButtonProps,
@@ -2718,6 +2672,18 @@ function useSelect(userProps) {
2718
2672
  };
2719
2673
  }
2720
2674
 
2675
+ function getInitialState$2(props) {
2676
+ var initialState = getInitialState$3(props);
2677
+ var selectedItem = initialState.selectedItem;
2678
+ var inputValue = initialState.inputValue;
2679
+ if (inputValue === '' && selectedItem && props.defaultInputValue === undefined && props.initialInputValue === undefined && props.inputValue === undefined) {
2680
+ inputValue = props.itemToString(selectedItem);
2681
+ }
2682
+ return _extends({}, initialState, {
2683
+ inputValue: inputValue
2684
+ });
2685
+ }
2686
+
2721
2687
  var InputKeyDownArrowDown = process.env.NODE_ENV !== "production" ? '__input_keydown_arrow_down__' : 0;
2722
2688
  var InputKeyDownArrowUp = process.env.NODE_ENV !== "production" ? '__input_keydown_arrow_up__' : 1;
2723
2689
  var InputKeyDownEscape = process.env.NODE_ENV !== "production" ? '__input_keydown_escape__' : 2;
@@ -2769,27 +2735,6 @@ var stateChangeTypes$2 = /*#__PURE__*/Object.freeze({
2769
2735
  ToggleButtonClick: ToggleButtonClick
2770
2736
  });
2771
2737
 
2772
- function getInitialState$2(props) {
2773
- var initialState = getInitialState$3(props);
2774
- var selectedItem = initialState.selectedItem;
2775
- var inputValue = initialState.inputValue;
2776
- if (inputValue === '' && selectedItem && props.defaultInputValue === undefined && props.initialInputValue === undefined && props.inputValue === undefined) {
2777
- inputValue = props.itemToString(selectedItem);
2778
- }
2779
- return _extends({}, initialState, {
2780
- inputValue: inputValue
2781
- });
2782
- }
2783
- var propTypes$2 = _extends({}, propTypes$4, {
2784
- items: PropTypes.array.isRequired,
2785
- isItemDisabled: PropTypes.func,
2786
- inputValue: PropTypes.string,
2787
- defaultInputValue: PropTypes.string,
2788
- initialInputValue: PropTypes.string,
2789
- inputId: PropTypes.string,
2790
- onInputValueChange: PropTypes.func
2791
- });
2792
-
2793
2738
  /**
2794
2739
  * The useCombobox version of useControlledReducer, which also
2795
2740
  * checks if the controlled prop selectedItem changed between
@@ -2797,20 +2742,20 @@ var propTypes$2 = _extends({}, propTypes$4, {
2797
2742
  * string equivalent. It uses the common useEnhancedReducer to
2798
2743
  * compute the rest of the state.
2799
2744
  *
2800
- * @param {Function} reducer Reducer function from downshift.
2801
- * @param {Object} props The hook props, also passed to createInitialState.
2802
- * @param {Function} createInitialState Function that returns the initial state.
2803
- * @param {Function} isStateEqual Function that checks if a previous state is equal to the next.
2804
- * @returns {Array} An array with the state and an action dispatcher.
2745
+ * @param reducer Reducer function from downshift.
2746
+ * @param props The hook props, also passed to createInitialState.
2747
+ * @param createInitialState Function that returns the initial state.
2748
+ * @param isStateEqual Function that checks if a previous state is equal to the next.
2749
+ * @returns An array with the state and an action dispatcher.
2805
2750
  */
2806
2751
  function useControlledReducer(reducer, props, createInitialState, isStateEqual) {
2807
- var previousSelectedItemRef = React.useRef();
2752
+ var previousSelectedItemRef = React.useRef(null);
2808
2753
  var _useEnhancedReducer = useEnhancedReducer(reducer, props, createInitialState, isStateEqual),
2809
2754
  state = _useEnhancedReducer[0],
2810
2755
  dispatch = _useEnhancedReducer[1];
2811
2756
  var isInitialMount = useIsInitialMount();
2812
2757
  React.useEffect(function () {
2813
- if (!isControlledProp(props, 'selectedItem')) {
2758
+ if (props.selectedItem === undefined) {
2814
2759
  return;
2815
2760
  }
2816
2761
  if (!isInitialMount // on first mount we already have the proper inputValue for a initial selected item.
@@ -2828,23 +2773,27 @@ function useControlledReducer(reducer, props, createInitialState, isStateEqual)
2828
2773
  }, [state.selectedItem, props.selectedItem]);
2829
2774
  return [getState(state, props), dispatch];
2830
2775
  }
2831
- var defaultProps$1 = _extends({}, defaultProps$3, {
2832
- isItemDisabled: function isItemDisabled() {
2833
- return false;
2834
- }
2776
+
2777
+ var propTypes$2 = _extends({}, dropdownPropTypes, {
2778
+ items: PropTypes.array.isRequired,
2779
+ isItemDisabled: PropTypes.func,
2780
+ inputValue: PropTypes.string,
2781
+ defaultInputValue: PropTypes.string,
2782
+ initialInputValue: PropTypes.string,
2783
+ inputId: PropTypes.string,
2784
+ onInputValueChange: PropTypes.func
2835
2785
  });
2836
2786
 
2837
2787
  /* eslint-disable complexity */
2838
- function downshiftUseComboboxReducer(state, props, action) {
2839
- var _props$items;
2788
+ function downshiftUseComboboxReducer(state, action) {
2840
2789
  var type = action.type,
2841
- altKey = action.altKey;
2790
+ props = action.props;
2842
2791
  var changes;
2843
2792
  switch (type) {
2844
2793
  case ItemClick:
2845
2794
  changes = {
2846
- isOpen: getDefaultValue$1(props, 'isOpen', defaultStateValues$1),
2847
- highlightedIndex: getDefaultHighlightedIndex(props),
2795
+ isOpen: getDefaultValue(props.defaultIsOpen, dropdownDefaultStateValues.isOpen),
2796
+ highlightedIndex: getDefaultHighlightedIndex(props.items, props.isItemDisabled, props.defaultHighlightedIndex),
2848
2797
  selectedItem: props.items[action.index],
2849
2798
  inputValue: props.itemToString(props.items[action.index])
2850
2799
  };
@@ -2856,15 +2805,15 @@ function downshiftUseComboboxReducer(state, props, action) {
2856
2805
  };
2857
2806
  } else {
2858
2807
  changes = {
2859
- highlightedIndex: altKey && state.selectedItem == null ? -1 : getHighlightedIndexOnOpen(props, state, 1),
2808
+ highlightedIndex: action.altKey && state.selectedItem == null ? -1 : getHighlightedIndexOnOpen(props.items, props.initialHighlightedIndex, props.defaultHighlightedIndex, props.isItemDisabled, props.itemToKey, state.selectedItem, state.highlightedIndex, 1),
2860
2809
  isOpen: props.items.length >= 0
2861
2810
  };
2862
2811
  }
2863
2812
  break;
2864
2813
  case InputKeyDownArrowUp:
2865
2814
  if (state.isOpen) {
2866
- if (altKey) {
2867
- changes = getChangesOnSelection(props, state.highlightedIndex);
2815
+ if (action.altKey) {
2816
+ changes = getChangesOnSelection(props.items, props.itemToString, props.defaultIsOpen, props.defaultHighlightedIndex, state.highlightedIndex, true);
2868
2817
  } else {
2869
2818
  changes = {
2870
2819
  highlightedIndex: getHighlightedIndex(state.highlightedIndex, -1, props.items, props.isItemDisabled, true)
@@ -2872,13 +2821,13 @@ function downshiftUseComboboxReducer(state, props, action) {
2872
2821
  }
2873
2822
  } else {
2874
2823
  changes = {
2875
- highlightedIndex: getHighlightedIndexOnOpen(props, state, -1),
2824
+ highlightedIndex: getHighlightedIndexOnOpen(props.items, props.initialHighlightedIndex, props.defaultHighlightedIndex, props.isItemDisabled, props.itemToKey, state.selectedItem, state.highlightedIndex, -1),
2876
2825
  isOpen: props.items.length >= 0
2877
2826
  };
2878
2827
  }
2879
2828
  break;
2880
2829
  case InputKeyDownEnter:
2881
- changes = getChangesOnSelection(props, state.highlightedIndex);
2830
+ changes = getChangesOnSelection(props.items, props.itemToString, props.defaultIsOpen, props.defaultHighlightedIndex, state.highlightedIndex, true);
2882
2831
  break;
2883
2832
  case InputKeyDownEscape:
2884
2833
  changes = _extends({
@@ -2913,7 +2862,7 @@ function downshiftUseComboboxReducer(state, props, action) {
2913
2862
  changes = _extends({
2914
2863
  isOpen: false,
2915
2864
  highlightedIndex: -1
2916
- }, state.highlightedIndex >= 0 && ((_props$items = props.items) == null ? void 0 : _props$items.length) && action.selectItem && {
2865
+ }, state.highlightedIndex >= 0 && props.items.length && action.selectItem && {
2917
2866
  selectedItem: props.items[state.highlightedIndex],
2918
2867
  inputValue: props.itemToString(props.items[state.highlightedIndex])
2919
2868
  });
@@ -2921,14 +2870,14 @@ function downshiftUseComboboxReducer(state, props, action) {
2921
2870
  case InputChange:
2922
2871
  changes = {
2923
2872
  isOpen: true,
2924
- highlightedIndex: getDefaultHighlightedIndex(props),
2873
+ highlightedIndex: getDefaultHighlightedIndex(props.items, props.isItemDisabled, props.defaultHighlightedIndex),
2925
2874
  inputValue: action.inputValue
2926
2875
  };
2927
2876
  break;
2928
2877
  case InputClick:
2929
2878
  changes = {
2930
2879
  isOpen: !state.isOpen,
2931
- highlightedIndex: state.isOpen ? -1 : getHighlightedIndexOnOpen(props, state, 0)
2880
+ highlightedIndex: state.isOpen ? -1 : getHighlightedIndexOnOpen(props.items, props.initialHighlightedIndex, props.defaultHighlightedIndex, props.isItemDisabled, props.itemToKey, state.selectedItem, state.highlightedIndex, 0)
2932
2881
  };
2933
2882
  break;
2934
2883
  case FunctionSelectItem:
@@ -2949,10 +2898,10 @@ function downshiftUseComboboxReducer(state, props, action) {
2949
2898
  }
2950
2899
  /* eslint-enable complexity */
2951
2900
 
2952
- var _excluded$2 = ["onMouseLeave", "refKey", "ref"],
2901
+ var _excluded$2 = ["onMouseLeave", "refKey", "ref", "aria-label"],
2953
2902
  _excluded2$2 = ["item", "index", "refKey", "ref", "onMouseMove", "onMouseDown", "onClick", "onPress", "disabled"],
2954
- _excluded3$1 = ["onClick", "onPress", "refKey", "ref"],
2955
- _excluded4 = ["onKeyDown", "onChange", "onInput", "onBlur", "onChangeText", "onClick", "refKey", "ref"];
2903
+ _excluded3$1 = ["onClick", "onPress", "refKey", "ref", "disabled"],
2904
+ _excluded4 = ["aria-label", "disabled", "onKeyDown", "onChange", "onInput", "onBlur", "onChangeText", "onClick", "refKey", "ref"];
2956
2905
  useCombobox.stateChangeTypes = stateChangeTypes$2;
2957
2906
  function useCombobox(userProps) {
2958
2907
  if (userProps === void 0) {
@@ -2960,13 +2909,13 @@ function useCombobox(userProps) {
2960
2909
  }
2961
2910
  validatePropTypes$1(userProps, useCombobox, propTypes$2);
2962
2911
  // Props defaults and destructuring.
2963
- var props = _extends({}, defaultProps$1, userProps);
2912
+ var props = _extends({}, dropdownDefaultProps, userProps);
2964
2913
  var items = props.items,
2965
2914
  scrollIntoView = props.scrollIntoView,
2966
2915
  environment = props.environment,
2967
2916
  getA11yStatusMessage = props.getA11yStatusMessage;
2968
2917
  // Initial state depending on controlled props.
2969
- var _useControlledReducer = useControlledReducer(downshiftUseComboboxReducer, props, getInitialState$2, isDropdownsStateEqual),
2918
+ var _useControlledReducer = useControlledReducer(downshiftUseComboboxReducer, props, getInitialState$2, isDropdownStateEqual),
2970
2919
  state = _useControlledReducer[0],
2971
2920
  dispatch = _useControlledReducer[1];
2972
2921
  var isOpen = state.isOpen,
@@ -2976,7 +2925,7 @@ function useCombobox(userProps) {
2976
2925
 
2977
2926
  // Element refs.
2978
2927
  var menuRef = React.useRef(null);
2979
- var itemRefs = React.useRef({});
2928
+ var itemsRef = React.useRef({});
2980
2929
  var inputRef = React.useRef(null);
2981
2930
  var toggleButtonRef = React.useRef(null);
2982
2931
  var isInitialMount = useIsInitialMount();
@@ -2990,29 +2939,19 @@ function useCombobox(userProps) {
2990
2939
  state: state,
2991
2940
  props: props
2992
2941
  });
2993
- var getItemNodeFromIndex = React.useCallback(function (index) {
2994
- return itemRefs.current[elementIds.getItemId(index)];
2995
- }, [elementIds]);
2996
2942
 
2997
2943
  // Effects.
2998
2944
  // Adds an a11y aria live status message if getA11yStatusMessage is passed.
2999
2945
  useA11yMessageStatus(getA11yStatusMessage, state, [isOpen, highlightedIndex, selectedItem, inputValue], environment);
3000
2946
  // Scroll on highlighted item if change comes from keyboard.
3001
- var shouldScrollRef = useScrollIntoView({
3002
- menuElement: menuRef.current,
3003
- highlightedIndex: highlightedIndex,
3004
- isOpen: isOpen,
3005
- itemRefs: itemRefs,
3006
- scrollIntoView: scrollIntoView,
3007
- getItemNodeFromIndex: getItemNodeFromIndex
3008
- });
2947
+ var preventScroll = useScrollIntoView(scrollIntoView, highlightedIndex, isOpen, menuRef.current, itemsRef.current, elementIds.getItemId);
3009
2948
  useControlPropsValidator({
3010
- props: props,
3011
- state: state
2949
+ state: state,
2950
+ props: props
3012
2951
  });
3013
2952
  // Focus the input on first render if required.
3014
2953
  React.useEffect(function () {
3015
- var focusOnOpen = getInitialValue$1(props, 'isOpen', defaultStateValues$1);
2954
+ var focusOnOpen = getInitialValue(props.isOpen, props.initialIsOpen, props.defaultIsOpen, dropdownDefaultStateValues.isOpen);
3016
2955
  if (focusOnOpen && inputRef.current) {
3017
2956
  inputRef.current.focus();
3018
2957
  }
@@ -3038,13 +2977,13 @@ function useCombobox(userProps) {
3038
2977
  // Reset itemRefs on close.
3039
2978
  React.useEffect(function () {
3040
2979
  if (!isOpen) {
3041
- itemRefs.current = {};
2980
+ itemsRef.current = {};
3042
2981
  }
3043
2982
  }, [isOpen]);
3044
2983
  // Reset itemRefs on close.
3045
2984
  React.useEffect(function () {
3046
2985
  var _inputRef$current;
3047
- if (!isOpen || !(environment != null && environment.document) || !(inputRef != null && (_inputRef$current = inputRef.current) != null && _inputRef$current.focus)) {
2986
+ if (!isOpen || !(environment != null && environment.document) || !((_inputRef$current = inputRef.current) != null && _inputRef$current.focus)) {
3048
2987
  return;
3049
2988
  }
3050
2989
  if (environment.document.activeElement !== inputRef.current) {
@@ -3134,29 +3073,30 @@ function useCombobox(userProps) {
3134
3073
  htmlFor: elementIds.inputId
3135
3074
  }, labelProps);
3136
3075
  }, [elementIds]);
3137
- var getMenuProps = React.useCallback(function (_temp, _temp2) {
3076
+ var getMenuProps = React.useCallback(function (menuProps, otherProps) {
3138
3077
  var _extends2;
3139
- var _ref = _temp === void 0 ? {} : _temp,
3078
+ var _ref = menuProps != null ? menuProps : {},
3140
3079
  onMouseLeave = _ref.onMouseLeave,
3141
3080
  _ref$refKey = _ref.refKey,
3142
3081
  refKey = _ref$refKey === void 0 ? 'ref' : _ref$refKey,
3143
3082
  ref = _ref.ref,
3083
+ ariaLabel = _ref['aria-label'],
3144
3084
  rest = _objectWithoutPropertiesLoose(_ref, _excluded$2);
3145
- var _ref2 = _temp2 === void 0 ? {} : _temp2,
3085
+ var _ref2 = otherProps != null ? otherProps : {},
3146
3086
  _ref2$suppressRefErro = _ref2.suppressRefError,
3147
3087
  suppressRefError = _ref2$suppressRefErro === void 0 ? false : _ref2$suppressRefErro;
3148
3088
  setGetterPropCallInfo('getMenuProps', suppressRefError, refKey, menuRef);
3149
3089
  return _extends((_extends2 = {}, _extends2[refKey] = handleRefs(ref, function (menuNode) {
3150
3090
  menuRef.current = menuNode;
3151
- }), _extends2.id = elementIds.menuId, _extends2.role = 'listbox', _extends2['aria-labelledby'] = rest && rest['aria-label'] ? undefined : "" + elementIds.labelId, _extends2.onMouseLeave = callAllEventHandlers(onMouseLeave, function () {
3091
+ }), _extends2.id = elementIds.menuId, _extends2.role = 'listbox', _extends2['aria-label'] = ariaLabel, _extends2['aria-labelledby'] = ariaLabel ? undefined : "" + elementIds.labelId, _extends2.onMouseLeave = callAllEventHandlers(onMouseLeave, function () {
3152
3092
  dispatch({
3153
3093
  type: MenuMouseLeave
3154
3094
  });
3155
3095
  }), _extends2), rest);
3156
3096
  }, [dispatch, setGetterPropCallInfo, elementIds]);
3157
- var getItemProps = React.useCallback(function (_temp3) {
3097
+ var getItemProps = React.useCallback(function (itemProps) {
3158
3098
  var _extends3, _ref4;
3159
- var _ref3 = _temp3 === void 0 ? {} : _temp3,
3099
+ var _ref3 = itemProps != null ? itemProps : {},
3160
3100
  itemProp = _ref3.item,
3161
3101
  indexProp = _ref3.index,
3162
3102
  _ref3$refKey = _ref3.refKey,
@@ -3184,7 +3124,7 @@ function useCombobox(userProps) {
3184
3124
  if (mouseAndTouchTrackers.isTouchEnd || index === latestState.highlightedIndex) {
3185
3125
  return;
3186
3126
  }
3187
- shouldScrollRef.current = false;
3127
+ preventScroll();
3188
3128
  dispatch({
3189
3129
  type: ItemMouseMove,
3190
3130
  index: index,
@@ -3203,21 +3143,22 @@ function useCombobox(userProps) {
3203
3143
 
3204
3144
  return _extends((_extends3 = {}, _extends3[refKey] = handleRefs(ref, function (itemNode) {
3205
3145
  if (itemNode) {
3206
- itemRefs.current[elementIds.getItemId(index)] = itemNode;
3146
+ itemsRef.current[elementIds.getItemId(index)] = itemNode;
3207
3147
  }
3208
3148
  }), _extends3['aria-disabled'] = disabled, _extends3['aria-selected'] = index === latestState.highlightedIndex, _extends3.id = elementIds.getItemId(index), _extends3.role = 'option', _extends3), !disabled && (_ref4 = {}, _ref4[onSelectKey] = callAllEventHandlers(customClickHandler, itemHandleClick), _ref4), {
3209
3149
  onMouseMove: callAllEventHandlers(onMouseMove, itemHandleMouseMove),
3210
3150
  onMouseDown: callAllEventHandlers(onMouseDown, itemHandleMouseDown)
3211
3151
  }, rest);
3212
- }, [dispatch, elementIds, latest, mouseAndTouchTrackers, shouldScrollRef]);
3213
- var getToggleButtonProps = React.useCallback(function (_temp4) {
3152
+ }, [dispatch, elementIds, latest, mouseAndTouchTrackers, preventScroll]);
3153
+ var getToggleButtonProps = React.useCallback(function (toggleButtonProps) {
3214
3154
  var _extends4;
3215
- var _ref5 = _temp4 === void 0 ? {} : _temp4;
3155
+ var _ref5 = toggleButtonProps != null ? toggleButtonProps : {};
3216
3156
  _ref5.onClick;
3217
3157
  var onPress = _ref5.onPress,
3218
3158
  _ref5$refKey = _ref5.refKey,
3219
3159
  refKey = _ref5$refKey === void 0 ? 'ref' : _ref5$refKey,
3220
3160
  ref = _ref5.ref,
3161
+ disabled = _ref5.disabled,
3221
3162
  rest = _objectWithoutPropertiesLoose(_ref5, _excluded3$1);
3222
3163
  var latestState = latest.current.state;
3223
3164
  var toggleButtonHandleClick = function toggleButtonHandleClick() {
@@ -3227,13 +3168,17 @@ function useCombobox(userProps) {
3227
3168
  };
3228
3169
  return _extends((_extends4 = {}, _extends4[refKey] = handleRefs(ref, function (toggleButtonNode) {
3229
3170
  toggleButtonRef.current = toggleButtonNode;
3230
- }), _extends4['aria-controls'] = elementIds.menuId, _extends4['aria-expanded'] = latestState.isOpen, _extends4.id = elementIds.toggleButtonId, _extends4.tabIndex = -1, _extends4), !rest.disabled && _extends({}, /* istanbul ignore next (react-native) */{
3171
+ }), _extends4['aria-controls'] = elementIds.menuId, _extends4['aria-expanded'] = latestState.isOpen, _extends4.id = elementIds.toggleButtonId, _extends4.tabIndex = -1, _extends4), !disabled && _extends({}, /* istanbul ignore next (react-native) */{
3231
3172
  onPress: callAllEventHandlers(onPress, toggleButtonHandleClick)
3232
- } ), rest);
3173
+ } ), {
3174
+ disabled: disabled
3175
+ }, rest);
3233
3176
  }, [dispatch, latest, elementIds]);
3234
- var getInputProps = React.useCallback(function (_temp5, _temp6) {
3177
+ var getInputProps = React.useCallback(function (inputProps, otherProps) {
3235
3178
  var _extends5;
3236
- var _ref6 = _temp5 === void 0 ? {} : _temp5,
3179
+ var _ref6 = inputProps != null ? inputProps : {},
3180
+ ariaLabel = _ref6['aria-label'],
3181
+ disabled = _ref6.disabled,
3237
3182
  onKeyDown = _ref6.onKeyDown,
3238
3183
  onChange = _ref6.onChange,
3239
3184
  onInput = _ref6.onInput,
@@ -3244,15 +3189,16 @@ function useCombobox(userProps) {
3244
3189
  refKey = _ref6$refKey === void 0 ? 'ref' : _ref6$refKey,
3245
3190
  ref = _ref6.ref,
3246
3191
  rest = _objectWithoutPropertiesLoose(_ref6, _excluded4);
3247
- var _ref7 = _temp6 === void 0 ? {} : _temp6,
3192
+ var _ref7 = otherProps != null ? otherProps : {},
3248
3193
  _ref7$suppressRefErro = _ref7.suppressRefError,
3249
3194
  suppressRefError = _ref7$suppressRefErro === void 0 ? false : _ref7$suppressRefErro;
3250
3195
  setGetterPropCallInfo('getInputProps', suppressRefError, refKey, inputRef);
3251
3196
  var latestState = latest.current.state;
3252
3197
  var inputHandleKeyDown = function inputHandleKeyDown(event) {
3253
3198
  var key = normalizeArrowKey(event);
3254
- if (key && inputKeyDownHandlers[key]) {
3255
- inputKeyDownHandlers[key](event);
3199
+ if (key && key in inputKeyDownHandlers) {
3200
+ var validKey = key;
3201
+ inputKeyDownHandlers[validKey](event);
3256
3202
  }
3257
3203
  };
3258
3204
  var inputHandleChange = function inputHandleChange(event) {
@@ -3280,7 +3226,7 @@ function useCombobox(userProps) {
3280
3226
  /* istanbul ignore next (preact) */
3281
3227
  var onChangeKey = 'onChange';
3282
3228
  var eventHandlers = {};
3283
- if (!rest.disabled) {
3229
+ if (!disabled) {
3284
3230
  var _eventHandlers;
3285
3231
  eventHandlers = (_eventHandlers = {}, _eventHandlers[onChangeKey] = callAllEventHandlers(onChange, onInput, inputHandleChange), _eventHandlers.onKeyDown = callAllEventHandlers(onKeyDown, inputHandleKeyDown), _eventHandlers.onBlur = callAllEventHandlers(onBlur, inputHandleBlur), _eventHandlers.onClick = callAllEventHandlers(onClick, inputHandleClick), _eventHandlers);
3286
3232
  }
@@ -3298,7 +3244,7 @@ function useCombobox(userProps) {
3298
3244
  }
3299
3245
  return _extends((_extends5 = {}, _extends5[refKey] = handleRefs(ref, function (inputNode) {
3300
3246
  inputRef.current = inputNode;
3301
- }), _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'] = rest && rest['aria-label'] ? undefined : elementIds.labelId, _extends5.autoComplete = 'off', _extends5.id = elementIds.inputId, _extends5.role = 'combobox', _extends5.value = latestState.inputValue, _extends5), eventHandlers, rest);
3247
+ }), _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'] = ariaLabel ? undefined : elementIds.labelId, _extends5['aria-label'] = ariaLabel, _extends5.autoComplete = 'off', _extends5.disabled = disabled, _extends5.id = elementIds.inputId, _extends5.role = 'combobox', _extends5.value = latestState.inputValue, _extends5), eventHandlers, rest);
3302
3248
  }, [dispatch, elementIds, environment, inputKeyDownHandlers, latest, mouseAndTouchTrackers, setGetterPropCallInfo]);
3303
3249
 
3304
3250
  // returns
@@ -3368,31 +3314,6 @@ var defaultStateValues = {
3368
3314
  selectedItems: []
3369
3315
  };
3370
3316
 
3371
- /**
3372
- * Returns the initial value for a state key in the following order:
3373
- * 1. controlled prop, 2. initial prop, 3. default prop, 4. default
3374
- * value from Downshift.
3375
- *
3376
- * @param {Object} props Props passed to the hook.
3377
- * @param {string} propKey Props key to generate the value for.
3378
- * @returns {any} The initial value for that prop.
3379
- */
3380
- function getInitialValue(props, propKey) {
3381
- return getInitialValue$1(props, propKey, defaultStateValues);
3382
- }
3383
-
3384
- /**
3385
- * Returns the default value for a state key in the following order:
3386
- * 1. controlled prop, 2. default prop, 3. default value from Downshift.
3387
- *
3388
- * @param {Object} props Props passed to the hook.
3389
- * @param {string} propKey Props key to generate the value for.
3390
- * @returns {any} The initial value for that prop.
3391
- */
3392
- function getDefaultValue(props, propKey) {
3393
- return getDefaultValue$1(props, propKey, defaultStateValues);
3394
- }
3395
-
3396
3317
  /**
3397
3318
  * Gets the initial state based on the provided props. It uses initial, default
3398
3319
  * and controlled props related to state in order to compute the initial value.
@@ -3401,8 +3322,8 @@ function getDefaultValue(props, propKey) {
3401
3322
  * @returns {Object} The initial state.
3402
3323
  */
3403
3324
  function getInitialState$1(props) {
3404
- var activeIndex = getInitialValue(props, 'activeIndex');
3405
- var selectedItems = getInitialValue(props, 'selectedItems');
3325
+ var activeIndex = getInitialValue(props.activeIndex, props.initialActiveIndex, props.defaultActiveIndex, defaultStateValues.activeIndex);
3326
+ var selectedItems = getInitialValue(props.selectedItems, props.initialSelectedItems, props.defaultSelectedItems, defaultStateValues.selectedItems);
3406
3327
  return {
3407
3328
  activeIndex: activeIndex,
3408
3329
  selectedItems: selectedItems
@@ -3446,9 +3367,9 @@ function isStateEqual$1(prevState, newState) {
3446
3367
  return prevState.selectedItems === newState.selectedItems && prevState.activeIndex === newState.activeIndex;
3447
3368
  }
3448
3369
  var propTypes$1 = {
3449
- stateReducer: propTypes$4.stateReducer,
3450
- itemToKey: propTypes$4.itemToKey,
3451
- environment: propTypes$4.environment,
3370
+ stateReducer: dropdownPropTypes.stateReducer,
3371
+ itemToKey: dropdownPropTypes.itemToKey,
3372
+ environment: dropdownPropTypes.environment,
3452
3373
  selectedItems: PropTypes.array,
3453
3374
  initialSelectedItems: PropTypes.array,
3454
3375
  defaultSelectedItems: PropTypes.array,
@@ -3462,9 +3383,9 @@ var propTypes$1 = {
3462
3383
  keyNavigationPrevious: PropTypes.string
3463
3384
  };
3464
3385
  var defaultProps = {
3465
- itemToKey: defaultProps$3.itemToKey,
3466
- stateReducer: defaultProps$3.stateReducer,
3467
- environment: defaultProps$3.environment,
3386
+ itemToKey: dropdownDefaultProps.itemToKey,
3387
+ stateReducer: dropdownDefaultProps.stateReducer,
3388
+ environment: dropdownDefaultProps.environment,
3468
3389
  keyNavigationNext: 'ArrowRight',
3469
3390
  keyNavigationPrevious: 'ArrowLeft'
3470
3391
  };
@@ -3510,10 +3431,11 @@ var stateChangeTypes$1 = /*#__PURE__*/Object.freeze({
3510
3431
  });
3511
3432
 
3512
3433
  /* eslint-disable complexity */
3513
- function downshiftMultipleSelectionReducer(state, props, action) {
3434
+ function downshiftMultipleSelectionReducer(state, action) {
3514
3435
  var type = action.type,
3515
3436
  index = action.index,
3516
- selectedItem = action.selectedItem;
3437
+ selectedItem = action.selectedItem,
3438
+ props = action.props;
3517
3439
  var activeIndex = state.activeIndex,
3518
3440
  selectedItems = state.selectedItems;
3519
3441
  var changes;
@@ -3610,8 +3532,8 @@ function downshiftMultipleSelectionReducer(state, props, action) {
3610
3532
  }
3611
3533
  case FunctionReset:
3612
3534
  changes = {
3613
- activeIndex: getDefaultValue(props, 'activeIndex'),
3614
- selectedItems: getDefaultValue(props, 'selectedItems')
3535
+ activeIndex: getDefaultValue(props.defaultActiveIndex, defaultStateValues.activeIndex),
3536
+ selectedItems: getDefaultValue(props.defaultSelectedItems, defaultStateValues.selectedItems)
3615
3537
  };
3616
3538
  break;
3617
3539
  default:
@@ -3843,7 +3765,7 @@ var stateChangeTypes = /*#__PURE__*/Object.freeze({
3843
3765
  TagRemoveClick: TagRemoveClick
3844
3766
  });
3845
3767
 
3846
- function useTagGroupReducer(state, _props, action) {
3768
+ function useTagGroupReducer(state, action) {
3847
3769
  var type = action.type;
3848
3770
  var changes;
3849
3771
  switch (type) {
@@ -4081,7 +4003,7 @@ var _useTagGroup = function useTagGroup(userProps) {
4081
4003
  'aria-atomic': 'false',
4082
4004
  'aria-relevant': 'additions',
4083
4005
  role: 'listbox',
4084
- onKeyDown: callAllEventHandlers$1(onKeyDown, handleKeyDown)
4006
+ onKeyDown: callAllEventHandlers(onKeyDown, handleKeyDown)
4085
4007
  }, rest);
4086
4008
  return tagGroupProps;
4087
4009
  }, [dispatch, elementIds.tagGroupId]);
@@ -4106,11 +4028,11 @@ var _useTagGroup = function useTagGroup(userProps) {
4106
4028
  var tagId = elementIds.getTagId(index);
4107
4029
  return _extends((_extends2 = {
4108
4030
  'aria-describedby': A11Y_DESCRIPTION_ELEMENT_ID
4109
- }, _extends2[refKey] = handleRefs$1(ref, function (itemNode) {
4031
+ }, _extends2[refKey] = handleRefs(ref, function (itemNode) {
4110
4032
  if (itemNode) {
4111
4033
  itemRefs.current[tagId] = itemNode;
4112
4034
  }
4113
- }), _extends2['aria-labelledby'] = tagId, _extends2.role = 'option', _extends2.id = tagId, _extends2.onClick = callAllEventHandlers$1(onClick, handleClick), _extends2.tabIndex = latestState.activeIndex === index ? 0 : -1, _extends2), rest);
4035
+ }), _extends2['aria-labelledby'] = tagId, _extends2.role = 'option', _extends2.id = tagId, _extends2.onClick = callAllEventHandlers(onClick, handleClick), _extends2.tabIndex = latestState.activeIndex === index ? 0 : -1, _extends2), rest);
4114
4036
  }, [dispatch, elementIds, latest, itemRefs]);
4115
4037
  var getTagRemoveProps = React.useCallback(function (options) {
4116
4038
  var index = options.index,
@@ -4132,7 +4054,7 @@ var _useTagGroup = function useTagGroup(userProps) {
4132
4054
  id: tagRemoveId,
4133
4055
  tabIndex: -1,
4134
4056
  'aria-labelledby': tagRemoveId + " " + tagId,
4135
- onClick: callAllEventHandlers$1(onClick, handleClick)
4057
+ onClick: callAllEventHandlers(onClick, handleClick)
4136
4058
  }, rest);
4137
4059
  }, [elementIds, dispatch]);
4138
4060