downshift 5.0.1 → 5.0.5
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.
- package/README.md +2 -0
- package/dist/downshift.cjs.js +29 -29
- package/dist/downshift.esm.js +29 -29
- package/dist/downshift.native.cjs.js +29 -29
- package/dist/downshift.umd.js +29 -29
- package/dist/downshift.umd.js.map +1 -1
- package/dist/downshift.umd.min.js +1 -1
- package/dist/downshift.umd.min.js.map +1 -1
- package/package.json +1 -1
- package/preact/dist/downshift.cjs.js +29 -29
- package/preact/dist/downshift.esm.js +29 -29
- package/preact/dist/downshift.umd.js +29 -29
- package/preact/dist/downshift.umd.js.map +1 -1
- package/preact/dist/downshift.umd.min.js +1 -1
- package/preact/dist/downshift.umd.min.js.map +1 -1
package/README.md
CHANGED
|
@@ -1388,6 +1388,8 @@ Thanks goes to these people ([emoji key][emojis]):
|
|
|
1388
1388
|
<tr>
|
|
1389
1389
|
<td align="center"><a href="https://kubajastrz.com"><img src="https://avatars0.githubusercontent.com/u/6443113?v=4" width="100px;" alt=""/><br /><sub><b>Jakub Jastrzębski</b></sub></a><br /><a href="https://github.com/downshift-js/downshift/commits?author=KubaJastrz" title="Code">💻</a></td>
|
|
1390
1390
|
<td align="center"><a href="https://github.com/mufasa71"><img src="https://avatars1.githubusercontent.com/u/626420?v=4" width="100px;" alt=""/><br /><sub><b>Shukhrat Mukimov</b></sub></a><br /><a href="https://github.com/downshift-js/downshift/commits?author=mufasa71" title="Code">💻</a></td>
|
|
1391
|
+
<td align="center"><a href="http://jhonnymoreira.dev"><img src="https://avatars0.githubusercontent.com/u/2177742?v=4" width="100px;" alt=""/><br /><sub><b>Jhonny Moreira</b></sub></a><br /><a href="https://github.com/downshift-js/downshift/commits?author=jhonnymoreira" title="Code">💻</a></td>
|
|
1392
|
+
<td align="center"><a href="https://github.com/stefanprobst"><img src="https://avatars0.githubusercontent.com/u/20753323?v=4" width="100px;" alt=""/><br /><sub><b>stefanprobst</b></sub></a><br /><a href="https://github.com/downshift-js/downshift/commits?author=stefanprobst" title="Code">💻</a> <a href="https://github.com/downshift-js/downshift/commits?author=stefanprobst" title="Tests">⚠️</a></td>
|
|
1391
1393
|
</tr>
|
|
1392
1394
|
</table>
|
|
1393
1395
|
|
package/dist/downshift.cjs.js
CHANGED
|
@@ -1735,8 +1735,7 @@ function getPropTypesValidator(caller, propTypes) {
|
|
|
1735
1735
|
options = {};
|
|
1736
1736
|
}
|
|
1737
1737
|
|
|
1738
|
-
Object.
|
|
1739
|
-
var key = _ref2[0];
|
|
1738
|
+
Object.keys(propTypes).forEach(function (key) {
|
|
1740
1739
|
PropTypes.checkPropTypes(propTypes, options, key, caller.name);
|
|
1741
1740
|
});
|
|
1742
1741
|
};
|
|
@@ -1750,21 +1749,30 @@ function capitalizeString(string) {
|
|
|
1750
1749
|
return "" + string.slice(0, 1).toUpperCase() + string.slice(1);
|
|
1751
1750
|
}
|
|
1752
1751
|
|
|
1753
|
-
function invokeOnChangeHandler(
|
|
1754
|
-
var handler = "on" + capitalizeString(
|
|
1752
|
+
function invokeOnChangeHandler(key, props, state, newState) {
|
|
1753
|
+
var handler = "on" + capitalizeString(key) + "Change";
|
|
1755
1754
|
|
|
1756
|
-
if (props[handler] &&
|
|
1757
|
-
props[handler](
|
|
1755
|
+
if (props[handler] && newState[key] !== undefined && newState[key] !== state[key]) {
|
|
1756
|
+
props[handler](newState);
|
|
1758
1757
|
}
|
|
1759
1758
|
}
|
|
1760
1759
|
|
|
1761
|
-
function callOnChangeProps(
|
|
1762
|
-
|
|
1763
|
-
|
|
1760
|
+
function callOnChangeProps(action, state, newState) {
|
|
1761
|
+
var props = action.props,
|
|
1762
|
+
type = action.type;
|
|
1763
|
+
var changes = {};
|
|
1764
|
+
Object.keys(state).forEach(function (key) {
|
|
1765
|
+
invokeOnChangeHandler(key, props, state, newState);
|
|
1766
|
+
|
|
1767
|
+
if (newState[key] !== state[key]) {
|
|
1768
|
+
changes[key] = newState[key];
|
|
1769
|
+
}
|
|
1764
1770
|
});
|
|
1765
1771
|
|
|
1766
|
-
if (props.onStateChange && changes
|
|
1767
|
-
props.onStateChange(
|
|
1772
|
+
if (props.onStateChange && Object.keys(changes).length) {
|
|
1773
|
+
props.onStateChange(_extends({
|
|
1774
|
+
type: type
|
|
1775
|
+
}, changes));
|
|
1768
1776
|
}
|
|
1769
1777
|
}
|
|
1770
1778
|
|
|
@@ -1776,7 +1784,7 @@ function useEnhancedReducer(reducer, initialState, props) {
|
|
|
1776
1784
|
var newState = stateReduceLocal(state, _extends({}, action, {
|
|
1777
1785
|
changes: changes
|
|
1778
1786
|
}));
|
|
1779
|
-
callOnChangeProps(action
|
|
1787
|
+
callOnChangeProps(action, state, newState);
|
|
1780
1788
|
return newState;
|
|
1781
1789
|
}, [reducer]);
|
|
1782
1790
|
|
|
@@ -1784,7 +1792,11 @@ function useEnhancedReducer(reducer, initialState, props) {
|
|
|
1784
1792
|
state = _useReducer[0],
|
|
1785
1793
|
dispatch = _useReducer[1];
|
|
1786
1794
|
|
|
1787
|
-
return [getState(state, props),
|
|
1795
|
+
return [getState(state, props), function dispatchWithProps(action) {
|
|
1796
|
+
return dispatch(_extends({
|
|
1797
|
+
props: props
|
|
1798
|
+
}, action));
|
|
1799
|
+
}];
|
|
1788
1800
|
}
|
|
1789
1801
|
/**
|
|
1790
1802
|
* Default state reducer that returns the changes.
|
|
@@ -2244,13 +2256,7 @@ function useSelect(userProps) {
|
|
|
2244
2256
|
highlightedIndex = _useEnhancedReducer$.highlightedIndex,
|
|
2245
2257
|
selectedItem = _useEnhancedReducer$.selectedItem,
|
|
2246
2258
|
inputValue = _useEnhancedReducer$.inputValue,
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
var dispatch = function (action) {
|
|
2250
|
-
return dispatchWithoutProps(_extends({
|
|
2251
|
-
props: props
|
|
2252
|
-
}, action));
|
|
2253
|
-
};
|
|
2259
|
+
dispatch = _useEnhancedReducer[1];
|
|
2254
2260
|
/* Refs */
|
|
2255
2261
|
|
|
2256
2262
|
|
|
@@ -2605,7 +2611,7 @@ function useSelect(userProps) {
|
|
|
2605
2611
|
|
|
2606
2612
|
return _extends((_extends2 = {}, _extends2[refKey] = handleRefs(ref, function (menuNode) {
|
|
2607
2613
|
menuRef.current = menuNode;
|
|
2608
|
-
}), _extends2.id = elementIds.current.menuId, _extends2.role = 'listbox', _extends2['aria-labelledby'] = elementIds.current.labelId, _extends2.tabIndex = -1, _extends2), highlightedIndex > -1 && {
|
|
2614
|
+
}), _extends2.id = elementIds.current.menuId, _extends2.role = 'listbox', _extends2['aria-labelledby'] = elementIds.current.labelId, _extends2.tabIndex = -1, _extends2), isOpen && highlightedIndex > -1 && {
|
|
2609
2615
|
'aria-activedescendant': elementIds.current.getItemId(highlightedIndex)
|
|
2610
2616
|
}, {
|
|
2611
2617
|
onMouseLeave: callAllEventHandlers(onMouseLeave, menuHandleMouseLeave),
|
|
@@ -3008,13 +3014,7 @@ function useCombobox(userProps) {
|
|
|
3008
3014
|
highlightedIndex = _useEnhancedReducer$.highlightedIndex,
|
|
3009
3015
|
selectedItem = _useEnhancedReducer$.selectedItem,
|
|
3010
3016
|
inputValue = _useEnhancedReducer$.inputValue,
|
|
3011
|
-
|
|
3012
|
-
|
|
3013
|
-
var dispatch = function (action) {
|
|
3014
|
-
return dispatchWithoutProps(_extends({
|
|
3015
|
-
props: props
|
|
3016
|
-
}, action));
|
|
3017
|
-
};
|
|
3017
|
+
dispatch = _useEnhancedReducer[1];
|
|
3018
3018
|
/* Refs */
|
|
3019
3019
|
|
|
3020
3020
|
|
|
@@ -3356,7 +3356,7 @@ function useCombobox(userProps) {
|
|
|
3356
3356
|
|
|
3357
3357
|
return _extends((_extends5 = {}, _extends5[refKey] = handleRefs(ref, function (inputNode) {
|
|
3358
3358
|
inputRef.current = inputNode;
|
|
3359
|
-
}), _extends5.id = elementIds.current.inputId, _extends5['aria-autocomplete'] = 'list', _extends5['aria-controls'] = elementIds.current.menuId, _extends5), highlightedIndex > -1 && {
|
|
3359
|
+
}), _extends5.id = elementIds.current.inputId, _extends5['aria-autocomplete'] = 'list', _extends5['aria-controls'] = elementIds.current.menuId, _extends5), isOpen && highlightedIndex > -1 && {
|
|
3360
3360
|
'aria-activedescendant': elementIds.current.getItemId(highlightedIndex)
|
|
3361
3361
|
}, {
|
|
3362
3362
|
'aria-labelledby': elementIds.current.labelId,
|
package/dist/downshift.esm.js
CHANGED
|
@@ -1729,8 +1729,7 @@ function getPropTypesValidator(caller, propTypes) {
|
|
|
1729
1729
|
options = {};
|
|
1730
1730
|
}
|
|
1731
1731
|
|
|
1732
|
-
Object.
|
|
1733
|
-
var key = _ref2[0];
|
|
1732
|
+
Object.keys(propTypes).forEach(function (key) {
|
|
1734
1733
|
PropTypes.checkPropTypes(propTypes, options, key, caller.name);
|
|
1735
1734
|
});
|
|
1736
1735
|
};
|
|
@@ -1744,21 +1743,30 @@ function capitalizeString(string) {
|
|
|
1744
1743
|
return "" + string.slice(0, 1).toUpperCase() + string.slice(1);
|
|
1745
1744
|
}
|
|
1746
1745
|
|
|
1747
|
-
function invokeOnChangeHandler(
|
|
1748
|
-
var handler = "on" + capitalizeString(
|
|
1746
|
+
function invokeOnChangeHandler(key, props, state, newState) {
|
|
1747
|
+
var handler = "on" + capitalizeString(key) + "Change";
|
|
1749
1748
|
|
|
1750
|
-
if (props[handler] &&
|
|
1751
|
-
props[handler](
|
|
1749
|
+
if (props[handler] && newState[key] !== undefined && newState[key] !== state[key]) {
|
|
1750
|
+
props[handler](newState);
|
|
1752
1751
|
}
|
|
1753
1752
|
}
|
|
1754
1753
|
|
|
1755
|
-
function callOnChangeProps(
|
|
1756
|
-
|
|
1757
|
-
|
|
1754
|
+
function callOnChangeProps(action, state, newState) {
|
|
1755
|
+
var props = action.props,
|
|
1756
|
+
type = action.type;
|
|
1757
|
+
var changes = {};
|
|
1758
|
+
Object.keys(state).forEach(function (key) {
|
|
1759
|
+
invokeOnChangeHandler(key, props, state, newState);
|
|
1760
|
+
|
|
1761
|
+
if (newState[key] !== state[key]) {
|
|
1762
|
+
changes[key] = newState[key];
|
|
1763
|
+
}
|
|
1758
1764
|
});
|
|
1759
1765
|
|
|
1760
|
-
if (props.onStateChange && changes
|
|
1761
|
-
props.onStateChange(
|
|
1766
|
+
if (props.onStateChange && Object.keys(changes).length) {
|
|
1767
|
+
props.onStateChange(_extends({
|
|
1768
|
+
type: type
|
|
1769
|
+
}, changes));
|
|
1762
1770
|
}
|
|
1763
1771
|
}
|
|
1764
1772
|
|
|
@@ -1770,7 +1778,7 @@ function useEnhancedReducer(reducer, initialState, props) {
|
|
|
1770
1778
|
var newState = stateReduceLocal(state, _extends({}, action, {
|
|
1771
1779
|
changes: changes
|
|
1772
1780
|
}));
|
|
1773
|
-
callOnChangeProps(action
|
|
1781
|
+
callOnChangeProps(action, state, newState);
|
|
1774
1782
|
return newState;
|
|
1775
1783
|
}, [reducer]);
|
|
1776
1784
|
|
|
@@ -1778,7 +1786,11 @@ function useEnhancedReducer(reducer, initialState, props) {
|
|
|
1778
1786
|
state = _useReducer[0],
|
|
1779
1787
|
dispatch = _useReducer[1];
|
|
1780
1788
|
|
|
1781
|
-
return [getState(state, props),
|
|
1789
|
+
return [getState(state, props), function dispatchWithProps(action) {
|
|
1790
|
+
return dispatch(_extends({
|
|
1791
|
+
props: props
|
|
1792
|
+
}, action));
|
|
1793
|
+
}];
|
|
1782
1794
|
}
|
|
1783
1795
|
/**
|
|
1784
1796
|
* Default state reducer that returns the changes.
|
|
@@ -2238,13 +2250,7 @@ function useSelect(userProps) {
|
|
|
2238
2250
|
highlightedIndex = _useEnhancedReducer$.highlightedIndex,
|
|
2239
2251
|
selectedItem = _useEnhancedReducer$.selectedItem,
|
|
2240
2252
|
inputValue = _useEnhancedReducer$.inputValue,
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
var dispatch = function (action) {
|
|
2244
|
-
return dispatchWithoutProps(_extends({
|
|
2245
|
-
props: props
|
|
2246
|
-
}, action));
|
|
2247
|
-
};
|
|
2253
|
+
dispatch = _useEnhancedReducer[1];
|
|
2248
2254
|
/* Refs */
|
|
2249
2255
|
|
|
2250
2256
|
|
|
@@ -2599,7 +2605,7 @@ function useSelect(userProps) {
|
|
|
2599
2605
|
|
|
2600
2606
|
return _extends((_extends2 = {}, _extends2[refKey] = handleRefs(ref, function (menuNode) {
|
|
2601
2607
|
menuRef.current = menuNode;
|
|
2602
|
-
}), _extends2.id = elementIds.current.menuId, _extends2.role = 'listbox', _extends2['aria-labelledby'] = elementIds.current.labelId, _extends2.tabIndex = -1, _extends2), highlightedIndex > -1 && {
|
|
2608
|
+
}), _extends2.id = elementIds.current.menuId, _extends2.role = 'listbox', _extends2['aria-labelledby'] = elementIds.current.labelId, _extends2.tabIndex = -1, _extends2), isOpen && highlightedIndex > -1 && {
|
|
2603
2609
|
'aria-activedescendant': elementIds.current.getItemId(highlightedIndex)
|
|
2604
2610
|
}, {
|
|
2605
2611
|
onMouseLeave: callAllEventHandlers(onMouseLeave, menuHandleMouseLeave),
|
|
@@ -3002,13 +3008,7 @@ function useCombobox(userProps) {
|
|
|
3002
3008
|
highlightedIndex = _useEnhancedReducer$.highlightedIndex,
|
|
3003
3009
|
selectedItem = _useEnhancedReducer$.selectedItem,
|
|
3004
3010
|
inputValue = _useEnhancedReducer$.inputValue,
|
|
3005
|
-
|
|
3006
|
-
|
|
3007
|
-
var dispatch = function (action) {
|
|
3008
|
-
return dispatchWithoutProps(_extends({
|
|
3009
|
-
props: props
|
|
3010
|
-
}, action));
|
|
3011
|
-
};
|
|
3011
|
+
dispatch = _useEnhancedReducer[1];
|
|
3012
3012
|
/* Refs */
|
|
3013
3013
|
|
|
3014
3014
|
|
|
@@ -3350,7 +3350,7 @@ function useCombobox(userProps) {
|
|
|
3350
3350
|
|
|
3351
3351
|
return _extends((_extends5 = {}, _extends5[refKey] = handleRefs(ref, function (inputNode) {
|
|
3352
3352
|
inputRef.current = inputNode;
|
|
3353
|
-
}), _extends5.id = elementIds.current.inputId, _extends5['aria-autocomplete'] = 'list', _extends5['aria-controls'] = elementIds.current.menuId, _extends5), highlightedIndex > -1 && {
|
|
3353
|
+
}), _extends5.id = elementIds.current.inputId, _extends5['aria-autocomplete'] = 'list', _extends5['aria-controls'] = elementIds.current.menuId, _extends5), isOpen && highlightedIndex > -1 && {
|
|
3354
3354
|
'aria-activedescendant': elementIds.current.getItemId(highlightedIndex)
|
|
3355
3355
|
}, {
|
|
3356
3356
|
'aria-labelledby': elementIds.current.labelId,
|
|
@@ -1668,8 +1668,7 @@ function getPropTypesValidator(caller, propTypes) {
|
|
|
1668
1668
|
options = {};
|
|
1669
1669
|
}
|
|
1670
1670
|
|
|
1671
|
-
Object.
|
|
1672
|
-
var key = _ref2[0];
|
|
1671
|
+
Object.keys(propTypes).forEach(function (key) {
|
|
1673
1672
|
PropTypes.checkPropTypes(propTypes, options, key, caller.name);
|
|
1674
1673
|
});
|
|
1675
1674
|
};
|
|
@@ -1683,21 +1682,30 @@ function capitalizeString(string) {
|
|
|
1683
1682
|
return "" + string.slice(0, 1).toUpperCase() + string.slice(1);
|
|
1684
1683
|
}
|
|
1685
1684
|
|
|
1686
|
-
function invokeOnChangeHandler(
|
|
1687
|
-
var handler = "on" + capitalizeString(
|
|
1685
|
+
function invokeOnChangeHandler(key, props, state, newState) {
|
|
1686
|
+
var handler = "on" + capitalizeString(key) + "Change";
|
|
1688
1687
|
|
|
1689
|
-
if (props[handler] &&
|
|
1690
|
-
props[handler](
|
|
1688
|
+
if (props[handler] && newState[key] !== undefined && newState[key] !== state[key]) {
|
|
1689
|
+
props[handler](newState);
|
|
1691
1690
|
}
|
|
1692
1691
|
}
|
|
1693
1692
|
|
|
1694
|
-
function callOnChangeProps(
|
|
1695
|
-
|
|
1696
|
-
|
|
1693
|
+
function callOnChangeProps(action, state, newState) {
|
|
1694
|
+
var props = action.props,
|
|
1695
|
+
type = action.type;
|
|
1696
|
+
var changes = {};
|
|
1697
|
+
Object.keys(state).forEach(function (key) {
|
|
1698
|
+
invokeOnChangeHandler(key, props, state, newState);
|
|
1699
|
+
|
|
1700
|
+
if (newState[key] !== state[key]) {
|
|
1701
|
+
changes[key] = newState[key];
|
|
1702
|
+
}
|
|
1697
1703
|
});
|
|
1698
1704
|
|
|
1699
|
-
if (props.onStateChange && changes
|
|
1700
|
-
props.onStateChange(
|
|
1705
|
+
if (props.onStateChange && Object.keys(changes).length) {
|
|
1706
|
+
props.onStateChange(_extends({
|
|
1707
|
+
type: type
|
|
1708
|
+
}, changes));
|
|
1701
1709
|
}
|
|
1702
1710
|
}
|
|
1703
1711
|
|
|
@@ -1709,7 +1717,7 @@ function useEnhancedReducer(reducer, initialState, props) {
|
|
|
1709
1717
|
var newState = stateReduceLocal(state, _extends({}, action, {
|
|
1710
1718
|
changes: changes
|
|
1711
1719
|
}));
|
|
1712
|
-
callOnChangeProps(action
|
|
1720
|
+
callOnChangeProps(action, state, newState);
|
|
1713
1721
|
return newState;
|
|
1714
1722
|
}, [reducer]);
|
|
1715
1723
|
|
|
@@ -1717,7 +1725,11 @@ function useEnhancedReducer(reducer, initialState, props) {
|
|
|
1717
1725
|
state = _useReducer[0],
|
|
1718
1726
|
dispatch = _useReducer[1];
|
|
1719
1727
|
|
|
1720
|
-
return [getState(state, props),
|
|
1728
|
+
return [getState(state, props), function dispatchWithProps(action) {
|
|
1729
|
+
return dispatch(_extends({
|
|
1730
|
+
props: props
|
|
1731
|
+
}, action));
|
|
1732
|
+
}];
|
|
1721
1733
|
}
|
|
1722
1734
|
/**
|
|
1723
1735
|
* Default state reducer that returns the changes.
|
|
@@ -2177,13 +2189,7 @@ function useSelect(userProps) {
|
|
|
2177
2189
|
highlightedIndex = _useEnhancedReducer$.highlightedIndex,
|
|
2178
2190
|
selectedItem = _useEnhancedReducer$.selectedItem,
|
|
2179
2191
|
inputValue = _useEnhancedReducer$.inputValue,
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
var dispatch = function (action) {
|
|
2183
|
-
return dispatchWithoutProps(_extends({
|
|
2184
|
-
props: props
|
|
2185
|
-
}, action));
|
|
2186
|
-
};
|
|
2192
|
+
dispatch = _useEnhancedReducer[1];
|
|
2187
2193
|
/* Refs */
|
|
2188
2194
|
|
|
2189
2195
|
|
|
@@ -2538,7 +2544,7 @@ function useSelect(userProps) {
|
|
|
2538
2544
|
|
|
2539
2545
|
return _extends((_extends2 = {}, _extends2[refKey] = handleRefs(ref, function (menuNode) {
|
|
2540
2546
|
menuRef.current = menuNode;
|
|
2541
|
-
}), _extends2.id = elementIds.current.menuId, _extends2.role = 'listbox', _extends2['aria-labelledby'] = elementIds.current.labelId, _extends2.tabIndex = -1, _extends2), highlightedIndex > -1 && {
|
|
2547
|
+
}), _extends2.id = elementIds.current.menuId, _extends2.role = 'listbox', _extends2['aria-labelledby'] = elementIds.current.labelId, _extends2.tabIndex = -1, _extends2), isOpen && highlightedIndex > -1 && {
|
|
2542
2548
|
'aria-activedescendant': elementIds.current.getItemId(highlightedIndex)
|
|
2543
2549
|
}, {
|
|
2544
2550
|
onMouseLeave: callAllEventHandlers(onMouseLeave, menuHandleMouseLeave),
|
|
@@ -2941,13 +2947,7 @@ function useCombobox(userProps) {
|
|
|
2941
2947
|
highlightedIndex = _useEnhancedReducer$.highlightedIndex,
|
|
2942
2948
|
selectedItem = _useEnhancedReducer$.selectedItem,
|
|
2943
2949
|
inputValue = _useEnhancedReducer$.inputValue,
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
var dispatch = function (action) {
|
|
2947
|
-
return dispatchWithoutProps(_extends({
|
|
2948
|
-
props: props
|
|
2949
|
-
}, action));
|
|
2950
|
-
};
|
|
2950
|
+
dispatch = _useEnhancedReducer[1];
|
|
2951
2951
|
/* Refs */
|
|
2952
2952
|
|
|
2953
2953
|
|
|
@@ -3303,7 +3303,7 @@ function useCombobox(userProps) {
|
|
|
3303
3303
|
});
|
|
3304
3304
|
return _extends((_extends5 = {}, _extends5[refKey] = handleRefs(ref, function (inputNode) {
|
|
3305
3305
|
inputRef.current = inputNode;
|
|
3306
|
-
}), _extends5.id = elementIds.current.inputId, _extends5['aria-autocomplete'] = 'list', _extends5['aria-controls'] = elementIds.current.menuId, _extends5), highlightedIndex > -1 && {
|
|
3306
|
+
}), _extends5.id = elementIds.current.inputId, _extends5['aria-autocomplete'] = 'list', _extends5['aria-controls'] = elementIds.current.menuId, _extends5), isOpen && highlightedIndex > -1 && {
|
|
3307
3307
|
'aria-activedescendant': elementIds.current.getItemId(highlightedIndex)
|
|
3308
3308
|
}, {
|
|
3309
3309
|
'aria-labelledby': elementIds.current.labelId,
|
package/dist/downshift.umd.js
CHANGED
|
@@ -3235,8 +3235,7 @@
|
|
|
3235
3235
|
options = {};
|
|
3236
3236
|
}
|
|
3237
3237
|
|
|
3238
|
-
Object.
|
|
3239
|
-
var key = _ref2[0];
|
|
3238
|
+
Object.keys(propTypes$1).forEach(function (key) {
|
|
3240
3239
|
propTypes.checkPropTypes(propTypes$1, options, key, caller.name);
|
|
3241
3240
|
});
|
|
3242
3241
|
};
|
|
@@ -3250,21 +3249,30 @@
|
|
|
3250
3249
|
return "" + string.slice(0, 1).toUpperCase() + string.slice(1);
|
|
3251
3250
|
}
|
|
3252
3251
|
|
|
3253
|
-
function invokeOnChangeHandler(
|
|
3254
|
-
var handler = "on" + capitalizeString(
|
|
3252
|
+
function invokeOnChangeHandler(key, props, state, newState) {
|
|
3253
|
+
var handler = "on" + capitalizeString(key) + "Change";
|
|
3255
3254
|
|
|
3256
|
-
if (props[handler] &&
|
|
3257
|
-
props[handler](
|
|
3255
|
+
if (props[handler] && newState[key] !== undefined && newState[key] !== state[key]) {
|
|
3256
|
+
props[handler](newState);
|
|
3258
3257
|
}
|
|
3259
3258
|
}
|
|
3260
3259
|
|
|
3261
|
-
function callOnChangeProps(
|
|
3262
|
-
|
|
3263
|
-
|
|
3260
|
+
function callOnChangeProps(action, state, newState) {
|
|
3261
|
+
var props = action.props,
|
|
3262
|
+
type = action.type;
|
|
3263
|
+
var changes = {};
|
|
3264
|
+
Object.keys(state).forEach(function (key) {
|
|
3265
|
+
invokeOnChangeHandler(key, props, state, newState);
|
|
3266
|
+
|
|
3267
|
+
if (newState[key] !== state[key]) {
|
|
3268
|
+
changes[key] = newState[key];
|
|
3269
|
+
}
|
|
3264
3270
|
});
|
|
3265
3271
|
|
|
3266
|
-
if (props.onStateChange && changes
|
|
3267
|
-
props.onStateChange(
|
|
3272
|
+
if (props.onStateChange && Object.keys(changes).length) {
|
|
3273
|
+
props.onStateChange(_extends({
|
|
3274
|
+
type: type
|
|
3275
|
+
}, changes));
|
|
3268
3276
|
}
|
|
3269
3277
|
}
|
|
3270
3278
|
|
|
@@ -3276,7 +3284,7 @@
|
|
|
3276
3284
|
var newState = stateReduceLocal(state, _extends({}, action, {
|
|
3277
3285
|
changes: changes
|
|
3278
3286
|
}));
|
|
3279
|
-
callOnChangeProps(action
|
|
3287
|
+
callOnChangeProps(action, state, newState);
|
|
3280
3288
|
return newState;
|
|
3281
3289
|
}, [reducer]);
|
|
3282
3290
|
|
|
@@ -3284,7 +3292,11 @@
|
|
|
3284
3292
|
state = _useReducer[0],
|
|
3285
3293
|
dispatch = _useReducer[1];
|
|
3286
3294
|
|
|
3287
|
-
return [getState(state, props),
|
|
3295
|
+
return [getState(state, props), function dispatchWithProps(action) {
|
|
3296
|
+
return dispatch(_extends({
|
|
3297
|
+
props: props
|
|
3298
|
+
}, action));
|
|
3299
|
+
}];
|
|
3288
3300
|
}
|
|
3289
3301
|
/**
|
|
3290
3302
|
* Default state reducer that returns the changes.
|
|
@@ -3739,13 +3751,7 @@
|
|
|
3739
3751
|
highlightedIndex = _useEnhancedReducer$.highlightedIndex,
|
|
3740
3752
|
selectedItem = _useEnhancedReducer$.selectedItem,
|
|
3741
3753
|
inputValue = _useEnhancedReducer$.inputValue,
|
|
3742
|
-
|
|
3743
|
-
|
|
3744
|
-
var dispatch = function (action) {
|
|
3745
|
-
return dispatchWithoutProps(_extends({
|
|
3746
|
-
props: props
|
|
3747
|
-
}, action));
|
|
3748
|
-
};
|
|
3754
|
+
dispatch = _useEnhancedReducer[1];
|
|
3749
3755
|
/* Refs */
|
|
3750
3756
|
|
|
3751
3757
|
|
|
@@ -4100,7 +4106,7 @@
|
|
|
4100
4106
|
|
|
4101
4107
|
return _extends((_extends2 = {}, _extends2[refKey] = handleRefs(ref, function (menuNode) {
|
|
4102
4108
|
menuRef.current = menuNode;
|
|
4103
|
-
}), _extends2.id = elementIds.current.menuId, _extends2.role = 'listbox', _extends2['aria-labelledby'] = elementIds.current.labelId, _extends2.tabIndex = -1, _extends2), highlightedIndex > -1 && {
|
|
4109
|
+
}), _extends2.id = elementIds.current.menuId, _extends2.role = 'listbox', _extends2['aria-labelledby'] = elementIds.current.labelId, _extends2.tabIndex = -1, _extends2), isOpen && highlightedIndex > -1 && {
|
|
4104
4110
|
'aria-activedescendant': elementIds.current.getItemId(highlightedIndex)
|
|
4105
4111
|
}, {
|
|
4106
4112
|
onMouseLeave: callAllEventHandlers(onMouseLeave, menuHandleMouseLeave),
|
|
@@ -4498,13 +4504,7 @@
|
|
|
4498
4504
|
highlightedIndex = _useEnhancedReducer$.highlightedIndex,
|
|
4499
4505
|
selectedItem = _useEnhancedReducer$.selectedItem,
|
|
4500
4506
|
inputValue = _useEnhancedReducer$.inputValue,
|
|
4501
|
-
|
|
4502
|
-
|
|
4503
|
-
var dispatch = function (action) {
|
|
4504
|
-
return dispatchWithoutProps(_extends({
|
|
4505
|
-
props: props
|
|
4506
|
-
}, action));
|
|
4507
|
-
};
|
|
4507
|
+
dispatch = _useEnhancedReducer[1];
|
|
4508
4508
|
/* Refs */
|
|
4509
4509
|
|
|
4510
4510
|
|
|
@@ -4846,7 +4846,7 @@
|
|
|
4846
4846
|
|
|
4847
4847
|
return _extends((_extends5 = {}, _extends5[refKey] = handleRefs(ref, function (inputNode) {
|
|
4848
4848
|
inputRef.current = inputNode;
|
|
4849
|
-
}), _extends5.id = elementIds.current.inputId, _extends5['aria-autocomplete'] = 'list', _extends5['aria-controls'] = elementIds.current.menuId, _extends5), highlightedIndex > -1 && {
|
|
4849
|
+
}), _extends5.id = elementIds.current.inputId, _extends5['aria-autocomplete'] = 'list', _extends5['aria-controls'] = elementIds.current.menuId, _extends5), isOpen && highlightedIndex > -1 && {
|
|
4850
4850
|
'aria-activedescendant': elementIds.current.getItemId(highlightedIndex)
|
|
4851
4851
|
}, {
|
|
4852
4852
|
'aria-labelledby': elementIds.current.labelId,
|