downshift 8.2.2 → 8.2.3

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.
@@ -56,22 +56,22 @@ export namespace defaultProps {
56
56
  * returning the new state.
57
57
  *
58
58
  * @param {Function} reducer Reducer function from downshift.
59
- * @param {Object} initialState Initial state of the hook.
60
- * @param {Object} props The hook props.
59
+ * @param {Object} props The hook props, also passed to createInitialState.
60
+ * @param {Function} createInitialState Function that returns the initial state.
61
61
  * @returns {Array} An array with the state and an action dispatcher.
62
62
  */
63
- export function useControlledReducer(reducer: Function, initialState: Object, props: Object): any[];
63
+ export function useControlledReducer(reducer: Function, props: Object, createInitialState: Function): any[];
64
64
  /**
65
65
  * Computes the controlled state using a the previous state, props,
66
66
  * two reducers, one from downshift and an optional one from the user.
67
67
  * Also calls the onChange handlers for state values that have changed.
68
68
  *
69
69
  * @param {Function} reducer Reducer function from downshift.
70
- * @param {Object} initialState Initial state of the hook.
71
- * @param {Object} props The hook props.
70
+ * @param {Object} props The hook props, also passed to createInitialState.
71
+ * @param {Function} createInitialState Function that returns the initial state.
72
72
  * @returns {Array} An array with the state and an action dispatcher.
73
73
  */
74
- export function useEnhancedReducer(reducer: Function, initialState: Object, props: Object): any[];
74
+ export function useEnhancedReducer(reducer: Function, props: Object, createInitialState: Function): any[];
75
75
  export function useLatestRef(val: any): React.MutableRefObject<any>;
76
76
  export function capitalizeString(string: any): string;
77
77
  export function isAcceptedCharacterKey(key: any): boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "downshift",
3
- "version": "8.2.2",
3
+ "version": "8.2.3",
4
4
  "description": "🏎 A set of primitives to build simple, flexible, WAI-ARIA compliant React autocomplete, combobox or select dropdown components.",
5
5
  "main": "dist/downshift.cjs.js",
6
6
  "react-native": "dist/downshift.native.cjs.js",
@@ -1656,11 +1656,11 @@ function useLatestRef(val) {
1656
1656
  * Also calls the onChange handlers for state values that have changed.
1657
1657
  *
1658
1658
  * @param {Function} reducer Reducer function from downshift.
1659
- * @param {Object} initialState Initial state of the hook.
1660
- * @param {Object} props The hook props.
1659
+ * @param {Object} props The hook props, also passed to createInitialState.
1660
+ * @param {Function} createInitialState Function that returns the initial state.
1661
1661
  * @returns {Array} An array with the state and an action dispatcher.
1662
1662
  */
1663
- function useEnhancedReducer(reducer, initialState, props) {
1663
+ function useEnhancedReducer(reducer, props, createInitialState) {
1664
1664
  var prevStateRef = React.useRef();
1665
1665
  var actionRef = React.useRef();
1666
1666
  var enhancedReducer = React.useCallback(function (state, action) {
@@ -1672,7 +1672,7 @@ function useEnhancedReducer(reducer, initialState, props) {
1672
1672
  }));
1673
1673
  return newState;
1674
1674
  }, [reducer]);
1675
- var _useReducer = React.useReducer(enhancedReducer, initialState),
1675
+ var _useReducer = React.useReducer(enhancedReducer, props, createInitialState),
1676
1676
  state = _useReducer[0],
1677
1677
  dispatch = _useReducer[1];
1678
1678
  var propsRef = useLatestRef(props);
@@ -1696,12 +1696,12 @@ function useEnhancedReducer(reducer, initialState, props) {
1696
1696
  * returning the new state.
1697
1697
  *
1698
1698
  * @param {Function} reducer Reducer function from downshift.
1699
- * @param {Object} initialState Initial state of the hook.
1700
- * @param {Object} props The hook props.
1699
+ * @param {Object} props The hook props, also passed to createInitialState.
1700
+ * @param {Function} createInitialState Function that returns the initial state.
1701
1701
  * @returns {Array} An array with the state and an action dispatcher.
1702
1702
  */
1703
- function useControlledReducer$1(reducer, initialState, props) {
1704
- var _useEnhancedReducer = useEnhancedReducer(reducer, initialState, props),
1703
+ function useControlledReducer$1(reducer, props, createInitialState) {
1704
+ var _useEnhancedReducer = useEnhancedReducer(reducer, props, createInitialState),
1705
1705
  state = _useEnhancedReducer[0],
1706
1706
  dispatch = _useEnhancedReducer[1];
1707
1707
  return [getState(state, props), dispatch];
@@ -2305,8 +2305,7 @@ function useSelect(userProps) {
2305
2305
  getA11ySelectionMessage = props.getA11ySelectionMessage,
2306
2306
  getA11yStatusMessage = props.getA11yStatusMessage;
2307
2307
  // Initial state depending on controlled props.
2308
- var initialState = getInitialState$2(props);
2309
- var _useControlledReducer = useControlledReducer$1(downshiftSelectReducer, initialState, props),
2308
+ var _useControlledReducer = useControlledReducer$1(downshiftSelectReducer, props, getInitialState$2),
2310
2309
  state = _useControlledReducer[0],
2311
2310
  dispatch = _useControlledReducer[1];
2312
2311
  var isOpen = state.isOpen,
@@ -2789,13 +2788,13 @@ var propTypes$1 = _extends__default["default"]({}, commonDropdownPropTypes, {
2789
2788
  * compute the rest of the state.
2790
2789
  *
2791
2790
  * @param {Function} reducer Reducer function from downshift.
2792
- * @param {Object} initialState Initial state of the hook.
2793
- * @param {Object} props The hook props.
2791
+ * @param {Object} props The hook props, also passed to createInitialState.
2792
+ * @param {Function} createInitialState Function that returns the initial state.
2794
2793
  * @returns {Array} An array with the state and an action dispatcher.
2795
2794
  */
2796
- function useControlledReducer(reducer, initialState, props) {
2795
+ function useControlledReducer(reducer, props, createInitialState) {
2797
2796
  var previousSelectedItemRef = React.useRef();
2798
- var _useEnhancedReducer = useEnhancedReducer(reducer, initialState, props),
2797
+ var _useEnhancedReducer = useEnhancedReducer(reducer, props, createInitialState),
2799
2798
  state = _useEnhancedReducer[0],
2800
2799
  dispatch = _useEnhancedReducer[1];
2801
2800
 
@@ -2969,8 +2968,7 @@ function useCombobox(userProps) {
2969
2968
  getA11ySelectionMessage = props.getA11ySelectionMessage,
2970
2969
  itemToString = props.itemToString;
2971
2970
  // Initial state depending on controlled props.
2972
- var initialState = getInitialState$1(props);
2973
- var _useControlledReducer = useControlledReducer(downshiftUseComboboxReducer, initialState, props),
2971
+ var _useControlledReducer = useControlledReducer(downshiftUseComboboxReducer, props, getInitialState$1),
2974
2972
  state = _useControlledReducer[0],
2975
2973
  dispatch = _useControlledReducer[1];
2976
2974
  var isOpen = state.isOpen,
@@ -3644,7 +3642,7 @@ function useMultipleSelection(userProps) {
3644
3642
  keyNavigationPrevious = props.keyNavigationPrevious;
3645
3643
 
3646
3644
  // Reducer init.
3647
- var _useControlledReducer = useControlledReducer$1(downshiftMultipleSelectionReducer, getInitialState(props), props),
3645
+ var _useControlledReducer = useControlledReducer$1(downshiftMultipleSelectionReducer, props, getInitialState),
3648
3646
  state = _useControlledReducer[0],
3649
3647
  dispatch = _useControlledReducer[1];
3650
3648
  var activeIndex = state.activeIndex,
@@ -1643,11 +1643,11 @@ function useLatestRef(val) {
1643
1643
  * Also calls the onChange handlers for state values that have changed.
1644
1644
  *
1645
1645
  * @param {Function} reducer Reducer function from downshift.
1646
- * @param {Object} initialState Initial state of the hook.
1647
- * @param {Object} props The hook props.
1646
+ * @param {Object} props The hook props, also passed to createInitialState.
1647
+ * @param {Function} createInitialState Function that returns the initial state.
1648
1648
  * @returns {Array} An array with the state and an action dispatcher.
1649
1649
  */
1650
- function useEnhancedReducer(reducer, initialState, props) {
1650
+ function useEnhancedReducer(reducer, props, createInitialState) {
1651
1651
  var prevStateRef = useRef();
1652
1652
  var actionRef = useRef();
1653
1653
  var enhancedReducer = useCallback(function (state, action) {
@@ -1659,7 +1659,7 @@ function useEnhancedReducer(reducer, initialState, props) {
1659
1659
  }));
1660
1660
  return newState;
1661
1661
  }, [reducer]);
1662
- var _useReducer = useReducer(enhancedReducer, initialState),
1662
+ var _useReducer = useReducer(enhancedReducer, props, createInitialState),
1663
1663
  state = _useReducer[0],
1664
1664
  dispatch = _useReducer[1];
1665
1665
  var propsRef = useLatestRef(props);
@@ -1683,12 +1683,12 @@ function useEnhancedReducer(reducer, initialState, props) {
1683
1683
  * returning the new state.
1684
1684
  *
1685
1685
  * @param {Function} reducer Reducer function from downshift.
1686
- * @param {Object} initialState Initial state of the hook.
1687
- * @param {Object} props The hook props.
1686
+ * @param {Object} props The hook props, also passed to createInitialState.
1687
+ * @param {Function} createInitialState Function that returns the initial state.
1688
1688
  * @returns {Array} An array with the state and an action dispatcher.
1689
1689
  */
1690
- function useControlledReducer$1(reducer, initialState, props) {
1691
- var _useEnhancedReducer = useEnhancedReducer(reducer, initialState, props),
1690
+ function useControlledReducer$1(reducer, props, createInitialState) {
1691
+ var _useEnhancedReducer = useEnhancedReducer(reducer, props, createInitialState),
1692
1692
  state = _useEnhancedReducer[0],
1693
1693
  dispatch = _useEnhancedReducer[1];
1694
1694
  return [getState(state, props), dispatch];
@@ -2292,8 +2292,7 @@ function useSelect(userProps) {
2292
2292
  getA11ySelectionMessage = props.getA11ySelectionMessage,
2293
2293
  getA11yStatusMessage = props.getA11yStatusMessage;
2294
2294
  // Initial state depending on controlled props.
2295
- var initialState = getInitialState$2(props);
2296
- var _useControlledReducer = useControlledReducer$1(downshiftSelectReducer, initialState, props),
2295
+ var _useControlledReducer = useControlledReducer$1(downshiftSelectReducer, props, getInitialState$2),
2297
2296
  state = _useControlledReducer[0],
2298
2297
  dispatch = _useControlledReducer[1];
2299
2298
  var isOpen = state.isOpen,
@@ -2776,13 +2775,13 @@ var propTypes$1 = _extends({}, commonDropdownPropTypes, {
2776
2775
  * compute the rest of the state.
2777
2776
  *
2778
2777
  * @param {Function} reducer Reducer function from downshift.
2779
- * @param {Object} initialState Initial state of the hook.
2780
- * @param {Object} props The hook props.
2778
+ * @param {Object} props The hook props, also passed to createInitialState.
2779
+ * @param {Function} createInitialState Function that returns the initial state.
2781
2780
  * @returns {Array} An array with the state and an action dispatcher.
2782
2781
  */
2783
- function useControlledReducer(reducer, initialState, props) {
2782
+ function useControlledReducer(reducer, props, createInitialState) {
2784
2783
  var previousSelectedItemRef = useRef();
2785
- var _useEnhancedReducer = useEnhancedReducer(reducer, initialState, props),
2784
+ var _useEnhancedReducer = useEnhancedReducer(reducer, props, createInitialState),
2786
2785
  state = _useEnhancedReducer[0],
2787
2786
  dispatch = _useEnhancedReducer[1];
2788
2787
 
@@ -2956,8 +2955,7 @@ function useCombobox(userProps) {
2956
2955
  getA11ySelectionMessage = props.getA11ySelectionMessage,
2957
2956
  itemToString = props.itemToString;
2958
2957
  // Initial state depending on controlled props.
2959
- var initialState = getInitialState$1(props);
2960
- var _useControlledReducer = useControlledReducer(downshiftUseComboboxReducer, initialState, props),
2958
+ var _useControlledReducer = useControlledReducer(downshiftUseComboboxReducer, props, getInitialState$1),
2961
2959
  state = _useControlledReducer[0],
2962
2960
  dispatch = _useControlledReducer[1];
2963
2961
  var isOpen = state.isOpen,
@@ -3631,7 +3629,7 @@ function useMultipleSelection(userProps) {
3631
3629
  keyNavigationPrevious = props.keyNavigationPrevious;
3632
3630
 
3633
3631
  // Reducer init.
3634
- var _useControlledReducer = useControlledReducer$1(downshiftMultipleSelectionReducer, getInitialState(props), props),
3632
+ var _useControlledReducer = useControlledReducer$1(downshiftMultipleSelectionReducer, props, getInitialState),
3635
3633
  state = _useControlledReducer[0],
3636
3634
  dispatch = _useControlledReducer[1];
3637
3635
  var activeIndex = state.activeIndex,
@@ -295,7 +295,7 @@
295
295
 
296
296
  var reactIsExports = reactIs.exports;
297
297
 
298
- const t=t=>"object"==typeof t&&null!=t&&1===t.nodeType,e=(t,e)=>(!e||"hidden"!==t)&&("visible"!==t&&"clip"!==t),n=(t,n)=>{if(t.clientHeight<t.scrollHeight||t.clientWidth<t.scrollWidth){const o=getComputedStyle(t,null);return e(o.overflowY,n)||e(o.overflowX,n)||(t=>{const e=(t=>{if(!t.ownerDocument||!t.ownerDocument.defaultView)return null;try{return t.ownerDocument.defaultView.frameElement}catch(t){return null}})(t);return !!e&&(e.clientHeight<t.scrollHeight||e.clientWidth<t.scrollWidth)})(t)}return !1},o=(t,e,n,o,i,l,r,d)=>l<t&&r>e||l>t&&r<e?0:l<=t&&d<=n||r>=e&&d>=n?l-t-o:r>e&&d<n||l<t&&d>n?r-e+i:0,i=t=>{const e=t.parentElement;return null==e?t.getRootNode().host||null:e},l=(e,l)=>{var r,d,s,h;if("undefined"==typeof document)return [];const{scrollMode:c,block:f,inline:u,boundary:a,skipOverflowHiddenElements:g}=l,m="function"==typeof a?a:t=>t!==a;if(!t(e))throw new TypeError("Invalid target");const p=document.scrollingElement||document.documentElement,w=[];let W=e;for(;t(W)&&m(W);){if(W=i(W),W===p){w.push(W);break}null!=W&&W===document.body&&n(W)&&!n(document.documentElement)||null!=W&&n(W,g)&&w.push(W);}const H=null!=(d=null==(r=window.visualViewport)?void 0:r.width)?d:innerWidth,b=null!=(h=null==(s=window.visualViewport)?void 0:s.height)?h:innerHeight,{scrollX:v,scrollY:y}=window,{height:E,width:M,top:x,right:I,bottom:C,left:R}=e.getBoundingClientRect();let T="start"===f||"nearest"===f?x:"end"===f?C:x+E/2,V="center"===u?R+M/2:"end"===u?I:R;const k=[];for(let t=0;t<w.length;t++){const e=w[t],{height:n,width:i,top:l,right:r,bottom:d,left:s}=e.getBoundingClientRect();if("if-needed"===c&&x>=0&&R>=0&&C<=b&&I<=H&&x>=l&&C<=d&&R>=s&&I<=r)return k;const h=getComputedStyle(e),a=parseInt(h.borderLeftWidth,10),g=parseInt(h.borderTopWidth,10),m=parseInt(h.borderRightWidth,10),W=parseInt(h.borderBottomWidth,10);let B=0,D=0;const L="offsetWidth"in e?e.offsetWidth-e.clientWidth-a-m:0,S="offsetHeight"in e?e.offsetHeight-e.clientHeight-g-W:0,X="offsetWidth"in e?0===e.offsetWidth?0:i/e.offsetWidth:0,Y="offsetHeight"in e?0===e.offsetHeight?0:n/e.offsetHeight:0;if(p===e)B="start"===f?T:"end"===f?T-b:"nearest"===f?o(y,y+b,b,g,W,y+T,y+T+E,E):T-b/2,D="start"===u?V:"center"===u?V-H/2:"end"===u?V-H:o(v,v+H,H,a,m,v+V,v+V+M,M),B=Math.max(0,B+y),D=Math.max(0,D+v);else {B="start"===f?T-l-g:"end"===f?T-d+W+S:"nearest"===f?o(l,d,n,g,W+S,T,T+E,E):T-(l+n/2)+S/2,D="start"===u?V-s-a:"center"===u?V-(s+i/2)+L/2:"end"===u?V-r+m+L:o(s,r,i,a,m+L,V,V+M,M);const{scrollLeft:t,scrollTop:h}=e;B=Math.max(0,Math.min(h+B/Y,e.scrollHeight-n/Y+S)),D=Math.max(0,Math.min(t+D/X,e.scrollWidth-i/X+L)),T+=h-B,V+=t-D;}k.push({el:e,top:B,left:D});}return k};
298
+ const t=t=>"object"==typeof t&&null!=t&&1===t.nodeType,e=(t,e)=>(!e||"hidden"!==t)&&("visible"!==t&&"clip"!==t),n=(t,n)=>{if(t.clientHeight<t.scrollHeight||t.clientWidth<t.scrollWidth){const o=getComputedStyle(t,null);return e(o.overflowY,n)||e(o.overflowX,n)||(t=>{const e=(t=>{if(!t.ownerDocument||!t.ownerDocument.defaultView)return null;try{return t.ownerDocument.defaultView.frameElement}catch(t){return null}})(t);return !!e&&(e.clientHeight<t.scrollHeight||e.clientWidth<t.scrollWidth)})(t)}return !1},o=(t,e,n,o,l,r,i,s)=>r<t&&i>e||r>t&&i<e?0:r<=t&&s<=n||i>=e&&s>=n?r-t-o:i>e&&s<n||r<t&&s>n?i-e+l:0,l=t=>{const e=t.parentElement;return null==e?t.getRootNode().host||null:e},r=(e,r)=>{var i,s,d,h;if("undefined"==typeof document)return [];const{scrollMode:c,block:f,inline:u,boundary:a,skipOverflowHiddenElements:g}=r,p="function"==typeof a?a:t=>t!==a;if(!t(e))throw new TypeError("Invalid target");const m=document.scrollingElement||document.documentElement,w=[];let W=e;for(;t(W)&&p(W);){if(W=l(W),W===m){w.push(W);break}null!=W&&W===document.body&&n(W)&&!n(document.documentElement)||null!=W&&n(W,g)&&w.push(W);}const b=null!=(s=null==(i=window.visualViewport)?void 0:i.width)?s:innerWidth,H=null!=(h=null==(d=window.visualViewport)?void 0:d.height)?h:innerHeight,{scrollX:y,scrollY:M}=window,{height:v,width:E,top:x,right:C,bottom:I,left:R}=e.getBoundingClientRect(),{top:T,right:B,bottom:F,left:V}=(t=>{const e=window.getComputedStyle(t);return {top:parseFloat(e.scrollMarginTop)||0,right:parseFloat(e.scrollMarginRight)||0,bottom:parseFloat(e.scrollMarginBottom)||0,left:parseFloat(e.scrollMarginLeft)||0}})(e);let k="start"===f||"nearest"===f?x-T:"end"===f?I+F:x+v/2-T+F,D="center"===u?R+E/2-V+B:"end"===u?C+B:R-V;const L=[];for(let t=0;t<w.length;t++){const e=w[t],{height:n,width:l,top:r,right:i,bottom:s,left:d}=e.getBoundingClientRect();if("if-needed"===c&&x>=0&&R>=0&&I<=H&&C<=b&&x>=r&&I<=s&&R>=d&&C<=i)return L;const h=getComputedStyle(e),a=parseInt(h.borderLeftWidth,10),g=parseInt(h.borderTopWidth,10),p=parseInt(h.borderRightWidth,10),W=parseInt(h.borderBottomWidth,10);let T=0,B=0;const F="offsetWidth"in e?e.offsetWidth-e.clientWidth-a-p:0,V="offsetHeight"in e?e.offsetHeight-e.clientHeight-g-W:0,S="offsetWidth"in e?0===e.offsetWidth?0:l/e.offsetWidth:0,X="offsetHeight"in e?0===e.offsetHeight?0:n/e.offsetHeight:0;if(m===e)T="start"===f?k:"end"===f?k-H:"nearest"===f?o(M,M+H,H,g,W,M+k,M+k+v,v):k-H/2,B="start"===u?D:"center"===u?D-b/2:"end"===u?D-b:o(y,y+b,b,a,p,y+D,y+D+E,E),T=Math.max(0,T+M),B=Math.max(0,B+y);else {T="start"===f?k-r-g:"end"===f?k-s+W+V:"nearest"===f?o(r,s,n,g,W+V,k,k+v,v):k-(r+n/2)+V/2,B="start"===u?D-d-a:"center"===u?D-(d+l/2)+F/2:"end"===u?D-i+p+F:o(d,i,l,a,p+F,D,D+E,E);const{scrollLeft:t,scrollTop:h}=e;T=0===X?0:Math.max(0,Math.min(h+T/X,e.scrollHeight-n/X+V)),B=0===S?0:Math.max(0,Math.min(t+B/S,e.scrollWidth-l/S+F)),k+=h-T,D+=t-B;}L.push({el:e,top:T,left:B});}return L};
299
299
 
300
300
  var idCounter = 0;
301
301
 
@@ -321,7 +321,7 @@
321
321
  if (!node) {
322
322
  return;
323
323
  }
324
- var actions = l(node, {
324
+ var actions = r(node, {
325
325
  boundary: menuNode,
326
326
  block: 'nearest',
327
327
  scrollMode: 'if-needed'
@@ -1925,11 +1925,11 @@
1925
1925
  * Also calls the onChange handlers for state values that have changed.
1926
1926
  *
1927
1927
  * @param {Function} reducer Reducer function from downshift.
1928
- * @param {Object} initialState Initial state of the hook.
1929
- * @param {Object} props The hook props.
1928
+ * @param {Object} props The hook props, also passed to createInitialState.
1929
+ * @param {Function} createInitialState Function that returns the initial state.
1930
1930
  * @returns {Array} An array with the state and an action dispatcher.
1931
1931
  */
1932
- function useEnhancedReducer(reducer, initialState, props) {
1932
+ function useEnhancedReducer(reducer, props, createInitialState) {
1933
1933
  var prevStateRef = React.useRef();
1934
1934
  var actionRef = React.useRef();
1935
1935
  var enhancedReducer = React.useCallback(function (state, action) {
@@ -1941,7 +1941,7 @@
1941
1941
  }));
1942
1942
  return newState;
1943
1943
  }, [reducer]);
1944
- var _useReducer = React.useReducer(enhancedReducer, initialState),
1944
+ var _useReducer = React.useReducer(enhancedReducer, props, createInitialState),
1945
1945
  state = _useReducer[0],
1946
1946
  dispatch = _useReducer[1];
1947
1947
  var propsRef = useLatestRef(props);
@@ -1965,12 +1965,12 @@
1965
1965
  * returning the new state.
1966
1966
  *
1967
1967
  * @param {Function} reducer Reducer function from downshift.
1968
- * @param {Object} initialState Initial state of the hook.
1969
- * @param {Object} props The hook props.
1968
+ * @param {Object} props The hook props, also passed to createInitialState.
1969
+ * @param {Function} createInitialState Function that returns the initial state.
1970
1970
  * @returns {Array} An array with the state and an action dispatcher.
1971
1971
  */
1972
- function useControlledReducer$1(reducer, initialState, props) {
1973
- var _useEnhancedReducer = useEnhancedReducer(reducer, initialState, props),
1972
+ function useControlledReducer$1(reducer, props, createInitialState) {
1973
+ var _useEnhancedReducer = useEnhancedReducer(reducer, props, createInitialState),
1974
1974
  state = _useEnhancedReducer[0],
1975
1975
  dispatch = _useEnhancedReducer[1];
1976
1976
  return [getState(state, props), dispatch];
@@ -2605,8 +2605,7 @@
2605
2605
  getA11ySelectionMessage = props.getA11ySelectionMessage,
2606
2606
  getA11yStatusMessage = props.getA11yStatusMessage;
2607
2607
  // Initial state depending on controlled props.
2608
- var initialState = getInitialState$2(props);
2609
- var _useControlledReducer = useControlledReducer$1(downshiftSelectReducer, initialState, props),
2608
+ var _useControlledReducer = useControlledReducer$1(downshiftSelectReducer, props, getInitialState$2),
2610
2609
  state = _useControlledReducer[0],
2611
2610
  dispatch = _useControlledReducer[1];
2612
2611
  var isOpen = state.isOpen,
@@ -3089,13 +3088,13 @@
3089
3088
  * compute the rest of the state.
3090
3089
  *
3091
3090
  * @param {Function} reducer Reducer function from downshift.
3092
- * @param {Object} initialState Initial state of the hook.
3093
- * @param {Object} props The hook props.
3091
+ * @param {Object} props The hook props, also passed to createInitialState.
3092
+ * @param {Function} createInitialState Function that returns the initial state.
3094
3093
  * @returns {Array} An array with the state and an action dispatcher.
3095
3094
  */
3096
- function useControlledReducer(reducer, initialState, props) {
3095
+ function useControlledReducer(reducer, props, createInitialState) {
3097
3096
  var previousSelectedItemRef = React.useRef();
3098
- var _useEnhancedReducer = useEnhancedReducer(reducer, initialState, props),
3097
+ var _useEnhancedReducer = useEnhancedReducer(reducer, props, createInitialState),
3099
3098
  state = _useEnhancedReducer[0],
3100
3099
  dispatch = _useEnhancedReducer[1];
3101
3100
 
@@ -3269,8 +3268,7 @@
3269
3268
  getA11ySelectionMessage = props.getA11ySelectionMessage,
3270
3269
  itemToString = props.itemToString;
3271
3270
  // Initial state depending on controlled props.
3272
- var initialState = getInitialState$1(props);
3273
- var _useControlledReducer = useControlledReducer(downshiftUseComboboxReducer, initialState, props),
3271
+ var _useControlledReducer = useControlledReducer(downshiftUseComboboxReducer, props, getInitialState$1),
3274
3272
  state = _useControlledReducer[0],
3275
3273
  dispatch = _useControlledReducer[1];
3276
3274
  var isOpen = state.isOpen,
@@ -3944,7 +3942,7 @@
3944
3942
  keyNavigationPrevious = props.keyNavigationPrevious;
3945
3943
 
3946
3944
  // Reducer init.
3947
- var _useControlledReducer = useControlledReducer$1(downshiftMultipleSelectionReducer, getInitialState(props), props),
3945
+ var _useControlledReducer = useControlledReducer$1(downshiftMultipleSelectionReducer, props, getInitialState),
3948
3946
  state = _useControlledReducer[0],
3949
3947
  dispatch = _useControlledReducer[1];
3950
3948
  var activeIndex = state.activeIndex,