downshift 8.5.0 → 9.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,7 +4,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var _objectWithoutPropertiesLoose = require('@babel/runtime/helpers/objectWithoutPropertiesLoose');
6
6
  var _extends = require('@babel/runtime/helpers/extends');
7
- var _assertThisInitialized = require('@babel/runtime/helpers/assertThisInitialized');
8
7
  var _inheritsLoose = require('@babel/runtime/helpers/inheritsLoose');
9
8
  var PropTypes = require('prop-types');
10
9
  var React = require('react');
@@ -16,7 +15,6 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
16
15
 
17
16
  var _objectWithoutPropertiesLoose__default = /*#__PURE__*/_interopDefaultLegacy(_objectWithoutPropertiesLoose);
18
17
  var _extends__default = /*#__PURE__*/_interopDefaultLegacy(_extends);
19
- var _assertThisInitialized__default = /*#__PURE__*/_interopDefaultLegacy(_assertThisInitialized);
20
18
  var _inheritsLoose__default = /*#__PURE__*/_interopDefaultLegacy(_inheritsLoose);
21
19
  var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
22
20
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
@@ -165,7 +163,7 @@ function resetIdCounter() {
165
163
  * @param {Object} param the downshift state and other relevant properties
166
164
  * @return {String} the a11y status message
167
165
  */
168
- function getA11yStatusMessage$1(_ref2) {
166
+ function getA11yStatusMessage(_ref2) {
169
167
  var isOpen = _ref2.isOpen,
170
168
  resultCount = _ref2.resultCount,
171
169
  previousResultCount = _ref2.previousResultCount;
@@ -453,6 +451,17 @@ function setStatus(status, documentProp) {
453
451
  cleanupStatus(documentProp);
454
452
  }
455
453
 
454
+ /**
455
+ * Removes the status element from the DOM
456
+ * @param {Document} documentProp
457
+ */
458
+ function cleanupStatusDiv(documentProp) {
459
+ var statusDiv = documentProp == null ? void 0 : documentProp.getElementById('a11y-status-message');
460
+ if (statusDiv) {
461
+ statusDiv.remove();
462
+ }
463
+ }
464
+
456
465
  var unknown = process.env.NODE_ENV !== "production" ? '__autocomplete_unknown__' : 0;
457
466
  var mouseUp = process.env.NODE_ENV !== "production" ? '__autocomplete_mouseup__' : 1;
458
467
  var itemMouseEnter = process.env.NODE_ENV !== "production" ? '__autocomplete_item_mouseenter__' : 2;
@@ -492,14 +501,13 @@ var stateChangeTypes$3 = /*#__PURE__*/Object.freeze({
492
501
  touchEnd: touchEnd
493
502
  });
494
503
 
495
- var _excluded$4 = ["refKey", "ref"],
504
+ var _excluded$3 = ["refKey", "ref"],
496
505
  _excluded2$3 = ["onClick", "onPress", "onKeyDown", "onKeyUp", "onBlur"],
497
506
  _excluded3$2 = ["onKeyDown", "onBlur", "onChange", "onInput", "onChangeText"],
498
507
  _excluded4$2 = ["refKey", "ref"],
499
508
  _excluded5 = ["onMouseMove", "onMouseDown", "onClick", "onPress", "index", "item"];
500
509
  var Downshift = /*#__PURE__*/function () {
501
510
  var Downshift = /*#__PURE__*/function (_Component) {
502
- _inheritsLoose__default["default"](Downshift, _Component);
503
511
  function Downshift(_props) {
504
512
  var _this;
505
513
  _this = _Component.call(this, _props) || this;
@@ -685,7 +693,7 @@ var Downshift = /*#__PURE__*/function () {
685
693
  _ref$refKey = _ref.refKey,
686
694
  refKey = _ref$refKey === void 0 ? 'ref' : _ref$refKey,
687
695
  ref = _ref.ref,
688
- rest = _objectWithoutPropertiesLoose__default["default"](_ref, _excluded$4);
696
+ rest = _objectWithoutPropertiesLoose__default["default"](_ref, _excluded$3);
689
697
  var _ref2 = _temp2 === void 0 ? {} : _temp2,
690
698
  _ref2$suppressRefErro = _ref2.suppressRefError,
691
699
  suppressRefError = _ref2$suppressRefErro === void 0 ? false : _ref2$suppressRefErro;
@@ -866,7 +874,7 @@ var Downshift = /*#__PURE__*/function () {
866
874
  _this.buttonHandleKeyDown = function (event) {
867
875
  var key = normalizeArrowKey(event);
868
876
  if (_this.buttonKeyDownHandlers[key]) {
869
- _this.buttonKeyDownHandlers[key].call(_assertThisInitialized__default["default"](_this), event);
877
+ _this.buttonKeyDownHandlers[key].call(_this, event);
870
878
  }
871
879
  };
872
880
  _this.buttonHandleClick = function (event) {
@@ -962,7 +970,7 @@ var Downshift = /*#__PURE__*/function () {
962
970
  _this.inputHandleKeyDown = function (event) {
963
971
  var key = normalizeArrowKey(event);
964
972
  if (key && _this.inputKeyDownHandlers[key]) {
965
- _this.inputKeyDownHandlers[key].call(_assertThisInitialized__default["default"](_this), event);
973
+ _this.inputKeyDownHandlers[key].call(_this, event);
966
974
  }
967
975
  };
968
976
  _this.inputHandleChange = function (event) {
@@ -1166,6 +1174,7 @@ var Downshift = /*#__PURE__*/function () {
1166
1174
  _this.state = _state;
1167
1175
  return _this;
1168
1176
  }
1177
+ _inheritsLoose__default["default"](Downshift, _Component);
1169
1178
  var _proto = Downshift.prototype;
1170
1179
  /**
1171
1180
  * Clear all running timeouts
@@ -1446,7 +1455,7 @@ var Downshift = /*#__PURE__*/function () {
1446
1455
  Downshift.defaultProps = {
1447
1456
  defaultHighlightedIndex: null,
1448
1457
  defaultIsOpen: false,
1449
- getA11yStatusMessage: getA11yStatusMessage$1,
1458
+ getA11yStatusMessage: getA11yStatusMessage,
1450
1459
  itemToString: function itemToString(i) {
1451
1460
  if (i == null) {
1452
1461
  return '';
@@ -1548,7 +1557,6 @@ function validateGetRootPropsCalledCorrectly(element, _ref13) {
1548
1557
  }
1549
1558
  }
1550
1559
 
1551
- var _excluded$3 = ["highlightedIndex", "items", "environment"];
1552
1560
  var dropdownDefaultStateValues = {
1553
1561
  highlightedIndex: -1,
1554
1562
  isOpen: false,
@@ -1593,23 +1601,11 @@ function stateReducer(s, a) {
1593
1601
  return a.changes;
1594
1602
  }
1595
1603
 
1596
- /**
1597
- * Returns a message to be added to aria-live region when item is selected.
1598
- *
1599
- * @param {Object} selectionParameters Parameters required to build the message.
1600
- * @returns {string} The a11y message.
1601
- */
1602
- function getA11ySelectionMessage(selectionParameters) {
1603
- var selectedItem = selectionParameters.selectedItem,
1604
- itemToString = selectionParameters.itemToString;
1605
- return selectedItem ? itemToString(selectedItem) + " has been selected." : '';
1606
- }
1607
-
1608
1604
  /**
1609
1605
  * Debounced call for updating the a11y message.
1610
1606
  */
1611
- var updateA11yStatus = debounce(function (getA11yMessage, document) {
1612
- setStatus(getA11yMessage(), document);
1607
+ var updateA11yStatus = debounce(function (status, document) {
1608
+ setStatus(status, document);
1613
1609
  }, 200);
1614
1610
 
1615
1611
  // istanbul ignore next
@@ -1757,7 +1753,6 @@ var defaultProps$3 = {
1757
1753
  return item;
1758
1754
  },
1759
1755
  stateReducer: stateReducer,
1760
- getA11ySelectionMessage: getA11ySelectionMessage,
1761
1756
  scrollIntoView: scrollIntoView,
1762
1757
  environment: /* istanbul ignore next (ssr) */
1763
1758
  typeof window === 'undefined' || false ? undefined : window
@@ -1941,34 +1936,47 @@ if (process.env.NODE_ENV !== 'production') {
1941
1936
  return setGetterPropCallInfo;
1942
1937
  };
1943
1938
  }
1944
- function useA11yMessageSetter(getA11yMessage, dependencyArray, _ref3) {
1945
- var highlightedIndex = _ref3.highlightedIndex,
1946
- items = _ref3.items,
1947
- environment = _ref3.environment,
1948
- rest = _objectWithoutPropertiesLoose__default["default"](_ref3, _excluded$3);
1939
+
1940
+ /**
1941
+ * Adds an a11y aria live status message if getA11yStatusMessage is passed.
1942
+ * @param {(options: Object) => string} getA11yStatusMessage The function that builds the status message.
1943
+ * @param {Object} options The options to be passed to getA11yStatusMessage if called.
1944
+ * @param {Array<unknown>} dependencyArray The dependency array that triggers the status message setter via useEffect.
1945
+ * @param {{document: Document}} environment The environment object containing the document.
1946
+ */
1947
+ function useA11yMessageStatus(getA11yStatusMessage, options, dependencyArray, environment) {
1948
+ if (environment === void 0) {
1949
+ environment = {};
1950
+ }
1951
+ var document = environment.document;
1949
1952
  var isInitialMount = useIsInitialMount();
1950
- // Sets a11y status message on changes in state.
1953
+
1954
+ // Adds an a11y aria live status message if getA11yStatusMessage is passed.
1951
1955
  React.useEffect(function () {
1952
- if (isInitialMount || false || !(environment != null && environment.document)) {
1956
+ if (!getA11yStatusMessage || isInitialMount || false || !document) {
1953
1957
  return;
1954
1958
  }
1955
- updateA11yStatus(function () {
1956
- return getA11yMessage(_extends__default["default"]({
1957
- highlightedIndex: highlightedIndex,
1958
- highlightedItem: items[highlightedIndex],
1959
- resultCount: items.length
1960
- }, rest));
1961
- }, environment.document);
1959
+ var status = getA11yStatusMessage(options);
1960
+ updateA11yStatus(status, document);
1961
+
1962
1962
  // eslint-disable-next-line react-hooks/exhaustive-deps
1963
- }, dependencyArray);
1964
- }
1965
- function useScrollIntoView(_ref4) {
1966
- var highlightedIndex = _ref4.highlightedIndex,
1967
- isOpen = _ref4.isOpen,
1968
- itemRefs = _ref4.itemRefs,
1969
- getItemNodeFromIndex = _ref4.getItemNodeFromIndex,
1970
- menuElement = _ref4.menuElement,
1971
- scrollIntoViewProp = _ref4.scrollIntoView;
1963
+ }, [dependencyArray]);
1964
+
1965
+ // Cleanup the status message container.
1966
+ React.useEffect(function () {
1967
+ return function () {
1968
+ updateA11yStatus.cancel();
1969
+ cleanupStatusDiv(document);
1970
+ };
1971
+ }, [document]);
1972
+ }
1973
+ function useScrollIntoView(_ref3) {
1974
+ var highlightedIndex = _ref3.highlightedIndex,
1975
+ isOpen = _ref3.isOpen,
1976
+ itemRefs = _ref3.itemRefs,
1977
+ getItemNodeFromIndex = _ref3.getItemNodeFromIndex,
1978
+ menuElement = _ref3.menuElement,
1979
+ scrollIntoViewProp = _ref3.scrollIntoView;
1972
1980
  // used not to scroll on highlight by mouse.
1973
1981
  var shouldScrollRef = React.useRef(true);
1974
1982
  // Scroll on highlighted item if change comes from keyboard.
@@ -1990,9 +1998,9 @@ function useScrollIntoView(_ref4) {
1990
1998
  var useControlPropsValidator = noop;
1991
1999
  /* istanbul ignore next */
1992
2000
  if (process.env.NODE_ENV !== 'production') {
1993
- useControlPropsValidator = function useControlPropsValidator(_ref5) {
1994
- var props = _ref5.props,
1995
- state = _ref5.state;
2001
+ useControlPropsValidator = function useControlPropsValidator(_ref4) {
2002
+ var props = _ref4.props,
2003
+ state = _ref4.state;
1996
2004
  // used for checking when props are moving from controlled to uncontrolled.
1997
2005
  var prevPropsRef = React.useRef(props);
1998
2006
  var isInitialMount = useIsInitialMount();
@@ -2173,29 +2181,8 @@ function getItemIndexByCharacterKey(_a) {
2173
2181
  }
2174
2182
  return highlightedIndex;
2175
2183
  }
2176
- var propTypes$2 = tslib.__assign(tslib.__assign({}, commonDropdownPropTypes), { items: PropTypes__default["default"].array.isRequired, isItemDisabled: PropTypes__default["default"].func, getA11ySelectionMessage: PropTypes__default["default"].func });
2177
- /**
2178
- * Default implementation for status message. Only added when menu is open.
2179
- * Will specift if there are results in the list, and if so, how many,
2180
- * and what keys are relevant.
2181
- *
2182
- * @param {Object} param the downshift state and other relevant properties
2183
- * @return {String} the a11y status message
2184
- */
2185
- function getA11yStatusMessage(_a) {
2186
- var isOpen = _a.isOpen, resultCount = _a.resultCount, previousResultCount = _a.previousResultCount;
2187
- if (!isOpen) {
2188
- return '';
2189
- }
2190
- if (!resultCount) {
2191
- return 'No results are available.';
2192
- }
2193
- if (resultCount !== previousResultCount) {
2194
- return "".concat(resultCount, " result").concat(resultCount === 1 ? ' is' : 's are', " available, use up and down arrow keys to navigate. Press Enter or Space Bar keys to select.");
2195
- }
2196
- return '';
2197
- }
2198
- var defaultProps$2 = tslib.__assign(tslib.__assign({}, defaultProps$3), { getA11yStatusMessage: getA11yStatusMessage, isItemDisabled: function () {
2184
+ var propTypes$2 = tslib.__assign(tslib.__assign({}, commonDropdownPropTypes), { items: PropTypes__default["default"].array.isRequired, isItemDisabled: PropTypes__default["default"].func });
2185
+ var defaultProps$2 = tslib.__assign(tslib.__assign({}, defaultProps$3), { isItemDisabled: function () {
2199
2186
  return false;
2200
2187
  } });
2201
2188
  // eslint-disable-next-line import/no-mutable-exports
@@ -2377,11 +2364,8 @@ function useSelect(userProps) {
2377
2364
  validatePropTypes$2(userProps, useSelect);
2378
2365
  // Props defaults and destructuring.
2379
2366
  var props = _extends__default["default"]({}, defaultProps$2, userProps);
2380
- var items = props.items,
2381
- scrollIntoView = props.scrollIntoView,
2367
+ var scrollIntoView = props.scrollIntoView,
2382
2368
  environment = props.environment,
2383
- itemToString = props.itemToString,
2384
- getA11ySelectionMessage = props.getA11ySelectionMessage,
2385
2369
  getA11yStatusMessage = props.getA11yStatusMessage;
2386
2370
  // Initial state depending on controlled props.
2387
2371
  var _useControlledReducer = useControlledReducer$1(downshiftSelectReducer, props, getInitialState$2, isDropdownsStateEqual),
@@ -2399,9 +2383,6 @@ function useSelect(userProps) {
2399
2383
  var clearTimeoutRef = React.useRef(null);
2400
2384
  // prevent id re-generation between renders.
2401
2385
  var elementIds = useElementIds(props);
2402
- // used to keep track of how many items we had on previous cycle.
2403
- var previousResultCountRef = React.useRef();
2404
- var isInitialMount = useIsInitialMount();
2405
2386
  // utility callback to get item element.
2406
2387
  var latest = useLatestRef({
2407
2388
  state: state,
@@ -2414,20 +2395,8 @@ function useSelect(userProps) {
2414
2395
  }, [elementIds]);
2415
2396
 
2416
2397
  // Effects.
2417
- // Sets a11y status message on changes in state.
2418
- useA11yMessageSetter(getA11yStatusMessage, [isOpen, highlightedIndex, inputValue, items], _extends__default["default"]({
2419
- previousResultCount: previousResultCountRef.current,
2420
- items: items,
2421
- environment: environment,
2422
- itemToString: itemToString
2423
- }, state));
2424
- // Sets a11y status message on changes in selectedItem.
2425
- useA11yMessageSetter(getA11ySelectionMessage, [selectedItem], _extends__default["default"]({
2426
- previousResultCount: previousResultCountRef.current,
2427
- items: items,
2428
- environment: environment,
2429
- itemToString: itemToString
2430
- }, state));
2398
+ // Adds an a11y aria live status message if getA11yStatusMessage is passed.
2399
+ useA11yMessageStatus(getA11yStatusMessage, state, [isOpen, highlightedIndex, selectedItem, inputValue], environment);
2431
2400
  // Scroll on highlighted item if change comes from keyboard.
2432
2401
  var shouldScrollRef = useScrollIntoView({
2433
2402
  menuElement: menuRef.current,
@@ -2437,7 +2406,6 @@ function useSelect(userProps) {
2437
2406
  scrollIntoView: scrollIntoView,
2438
2407
  getItemNodeFromIndex: getItemNodeFromIndex
2439
2408
  });
2440
-
2441
2409
  // Sets cleanup for the keysSoFar callback, debounded after 500ms.
2442
2410
  React.useEffect(function () {
2443
2411
  // init the clean function here as we need access to dispatch.
@@ -2453,7 +2421,6 @@ function useSelect(userProps) {
2453
2421
  clearTimeoutRef.current.cancel();
2454
2422
  };
2455
2423
  }, []);
2456
-
2457
2424
  // Invokes the keysSoFar callback set up above.
2458
2425
  React.useEffect(function () {
2459
2426
  if (!inputValue) {
@@ -2465,12 +2432,6 @@ function useSelect(userProps) {
2465
2432
  props: props,
2466
2433
  state: state
2467
2434
  });
2468
- React.useEffect(function () {
2469
- if (isInitialMount) {
2470
- return;
2471
- }
2472
- previousResultCountRef.current = items.length;
2473
- });
2474
2435
  // Focus the toggle button on first render if required.
2475
2436
  React.useEffect(function () {
2476
2437
  var focusOnOpen = getInitialValue$1(props, 'isOpen');
@@ -2848,8 +2809,6 @@ function getInitialState$1(props) {
2848
2809
  var propTypes$1 = _extends__default["default"]({}, commonDropdownPropTypes, {
2849
2810
  items: PropTypes__default["default"].array.isRequired,
2850
2811
  isItemDisabled: PropTypes__default["default"].func,
2851
- selectedItemChanged: PropTypes__default["default"].func,
2852
- getA11ySelectionMessage: PropTypes__default["default"].func,
2853
2812
  inputValue: PropTypes__default["default"].string,
2854
2813
  defaultInputValue: PropTypes__default["default"].string,
2855
2814
  initialInputValue: PropTypes__default["default"].string,
@@ -2882,13 +2841,7 @@ function useControlledReducer(reducer, props, createInitialState, isStateEqual)
2882
2841
  }
2883
2842
  if (!isInitialMount // on first mount we already have the proper inputValue for a initial selected item.
2884
2843
  ) {
2885
- var shouldCallDispatch;
2886
- if (props.selectedItemChanged === undefined) {
2887
- shouldCallDispatch = props.itemToKey(props.selectedItem) !== props.itemToKey(previousSelectedItemRef.current);
2888
- } else {
2889
- console.warn("The \"selectedItemChanged\" is deprecated. Please use \"itemToKey instead\". https://github.com/downshift-js/downshift/blob/master/src/hooks/useCombobox/README.md#selecteditemchanged");
2890
- shouldCallDispatch = props.selectedItemChanged(previousSelectedItemRef.current, props.selectedItem);
2891
- }
2844
+ var shouldCallDispatch = props.itemToKey(props.selectedItem) !== props.itemToKey(previousSelectedItemRef.current);
2892
2845
  if (shouldCallDispatch) {
2893
2846
  dispatch({
2894
2847
  type: ControlledPropUpdatedSelectedItem,
@@ -2911,7 +2864,6 @@ if (process.env.NODE_ENV !== 'production') {
2911
2864
  };
2912
2865
  }
2913
2866
  var defaultProps$1 = _extends__default["default"]({}, defaultProps$3, {
2914
- getA11yStatusMessage: getA11yStatusMessage$1,
2915
2867
  isItemDisabled: function isItemDisabled() {
2916
2868
  return false;
2917
2869
  }
@@ -3048,9 +3000,7 @@ function useCombobox(userProps) {
3048
3000
  var items = props.items,
3049
3001
  scrollIntoView = props.scrollIntoView,
3050
3002
  environment = props.environment,
3051
- getA11yStatusMessage = props.getA11yStatusMessage,
3052
- getA11ySelectionMessage = props.getA11ySelectionMessage,
3053
- itemToString = props.itemToString;
3003
+ getA11yStatusMessage = props.getA11yStatusMessage;
3054
3004
  // Initial state depending on controlled props.
3055
3005
  var _useControlledReducer = useControlledReducer(downshiftUseComboboxReducer, props, getInitialState$1, isDropdownsStateEqual),
3056
3006
  state = _useControlledReducer[0],
@@ -3081,20 +3031,8 @@ function useCombobox(userProps) {
3081
3031
  }, [elementIds]);
3082
3032
 
3083
3033
  // Effects.
3084
- // Sets a11y status message on changes in state.
3085
- useA11yMessageSetter(getA11yStatusMessage, [isOpen, highlightedIndex, inputValue, items], _extends__default["default"]({
3086
- previousResultCount: previousResultCountRef.current,
3087
- items: items,
3088
- environment: environment,
3089
- itemToString: itemToString
3090
- }, state));
3091
- // Sets a11y status message on changes in selectedItem.
3092
- useA11yMessageSetter(getA11ySelectionMessage, [selectedItem], _extends__default["default"]({
3093
- previousResultCount: previousResultCountRef.current,
3094
- items: items,
3095
- environment: environment,
3096
- itemToString: itemToString
3097
- }, state));
3034
+ // Adds an a11y aria live status message if getA11yStatusMessage is passed.
3035
+ useA11yMessageStatus(getA11yStatusMessage, state, [isOpen, highlightedIndex, selectedItem, inputValue], environment);
3098
3036
  // Scroll on highlighted item if change comes from keyboard.
3099
3037
  var shouldScrollRef = useScrollIntoView({
3100
3038
  menuElement: menuRef.current,
@@ -3517,18 +3455,6 @@ function isKeyDownOperationPermitted(event) {
3517
3455
  return true;
3518
3456
  }
3519
3457
 
3520
- /**
3521
- * Returns a message to be added to aria-live region when item is removed.
3522
- *
3523
- * @param {Object} selectionParameters Parameters required to build the message.
3524
- * @returns {string} The a11y message.
3525
- */
3526
- function getA11yRemovalMessage(selectionParameters) {
3527
- var removedSelectedItem = selectionParameters.removedSelectedItem,
3528
- itemToStringLocal = selectionParameters.itemToString;
3529
- return itemToStringLocal(removedSelectedItem) + " has been removed.";
3530
- }
3531
-
3532
3458
  /**
3533
3459
  * Check if a state is equal for taglist, by comparing active index and selected items.
3534
3460
  * Used by useSelect and useCombobox.
@@ -3540,11 +3466,14 @@ function getA11yRemovalMessage(selectionParameters) {
3540
3466
  function isStateEqual(prevState, newState) {
3541
3467
  return prevState.selectedItems === newState.selectedItems && prevState.activeIndex === newState.activeIndex;
3542
3468
  }
3543
- var propTypes = _extends__default["default"]({}, commonPropTypes, {
3469
+ var propTypes = {
3470
+ stateReducer: commonPropTypes.stateReducer,
3471
+ itemToKey: commonPropTypes.itemToKey,
3472
+ environment: commonPropTypes.environment,
3544
3473
  selectedItems: PropTypes__default["default"].array,
3545
3474
  initialSelectedItems: PropTypes__default["default"].array,
3546
3475
  defaultSelectedItems: PropTypes__default["default"].array,
3547
- getA11yRemovalMessage: PropTypes__default["default"].func,
3476
+ getA11yStatusMessage: PropTypes__default["default"].func,
3548
3477
  activeIndex: PropTypes__default["default"].number,
3549
3478
  initialActiveIndex: PropTypes__default["default"].number,
3550
3479
  defaultActiveIndex: PropTypes__default["default"].number,
@@ -3552,13 +3481,11 @@ var propTypes = _extends__default["default"]({}, commonPropTypes, {
3552
3481
  onSelectedItemsChange: PropTypes__default["default"].func,
3553
3482
  keyNavigationNext: PropTypes__default["default"].string,
3554
3483
  keyNavigationPrevious: PropTypes__default["default"].string
3555
- });
3484
+ };
3556
3485
  var defaultProps = {
3557
- itemToString: defaultProps$3.itemToString,
3558
3486
  itemToKey: defaultProps$3.itemToKey,
3559
3487
  stateReducer: defaultProps$3.stateReducer,
3560
3488
  environment: defaultProps$3.environment,
3561
- getA11yRemovalMessage: getA11yRemovalMessage,
3562
3489
  keyNavigationNext: 'ArrowRight',
3563
3490
  keyNavigationPrevious: 'ArrowLeft'
3564
3491
  };
@@ -3725,8 +3652,7 @@ function useMultipleSelection(userProps) {
3725
3652
  validatePropTypes(userProps, useMultipleSelection);
3726
3653
  // Props defaults and destructuring.
3727
3654
  var props = _extends__default["default"]({}, defaultProps, userProps);
3728
- var getA11yRemovalMessage = props.getA11yRemovalMessage,
3729
- itemToString = props.itemToString,
3655
+ var getA11yStatusMessage = props.getA11yStatusMessage,
3730
3656
  environment = props.environment,
3731
3657
  keyNavigationNext = props.keyNavigationNext,
3732
3658
  keyNavigationPrevious = props.keyNavigationPrevious;
@@ -3741,7 +3667,6 @@ function useMultipleSelection(userProps) {
3741
3667
  // Refs.
3742
3668
  var isInitialMount = useIsInitialMount();
3743
3669
  var dropdownRef = React.useRef(null);
3744
- var previousSelectedItemsRef = React.useRef(selectedItems);
3745
3670
  var selectedItemRefs = React.useRef();
3746
3671
  selectedItemRefs.current = [];
3747
3672
  var latest = useLatestRef({
@@ -3750,29 +3675,8 @@ function useMultipleSelection(userProps) {
3750
3675
  });
3751
3676
 
3752
3677
  // Effects.
3753
- /* Sets a11y status message on changes in selectedItem. */
3754
- React.useEffect(function () {
3755
- if (isInitialMount || false || !(environment != null && environment.document)) {
3756
- return;
3757
- }
3758
- if (selectedItems.length < previousSelectedItemsRef.current.length) {
3759
- var removedSelectedItem = previousSelectedItemsRef.current.find(function (selectedItem) {
3760
- return selectedItems.findIndex(function (item) {
3761
- return props.itemToKey(item) === props.itemToKey(selectedItem);
3762
- }) < 0;
3763
- });
3764
- setStatus(getA11yRemovalMessage({
3765
- itemToString: itemToString,
3766
- resultCount: selectedItems.length,
3767
- removedSelectedItem: removedSelectedItem,
3768
- activeIndex: activeIndex,
3769
- activeSelectedItem: selectedItems[activeIndex]
3770
- }), environment.document);
3771
- }
3772
- previousSelectedItemsRef.current = selectedItems;
3773
-
3774
- // eslint-disable-next-line react-hooks/exhaustive-deps
3775
- }, [selectedItems.length]);
3678
+ // Adds an a11y aria live status message if getA11yStatusMessage is passed.
3679
+ useA11yMessageStatus(getA11yStatusMessage, state, [activeIndex, selectedItems], environment);
3776
3680
  // Sets focus on active item.
3777
3681
  React.useEffect(function () {
3778
3682
  if (isInitialMount) {