downshift 6.0.16 → 6.1.2
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 +1 -1
- package/dist/downshift.cjs.js +234 -216
- package/dist/downshift.esm.js +234 -216
- package/dist/downshift.native.cjs.js +230 -220
- package/dist/downshift.umd.js +475 -448
- package/dist/downshift.umd.js.map +1 -1
- package/dist/downshift.umd.min.js +26 -2
- package/dist/downshift.umd.min.js.map +1 -1
- package/package.json +24 -24
- package/preact/dist/downshift.cjs.js +234 -216
- package/preact/dist/downshift.esm.js +234 -216
- package/preact/dist/downshift.umd.js +318 -291
- package/preact/dist/downshift.umd.js.map +1 -1
- package/preact/dist/downshift.umd.min.js +12 -3
- package/preact/dist/downshift.umd.min.js.map +1 -1
|
@@ -175,7 +175,7 @@ function resetIdCounter() {
|
|
|
175
175
|
*/
|
|
176
176
|
|
|
177
177
|
|
|
178
|
-
function getA11yStatusMessage(_ref2) {
|
|
178
|
+
function getA11yStatusMessage$1(_ref2) {
|
|
179
179
|
var isOpen = _ref2.isOpen,
|
|
180
180
|
resultCount = _ref2.resultCount,
|
|
181
181
|
previousResultCount = _ref2.previousResultCount;
|
|
@@ -525,7 +525,7 @@ var blurButton = process.env.NODE_ENV !== "production" ? '__autocomplete_blur_bu
|
|
|
525
525
|
var controlledPropUpdatedSelectedItem = process.env.NODE_ENV !== "production" ? '__autocomplete_controlled_prop_updated_selected_item__' : 15;
|
|
526
526
|
var touchEnd = process.env.NODE_ENV !== "production" ? '__autocomplete_touchend__' : 16;
|
|
527
527
|
|
|
528
|
-
var stateChangeTypes = /*#__PURE__*/Object.freeze({
|
|
528
|
+
var stateChangeTypes$3 = /*#__PURE__*/Object.freeze({
|
|
529
529
|
__proto__: null,
|
|
530
530
|
unknown: unknown,
|
|
531
531
|
mouseUp: mouseUp,
|
|
@@ -867,12 +867,16 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
867
867
|
Home: function Home(event) {
|
|
868
868
|
var _this4 = this;
|
|
869
869
|
|
|
870
|
-
event.preventDefault();
|
|
871
|
-
var itemCount = this.getItemCount();
|
|
872
|
-
|
|
873
870
|
var _this$getState3 = this.getState(),
|
|
874
871
|
isOpen = _this$getState3.isOpen;
|
|
875
872
|
|
|
873
|
+
if (!isOpen) {
|
|
874
|
+
return;
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
event.preventDefault();
|
|
878
|
+
var itemCount = this.getItemCount();
|
|
879
|
+
|
|
876
880
|
if (itemCount <= 0 || !isOpen) {
|
|
877
881
|
return;
|
|
878
882
|
} // get next non-disabled starting downwards from 0 if that's disabled.
|
|
@@ -888,12 +892,16 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
888
892
|
End: function End(event) {
|
|
889
893
|
var _this5 = this;
|
|
890
894
|
|
|
891
|
-
event.preventDefault();
|
|
892
|
-
var itemCount = this.getItemCount();
|
|
893
|
-
|
|
894
895
|
var _this$getState4 = this.getState(),
|
|
895
896
|
isOpen = _this$getState4.isOpen;
|
|
896
897
|
|
|
898
|
+
if (!isOpen) {
|
|
899
|
+
return;
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
event.preventDefault();
|
|
903
|
+
var itemCount = this.getItemCount();
|
|
904
|
+
|
|
897
905
|
if (itemCount <= 0 || !isOpen) {
|
|
898
906
|
return;
|
|
899
907
|
} // get next non-disabled starting upwards from last index if that's disabled.
|
|
@@ -909,19 +917,18 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
909
917
|
});
|
|
910
918
|
|
|
911
919
|
_this.getToggleButtonProps = function (_temp3) {
|
|
912
|
-
var _ref3 = _temp3 === void 0 ? {} : _temp3
|
|
913
|
-
|
|
914
|
-
onPress = _ref3.onPress
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
rest = _objectWithoutPropertiesLoose__default['default'](_ref3, ["onClick", "onPress", "onKeyDown", "onKeyUp", "onBlur"]);
|
|
920
|
+
var _ref3 = _temp3 === void 0 ? {} : _temp3;
|
|
921
|
+
_ref3.onClick;
|
|
922
|
+
var onPress = _ref3.onPress;
|
|
923
|
+
_ref3.onKeyDown;
|
|
924
|
+
_ref3.onKeyUp;
|
|
925
|
+
_ref3.onBlur;
|
|
926
|
+
var rest = _objectWithoutPropertiesLoose__default['default'](_ref3, ["onClick", "onPress", "onKeyDown", "onKeyUp", "onBlur"]);
|
|
919
927
|
|
|
920
928
|
var _this$getState5 = _this.getState(),
|
|
921
929
|
isOpen = _this$getState5.isOpen;
|
|
922
930
|
|
|
923
|
-
var enabledEventHandlers =
|
|
924
|
-
/* istanbul ignore next (react-native) */
|
|
931
|
+
var enabledEventHandlers = /* istanbul ignore next (react-native) */
|
|
925
932
|
{
|
|
926
933
|
onPress: callAllEventHandlers(onPress, _this.buttonHandleClick)
|
|
927
934
|
} ;
|
|
@@ -1058,8 +1065,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1058
1065
|
_this.internalSetState({
|
|
1059
1066
|
type: changeInput,
|
|
1060
1067
|
isOpen: true,
|
|
1061
|
-
inputValue:
|
|
1062
|
-
/* istanbul ignore next (react-native) */
|
|
1068
|
+
inputValue: /* istanbul ignore next (react-native) */
|
|
1063
1069
|
event.nativeEvent.text ,
|
|
1064
1070
|
highlightedIndex: _this.props.defaultHighlightedIndex
|
|
1065
1071
|
});
|
|
@@ -1106,9 +1112,9 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1106
1112
|
|
|
1107
1113
|
var _ref7 = _temp7 === void 0 ? {} : _temp7,
|
|
1108
1114
|
onMouseMove = _ref7.onMouseMove,
|
|
1109
|
-
onMouseDown = _ref7.onMouseDown
|
|
1110
|
-
|
|
1111
|
-
onPress = _ref7.onPress,
|
|
1115
|
+
onMouseDown = _ref7.onMouseDown;
|
|
1116
|
+
_ref7.onClick;
|
|
1117
|
+
var onPress = _ref7.onPress,
|
|
1112
1118
|
index = _ref7.index,
|
|
1113
1119
|
_ref7$item = _ref7.item,
|
|
1114
1120
|
item = _ref7$item === void 0 ? process.env.NODE_ENV === 'production' ?
|
|
@@ -1124,11 +1130,9 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1124
1130
|
_this.items[index] = item;
|
|
1125
1131
|
}
|
|
1126
1132
|
|
|
1127
|
-
var onSelectKey =
|
|
1128
|
-
/* istanbul ignore next (react-native) */
|
|
1133
|
+
var onSelectKey = /* istanbul ignore next (react-native) */
|
|
1129
1134
|
'onPress' ;
|
|
1130
|
-
var customClickHandler =
|
|
1131
|
-
/* istanbul ignore next (react-native) */
|
|
1135
|
+
var customClickHandler = /* istanbul ignore next (react-native) */
|
|
1132
1136
|
onPress ;
|
|
1133
1137
|
var enabledEventHandlers = (_enabledEventHandlers = {
|
|
1134
1138
|
// onMouseMove is used over onMouseEnter here. onMouseMove
|
|
@@ -1523,7 +1527,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1523
1527
|
Downshift.defaultProps = {
|
|
1524
1528
|
defaultHighlightedIndex: null,
|
|
1525
1529
|
defaultIsOpen: false,
|
|
1526
|
-
getA11yStatusMessage: getA11yStatusMessage,
|
|
1530
|
+
getA11yStatusMessage: getA11yStatusMessage$1,
|
|
1527
1531
|
itemToString: function itemToString(i) {
|
|
1528
1532
|
if (i == null) {
|
|
1529
1533
|
return '';
|
|
@@ -1554,7 +1558,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1554
1558
|
suppressRefError: false,
|
|
1555
1559
|
scrollIntoView: scrollIntoView
|
|
1556
1560
|
};
|
|
1557
|
-
Downshift.stateChangeTypes = stateChangeTypes;
|
|
1561
|
+
Downshift.stateChangeTypes = stateChangeTypes$3;
|
|
1558
1562
|
return Downshift;
|
|
1559
1563
|
}();
|
|
1560
1564
|
|
|
@@ -1816,7 +1820,7 @@ function useEnhancedReducer(reducer, initialState, props) {
|
|
|
1816
1820
|
*/
|
|
1817
1821
|
|
|
1818
1822
|
|
|
1819
|
-
function useControlledReducer(reducer, initialState, props) {
|
|
1823
|
+
function useControlledReducer$1(reducer, initialState, props) {
|
|
1820
1824
|
var _useEnhancedReducer = useEnhancedReducer(reducer, initialState, props),
|
|
1821
1825
|
state = _useEnhancedReducer[0],
|
|
1822
1826
|
dispatch = _useEnhancedReducer[1];
|
|
@@ -1824,7 +1828,7 @@ function useControlledReducer(reducer, initialState, props) {
|
|
|
1824
1828
|
return [getState(state, props), dispatch];
|
|
1825
1829
|
}
|
|
1826
1830
|
|
|
1827
|
-
var defaultProps = {
|
|
1831
|
+
var defaultProps$3 = {
|
|
1828
1832
|
itemToString: itemToString,
|
|
1829
1833
|
stateReducer: stateReducer,
|
|
1830
1834
|
getA11ySelectionMessage: getA11ySelectionMessage,
|
|
@@ -1835,7 +1839,7 @@ var defaultProps = {
|
|
|
1835
1839
|
? {} : window
|
|
1836
1840
|
};
|
|
1837
1841
|
|
|
1838
|
-
function getDefaultValue(props, propKey, defaultStateValues) {
|
|
1842
|
+
function getDefaultValue$1(props, propKey, defaultStateValues) {
|
|
1839
1843
|
if (defaultStateValues === void 0) {
|
|
1840
1844
|
defaultStateValues = dropdownDefaultStateValues;
|
|
1841
1845
|
}
|
|
@@ -1849,7 +1853,7 @@ function getDefaultValue(props, propKey, defaultStateValues) {
|
|
|
1849
1853
|
return defaultStateValues[propKey];
|
|
1850
1854
|
}
|
|
1851
1855
|
|
|
1852
|
-
function getInitialValue(props, propKey, defaultStateValues) {
|
|
1856
|
+
function getInitialValue$1(props, propKey, defaultStateValues) {
|
|
1853
1857
|
if (defaultStateValues === void 0) {
|
|
1854
1858
|
defaultStateValues = dropdownDefaultStateValues;
|
|
1855
1859
|
}
|
|
@@ -1864,14 +1868,14 @@ function getInitialValue(props, propKey, defaultStateValues) {
|
|
|
1864
1868
|
return props[initialPropKey];
|
|
1865
1869
|
}
|
|
1866
1870
|
|
|
1867
|
-
return getDefaultValue(props, propKey, defaultStateValues);
|
|
1871
|
+
return getDefaultValue$1(props, propKey, defaultStateValues);
|
|
1868
1872
|
}
|
|
1869
1873
|
|
|
1870
|
-
function getInitialState(props) {
|
|
1871
|
-
var selectedItem = getInitialValue(props, 'selectedItem');
|
|
1872
|
-
var isOpen = getInitialValue(props, 'isOpen');
|
|
1873
|
-
var highlightedIndex = getInitialValue(props, 'highlightedIndex');
|
|
1874
|
-
var inputValue = getInitialValue(props, 'inputValue');
|
|
1874
|
+
function getInitialState$2(props) {
|
|
1875
|
+
var selectedItem = getInitialValue$1(props, 'selectedItem');
|
|
1876
|
+
var isOpen = getInitialValue$1(props, 'isOpen');
|
|
1877
|
+
var highlightedIndex = getInitialValue$1(props, 'highlightedIndex');
|
|
1878
|
+
var inputValue = getInitialValue$1(props, 'inputValue');
|
|
1875
1879
|
return {
|
|
1876
1880
|
highlightedIndex: highlightedIndex < 0 && selectedItem && isOpen ? props.items.indexOf(selectedItem) : highlightedIndex,
|
|
1877
1881
|
isOpen: isOpen,
|
|
@@ -2166,10 +2170,10 @@ function downshiftCommonReducer(state, action, stateChangeTypes) {
|
|
|
2166
2170
|
|
|
2167
2171
|
case stateChangeTypes.FunctionReset:
|
|
2168
2172
|
changes = {
|
|
2169
|
-
highlightedIndex: getDefaultValue(props, 'highlightedIndex'),
|
|
2170
|
-
isOpen: getDefaultValue(props, 'isOpen'),
|
|
2171
|
-
selectedItem: getDefaultValue(props, 'selectedItem'),
|
|
2172
|
-
inputValue: getDefaultValue(props, 'inputValue')
|
|
2173
|
+
highlightedIndex: getDefaultValue$1(props, 'highlightedIndex'),
|
|
2174
|
+
isOpen: getDefaultValue$1(props, 'isOpen'),
|
|
2175
|
+
selectedItem: getDefaultValue$1(props, 'selectedItem'),
|
|
2176
|
+
inputValue: getDefaultValue$1(props, 'inputValue')
|
|
2173
2177
|
};
|
|
2174
2178
|
break;
|
|
2175
2179
|
|
|
@@ -2199,7 +2203,7 @@ function getItemIndexByCharacterKey(keysSoFar, highlightedIndex, items, itemToSt
|
|
|
2199
2203
|
return highlightedIndex;
|
|
2200
2204
|
}
|
|
2201
2205
|
|
|
2202
|
-
var propTypes = {
|
|
2206
|
+
var propTypes$2 = {
|
|
2203
2207
|
items: PropTypes__default['default'].array.isRequired,
|
|
2204
2208
|
itemToString: PropTypes__default['default'].func,
|
|
2205
2209
|
getA11yStatusMessage: PropTypes__default['default'].func,
|
|
@@ -2243,7 +2247,7 @@ var propTypes = {
|
|
|
2243
2247
|
* @return {String} the a11y status message
|
|
2244
2248
|
*/
|
|
2245
2249
|
|
|
2246
|
-
function getA11yStatusMessage
|
|
2250
|
+
function getA11yStatusMessage(_ref) {
|
|
2247
2251
|
var isOpen = _ref.isOpen,
|
|
2248
2252
|
resultCount = _ref.resultCount,
|
|
2249
2253
|
previousResultCount = _ref.previousResultCount;
|
|
@@ -2263,17 +2267,17 @@ function getA11yStatusMessage$1(_ref) {
|
|
|
2263
2267
|
return '';
|
|
2264
2268
|
}
|
|
2265
2269
|
|
|
2266
|
-
var defaultProps$
|
|
2267
|
-
getA11yStatusMessage: getA11yStatusMessage
|
|
2270
|
+
var defaultProps$2 = _extends__default['default']({}, defaultProps$3, {
|
|
2271
|
+
getA11yStatusMessage: getA11yStatusMessage
|
|
2268
2272
|
}); // eslint-disable-next-line import/no-mutable-exports
|
|
2269
2273
|
|
|
2270
2274
|
|
|
2271
|
-
var validatePropTypes = noop;
|
|
2275
|
+
var validatePropTypes$2 = noop;
|
|
2272
2276
|
/* istanbul ignore next */
|
|
2273
2277
|
|
|
2274
2278
|
if (process.env.NODE_ENV !== 'production') {
|
|
2275
|
-
validatePropTypes = function validatePropTypes(options, caller) {
|
|
2276
|
-
PropTypes__default['default'].checkPropTypes(propTypes, options, 'prop', caller.name);
|
|
2279
|
+
validatePropTypes$2 = function validatePropTypes(options, caller) {
|
|
2280
|
+
PropTypes__default['default'].checkPropTypes(propTypes$2, options, 'prop', caller.name);
|
|
2277
2281
|
};
|
|
2278
2282
|
}
|
|
2279
2283
|
|
|
@@ -2286,22 +2290,22 @@ var MenuKeyDownEnter = process.env.NODE_ENV !== "production" ? '__menu_keydown_e
|
|
|
2286
2290
|
var MenuKeyDownSpaceButton = process.env.NODE_ENV !== "production" ? '__menu_keydown_space_button__' : 6;
|
|
2287
2291
|
var MenuKeyDownCharacter = process.env.NODE_ENV !== "production" ? '__menu_keydown_character__' : 7;
|
|
2288
2292
|
var MenuBlur = process.env.NODE_ENV !== "production" ? '__menu_blur__' : 8;
|
|
2289
|
-
var MenuMouseLeave = process.env.NODE_ENV !== "production" ? '__menu_mouse_leave__' : 9;
|
|
2290
|
-
var ItemMouseMove = process.env.NODE_ENV !== "production" ? '__item_mouse_move__' : 10;
|
|
2291
|
-
var ItemClick = process.env.NODE_ENV !== "production" ? '__item_click__' : 11;
|
|
2292
|
-
var ToggleButtonClick = process.env.NODE_ENV !== "production" ? '__togglebutton_click__' : 12;
|
|
2293
|
+
var MenuMouseLeave$1 = process.env.NODE_ENV !== "production" ? '__menu_mouse_leave__' : 9;
|
|
2294
|
+
var ItemMouseMove$1 = process.env.NODE_ENV !== "production" ? '__item_mouse_move__' : 10;
|
|
2295
|
+
var ItemClick$1 = process.env.NODE_ENV !== "production" ? '__item_click__' : 11;
|
|
2296
|
+
var ToggleButtonClick$1 = process.env.NODE_ENV !== "production" ? '__togglebutton_click__' : 12;
|
|
2293
2297
|
var ToggleButtonKeyDownArrowDown = process.env.NODE_ENV !== "production" ? '__togglebutton_keydown_arrow_down__' : 13;
|
|
2294
2298
|
var ToggleButtonKeyDownArrowUp = process.env.NODE_ENV !== "production" ? '__togglebutton_keydown_arrow_up__' : 14;
|
|
2295
2299
|
var ToggleButtonKeyDownCharacter = process.env.NODE_ENV !== "production" ? '__togglebutton_keydown_character__' : 15;
|
|
2296
|
-
var FunctionToggleMenu = process.env.NODE_ENV !== "production" ? '__function_toggle_menu__' : 16;
|
|
2297
|
-
var FunctionOpenMenu = process.env.NODE_ENV !== "production" ? '__function_open_menu__' : 17;
|
|
2298
|
-
var FunctionCloseMenu = process.env.NODE_ENV !== "production" ? '__function_close_menu__' : 18;
|
|
2299
|
-
var FunctionSetHighlightedIndex = process.env.NODE_ENV !== "production" ? '__function_set_highlighted_index__' : 19;
|
|
2300
|
-
var FunctionSelectItem = process.env.NODE_ENV !== "production" ? '__function_select_item__' : 20;
|
|
2301
|
-
var FunctionSetInputValue = process.env.NODE_ENV !== "production" ? '__function_set_input_value__' : 21;
|
|
2302
|
-
var FunctionReset = process.env.NODE_ENV !== "production" ? '__function_reset__' : 22;
|
|
2300
|
+
var FunctionToggleMenu$1 = process.env.NODE_ENV !== "production" ? '__function_toggle_menu__' : 16;
|
|
2301
|
+
var FunctionOpenMenu$1 = process.env.NODE_ENV !== "production" ? '__function_open_menu__' : 17;
|
|
2302
|
+
var FunctionCloseMenu$1 = process.env.NODE_ENV !== "production" ? '__function_close_menu__' : 18;
|
|
2303
|
+
var FunctionSetHighlightedIndex$1 = process.env.NODE_ENV !== "production" ? '__function_set_highlighted_index__' : 19;
|
|
2304
|
+
var FunctionSelectItem$1 = process.env.NODE_ENV !== "production" ? '__function_select_item__' : 20;
|
|
2305
|
+
var FunctionSetInputValue$1 = process.env.NODE_ENV !== "production" ? '__function_set_input_value__' : 21;
|
|
2306
|
+
var FunctionReset$2 = process.env.NODE_ENV !== "production" ? '__function_reset__' : 22;
|
|
2303
2307
|
|
|
2304
|
-
var stateChangeTypes$
|
|
2308
|
+
var stateChangeTypes$2 = /*#__PURE__*/Object.freeze({
|
|
2305
2309
|
__proto__: null,
|
|
2306
2310
|
MenuKeyDownArrowDown: MenuKeyDownArrowDown,
|
|
2307
2311
|
MenuKeyDownArrowUp: MenuKeyDownArrowUp,
|
|
@@ -2312,20 +2316,20 @@ var stateChangeTypes$1 = /*#__PURE__*/Object.freeze({
|
|
|
2312
2316
|
MenuKeyDownSpaceButton: MenuKeyDownSpaceButton,
|
|
2313
2317
|
MenuKeyDownCharacter: MenuKeyDownCharacter,
|
|
2314
2318
|
MenuBlur: MenuBlur,
|
|
2315
|
-
MenuMouseLeave: MenuMouseLeave,
|
|
2316
|
-
ItemMouseMove: ItemMouseMove,
|
|
2317
|
-
ItemClick: ItemClick,
|
|
2318
|
-
ToggleButtonClick: ToggleButtonClick,
|
|
2319
|
+
MenuMouseLeave: MenuMouseLeave$1,
|
|
2320
|
+
ItemMouseMove: ItemMouseMove$1,
|
|
2321
|
+
ItemClick: ItemClick$1,
|
|
2322
|
+
ToggleButtonClick: ToggleButtonClick$1,
|
|
2319
2323
|
ToggleButtonKeyDownArrowDown: ToggleButtonKeyDownArrowDown,
|
|
2320
2324
|
ToggleButtonKeyDownArrowUp: ToggleButtonKeyDownArrowUp,
|
|
2321
2325
|
ToggleButtonKeyDownCharacter: ToggleButtonKeyDownCharacter,
|
|
2322
|
-
FunctionToggleMenu: FunctionToggleMenu,
|
|
2323
|
-
FunctionOpenMenu: FunctionOpenMenu,
|
|
2324
|
-
FunctionCloseMenu: FunctionCloseMenu,
|
|
2325
|
-
FunctionSetHighlightedIndex: FunctionSetHighlightedIndex,
|
|
2326
|
-
FunctionSelectItem: FunctionSelectItem,
|
|
2327
|
-
FunctionSetInputValue: FunctionSetInputValue,
|
|
2328
|
-
FunctionReset: FunctionReset
|
|
2326
|
+
FunctionToggleMenu: FunctionToggleMenu$1,
|
|
2327
|
+
FunctionOpenMenu: FunctionOpenMenu$1,
|
|
2328
|
+
FunctionCloseMenu: FunctionCloseMenu$1,
|
|
2329
|
+
FunctionSetHighlightedIndex: FunctionSetHighlightedIndex$1,
|
|
2330
|
+
FunctionSelectItem: FunctionSelectItem$1,
|
|
2331
|
+
FunctionSetInputValue: FunctionSetInputValue$1,
|
|
2332
|
+
FunctionReset: FunctionReset$2
|
|
2329
2333
|
});
|
|
2330
2334
|
|
|
2331
2335
|
/* eslint-disable complexity */
|
|
@@ -2337,10 +2341,10 @@ function downshiftSelectReducer(state, action) {
|
|
|
2337
2341
|
var changes;
|
|
2338
2342
|
|
|
2339
2343
|
switch (type) {
|
|
2340
|
-
case ItemClick:
|
|
2344
|
+
case ItemClick$1:
|
|
2341
2345
|
changes = {
|
|
2342
|
-
isOpen: getDefaultValue(props, 'isOpen'),
|
|
2343
|
-
highlightedIndex: getDefaultValue(props, 'highlightedIndex'),
|
|
2346
|
+
isOpen: getDefaultValue$1(props, 'isOpen'),
|
|
2347
|
+
highlightedIndex: getDefaultValue$1(props, 'highlightedIndex'),
|
|
2344
2348
|
selectedItem: props.items[action.index]
|
|
2345
2349
|
};
|
|
2346
2350
|
break;
|
|
@@ -2375,8 +2379,8 @@ function downshiftSelectReducer(state, action) {
|
|
|
2375
2379
|
case MenuKeyDownEnter:
|
|
2376
2380
|
case MenuKeyDownSpaceButton:
|
|
2377
2381
|
changes = _extends__default['default']({
|
|
2378
|
-
isOpen: getDefaultValue(props, 'isOpen'),
|
|
2379
|
-
highlightedIndex: getDefaultValue(props, 'highlightedIndex')
|
|
2382
|
+
isOpen: getDefaultValue$1(props, 'isOpen'),
|
|
2383
|
+
highlightedIndex: getDefaultValue$1(props, 'highlightedIndex')
|
|
2380
2384
|
}, state.highlightedIndex >= 0 && {
|
|
2381
2385
|
selectedItem: props.items[state.highlightedIndex]
|
|
2382
2386
|
});
|
|
@@ -2435,30 +2439,30 @@ function downshiftSelectReducer(state, action) {
|
|
|
2435
2439
|
};
|
|
2436
2440
|
break;
|
|
2437
2441
|
|
|
2438
|
-
case FunctionSelectItem:
|
|
2442
|
+
case FunctionSelectItem$1:
|
|
2439
2443
|
changes = {
|
|
2440
2444
|
selectedItem: action.selectedItem
|
|
2441
2445
|
};
|
|
2442
2446
|
break;
|
|
2443
2447
|
|
|
2444
2448
|
default:
|
|
2445
|
-
return downshiftCommonReducer(state, action, stateChangeTypes$
|
|
2449
|
+
return downshiftCommonReducer(state, action, stateChangeTypes$2);
|
|
2446
2450
|
}
|
|
2447
2451
|
|
|
2448
2452
|
return _extends__default['default']({}, state, changes);
|
|
2449
2453
|
}
|
|
2450
2454
|
/* eslint-enable complexity */
|
|
2451
2455
|
|
|
2452
|
-
useSelect.stateChangeTypes = stateChangeTypes$
|
|
2456
|
+
useSelect.stateChangeTypes = stateChangeTypes$2;
|
|
2453
2457
|
|
|
2454
2458
|
function useSelect(userProps) {
|
|
2455
2459
|
if (userProps === void 0) {
|
|
2456
2460
|
userProps = {};
|
|
2457
2461
|
}
|
|
2458
2462
|
|
|
2459
|
-
validatePropTypes(userProps, useSelect); // Props defaults and destructuring.
|
|
2463
|
+
validatePropTypes$2(userProps, useSelect); // Props defaults and destructuring.
|
|
2460
2464
|
|
|
2461
|
-
var props = _extends__default['default']({}, defaultProps$
|
|
2465
|
+
var props = _extends__default['default']({}, defaultProps$2, userProps);
|
|
2462
2466
|
|
|
2463
2467
|
var items = props.items,
|
|
2464
2468
|
scrollIntoView = props.scrollIntoView,
|
|
@@ -2469,9 +2473,9 @@ function useSelect(userProps) {
|
|
|
2469
2473
|
getA11ySelectionMessage = props.getA11ySelectionMessage,
|
|
2470
2474
|
getA11yStatusMessage = props.getA11yStatusMessage; // Initial state depending on controlled props.
|
|
2471
2475
|
|
|
2472
|
-
var initialState = getInitialState(props);
|
|
2476
|
+
var initialState = getInitialState$2(props);
|
|
2473
2477
|
|
|
2474
|
-
var _useControlledReducer = useControlledReducer(downshiftSelectReducer, initialState, props),
|
|
2478
|
+
var _useControlledReducer = useControlledReducer$1(downshiftSelectReducer, initialState, props),
|
|
2475
2479
|
state = _useControlledReducer[0],
|
|
2476
2480
|
dispatch = _useControlledReducer[1];
|
|
2477
2481
|
|
|
@@ -2526,19 +2530,23 @@ function useSelect(userProps) {
|
|
|
2526
2530
|
itemRefs: itemRefs,
|
|
2527
2531
|
scrollIntoView: scrollIntoView,
|
|
2528
2532
|
getItemNodeFromIndex: getItemNodeFromIndex
|
|
2529
|
-
}); // Sets cleanup for the keysSoFar after 500ms.
|
|
2533
|
+
}); // Sets cleanup for the keysSoFar callback, debounded after 500ms.
|
|
2530
2534
|
|
|
2531
2535
|
react.useEffect(function () {
|
|
2532
2536
|
// init the clean function here as we need access to dispatch.
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
}, 500);
|
|
2540
|
-
}
|
|
2537
|
+
clearTimeoutRef.current = debounce(function (outerDispatch) {
|
|
2538
|
+
outerDispatch({
|
|
2539
|
+
type: FunctionSetInputValue$1,
|
|
2540
|
+
inputValue: ''
|
|
2541
|
+
});
|
|
2542
|
+
}, 500); // Cancel any pending debounced calls on mount
|
|
2541
2543
|
|
|
2544
|
+
return function () {
|
|
2545
|
+
clearTimeoutRef.current.cancel();
|
|
2546
|
+
};
|
|
2547
|
+
}, []); // Invokes the keysSoFar callback set up above.
|
|
2548
|
+
|
|
2549
|
+
react.useEffect(function () {
|
|
2542
2550
|
if (!inputValue) {
|
|
2543
2551
|
return;
|
|
2544
2552
|
}
|
|
@@ -2682,39 +2690,39 @@ function useSelect(userProps) {
|
|
|
2682
2690
|
|
|
2683
2691
|
var toggleMenu = react.useCallback(function () {
|
|
2684
2692
|
dispatch({
|
|
2685
|
-
type: FunctionToggleMenu
|
|
2693
|
+
type: FunctionToggleMenu$1
|
|
2686
2694
|
});
|
|
2687
2695
|
}, [dispatch]);
|
|
2688
2696
|
var closeMenu = react.useCallback(function () {
|
|
2689
2697
|
dispatch({
|
|
2690
|
-
type: FunctionCloseMenu
|
|
2698
|
+
type: FunctionCloseMenu$1
|
|
2691
2699
|
});
|
|
2692
2700
|
}, [dispatch]);
|
|
2693
2701
|
var openMenu = react.useCallback(function () {
|
|
2694
2702
|
dispatch({
|
|
2695
|
-
type: FunctionOpenMenu
|
|
2703
|
+
type: FunctionOpenMenu$1
|
|
2696
2704
|
});
|
|
2697
2705
|
}, [dispatch]);
|
|
2698
2706
|
var setHighlightedIndex = react.useCallback(function (newHighlightedIndex) {
|
|
2699
2707
|
dispatch({
|
|
2700
|
-
type: FunctionSetHighlightedIndex,
|
|
2708
|
+
type: FunctionSetHighlightedIndex$1,
|
|
2701
2709
|
highlightedIndex: newHighlightedIndex
|
|
2702
2710
|
});
|
|
2703
2711
|
}, [dispatch]);
|
|
2704
2712
|
var selectItem = react.useCallback(function (newSelectedItem) {
|
|
2705
2713
|
dispatch({
|
|
2706
|
-
type: FunctionSelectItem,
|
|
2714
|
+
type: FunctionSelectItem$1,
|
|
2707
2715
|
selectedItem: newSelectedItem
|
|
2708
2716
|
});
|
|
2709
2717
|
}, [dispatch]);
|
|
2710
2718
|
var reset = react.useCallback(function () {
|
|
2711
2719
|
dispatch({
|
|
2712
|
-
type: FunctionReset
|
|
2720
|
+
type: FunctionReset$2
|
|
2713
2721
|
});
|
|
2714
2722
|
}, [dispatch]);
|
|
2715
2723
|
var setInputValue = react.useCallback(function (newInputValue) {
|
|
2716
2724
|
dispatch({
|
|
2717
|
-
type: FunctionSetInputValue,
|
|
2725
|
+
type: FunctionSetInputValue$1,
|
|
2718
2726
|
inputValue: newInputValue
|
|
2719
2727
|
});
|
|
2720
2728
|
}, [dispatch]); // Getter functions.
|
|
@@ -2776,7 +2784,7 @@ function useSelect(userProps) {
|
|
|
2776
2784
|
|
|
2777
2785
|
var menuHandleMouseLeave = function menuHandleMouseLeave() {
|
|
2778
2786
|
dispatch({
|
|
2779
|
-
type: MenuMouseLeave
|
|
2787
|
+
type: MenuMouseLeave$1
|
|
2780
2788
|
});
|
|
2781
2789
|
};
|
|
2782
2790
|
|
|
@@ -2808,7 +2816,7 @@ function useSelect(userProps) {
|
|
|
2808
2816
|
|
|
2809
2817
|
var toggleButtonHandleClick = function toggleButtonHandleClick() {
|
|
2810
2818
|
dispatch({
|
|
2811
|
-
type: ToggleButtonClick
|
|
2819
|
+
type: ToggleButtonClick$1
|
|
2812
2820
|
});
|
|
2813
2821
|
};
|
|
2814
2822
|
|
|
@@ -2862,14 +2870,14 @@ function useSelect(userProps) {
|
|
|
2862
2870
|
|
|
2863
2871
|
shouldScrollRef.current = false;
|
|
2864
2872
|
dispatch({
|
|
2865
|
-
type: ItemMouseMove,
|
|
2873
|
+
type: ItemMouseMove$1,
|
|
2866
2874
|
index: index
|
|
2867
2875
|
});
|
|
2868
2876
|
};
|
|
2869
2877
|
|
|
2870
2878
|
var itemHandleClick = function itemHandleClick() {
|
|
2871
2879
|
dispatch({
|
|
2872
|
-
type: ItemClick,
|
|
2880
|
+
type: ItemClick$1,
|
|
2873
2881
|
index: index
|
|
2874
2882
|
});
|
|
2875
2883
|
};
|
|
@@ -2927,20 +2935,20 @@ var InputKeyDownEnd = process.env.NODE_ENV !== "production" ? '__input_keydown_e
|
|
|
2927
2935
|
var InputKeyDownEnter = process.env.NODE_ENV !== "production" ? '__input_keydown_enter__' : 5;
|
|
2928
2936
|
var InputChange = process.env.NODE_ENV !== "production" ? '__input_change__' : 6;
|
|
2929
2937
|
var InputBlur = process.env.NODE_ENV !== "production" ? '__input_blur__' : 7;
|
|
2930
|
-
var MenuMouseLeave
|
|
2931
|
-
var ItemMouseMove
|
|
2932
|
-
var ItemClick
|
|
2933
|
-
var ToggleButtonClick
|
|
2934
|
-
var FunctionToggleMenu
|
|
2935
|
-
var FunctionOpenMenu
|
|
2936
|
-
var FunctionCloseMenu
|
|
2937
|
-
var FunctionSetHighlightedIndex
|
|
2938
|
-
var FunctionSelectItem
|
|
2939
|
-
var FunctionSetInputValue
|
|
2938
|
+
var MenuMouseLeave = process.env.NODE_ENV !== "production" ? '__menu_mouse_leave__' : 8;
|
|
2939
|
+
var ItemMouseMove = process.env.NODE_ENV !== "production" ? '__item_mouse_move__' : 9;
|
|
2940
|
+
var ItemClick = process.env.NODE_ENV !== "production" ? '__item_click__' : 10;
|
|
2941
|
+
var ToggleButtonClick = process.env.NODE_ENV !== "production" ? '__togglebutton_click__' : 11;
|
|
2942
|
+
var FunctionToggleMenu = process.env.NODE_ENV !== "production" ? '__function_toggle_menu__' : 12;
|
|
2943
|
+
var FunctionOpenMenu = process.env.NODE_ENV !== "production" ? '__function_open_menu__' : 13;
|
|
2944
|
+
var FunctionCloseMenu = process.env.NODE_ENV !== "production" ? '__function_close_menu__' : 14;
|
|
2945
|
+
var FunctionSetHighlightedIndex = process.env.NODE_ENV !== "production" ? '__function_set_highlighted_index__' : 15;
|
|
2946
|
+
var FunctionSelectItem = process.env.NODE_ENV !== "production" ? '__function_select_item__' : 16;
|
|
2947
|
+
var FunctionSetInputValue = process.env.NODE_ENV !== "production" ? '__function_set_input_value__' : 17;
|
|
2940
2948
|
var FunctionReset$1 = process.env.NODE_ENV !== "production" ? '__function_reset__' : 18;
|
|
2941
2949
|
var ControlledPropUpdatedSelectedItem = process.env.NODE_ENV !== "production" ? '__controlled_prop_updated_selected_item__' : 19;
|
|
2942
2950
|
|
|
2943
|
-
var stateChangeTypes$
|
|
2951
|
+
var stateChangeTypes$1 = /*#__PURE__*/Object.freeze({
|
|
2944
2952
|
__proto__: null,
|
|
2945
2953
|
InputKeyDownArrowDown: InputKeyDownArrowDown,
|
|
2946
2954
|
InputKeyDownArrowUp: InputKeyDownArrowUp,
|
|
@@ -2950,22 +2958,22 @@ var stateChangeTypes$2 = /*#__PURE__*/Object.freeze({
|
|
|
2950
2958
|
InputKeyDownEnter: InputKeyDownEnter,
|
|
2951
2959
|
InputChange: InputChange,
|
|
2952
2960
|
InputBlur: InputBlur,
|
|
2953
|
-
MenuMouseLeave: MenuMouseLeave
|
|
2954
|
-
ItemMouseMove: ItemMouseMove
|
|
2955
|
-
ItemClick: ItemClick
|
|
2956
|
-
ToggleButtonClick: ToggleButtonClick
|
|
2957
|
-
FunctionToggleMenu: FunctionToggleMenu
|
|
2958
|
-
FunctionOpenMenu: FunctionOpenMenu
|
|
2959
|
-
FunctionCloseMenu: FunctionCloseMenu
|
|
2960
|
-
FunctionSetHighlightedIndex: FunctionSetHighlightedIndex
|
|
2961
|
-
FunctionSelectItem: FunctionSelectItem
|
|
2962
|
-
FunctionSetInputValue: FunctionSetInputValue
|
|
2961
|
+
MenuMouseLeave: MenuMouseLeave,
|
|
2962
|
+
ItemMouseMove: ItemMouseMove,
|
|
2963
|
+
ItemClick: ItemClick,
|
|
2964
|
+
ToggleButtonClick: ToggleButtonClick,
|
|
2965
|
+
FunctionToggleMenu: FunctionToggleMenu,
|
|
2966
|
+
FunctionOpenMenu: FunctionOpenMenu,
|
|
2967
|
+
FunctionCloseMenu: FunctionCloseMenu,
|
|
2968
|
+
FunctionSetHighlightedIndex: FunctionSetHighlightedIndex,
|
|
2969
|
+
FunctionSelectItem: FunctionSelectItem,
|
|
2970
|
+
FunctionSetInputValue: FunctionSetInputValue,
|
|
2963
2971
|
FunctionReset: FunctionReset$1,
|
|
2964
2972
|
ControlledPropUpdatedSelectedItem: ControlledPropUpdatedSelectedItem
|
|
2965
2973
|
});
|
|
2966
2974
|
|
|
2967
2975
|
function getInitialState$1(props) {
|
|
2968
|
-
var initialState = getInitialState(props);
|
|
2976
|
+
var initialState = getInitialState$2(props);
|
|
2969
2977
|
var selectedItem = initialState.selectedItem;
|
|
2970
2978
|
var inputValue = initialState.inputValue;
|
|
2971
2979
|
|
|
@@ -3031,7 +3039,7 @@ var propTypes$1 = {
|
|
|
3031
3039
|
* @returns {Array} An array with the state and an action dispatcher.
|
|
3032
3040
|
*/
|
|
3033
3041
|
|
|
3034
|
-
function useControlledReducer
|
|
3042
|
+
function useControlledReducer(reducer, initialState, props) {
|
|
3035
3043
|
var previousSelectedItemRef = react.useRef();
|
|
3036
3044
|
|
|
3037
3045
|
var _useEnhancedReducer = useEnhancedReducer(reducer, initialState, props),
|
|
@@ -3064,8 +3072,8 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
3064
3072
|
};
|
|
3065
3073
|
}
|
|
3066
3074
|
|
|
3067
|
-
var defaultProps$
|
|
3068
|
-
getA11yStatusMessage: getA11yStatusMessage,
|
|
3075
|
+
var defaultProps$1 = _extends__default['default']({}, defaultProps$3, {
|
|
3076
|
+
getA11yStatusMessage: getA11yStatusMessage$1,
|
|
3069
3077
|
circularNavigation: true
|
|
3070
3078
|
});
|
|
3071
3079
|
|
|
@@ -3078,10 +3086,10 @@ function downshiftUseComboboxReducer(state, action) {
|
|
|
3078
3086
|
var changes;
|
|
3079
3087
|
|
|
3080
3088
|
switch (type) {
|
|
3081
|
-
case ItemClick
|
|
3089
|
+
case ItemClick:
|
|
3082
3090
|
changes = {
|
|
3083
|
-
isOpen: getDefaultValue(props, 'isOpen'),
|
|
3084
|
-
highlightedIndex: getDefaultValue(props, 'highlightedIndex'),
|
|
3091
|
+
isOpen: getDefaultValue$1(props, 'isOpen'),
|
|
3092
|
+
highlightedIndex: getDefaultValue$1(props, 'highlightedIndex'),
|
|
3085
3093
|
selectedItem: props.items[action.index],
|
|
3086
3094
|
inputValue: props.itemToString(props.items[action.index])
|
|
3087
3095
|
};
|
|
@@ -3095,7 +3103,7 @@ function downshiftUseComboboxReducer(state, action) {
|
|
|
3095
3103
|
} else {
|
|
3096
3104
|
changes = {
|
|
3097
3105
|
highlightedIndex: getHighlightedIndexOnOpen(props, state, 1, action.getItemNodeFromIndex),
|
|
3098
|
-
isOpen:
|
|
3106
|
+
isOpen: props.items.length >= 0
|
|
3099
3107
|
};
|
|
3100
3108
|
}
|
|
3101
3109
|
|
|
@@ -3109,7 +3117,7 @@ function downshiftUseComboboxReducer(state, action) {
|
|
|
3109
3117
|
} else {
|
|
3110
3118
|
changes = {
|
|
3111
3119
|
highlightedIndex: getHighlightedIndexOnOpen(props, state, -1, action.getItemNodeFromIndex),
|
|
3112
|
-
isOpen:
|
|
3120
|
+
isOpen: props.items.length >= 0
|
|
3113
3121
|
};
|
|
3114
3122
|
}
|
|
3115
3123
|
|
|
@@ -3118,8 +3126,8 @@ function downshiftUseComboboxReducer(state, action) {
|
|
|
3118
3126
|
case InputKeyDownEnter:
|
|
3119
3127
|
changes = _extends__default['default']({}, state.isOpen && state.highlightedIndex >= 0 && {
|
|
3120
3128
|
selectedItem: props.items[state.highlightedIndex],
|
|
3121
|
-
isOpen: getDefaultValue(props, 'isOpen'),
|
|
3122
|
-
highlightedIndex: getDefaultValue(props, 'highlightedIndex'),
|
|
3129
|
+
isOpen: getDefaultValue$1(props, 'isOpen'),
|
|
3130
|
+
highlightedIndex: getDefaultValue$1(props, 'highlightedIndex'),
|
|
3123
3131
|
inputValue: props.itemToString(props.items[state.highlightedIndex])
|
|
3124
3132
|
});
|
|
3125
3133
|
break;
|
|
@@ -3135,39 +3143,36 @@ function downshiftUseComboboxReducer(state, action) {
|
|
|
3135
3143
|
break;
|
|
3136
3144
|
|
|
3137
3145
|
case InputKeyDownHome:
|
|
3138
|
-
changes =
|
|
3146
|
+
changes = {
|
|
3139
3147
|
highlightedIndex: getNextNonDisabledIndex(1, 0, props.items.length, action.getItemNodeFromIndex, false)
|
|
3140
|
-
}
|
|
3148
|
+
};
|
|
3141
3149
|
break;
|
|
3142
3150
|
|
|
3143
3151
|
case InputKeyDownEnd:
|
|
3144
|
-
changes =
|
|
3152
|
+
changes = {
|
|
3145
3153
|
highlightedIndex: getNextNonDisabledIndex(-1, props.items.length - 1, props.items.length, action.getItemNodeFromIndex, false)
|
|
3146
|
-
}
|
|
3154
|
+
};
|
|
3147
3155
|
break;
|
|
3148
3156
|
|
|
3149
3157
|
case InputBlur:
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
});
|
|
3158
|
-
}
|
|
3159
|
-
|
|
3158
|
+
changes = _extends__default['default']({
|
|
3159
|
+
isOpen: false,
|
|
3160
|
+
highlightedIndex: -1
|
|
3161
|
+
}, state.highlightedIndex >= 0 && action.selectItem && {
|
|
3162
|
+
selectedItem: props.items[state.highlightedIndex],
|
|
3163
|
+
inputValue: props.itemToString(props.items[state.highlightedIndex])
|
|
3164
|
+
});
|
|
3160
3165
|
break;
|
|
3161
3166
|
|
|
3162
3167
|
case InputChange:
|
|
3163
3168
|
changes = {
|
|
3164
3169
|
isOpen: true,
|
|
3165
|
-
highlightedIndex: getDefaultValue(props, 'highlightedIndex'),
|
|
3170
|
+
highlightedIndex: getDefaultValue$1(props, 'highlightedIndex'),
|
|
3166
3171
|
inputValue: action.inputValue
|
|
3167
3172
|
};
|
|
3168
3173
|
break;
|
|
3169
3174
|
|
|
3170
|
-
case FunctionSelectItem
|
|
3175
|
+
case FunctionSelectItem:
|
|
3171
3176
|
changes = {
|
|
3172
3177
|
selectedItem: action.selectedItem,
|
|
3173
3178
|
inputValue: props.itemToString(action.selectedItem)
|
|
@@ -3181,14 +3186,14 @@ function downshiftUseComboboxReducer(state, action) {
|
|
|
3181
3186
|
break;
|
|
3182
3187
|
|
|
3183
3188
|
default:
|
|
3184
|
-
return downshiftCommonReducer(state, action, stateChangeTypes$
|
|
3189
|
+
return downshiftCommonReducer(state, action, stateChangeTypes$1);
|
|
3185
3190
|
}
|
|
3186
3191
|
|
|
3187
3192
|
return _extends__default['default']({}, state, changes);
|
|
3188
3193
|
}
|
|
3189
3194
|
/* eslint-enable complexity */
|
|
3190
3195
|
|
|
3191
|
-
useCombobox.stateChangeTypes = stateChangeTypes$
|
|
3196
|
+
useCombobox.stateChangeTypes = stateChangeTypes$1;
|
|
3192
3197
|
|
|
3193
3198
|
function useCombobox(userProps) {
|
|
3194
3199
|
if (userProps === void 0) {
|
|
@@ -3197,7 +3202,7 @@ function useCombobox(userProps) {
|
|
|
3197
3202
|
|
|
3198
3203
|
validatePropTypes$1(userProps, useCombobox); // Props defaults and destructuring.
|
|
3199
3204
|
|
|
3200
|
-
var props = _extends__default['default']({}, defaultProps$
|
|
3205
|
+
var props = _extends__default['default']({}, defaultProps$1, userProps);
|
|
3201
3206
|
|
|
3202
3207
|
var initialIsOpen = props.initialIsOpen,
|
|
3203
3208
|
defaultIsOpen = props.defaultIsOpen,
|
|
@@ -3210,7 +3215,7 @@ function useCombobox(userProps) {
|
|
|
3210
3215
|
|
|
3211
3216
|
var initialState = getInitialState$1(props);
|
|
3212
3217
|
|
|
3213
|
-
var _useControlledReducer = useControlledReducer
|
|
3218
|
+
var _useControlledReducer = useControlledReducer(downshiftUseComboboxReducer, initialState, props),
|
|
3214
3219
|
state = _useControlledReducer[0],
|
|
3215
3220
|
dispatch = _useControlledReducer[1];
|
|
3216
3221
|
|
|
@@ -3323,6 +3328,10 @@ function useCombobox(userProps) {
|
|
|
3323
3328
|
});
|
|
3324
3329
|
},
|
|
3325
3330
|
Home: function Home(event) {
|
|
3331
|
+
if (!latest.current.state.isOpen) {
|
|
3332
|
+
return;
|
|
3333
|
+
}
|
|
3334
|
+
|
|
3326
3335
|
event.preventDefault();
|
|
3327
3336
|
dispatch({
|
|
3328
3337
|
type: InputKeyDownHome,
|
|
@@ -3330,6 +3339,10 @@ function useCombobox(userProps) {
|
|
|
3330
3339
|
});
|
|
3331
3340
|
},
|
|
3332
3341
|
End: function End(event) {
|
|
3342
|
+
if (!latest.current.state.isOpen) {
|
|
3343
|
+
return;
|
|
3344
|
+
}
|
|
3345
|
+
|
|
3333
3346
|
event.preventDefault();
|
|
3334
3347
|
dispatch({
|
|
3335
3348
|
type: InputKeyDownEnd,
|
|
@@ -3337,22 +3350,23 @@ function useCombobox(userProps) {
|
|
|
3337
3350
|
});
|
|
3338
3351
|
},
|
|
3339
3352
|
Escape: function Escape() {
|
|
3340
|
-
dispatch({
|
|
3341
|
-
type: InputKeyDownEscape
|
|
3342
|
-
});
|
|
3343
|
-
},
|
|
3344
|
-
Enter: function Enter(event) {
|
|
3345
|
-
// if IME composing, wait for next Enter keydown event.
|
|
3346
|
-
if (event.which === 229) {
|
|
3347
|
-
return;
|
|
3348
|
-
}
|
|
3349
|
-
|
|
3350
3353
|
var latestState = latest.current.state;
|
|
3351
3354
|
|
|
3352
|
-
if (latestState.isOpen) {
|
|
3353
|
-
|
|
3355
|
+
if (latestState.isOpen || latestState.inputValue || latestState.selectedItem || latestState.highlightedIndex > -1) {
|
|
3356
|
+
dispatch({
|
|
3357
|
+
type: InputKeyDownEscape
|
|
3358
|
+
});
|
|
3354
3359
|
}
|
|
3360
|
+
},
|
|
3361
|
+
Enter: function Enter(event) {
|
|
3362
|
+
var latestState = latest.current.state; // if closed or no highlighted index, do nothing.
|
|
3363
|
+
|
|
3364
|
+
if (!latestState.isOpen || latestState.highlightedIndex < 0 || event.which === 229 // if IME composing, wait for next Enter keydown event.
|
|
3365
|
+
) {
|
|
3366
|
+
return;
|
|
3367
|
+
}
|
|
3355
3368
|
|
|
3369
|
+
event.preventDefault();
|
|
3356
3370
|
dispatch({
|
|
3357
3371
|
type: InputKeyDownEnter,
|
|
3358
3372
|
getItemNodeFromIndex: getItemNodeFromIndex
|
|
@@ -3386,7 +3400,7 @@ function useCombobox(userProps) {
|
|
|
3386
3400
|
menuRef.current = menuNode;
|
|
3387
3401
|
}), _extends2.id = elementIds.menuId, _extends2.role = 'listbox', _extends2['aria-labelledby'] = elementIds.labelId, _extends2.onMouseLeave = callAllEventHandlers(onMouseLeave, function () {
|
|
3388
3402
|
dispatch({
|
|
3389
|
-
type: MenuMouseLeave
|
|
3403
|
+
type: MenuMouseLeave
|
|
3390
3404
|
});
|
|
3391
3405
|
}), _extends2), rest);
|
|
3392
3406
|
}, [dispatch, setGetterPropCallInfo, elementIds]);
|
|
@@ -3399,9 +3413,9 @@ function useCombobox(userProps) {
|
|
|
3399
3413
|
_ref3$refKey = _ref3.refKey,
|
|
3400
3414
|
refKey = _ref3$refKey === void 0 ? 'ref' : _ref3$refKey,
|
|
3401
3415
|
ref = _ref3.ref,
|
|
3402
|
-
onMouseMove = _ref3.onMouseMove
|
|
3403
|
-
|
|
3404
|
-
onPress = _ref3.onPress,
|
|
3416
|
+
onMouseMove = _ref3.onMouseMove;
|
|
3417
|
+
_ref3.onClick;
|
|
3418
|
+
var onPress = _ref3.onPress,
|
|
3405
3419
|
rest = _objectWithoutPropertiesLoose__default['default'](_ref3, ["item", "index", "refKey", "ref", "onMouseMove", "onClick", "onPress"]);
|
|
3406
3420
|
|
|
3407
3421
|
var _latest$current = latest.current,
|
|
@@ -3413,11 +3427,9 @@ function useCombobox(userProps) {
|
|
|
3413
3427
|
throw new Error('Pass either item or item index in getItemProps!');
|
|
3414
3428
|
}
|
|
3415
3429
|
|
|
3416
|
-
var onSelectKey =
|
|
3417
|
-
/* istanbul ignore next (react-native) */
|
|
3430
|
+
var onSelectKey = /* istanbul ignore next (react-native) */
|
|
3418
3431
|
'onPress' ;
|
|
3419
|
-
var customClickHandler =
|
|
3420
|
-
/* istanbul ignore next (react-native) */
|
|
3432
|
+
var customClickHandler = /* istanbul ignore next (react-native) */
|
|
3421
3433
|
onPress ;
|
|
3422
3434
|
|
|
3423
3435
|
var itemHandleMouseMove = function itemHandleMouseMove() {
|
|
@@ -3427,14 +3439,14 @@ function useCombobox(userProps) {
|
|
|
3427
3439
|
|
|
3428
3440
|
shouldScrollRef.current = false;
|
|
3429
3441
|
dispatch({
|
|
3430
|
-
type: ItemMouseMove
|
|
3442
|
+
type: ItemMouseMove,
|
|
3431
3443
|
index: index
|
|
3432
3444
|
});
|
|
3433
3445
|
};
|
|
3434
3446
|
|
|
3435
3447
|
var itemHandleClick = function itemHandleClick() {
|
|
3436
3448
|
dispatch({
|
|
3437
|
-
type: ItemClick
|
|
3449
|
+
type: ItemClick,
|
|
3438
3450
|
index: index
|
|
3439
3451
|
});
|
|
3440
3452
|
|
|
@@ -3454,9 +3466,9 @@ function useCombobox(userProps) {
|
|
|
3454
3466
|
var getToggleButtonProps = react.useCallback(function (_temp4) {
|
|
3455
3467
|
var _extends4;
|
|
3456
3468
|
|
|
3457
|
-
var _ref5 = _temp4 === void 0 ? {} : _temp4
|
|
3458
|
-
|
|
3459
|
-
onPress = _ref5.onPress,
|
|
3469
|
+
var _ref5 = _temp4 === void 0 ? {} : _temp4;
|
|
3470
|
+
_ref5.onClick;
|
|
3471
|
+
var onPress = _ref5.onPress,
|
|
3460
3472
|
_ref5$refKey = _ref5.refKey,
|
|
3461
3473
|
refKey = _ref5$refKey === void 0 ? 'ref' : _ref5$refKey,
|
|
3462
3474
|
ref = _ref5.ref,
|
|
@@ -3464,7 +3476,7 @@ function useCombobox(userProps) {
|
|
|
3464
3476
|
|
|
3465
3477
|
var toggleButtonHandleClick = function toggleButtonHandleClick() {
|
|
3466
3478
|
dispatch({
|
|
3467
|
-
type: ToggleButtonClick
|
|
3479
|
+
type: ToggleButtonClick
|
|
3468
3480
|
});
|
|
3469
3481
|
|
|
3470
3482
|
if (!latest.current.state.isOpen && inputRef.current) {
|
|
@@ -3474,8 +3486,7 @@ function useCombobox(userProps) {
|
|
|
3474
3486
|
|
|
3475
3487
|
return _extends__default['default']((_extends4 = {}, _extends4[refKey] = handleRefs(ref, function (toggleButtonNode) {
|
|
3476
3488
|
toggleButtonRef.current = toggleButtonNode;
|
|
3477
|
-
}), _extends4.id = elementIds.toggleButtonId, _extends4.tabIndex = -1, _extends4), !rest.disabled && _extends__default['default']({},
|
|
3478
|
-
/* istanbul ignore next (react-native) */
|
|
3489
|
+
}), _extends4.id = elementIds.toggleButtonId, _extends4.tabIndex = -1, _extends4), !rest.disabled && _extends__default['default']({}, /* istanbul ignore next (react-native) */
|
|
3479
3490
|
{
|
|
3480
3491
|
onPress: callAllEventHandlers(onPress, toggleButtonHandleClick)
|
|
3481
3492
|
} ), rest);
|
|
@@ -3512,15 +3523,14 @@ function useCombobox(userProps) {
|
|
|
3512
3523
|
var inputHandleChange = function inputHandleChange(event) {
|
|
3513
3524
|
dispatch({
|
|
3514
3525
|
type: InputChange,
|
|
3515
|
-
inputValue:
|
|
3516
|
-
/* istanbul ignore next (react-native) */
|
|
3526
|
+
inputValue: /* istanbul ignore next (react-native) */
|
|
3517
3527
|
event.nativeEvent.text
|
|
3518
3528
|
});
|
|
3519
3529
|
};
|
|
3520
3530
|
|
|
3521
3531
|
var inputHandleBlur = function inputHandleBlur() {
|
|
3522
3532
|
/* istanbul ignore else */
|
|
3523
|
-
if (!mouseAndTouchTrackersRef.current.isMouseDown) {
|
|
3533
|
+
if (latestState.isOpen && !mouseAndTouchTrackersRef.current.isMouseDown) {
|
|
3524
3534
|
dispatch({
|
|
3525
3535
|
type: InputBlur,
|
|
3526
3536
|
selectItem: true
|
|
@@ -3530,7 +3540,7 @@ function useCombobox(userProps) {
|
|
|
3530
3540
|
/* istanbul ignore next (preact) */
|
|
3531
3541
|
|
|
3532
3542
|
|
|
3533
|
-
var onChangeKey =
|
|
3543
|
+
var onChangeKey = 'onChange';
|
|
3534
3544
|
var eventHandlers = {};
|
|
3535
3545
|
|
|
3536
3546
|
if (!rest.disabled) {
|
|
@@ -3585,34 +3595,34 @@ function useCombobox(userProps) {
|
|
|
3585
3595
|
|
|
3586
3596
|
var toggleMenu = react.useCallback(function () {
|
|
3587
3597
|
dispatch({
|
|
3588
|
-
type: FunctionToggleMenu
|
|
3598
|
+
type: FunctionToggleMenu
|
|
3589
3599
|
});
|
|
3590
3600
|
}, [dispatch]);
|
|
3591
3601
|
var closeMenu = react.useCallback(function () {
|
|
3592
3602
|
dispatch({
|
|
3593
|
-
type: FunctionCloseMenu
|
|
3603
|
+
type: FunctionCloseMenu
|
|
3594
3604
|
});
|
|
3595
3605
|
}, [dispatch]);
|
|
3596
3606
|
var openMenu = react.useCallback(function () {
|
|
3597
3607
|
dispatch({
|
|
3598
|
-
type: FunctionOpenMenu
|
|
3608
|
+
type: FunctionOpenMenu
|
|
3599
3609
|
});
|
|
3600
3610
|
}, [dispatch]);
|
|
3601
3611
|
var setHighlightedIndex = react.useCallback(function (newHighlightedIndex) {
|
|
3602
3612
|
dispatch({
|
|
3603
|
-
type: FunctionSetHighlightedIndex
|
|
3613
|
+
type: FunctionSetHighlightedIndex,
|
|
3604
3614
|
highlightedIndex: newHighlightedIndex
|
|
3605
3615
|
});
|
|
3606
3616
|
}, [dispatch]);
|
|
3607
3617
|
var selectItem = react.useCallback(function (newSelectedItem) {
|
|
3608
3618
|
dispatch({
|
|
3609
|
-
type: FunctionSelectItem
|
|
3619
|
+
type: FunctionSelectItem,
|
|
3610
3620
|
selectedItem: newSelectedItem
|
|
3611
3621
|
});
|
|
3612
3622
|
}, [dispatch]);
|
|
3613
3623
|
var setInputValue = react.useCallback(function (newInputValue) {
|
|
3614
3624
|
dispatch({
|
|
3615
|
-
type: FunctionSetInputValue
|
|
3625
|
+
type: FunctionSetInputValue,
|
|
3616
3626
|
inputValue: newInputValue
|
|
3617
3627
|
});
|
|
3618
3628
|
}, [dispatch]);
|
|
@@ -3659,8 +3669,8 @@ var defaultStateValues = {
|
|
|
3659
3669
|
* @returns {any} The initial value for that prop.
|
|
3660
3670
|
*/
|
|
3661
3671
|
|
|
3662
|
-
function getInitialValue
|
|
3663
|
-
return getInitialValue(props, propKey, defaultStateValues);
|
|
3672
|
+
function getInitialValue(props, propKey) {
|
|
3673
|
+
return getInitialValue$1(props, propKey, defaultStateValues);
|
|
3664
3674
|
}
|
|
3665
3675
|
/**
|
|
3666
3676
|
* Returns the default value for a state key in the following order:
|
|
@@ -3672,8 +3682,8 @@ function getInitialValue$1(props, propKey) {
|
|
|
3672
3682
|
*/
|
|
3673
3683
|
|
|
3674
3684
|
|
|
3675
|
-
function getDefaultValue
|
|
3676
|
-
return getDefaultValue(props, propKey, defaultStateValues);
|
|
3685
|
+
function getDefaultValue(props, propKey) {
|
|
3686
|
+
return getDefaultValue$1(props, propKey, defaultStateValues);
|
|
3677
3687
|
}
|
|
3678
3688
|
/**
|
|
3679
3689
|
* Gets the initial state based on the provided props. It uses initial, default
|
|
@@ -3684,9 +3694,9 @@ function getDefaultValue$1(props, propKey) {
|
|
|
3684
3694
|
*/
|
|
3685
3695
|
|
|
3686
3696
|
|
|
3687
|
-
function getInitialState
|
|
3688
|
-
var activeIndex = getInitialValue
|
|
3689
|
-
var selectedItems = getInitialValue
|
|
3697
|
+
function getInitialState(props) {
|
|
3698
|
+
var activeIndex = getInitialValue(props, 'activeIndex');
|
|
3699
|
+
var selectedItems = getInitialValue(props, 'selectedItems');
|
|
3690
3700
|
return {
|
|
3691
3701
|
activeIndex: activeIndex,
|
|
3692
3702
|
selectedItems: selectedItems
|
|
@@ -3733,7 +3743,7 @@ function getA11yRemovalMessage(selectionParameters) {
|
|
|
3733
3743
|
return itemToStringLocal(removedSelectedItem) + " has been removed.";
|
|
3734
3744
|
}
|
|
3735
3745
|
|
|
3736
|
-
var propTypes
|
|
3746
|
+
var propTypes = {
|
|
3737
3747
|
selectedItems: PropTypes__default['default'].array,
|
|
3738
3748
|
initialSelectedItems: PropTypes__default['default'].array,
|
|
3739
3749
|
defaultSelectedItems: PropTypes__default['default'].array,
|
|
@@ -3757,21 +3767,21 @@ var propTypes$2 = {
|
|
|
3757
3767
|
})
|
|
3758
3768
|
})
|
|
3759
3769
|
};
|
|
3760
|
-
var defaultProps
|
|
3761
|
-
itemToString: defaultProps.itemToString,
|
|
3762
|
-
stateReducer: defaultProps.stateReducer,
|
|
3763
|
-
environment: defaultProps.environment,
|
|
3770
|
+
var defaultProps = {
|
|
3771
|
+
itemToString: defaultProps$3.itemToString,
|
|
3772
|
+
stateReducer: defaultProps$3.stateReducer,
|
|
3773
|
+
environment: defaultProps$3.environment,
|
|
3764
3774
|
getA11yRemovalMessage: getA11yRemovalMessage,
|
|
3765
3775
|
keyNavigationNext: 'ArrowRight',
|
|
3766
3776
|
keyNavigationPrevious: 'ArrowLeft'
|
|
3767
3777
|
}; // eslint-disable-next-line import/no-mutable-exports
|
|
3768
3778
|
|
|
3769
|
-
var validatePropTypes
|
|
3779
|
+
var validatePropTypes = noop;
|
|
3770
3780
|
/* istanbul ignore next */
|
|
3771
3781
|
|
|
3772
3782
|
if (process.env.NODE_ENV !== 'production') {
|
|
3773
|
-
validatePropTypes
|
|
3774
|
-
PropTypes__default['default'].checkPropTypes(propTypes
|
|
3783
|
+
validatePropTypes = function validatePropTypes(options, caller) {
|
|
3784
|
+
PropTypes__default['default'].checkPropTypes(propTypes, options, 'prop', caller.name);
|
|
3775
3785
|
};
|
|
3776
3786
|
}
|
|
3777
3787
|
|
|
@@ -3787,9 +3797,9 @@ var FunctionAddSelectedItem = process.env.NODE_ENV !== "production" ? '__functio
|
|
|
3787
3797
|
var FunctionRemoveSelectedItem = process.env.NODE_ENV !== "production" ? '__function_remove_selected_item__' : 9;
|
|
3788
3798
|
var FunctionSetSelectedItems = process.env.NODE_ENV !== "production" ? '__function_set_selected_items__' : 10;
|
|
3789
3799
|
var FunctionSetActiveIndex = process.env.NODE_ENV !== "production" ? '__function_set_active_index__' : 11;
|
|
3790
|
-
var FunctionReset
|
|
3800
|
+
var FunctionReset = process.env.NODE_ENV !== "production" ? '__function_reset__' : 12;
|
|
3791
3801
|
|
|
3792
|
-
var stateChangeTypes
|
|
3802
|
+
var stateChangeTypes = /*#__PURE__*/Object.freeze({
|
|
3793
3803
|
__proto__: null,
|
|
3794
3804
|
SelectedItemClick: SelectedItemClick,
|
|
3795
3805
|
SelectedItemKeyDownDelete: SelectedItemKeyDownDelete,
|
|
@@ -3803,7 +3813,7 @@ var stateChangeTypes$3 = /*#__PURE__*/Object.freeze({
|
|
|
3803
3813
|
FunctionRemoveSelectedItem: FunctionRemoveSelectedItem,
|
|
3804
3814
|
FunctionSetSelectedItems: FunctionSetSelectedItems,
|
|
3805
3815
|
FunctionSetActiveIndex: FunctionSetActiveIndex,
|
|
3806
|
-
FunctionReset: FunctionReset
|
|
3816
|
+
FunctionReset: FunctionReset
|
|
3807
3817
|
});
|
|
3808
3818
|
|
|
3809
3819
|
/* eslint-disable complexity */
|
|
@@ -3916,10 +3926,10 @@ function downshiftMultipleSelectionReducer(state, action) {
|
|
|
3916
3926
|
break;
|
|
3917
3927
|
}
|
|
3918
3928
|
|
|
3919
|
-
case FunctionReset
|
|
3929
|
+
case FunctionReset:
|
|
3920
3930
|
changes = {
|
|
3921
|
-
activeIndex: getDefaultValue
|
|
3922
|
-
selectedItems: getDefaultValue
|
|
3931
|
+
activeIndex: getDefaultValue(props, 'activeIndex'),
|
|
3932
|
+
selectedItems: getDefaultValue(props, 'selectedItems')
|
|
3923
3933
|
};
|
|
3924
3934
|
break;
|
|
3925
3935
|
|
|
@@ -3930,16 +3940,16 @@ function downshiftMultipleSelectionReducer(state, action) {
|
|
|
3930
3940
|
return _extends__default['default']({}, state, changes);
|
|
3931
3941
|
}
|
|
3932
3942
|
|
|
3933
|
-
useMultipleSelection.stateChangeTypes = stateChangeTypes
|
|
3943
|
+
useMultipleSelection.stateChangeTypes = stateChangeTypes;
|
|
3934
3944
|
|
|
3935
3945
|
function useMultipleSelection(userProps) {
|
|
3936
3946
|
if (userProps === void 0) {
|
|
3937
3947
|
userProps = {};
|
|
3938
3948
|
}
|
|
3939
3949
|
|
|
3940
|
-
validatePropTypes
|
|
3950
|
+
validatePropTypes(userProps, useMultipleSelection); // Props defaults and destructuring.
|
|
3941
3951
|
|
|
3942
|
-
var props = _extends__default['default']({}, defaultProps
|
|
3952
|
+
var props = _extends__default['default']({}, defaultProps, userProps);
|
|
3943
3953
|
|
|
3944
3954
|
var getA11yRemovalMessage = props.getA11yRemovalMessage,
|
|
3945
3955
|
itemToString = props.itemToString,
|
|
@@ -3947,7 +3957,7 @@ function useMultipleSelection(userProps) {
|
|
|
3947
3957
|
keyNavigationNext = props.keyNavigationNext,
|
|
3948
3958
|
keyNavigationPrevious = props.keyNavigationPrevious; // Reducer init.
|
|
3949
3959
|
|
|
3950
|
-
var _useControlledReducer = useControlledReducer(downshiftMultipleSelectionReducer, getInitialState
|
|
3960
|
+
var _useControlledReducer = useControlledReducer$1(downshiftMultipleSelectionReducer, getInitialState(props), props),
|
|
3951
3961
|
state = _useControlledReducer[0],
|
|
3952
3962
|
dispatch = _useControlledReducer[1];
|
|
3953
3963
|
|
|
@@ -4158,7 +4168,7 @@ function useMultipleSelection(userProps) {
|
|
|
4158
4168
|
}, [dispatch]);
|
|
4159
4169
|
var reset = react.useCallback(function () {
|
|
4160
4170
|
dispatch({
|
|
4161
|
-
type: FunctionReset
|
|
4171
|
+
type: FunctionReset
|
|
4162
4172
|
});
|
|
4163
4173
|
}, [dispatch]);
|
|
4164
4174
|
return {
|