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
package/dist/downshift.cjs.js
CHANGED
|
@@ -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.
|
|
@@ -910,9 +918,9 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
910
918
|
|
|
911
919
|
_this.getToggleButtonProps = function (_temp3) {
|
|
912
920
|
var _ref3 = _temp3 === void 0 ? {} : _temp3,
|
|
913
|
-
onClick = _ref3.onClick
|
|
914
|
-
|
|
915
|
-
onKeyDown = _ref3.onKeyDown,
|
|
921
|
+
onClick = _ref3.onClick;
|
|
922
|
+
_ref3.onPress;
|
|
923
|
+
var onKeyDown = _ref3.onKeyDown,
|
|
916
924
|
onKeyUp = _ref3.onKeyUp,
|
|
917
925
|
onBlur = _ref3.onBlur,
|
|
918
926
|
rest = _objectWithoutPropertiesLoose__default['default'](_ref3, ["onClick", "onPress", "onKeyDown", "onKeyUp", "onBlur"]);
|
|
@@ -920,7 +928,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
920
928
|
var _this$getState5 = _this.getState(),
|
|
921
929
|
isOpen = _this$getState5.isOpen;
|
|
922
930
|
|
|
923
|
-
var enabledEventHandlers =
|
|
931
|
+
var enabledEventHandlers = {
|
|
924
932
|
onClick: callAllEventHandlers(onClick, _this.buttonHandleClick),
|
|
925
933
|
onKeyDown: callAllEventHandlers(onKeyDown, _this.buttonHandleKeyDown),
|
|
926
934
|
onKeyUp: callAllEventHandlers(onKeyUp, _this.buttonHandleKeyUp),
|
|
@@ -955,7 +963,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
955
963
|
|
|
956
964
|
/* istanbul ignore if (can't reasonably test this) */
|
|
957
965
|
|
|
958
|
-
if (
|
|
966
|
+
if (_this.props.environment.document.activeElement === _this.props.environment.document.body) {
|
|
959
967
|
event.target.focus();
|
|
960
968
|
} // to simplify testing components that use downshift, we'll not wrap this in a setTimeout
|
|
961
969
|
// if the NODE_ENV is test. With the proper build system, this should be dead code eliminated
|
|
@@ -1002,9 +1010,9 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1002
1010
|
onKeyDown = _ref4.onKeyDown,
|
|
1003
1011
|
onBlur = _ref4.onBlur,
|
|
1004
1012
|
onChange = _ref4.onChange,
|
|
1005
|
-
onInput = _ref4.onInput
|
|
1006
|
-
|
|
1007
|
-
rest = _objectWithoutPropertiesLoose__default['default'](_ref4, ["onKeyDown", "onBlur", "onChange", "onInput", "onChangeText"]);
|
|
1013
|
+
onInput = _ref4.onInput;
|
|
1014
|
+
_ref4.onChangeText;
|
|
1015
|
+
var rest = _objectWithoutPropertiesLoose__default['default'](_ref4, ["onKeyDown", "onBlur", "onChange", "onInput", "onChangeText"]);
|
|
1008
1016
|
|
|
1009
1017
|
var onChangeKey;
|
|
1010
1018
|
var eventHandlers = {};
|
|
@@ -1050,7 +1058,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1050
1058
|
_this.internalSetState({
|
|
1051
1059
|
type: changeInput,
|
|
1052
1060
|
isOpen: true,
|
|
1053
|
-
inputValue:
|
|
1061
|
+
inputValue: event.target.value,
|
|
1054
1062
|
highlightedIndex: _this.props.defaultHighlightedIndex
|
|
1055
1063
|
});
|
|
1056
1064
|
};
|
|
@@ -1097,9 +1105,9 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1097
1105
|
var _ref7 = _temp7 === void 0 ? {} : _temp7,
|
|
1098
1106
|
onMouseMove = _ref7.onMouseMove,
|
|
1099
1107
|
onMouseDown = _ref7.onMouseDown,
|
|
1100
|
-
onClick = _ref7.onClick
|
|
1101
|
-
|
|
1102
|
-
index = _ref7.index,
|
|
1108
|
+
onClick = _ref7.onClick;
|
|
1109
|
+
_ref7.onPress;
|
|
1110
|
+
var index = _ref7.index,
|
|
1103
1111
|
_ref7$item = _ref7.item,
|
|
1104
1112
|
item = _ref7$item === void 0 ? process.env.NODE_ENV === 'production' ?
|
|
1105
1113
|
/* istanbul ignore next */
|
|
@@ -1114,8 +1122,8 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1114
1122
|
_this.items[index] = item;
|
|
1115
1123
|
}
|
|
1116
1124
|
|
|
1117
|
-
var onSelectKey =
|
|
1118
|
-
var customClickHandler =
|
|
1125
|
+
var onSelectKey = 'onClick';
|
|
1126
|
+
var customClickHandler = onClick;
|
|
1119
1127
|
var enabledEventHandlers = (_enabledEventHandlers = {
|
|
1120
1128
|
// onMouseMove is used over onMouseEnter here. onMouseMove
|
|
1121
1129
|
// is only triggered on actual mouse movement while onMouseEnter
|
|
@@ -1505,7 +1513,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1505
1513
|
validateControlledUnchanged(this.state, prevProps, this.props);
|
|
1506
1514
|
/* istanbul ignore if (react-native) */
|
|
1507
1515
|
|
|
1508
|
-
if (
|
|
1516
|
+
if (this.getMenuProps.called && !this.getMenuProps.suppressRefError) {
|
|
1509
1517
|
validateGetMenuPropsCalledCorrectly(this._menuNode, this.getMenuProps);
|
|
1510
1518
|
}
|
|
1511
1519
|
}
|
|
@@ -1590,7 +1598,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1590
1598
|
Downshift.defaultProps = {
|
|
1591
1599
|
defaultHighlightedIndex: null,
|
|
1592
1600
|
defaultIsOpen: false,
|
|
1593
|
-
getA11yStatusMessage: getA11yStatusMessage,
|
|
1601
|
+
getA11yStatusMessage: getA11yStatusMessage$1,
|
|
1594
1602
|
itemToString: function itemToString(i) {
|
|
1595
1603
|
if (i == null) {
|
|
1596
1604
|
return '';
|
|
@@ -1621,7 +1629,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1621
1629
|
suppressRefError: false,
|
|
1622
1630
|
scrollIntoView: scrollIntoView
|
|
1623
1631
|
};
|
|
1624
|
-
Downshift.stateChangeTypes = stateChangeTypes;
|
|
1632
|
+
Downshift.stateChangeTypes = stateChangeTypes$3;
|
|
1625
1633
|
return Downshift;
|
|
1626
1634
|
}();
|
|
1627
1635
|
|
|
@@ -1883,7 +1891,7 @@ function useEnhancedReducer(reducer, initialState, props) {
|
|
|
1883
1891
|
*/
|
|
1884
1892
|
|
|
1885
1893
|
|
|
1886
|
-
function useControlledReducer(reducer, initialState, props) {
|
|
1894
|
+
function useControlledReducer$1(reducer, initialState, props) {
|
|
1887
1895
|
var _useEnhancedReducer = useEnhancedReducer(reducer, initialState, props),
|
|
1888
1896
|
state = _useEnhancedReducer[0],
|
|
1889
1897
|
dispatch = _useEnhancedReducer[1];
|
|
@@ -1891,7 +1899,7 @@ function useControlledReducer(reducer, initialState, props) {
|
|
|
1891
1899
|
return [getState(state, props), dispatch];
|
|
1892
1900
|
}
|
|
1893
1901
|
|
|
1894
|
-
var defaultProps = {
|
|
1902
|
+
var defaultProps$3 = {
|
|
1895
1903
|
itemToString: itemToString,
|
|
1896
1904
|
stateReducer: stateReducer,
|
|
1897
1905
|
getA11ySelectionMessage: getA11ySelectionMessage,
|
|
@@ -1902,7 +1910,7 @@ var defaultProps = {
|
|
|
1902
1910
|
? {} : window
|
|
1903
1911
|
};
|
|
1904
1912
|
|
|
1905
|
-
function getDefaultValue(props, propKey, defaultStateValues) {
|
|
1913
|
+
function getDefaultValue$1(props, propKey, defaultStateValues) {
|
|
1906
1914
|
if (defaultStateValues === void 0) {
|
|
1907
1915
|
defaultStateValues = dropdownDefaultStateValues;
|
|
1908
1916
|
}
|
|
@@ -1916,7 +1924,7 @@ function getDefaultValue(props, propKey, defaultStateValues) {
|
|
|
1916
1924
|
return defaultStateValues[propKey];
|
|
1917
1925
|
}
|
|
1918
1926
|
|
|
1919
|
-
function getInitialValue(props, propKey, defaultStateValues) {
|
|
1927
|
+
function getInitialValue$1(props, propKey, defaultStateValues) {
|
|
1920
1928
|
if (defaultStateValues === void 0) {
|
|
1921
1929
|
defaultStateValues = dropdownDefaultStateValues;
|
|
1922
1930
|
}
|
|
@@ -1931,14 +1939,14 @@ function getInitialValue(props, propKey, defaultStateValues) {
|
|
|
1931
1939
|
return props[initialPropKey];
|
|
1932
1940
|
}
|
|
1933
1941
|
|
|
1934
|
-
return getDefaultValue(props, propKey, defaultStateValues);
|
|
1942
|
+
return getDefaultValue$1(props, propKey, defaultStateValues);
|
|
1935
1943
|
}
|
|
1936
1944
|
|
|
1937
|
-
function getInitialState(props) {
|
|
1938
|
-
var selectedItem = getInitialValue(props, 'selectedItem');
|
|
1939
|
-
var isOpen = getInitialValue(props, 'isOpen');
|
|
1940
|
-
var highlightedIndex = getInitialValue(props, 'highlightedIndex');
|
|
1941
|
-
var inputValue = getInitialValue(props, 'inputValue');
|
|
1945
|
+
function getInitialState$2(props) {
|
|
1946
|
+
var selectedItem = getInitialValue$1(props, 'selectedItem');
|
|
1947
|
+
var isOpen = getInitialValue$1(props, 'isOpen');
|
|
1948
|
+
var highlightedIndex = getInitialValue$1(props, 'highlightedIndex');
|
|
1949
|
+
var inputValue = getInitialValue$1(props, 'inputValue');
|
|
1942
1950
|
return {
|
|
1943
1951
|
highlightedIndex: highlightedIndex < 0 && selectedItem && isOpen ? props.items.indexOf(selectedItem) : highlightedIndex,
|
|
1944
1952
|
isOpen: isOpen,
|
|
@@ -2233,10 +2241,10 @@ function downshiftCommonReducer(state, action, stateChangeTypes) {
|
|
|
2233
2241
|
|
|
2234
2242
|
case stateChangeTypes.FunctionReset:
|
|
2235
2243
|
changes = {
|
|
2236
|
-
highlightedIndex: getDefaultValue(props, 'highlightedIndex'),
|
|
2237
|
-
isOpen: getDefaultValue(props, 'isOpen'),
|
|
2238
|
-
selectedItem: getDefaultValue(props, 'selectedItem'),
|
|
2239
|
-
inputValue: getDefaultValue(props, 'inputValue')
|
|
2244
|
+
highlightedIndex: getDefaultValue$1(props, 'highlightedIndex'),
|
|
2245
|
+
isOpen: getDefaultValue$1(props, 'isOpen'),
|
|
2246
|
+
selectedItem: getDefaultValue$1(props, 'selectedItem'),
|
|
2247
|
+
inputValue: getDefaultValue$1(props, 'inputValue')
|
|
2240
2248
|
};
|
|
2241
2249
|
break;
|
|
2242
2250
|
|
|
@@ -2266,7 +2274,7 @@ function getItemIndexByCharacterKey(keysSoFar, highlightedIndex, items, itemToSt
|
|
|
2266
2274
|
return highlightedIndex;
|
|
2267
2275
|
}
|
|
2268
2276
|
|
|
2269
|
-
var propTypes = {
|
|
2277
|
+
var propTypes$2 = {
|
|
2270
2278
|
items: PropTypes__default['default'].array.isRequired,
|
|
2271
2279
|
itemToString: PropTypes__default['default'].func,
|
|
2272
2280
|
getA11yStatusMessage: PropTypes__default['default'].func,
|
|
@@ -2310,7 +2318,7 @@ var propTypes = {
|
|
|
2310
2318
|
* @return {String} the a11y status message
|
|
2311
2319
|
*/
|
|
2312
2320
|
|
|
2313
|
-
function getA11yStatusMessage
|
|
2321
|
+
function getA11yStatusMessage(_ref) {
|
|
2314
2322
|
var isOpen = _ref.isOpen,
|
|
2315
2323
|
resultCount = _ref.resultCount,
|
|
2316
2324
|
previousResultCount = _ref.previousResultCount;
|
|
@@ -2330,17 +2338,17 @@ function getA11yStatusMessage$1(_ref) {
|
|
|
2330
2338
|
return '';
|
|
2331
2339
|
}
|
|
2332
2340
|
|
|
2333
|
-
var defaultProps$
|
|
2334
|
-
getA11yStatusMessage: getA11yStatusMessage
|
|
2341
|
+
var defaultProps$2 = _extends__default['default']({}, defaultProps$3, {
|
|
2342
|
+
getA11yStatusMessage: getA11yStatusMessage
|
|
2335
2343
|
}); // eslint-disable-next-line import/no-mutable-exports
|
|
2336
2344
|
|
|
2337
2345
|
|
|
2338
|
-
var validatePropTypes = noop;
|
|
2346
|
+
var validatePropTypes$2 = noop;
|
|
2339
2347
|
/* istanbul ignore next */
|
|
2340
2348
|
|
|
2341
2349
|
if (process.env.NODE_ENV !== 'production') {
|
|
2342
|
-
validatePropTypes = function validatePropTypes(options, caller) {
|
|
2343
|
-
PropTypes__default['default'].checkPropTypes(propTypes, options, 'prop', caller.name);
|
|
2350
|
+
validatePropTypes$2 = function validatePropTypes(options, caller) {
|
|
2351
|
+
PropTypes__default['default'].checkPropTypes(propTypes$2, options, 'prop', caller.name);
|
|
2344
2352
|
};
|
|
2345
2353
|
}
|
|
2346
2354
|
|
|
@@ -2353,22 +2361,22 @@ var MenuKeyDownEnter = process.env.NODE_ENV !== "production" ? '__menu_keydown_e
|
|
|
2353
2361
|
var MenuKeyDownSpaceButton = process.env.NODE_ENV !== "production" ? '__menu_keydown_space_button__' : 6;
|
|
2354
2362
|
var MenuKeyDownCharacter = process.env.NODE_ENV !== "production" ? '__menu_keydown_character__' : 7;
|
|
2355
2363
|
var MenuBlur = process.env.NODE_ENV !== "production" ? '__menu_blur__' : 8;
|
|
2356
|
-
var MenuMouseLeave = process.env.NODE_ENV !== "production" ? '__menu_mouse_leave__' : 9;
|
|
2357
|
-
var ItemMouseMove = process.env.NODE_ENV !== "production" ? '__item_mouse_move__' : 10;
|
|
2358
|
-
var ItemClick = process.env.NODE_ENV !== "production" ? '__item_click__' : 11;
|
|
2359
|
-
var ToggleButtonClick = process.env.NODE_ENV !== "production" ? '__togglebutton_click__' : 12;
|
|
2364
|
+
var MenuMouseLeave$1 = process.env.NODE_ENV !== "production" ? '__menu_mouse_leave__' : 9;
|
|
2365
|
+
var ItemMouseMove$1 = process.env.NODE_ENV !== "production" ? '__item_mouse_move__' : 10;
|
|
2366
|
+
var ItemClick$1 = process.env.NODE_ENV !== "production" ? '__item_click__' : 11;
|
|
2367
|
+
var ToggleButtonClick$1 = process.env.NODE_ENV !== "production" ? '__togglebutton_click__' : 12;
|
|
2360
2368
|
var ToggleButtonKeyDownArrowDown = process.env.NODE_ENV !== "production" ? '__togglebutton_keydown_arrow_down__' : 13;
|
|
2361
2369
|
var ToggleButtonKeyDownArrowUp = process.env.NODE_ENV !== "production" ? '__togglebutton_keydown_arrow_up__' : 14;
|
|
2362
2370
|
var ToggleButtonKeyDownCharacter = process.env.NODE_ENV !== "production" ? '__togglebutton_keydown_character__' : 15;
|
|
2363
|
-
var FunctionToggleMenu = process.env.NODE_ENV !== "production" ? '__function_toggle_menu__' : 16;
|
|
2364
|
-
var FunctionOpenMenu = process.env.NODE_ENV !== "production" ? '__function_open_menu__' : 17;
|
|
2365
|
-
var FunctionCloseMenu = process.env.NODE_ENV !== "production" ? '__function_close_menu__' : 18;
|
|
2366
|
-
var FunctionSetHighlightedIndex = process.env.NODE_ENV !== "production" ? '__function_set_highlighted_index__' : 19;
|
|
2367
|
-
var FunctionSelectItem = process.env.NODE_ENV !== "production" ? '__function_select_item__' : 20;
|
|
2368
|
-
var FunctionSetInputValue = process.env.NODE_ENV !== "production" ? '__function_set_input_value__' : 21;
|
|
2369
|
-
var FunctionReset = process.env.NODE_ENV !== "production" ? '__function_reset__' : 22;
|
|
2371
|
+
var FunctionToggleMenu$1 = process.env.NODE_ENV !== "production" ? '__function_toggle_menu__' : 16;
|
|
2372
|
+
var FunctionOpenMenu$1 = process.env.NODE_ENV !== "production" ? '__function_open_menu__' : 17;
|
|
2373
|
+
var FunctionCloseMenu$1 = process.env.NODE_ENV !== "production" ? '__function_close_menu__' : 18;
|
|
2374
|
+
var FunctionSetHighlightedIndex$1 = process.env.NODE_ENV !== "production" ? '__function_set_highlighted_index__' : 19;
|
|
2375
|
+
var FunctionSelectItem$1 = process.env.NODE_ENV !== "production" ? '__function_select_item__' : 20;
|
|
2376
|
+
var FunctionSetInputValue$1 = process.env.NODE_ENV !== "production" ? '__function_set_input_value__' : 21;
|
|
2377
|
+
var FunctionReset$2 = process.env.NODE_ENV !== "production" ? '__function_reset__' : 22;
|
|
2370
2378
|
|
|
2371
|
-
var stateChangeTypes$
|
|
2379
|
+
var stateChangeTypes$2 = /*#__PURE__*/Object.freeze({
|
|
2372
2380
|
__proto__: null,
|
|
2373
2381
|
MenuKeyDownArrowDown: MenuKeyDownArrowDown,
|
|
2374
2382
|
MenuKeyDownArrowUp: MenuKeyDownArrowUp,
|
|
@@ -2379,20 +2387,20 @@ var stateChangeTypes$1 = /*#__PURE__*/Object.freeze({
|
|
|
2379
2387
|
MenuKeyDownSpaceButton: MenuKeyDownSpaceButton,
|
|
2380
2388
|
MenuKeyDownCharacter: MenuKeyDownCharacter,
|
|
2381
2389
|
MenuBlur: MenuBlur,
|
|
2382
|
-
MenuMouseLeave: MenuMouseLeave,
|
|
2383
|
-
ItemMouseMove: ItemMouseMove,
|
|
2384
|
-
ItemClick: ItemClick,
|
|
2385
|
-
ToggleButtonClick: ToggleButtonClick,
|
|
2390
|
+
MenuMouseLeave: MenuMouseLeave$1,
|
|
2391
|
+
ItemMouseMove: ItemMouseMove$1,
|
|
2392
|
+
ItemClick: ItemClick$1,
|
|
2393
|
+
ToggleButtonClick: ToggleButtonClick$1,
|
|
2386
2394
|
ToggleButtonKeyDownArrowDown: ToggleButtonKeyDownArrowDown,
|
|
2387
2395
|
ToggleButtonKeyDownArrowUp: ToggleButtonKeyDownArrowUp,
|
|
2388
2396
|
ToggleButtonKeyDownCharacter: ToggleButtonKeyDownCharacter,
|
|
2389
|
-
FunctionToggleMenu: FunctionToggleMenu,
|
|
2390
|
-
FunctionOpenMenu: FunctionOpenMenu,
|
|
2391
|
-
FunctionCloseMenu: FunctionCloseMenu,
|
|
2392
|
-
FunctionSetHighlightedIndex: FunctionSetHighlightedIndex,
|
|
2393
|
-
FunctionSelectItem: FunctionSelectItem,
|
|
2394
|
-
FunctionSetInputValue: FunctionSetInputValue,
|
|
2395
|
-
FunctionReset: FunctionReset
|
|
2397
|
+
FunctionToggleMenu: FunctionToggleMenu$1,
|
|
2398
|
+
FunctionOpenMenu: FunctionOpenMenu$1,
|
|
2399
|
+
FunctionCloseMenu: FunctionCloseMenu$1,
|
|
2400
|
+
FunctionSetHighlightedIndex: FunctionSetHighlightedIndex$1,
|
|
2401
|
+
FunctionSelectItem: FunctionSelectItem$1,
|
|
2402
|
+
FunctionSetInputValue: FunctionSetInputValue$1,
|
|
2403
|
+
FunctionReset: FunctionReset$2
|
|
2396
2404
|
});
|
|
2397
2405
|
|
|
2398
2406
|
/* eslint-disable complexity */
|
|
@@ -2404,10 +2412,10 @@ function downshiftSelectReducer(state, action) {
|
|
|
2404
2412
|
var changes;
|
|
2405
2413
|
|
|
2406
2414
|
switch (type) {
|
|
2407
|
-
case ItemClick:
|
|
2415
|
+
case ItemClick$1:
|
|
2408
2416
|
changes = {
|
|
2409
|
-
isOpen: getDefaultValue(props, 'isOpen'),
|
|
2410
|
-
highlightedIndex: getDefaultValue(props, 'highlightedIndex'),
|
|
2417
|
+
isOpen: getDefaultValue$1(props, 'isOpen'),
|
|
2418
|
+
highlightedIndex: getDefaultValue$1(props, 'highlightedIndex'),
|
|
2411
2419
|
selectedItem: props.items[action.index]
|
|
2412
2420
|
};
|
|
2413
2421
|
break;
|
|
@@ -2442,8 +2450,8 @@ function downshiftSelectReducer(state, action) {
|
|
|
2442
2450
|
case MenuKeyDownEnter:
|
|
2443
2451
|
case MenuKeyDownSpaceButton:
|
|
2444
2452
|
changes = _extends__default['default']({
|
|
2445
|
-
isOpen: getDefaultValue(props, 'isOpen'),
|
|
2446
|
-
highlightedIndex: getDefaultValue(props, 'highlightedIndex')
|
|
2453
|
+
isOpen: getDefaultValue$1(props, 'isOpen'),
|
|
2454
|
+
highlightedIndex: getDefaultValue$1(props, 'highlightedIndex')
|
|
2447
2455
|
}, state.highlightedIndex >= 0 && {
|
|
2448
2456
|
selectedItem: props.items[state.highlightedIndex]
|
|
2449
2457
|
});
|
|
@@ -2502,30 +2510,30 @@ function downshiftSelectReducer(state, action) {
|
|
|
2502
2510
|
};
|
|
2503
2511
|
break;
|
|
2504
2512
|
|
|
2505
|
-
case FunctionSelectItem:
|
|
2513
|
+
case FunctionSelectItem$1:
|
|
2506
2514
|
changes = {
|
|
2507
2515
|
selectedItem: action.selectedItem
|
|
2508
2516
|
};
|
|
2509
2517
|
break;
|
|
2510
2518
|
|
|
2511
2519
|
default:
|
|
2512
|
-
return downshiftCommonReducer(state, action, stateChangeTypes$
|
|
2520
|
+
return downshiftCommonReducer(state, action, stateChangeTypes$2);
|
|
2513
2521
|
}
|
|
2514
2522
|
|
|
2515
2523
|
return _extends__default['default']({}, state, changes);
|
|
2516
2524
|
}
|
|
2517
2525
|
/* eslint-enable complexity */
|
|
2518
2526
|
|
|
2519
|
-
useSelect.stateChangeTypes = stateChangeTypes$
|
|
2527
|
+
useSelect.stateChangeTypes = stateChangeTypes$2;
|
|
2520
2528
|
|
|
2521
2529
|
function useSelect(userProps) {
|
|
2522
2530
|
if (userProps === void 0) {
|
|
2523
2531
|
userProps = {};
|
|
2524
2532
|
}
|
|
2525
2533
|
|
|
2526
|
-
validatePropTypes(userProps, useSelect); // Props defaults and destructuring.
|
|
2534
|
+
validatePropTypes$2(userProps, useSelect); // Props defaults and destructuring.
|
|
2527
2535
|
|
|
2528
|
-
var props = _extends__default['default']({}, defaultProps$
|
|
2536
|
+
var props = _extends__default['default']({}, defaultProps$2, userProps);
|
|
2529
2537
|
|
|
2530
2538
|
var items = props.items,
|
|
2531
2539
|
scrollIntoView = props.scrollIntoView,
|
|
@@ -2536,9 +2544,9 @@ function useSelect(userProps) {
|
|
|
2536
2544
|
getA11ySelectionMessage = props.getA11ySelectionMessage,
|
|
2537
2545
|
getA11yStatusMessage = props.getA11yStatusMessage; // Initial state depending on controlled props.
|
|
2538
2546
|
|
|
2539
|
-
var initialState = getInitialState(props);
|
|
2547
|
+
var initialState = getInitialState$2(props);
|
|
2540
2548
|
|
|
2541
|
-
var _useControlledReducer = useControlledReducer(downshiftSelectReducer, initialState, props),
|
|
2549
|
+
var _useControlledReducer = useControlledReducer$1(downshiftSelectReducer, initialState, props),
|
|
2542
2550
|
state = _useControlledReducer[0],
|
|
2543
2551
|
dispatch = _useControlledReducer[1];
|
|
2544
2552
|
|
|
@@ -2593,19 +2601,23 @@ function useSelect(userProps) {
|
|
|
2593
2601
|
itemRefs: itemRefs,
|
|
2594
2602
|
scrollIntoView: scrollIntoView,
|
|
2595
2603
|
getItemNodeFromIndex: getItemNodeFromIndex
|
|
2596
|
-
}); // Sets cleanup for the keysSoFar after 500ms.
|
|
2604
|
+
}); // Sets cleanup for the keysSoFar callback, debounded after 500ms.
|
|
2597
2605
|
|
|
2598
2606
|
react.useEffect(function () {
|
|
2599
2607
|
// init the clean function here as we need access to dispatch.
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
+
clearTimeoutRef.current = debounce(function (outerDispatch) {
|
|
2609
|
+
outerDispatch({
|
|
2610
|
+
type: FunctionSetInputValue$1,
|
|
2611
|
+
inputValue: ''
|
|
2612
|
+
});
|
|
2613
|
+
}, 500); // Cancel any pending debounced calls on mount
|
|
2614
|
+
|
|
2615
|
+
return function () {
|
|
2616
|
+
clearTimeoutRef.current.cancel();
|
|
2617
|
+
};
|
|
2618
|
+
}, []); // Invokes the keysSoFar callback set up above.
|
|
2608
2619
|
|
|
2620
|
+
react.useEffect(function () {
|
|
2609
2621
|
if (!inputValue) {
|
|
2610
2622
|
return;
|
|
2611
2623
|
}
|
|
@@ -2749,39 +2761,39 @@ function useSelect(userProps) {
|
|
|
2749
2761
|
|
|
2750
2762
|
var toggleMenu = react.useCallback(function () {
|
|
2751
2763
|
dispatch({
|
|
2752
|
-
type: FunctionToggleMenu
|
|
2764
|
+
type: FunctionToggleMenu$1
|
|
2753
2765
|
});
|
|
2754
2766
|
}, [dispatch]);
|
|
2755
2767
|
var closeMenu = react.useCallback(function () {
|
|
2756
2768
|
dispatch({
|
|
2757
|
-
type: FunctionCloseMenu
|
|
2769
|
+
type: FunctionCloseMenu$1
|
|
2758
2770
|
});
|
|
2759
2771
|
}, [dispatch]);
|
|
2760
2772
|
var openMenu = react.useCallback(function () {
|
|
2761
2773
|
dispatch({
|
|
2762
|
-
type: FunctionOpenMenu
|
|
2774
|
+
type: FunctionOpenMenu$1
|
|
2763
2775
|
});
|
|
2764
2776
|
}, [dispatch]);
|
|
2765
2777
|
var setHighlightedIndex = react.useCallback(function (newHighlightedIndex) {
|
|
2766
2778
|
dispatch({
|
|
2767
|
-
type: FunctionSetHighlightedIndex,
|
|
2779
|
+
type: FunctionSetHighlightedIndex$1,
|
|
2768
2780
|
highlightedIndex: newHighlightedIndex
|
|
2769
2781
|
});
|
|
2770
2782
|
}, [dispatch]);
|
|
2771
2783
|
var selectItem = react.useCallback(function (newSelectedItem) {
|
|
2772
2784
|
dispatch({
|
|
2773
|
-
type: FunctionSelectItem,
|
|
2785
|
+
type: FunctionSelectItem$1,
|
|
2774
2786
|
selectedItem: newSelectedItem
|
|
2775
2787
|
});
|
|
2776
2788
|
}, [dispatch]);
|
|
2777
2789
|
var reset = react.useCallback(function () {
|
|
2778
2790
|
dispatch({
|
|
2779
|
-
type: FunctionReset
|
|
2791
|
+
type: FunctionReset$2
|
|
2780
2792
|
});
|
|
2781
2793
|
}, [dispatch]);
|
|
2782
2794
|
var setInputValue = react.useCallback(function (newInputValue) {
|
|
2783
2795
|
dispatch({
|
|
2784
|
-
type: FunctionSetInputValue,
|
|
2796
|
+
type: FunctionSetInputValue$1,
|
|
2785
2797
|
inputValue: newInputValue
|
|
2786
2798
|
});
|
|
2787
2799
|
}, [dispatch]); // Getter functions.
|
|
@@ -2843,7 +2855,7 @@ function useSelect(userProps) {
|
|
|
2843
2855
|
|
|
2844
2856
|
var menuHandleMouseLeave = function menuHandleMouseLeave() {
|
|
2845
2857
|
dispatch({
|
|
2846
|
-
type: MenuMouseLeave
|
|
2858
|
+
type: MenuMouseLeave$1
|
|
2847
2859
|
});
|
|
2848
2860
|
};
|
|
2849
2861
|
|
|
@@ -2875,7 +2887,7 @@ function useSelect(userProps) {
|
|
|
2875
2887
|
|
|
2876
2888
|
var toggleButtonHandleClick = function toggleButtonHandleClick() {
|
|
2877
2889
|
dispatch({
|
|
2878
|
-
type: ToggleButtonClick
|
|
2890
|
+
type: ToggleButtonClick$1
|
|
2879
2891
|
});
|
|
2880
2892
|
};
|
|
2881
2893
|
|
|
@@ -2929,14 +2941,14 @@ function useSelect(userProps) {
|
|
|
2929
2941
|
|
|
2930
2942
|
shouldScrollRef.current = false;
|
|
2931
2943
|
dispatch({
|
|
2932
|
-
type: ItemMouseMove,
|
|
2944
|
+
type: ItemMouseMove$1,
|
|
2933
2945
|
index: index
|
|
2934
2946
|
});
|
|
2935
2947
|
};
|
|
2936
2948
|
|
|
2937
2949
|
var itemHandleClick = function itemHandleClick() {
|
|
2938
2950
|
dispatch({
|
|
2939
|
-
type: ItemClick,
|
|
2951
|
+
type: ItemClick$1,
|
|
2940
2952
|
index: index
|
|
2941
2953
|
});
|
|
2942
2954
|
};
|
|
@@ -2994,20 +3006,20 @@ var InputKeyDownEnd = process.env.NODE_ENV !== "production" ? '__input_keydown_e
|
|
|
2994
3006
|
var InputKeyDownEnter = process.env.NODE_ENV !== "production" ? '__input_keydown_enter__' : 5;
|
|
2995
3007
|
var InputChange = process.env.NODE_ENV !== "production" ? '__input_change__' : 6;
|
|
2996
3008
|
var InputBlur = process.env.NODE_ENV !== "production" ? '__input_blur__' : 7;
|
|
2997
|
-
var MenuMouseLeave
|
|
2998
|
-
var ItemMouseMove
|
|
2999
|
-
var ItemClick
|
|
3000
|
-
var ToggleButtonClick
|
|
3001
|
-
var FunctionToggleMenu
|
|
3002
|
-
var FunctionOpenMenu
|
|
3003
|
-
var FunctionCloseMenu
|
|
3004
|
-
var FunctionSetHighlightedIndex
|
|
3005
|
-
var FunctionSelectItem
|
|
3006
|
-
var FunctionSetInputValue
|
|
3009
|
+
var MenuMouseLeave = process.env.NODE_ENV !== "production" ? '__menu_mouse_leave__' : 8;
|
|
3010
|
+
var ItemMouseMove = process.env.NODE_ENV !== "production" ? '__item_mouse_move__' : 9;
|
|
3011
|
+
var ItemClick = process.env.NODE_ENV !== "production" ? '__item_click__' : 10;
|
|
3012
|
+
var ToggleButtonClick = process.env.NODE_ENV !== "production" ? '__togglebutton_click__' : 11;
|
|
3013
|
+
var FunctionToggleMenu = process.env.NODE_ENV !== "production" ? '__function_toggle_menu__' : 12;
|
|
3014
|
+
var FunctionOpenMenu = process.env.NODE_ENV !== "production" ? '__function_open_menu__' : 13;
|
|
3015
|
+
var FunctionCloseMenu = process.env.NODE_ENV !== "production" ? '__function_close_menu__' : 14;
|
|
3016
|
+
var FunctionSetHighlightedIndex = process.env.NODE_ENV !== "production" ? '__function_set_highlighted_index__' : 15;
|
|
3017
|
+
var FunctionSelectItem = process.env.NODE_ENV !== "production" ? '__function_select_item__' : 16;
|
|
3018
|
+
var FunctionSetInputValue = process.env.NODE_ENV !== "production" ? '__function_set_input_value__' : 17;
|
|
3007
3019
|
var FunctionReset$1 = process.env.NODE_ENV !== "production" ? '__function_reset__' : 18;
|
|
3008
3020
|
var ControlledPropUpdatedSelectedItem = process.env.NODE_ENV !== "production" ? '__controlled_prop_updated_selected_item__' : 19;
|
|
3009
3021
|
|
|
3010
|
-
var stateChangeTypes$
|
|
3022
|
+
var stateChangeTypes$1 = /*#__PURE__*/Object.freeze({
|
|
3011
3023
|
__proto__: null,
|
|
3012
3024
|
InputKeyDownArrowDown: InputKeyDownArrowDown,
|
|
3013
3025
|
InputKeyDownArrowUp: InputKeyDownArrowUp,
|
|
@@ -3017,22 +3029,22 @@ var stateChangeTypes$2 = /*#__PURE__*/Object.freeze({
|
|
|
3017
3029
|
InputKeyDownEnter: InputKeyDownEnter,
|
|
3018
3030
|
InputChange: InputChange,
|
|
3019
3031
|
InputBlur: InputBlur,
|
|
3020
|
-
MenuMouseLeave: MenuMouseLeave
|
|
3021
|
-
ItemMouseMove: ItemMouseMove
|
|
3022
|
-
ItemClick: ItemClick
|
|
3023
|
-
ToggleButtonClick: ToggleButtonClick
|
|
3024
|
-
FunctionToggleMenu: FunctionToggleMenu
|
|
3025
|
-
FunctionOpenMenu: FunctionOpenMenu
|
|
3026
|
-
FunctionCloseMenu: FunctionCloseMenu
|
|
3027
|
-
FunctionSetHighlightedIndex: FunctionSetHighlightedIndex
|
|
3028
|
-
FunctionSelectItem: FunctionSelectItem
|
|
3029
|
-
FunctionSetInputValue: FunctionSetInputValue
|
|
3032
|
+
MenuMouseLeave: MenuMouseLeave,
|
|
3033
|
+
ItemMouseMove: ItemMouseMove,
|
|
3034
|
+
ItemClick: ItemClick,
|
|
3035
|
+
ToggleButtonClick: ToggleButtonClick,
|
|
3036
|
+
FunctionToggleMenu: FunctionToggleMenu,
|
|
3037
|
+
FunctionOpenMenu: FunctionOpenMenu,
|
|
3038
|
+
FunctionCloseMenu: FunctionCloseMenu,
|
|
3039
|
+
FunctionSetHighlightedIndex: FunctionSetHighlightedIndex,
|
|
3040
|
+
FunctionSelectItem: FunctionSelectItem,
|
|
3041
|
+
FunctionSetInputValue: FunctionSetInputValue,
|
|
3030
3042
|
FunctionReset: FunctionReset$1,
|
|
3031
3043
|
ControlledPropUpdatedSelectedItem: ControlledPropUpdatedSelectedItem
|
|
3032
3044
|
});
|
|
3033
3045
|
|
|
3034
3046
|
function getInitialState$1(props) {
|
|
3035
|
-
var initialState = getInitialState(props);
|
|
3047
|
+
var initialState = getInitialState$2(props);
|
|
3036
3048
|
var selectedItem = initialState.selectedItem;
|
|
3037
3049
|
var inputValue = initialState.inputValue;
|
|
3038
3050
|
|
|
@@ -3098,7 +3110,7 @@ var propTypes$1 = {
|
|
|
3098
3110
|
* @returns {Array} An array with the state and an action dispatcher.
|
|
3099
3111
|
*/
|
|
3100
3112
|
|
|
3101
|
-
function useControlledReducer
|
|
3113
|
+
function useControlledReducer(reducer, initialState, props) {
|
|
3102
3114
|
var previousSelectedItemRef = react.useRef();
|
|
3103
3115
|
|
|
3104
3116
|
var _useEnhancedReducer = useEnhancedReducer(reducer, initialState, props),
|
|
@@ -3131,8 +3143,8 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
3131
3143
|
};
|
|
3132
3144
|
}
|
|
3133
3145
|
|
|
3134
|
-
var defaultProps$
|
|
3135
|
-
getA11yStatusMessage: getA11yStatusMessage,
|
|
3146
|
+
var defaultProps$1 = _extends__default['default']({}, defaultProps$3, {
|
|
3147
|
+
getA11yStatusMessage: getA11yStatusMessage$1,
|
|
3136
3148
|
circularNavigation: true
|
|
3137
3149
|
});
|
|
3138
3150
|
|
|
@@ -3145,10 +3157,10 @@ function downshiftUseComboboxReducer(state, action) {
|
|
|
3145
3157
|
var changes;
|
|
3146
3158
|
|
|
3147
3159
|
switch (type) {
|
|
3148
|
-
case ItemClick
|
|
3160
|
+
case ItemClick:
|
|
3149
3161
|
changes = {
|
|
3150
|
-
isOpen: getDefaultValue(props, 'isOpen'),
|
|
3151
|
-
highlightedIndex: getDefaultValue(props, 'highlightedIndex'),
|
|
3162
|
+
isOpen: getDefaultValue$1(props, 'isOpen'),
|
|
3163
|
+
highlightedIndex: getDefaultValue$1(props, 'highlightedIndex'),
|
|
3152
3164
|
selectedItem: props.items[action.index],
|
|
3153
3165
|
inputValue: props.itemToString(props.items[action.index])
|
|
3154
3166
|
};
|
|
@@ -3162,7 +3174,7 @@ function downshiftUseComboboxReducer(state, action) {
|
|
|
3162
3174
|
} else {
|
|
3163
3175
|
changes = {
|
|
3164
3176
|
highlightedIndex: getHighlightedIndexOnOpen(props, state, 1, action.getItemNodeFromIndex),
|
|
3165
|
-
isOpen:
|
|
3177
|
+
isOpen: props.items.length >= 0
|
|
3166
3178
|
};
|
|
3167
3179
|
}
|
|
3168
3180
|
|
|
@@ -3176,7 +3188,7 @@ function downshiftUseComboboxReducer(state, action) {
|
|
|
3176
3188
|
} else {
|
|
3177
3189
|
changes = {
|
|
3178
3190
|
highlightedIndex: getHighlightedIndexOnOpen(props, state, -1, action.getItemNodeFromIndex),
|
|
3179
|
-
isOpen:
|
|
3191
|
+
isOpen: props.items.length >= 0
|
|
3180
3192
|
};
|
|
3181
3193
|
}
|
|
3182
3194
|
|
|
@@ -3185,8 +3197,8 @@ function downshiftUseComboboxReducer(state, action) {
|
|
|
3185
3197
|
case InputKeyDownEnter:
|
|
3186
3198
|
changes = _extends__default['default']({}, state.isOpen && state.highlightedIndex >= 0 && {
|
|
3187
3199
|
selectedItem: props.items[state.highlightedIndex],
|
|
3188
|
-
isOpen: getDefaultValue(props, 'isOpen'),
|
|
3189
|
-
highlightedIndex: getDefaultValue(props, 'highlightedIndex'),
|
|
3200
|
+
isOpen: getDefaultValue$1(props, 'isOpen'),
|
|
3201
|
+
highlightedIndex: getDefaultValue$1(props, 'highlightedIndex'),
|
|
3190
3202
|
inputValue: props.itemToString(props.items[state.highlightedIndex])
|
|
3191
3203
|
});
|
|
3192
3204
|
break;
|
|
@@ -3202,39 +3214,36 @@ function downshiftUseComboboxReducer(state, action) {
|
|
|
3202
3214
|
break;
|
|
3203
3215
|
|
|
3204
3216
|
case InputKeyDownHome:
|
|
3205
|
-
changes =
|
|
3217
|
+
changes = {
|
|
3206
3218
|
highlightedIndex: getNextNonDisabledIndex(1, 0, props.items.length, action.getItemNodeFromIndex, false)
|
|
3207
|
-
}
|
|
3219
|
+
};
|
|
3208
3220
|
break;
|
|
3209
3221
|
|
|
3210
3222
|
case InputKeyDownEnd:
|
|
3211
|
-
changes =
|
|
3223
|
+
changes = {
|
|
3212
3224
|
highlightedIndex: getNextNonDisabledIndex(-1, props.items.length - 1, props.items.length, action.getItemNodeFromIndex, false)
|
|
3213
|
-
}
|
|
3225
|
+
};
|
|
3214
3226
|
break;
|
|
3215
3227
|
|
|
3216
3228
|
case InputBlur:
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
});
|
|
3225
|
-
}
|
|
3226
|
-
|
|
3229
|
+
changes = _extends__default['default']({
|
|
3230
|
+
isOpen: false,
|
|
3231
|
+
highlightedIndex: -1
|
|
3232
|
+
}, state.highlightedIndex >= 0 && action.selectItem && {
|
|
3233
|
+
selectedItem: props.items[state.highlightedIndex],
|
|
3234
|
+
inputValue: props.itemToString(props.items[state.highlightedIndex])
|
|
3235
|
+
});
|
|
3227
3236
|
break;
|
|
3228
3237
|
|
|
3229
3238
|
case InputChange:
|
|
3230
3239
|
changes = {
|
|
3231
3240
|
isOpen: true,
|
|
3232
|
-
highlightedIndex: getDefaultValue(props, 'highlightedIndex'),
|
|
3241
|
+
highlightedIndex: getDefaultValue$1(props, 'highlightedIndex'),
|
|
3233
3242
|
inputValue: action.inputValue
|
|
3234
3243
|
};
|
|
3235
3244
|
break;
|
|
3236
3245
|
|
|
3237
|
-
case FunctionSelectItem
|
|
3246
|
+
case FunctionSelectItem:
|
|
3238
3247
|
changes = {
|
|
3239
3248
|
selectedItem: action.selectedItem,
|
|
3240
3249
|
inputValue: props.itemToString(action.selectedItem)
|
|
@@ -3248,14 +3257,14 @@ function downshiftUseComboboxReducer(state, action) {
|
|
|
3248
3257
|
break;
|
|
3249
3258
|
|
|
3250
3259
|
default:
|
|
3251
|
-
return downshiftCommonReducer(state, action, stateChangeTypes$
|
|
3260
|
+
return downshiftCommonReducer(state, action, stateChangeTypes$1);
|
|
3252
3261
|
}
|
|
3253
3262
|
|
|
3254
3263
|
return _extends__default['default']({}, state, changes);
|
|
3255
3264
|
}
|
|
3256
3265
|
/* eslint-enable complexity */
|
|
3257
3266
|
|
|
3258
|
-
useCombobox.stateChangeTypes = stateChangeTypes$
|
|
3267
|
+
useCombobox.stateChangeTypes = stateChangeTypes$1;
|
|
3259
3268
|
|
|
3260
3269
|
function useCombobox(userProps) {
|
|
3261
3270
|
if (userProps === void 0) {
|
|
@@ -3264,7 +3273,7 @@ function useCombobox(userProps) {
|
|
|
3264
3273
|
|
|
3265
3274
|
validatePropTypes$1(userProps, useCombobox); // Props defaults and destructuring.
|
|
3266
3275
|
|
|
3267
|
-
var props = _extends__default['default']({}, defaultProps$
|
|
3276
|
+
var props = _extends__default['default']({}, defaultProps$1, userProps);
|
|
3268
3277
|
|
|
3269
3278
|
var initialIsOpen = props.initialIsOpen,
|
|
3270
3279
|
defaultIsOpen = props.defaultIsOpen,
|
|
@@ -3277,7 +3286,7 @@ function useCombobox(userProps) {
|
|
|
3277
3286
|
|
|
3278
3287
|
var initialState = getInitialState$1(props);
|
|
3279
3288
|
|
|
3280
|
-
var _useControlledReducer = useControlledReducer
|
|
3289
|
+
var _useControlledReducer = useControlledReducer(downshiftUseComboboxReducer, initialState, props),
|
|
3281
3290
|
state = _useControlledReducer[0],
|
|
3282
3291
|
dispatch = _useControlledReducer[1];
|
|
3283
3292
|
|
|
@@ -3390,6 +3399,10 @@ function useCombobox(userProps) {
|
|
|
3390
3399
|
});
|
|
3391
3400
|
},
|
|
3392
3401
|
Home: function Home(event) {
|
|
3402
|
+
if (!latest.current.state.isOpen) {
|
|
3403
|
+
return;
|
|
3404
|
+
}
|
|
3405
|
+
|
|
3393
3406
|
event.preventDefault();
|
|
3394
3407
|
dispatch({
|
|
3395
3408
|
type: InputKeyDownHome,
|
|
@@ -3397,6 +3410,10 @@ function useCombobox(userProps) {
|
|
|
3397
3410
|
});
|
|
3398
3411
|
},
|
|
3399
3412
|
End: function End(event) {
|
|
3413
|
+
if (!latest.current.state.isOpen) {
|
|
3414
|
+
return;
|
|
3415
|
+
}
|
|
3416
|
+
|
|
3400
3417
|
event.preventDefault();
|
|
3401
3418
|
dispatch({
|
|
3402
3419
|
type: InputKeyDownEnd,
|
|
@@ -3404,22 +3421,23 @@ function useCombobox(userProps) {
|
|
|
3404
3421
|
});
|
|
3405
3422
|
},
|
|
3406
3423
|
Escape: function Escape() {
|
|
3407
|
-
dispatch({
|
|
3408
|
-
type: InputKeyDownEscape
|
|
3409
|
-
});
|
|
3410
|
-
},
|
|
3411
|
-
Enter: function Enter(event) {
|
|
3412
|
-
// if IME composing, wait for next Enter keydown event.
|
|
3413
|
-
if (event.which === 229) {
|
|
3414
|
-
return;
|
|
3415
|
-
}
|
|
3416
|
-
|
|
3417
3424
|
var latestState = latest.current.state;
|
|
3418
3425
|
|
|
3419
|
-
if (latestState.isOpen) {
|
|
3420
|
-
|
|
3426
|
+
if (latestState.isOpen || latestState.inputValue || latestState.selectedItem || latestState.highlightedIndex > -1) {
|
|
3427
|
+
dispatch({
|
|
3428
|
+
type: InputKeyDownEscape
|
|
3429
|
+
});
|
|
3421
3430
|
}
|
|
3431
|
+
},
|
|
3432
|
+
Enter: function Enter(event) {
|
|
3433
|
+
var latestState = latest.current.state; // if closed or no highlighted index, do nothing.
|
|
3422
3434
|
|
|
3435
|
+
if (!latestState.isOpen || latestState.highlightedIndex < 0 || event.which === 229 // if IME composing, wait for next Enter keydown event.
|
|
3436
|
+
) {
|
|
3437
|
+
return;
|
|
3438
|
+
}
|
|
3439
|
+
|
|
3440
|
+
event.preventDefault();
|
|
3423
3441
|
dispatch({
|
|
3424
3442
|
type: InputKeyDownEnter,
|
|
3425
3443
|
getItemNodeFromIndex: getItemNodeFromIndex
|
|
@@ -3453,7 +3471,7 @@ function useCombobox(userProps) {
|
|
|
3453
3471
|
menuRef.current = menuNode;
|
|
3454
3472
|
}), _extends2.id = elementIds.menuId, _extends2.role = 'listbox', _extends2['aria-labelledby'] = elementIds.labelId, _extends2.onMouseLeave = callAllEventHandlers(onMouseLeave, function () {
|
|
3455
3473
|
dispatch({
|
|
3456
|
-
type: MenuMouseLeave
|
|
3474
|
+
type: MenuMouseLeave
|
|
3457
3475
|
});
|
|
3458
3476
|
}), _extends2), rest);
|
|
3459
3477
|
}, [dispatch, setGetterPropCallInfo, elementIds]);
|
|
@@ -3467,9 +3485,9 @@ function useCombobox(userProps) {
|
|
|
3467
3485
|
refKey = _ref3$refKey === void 0 ? 'ref' : _ref3$refKey,
|
|
3468
3486
|
ref = _ref3.ref,
|
|
3469
3487
|
onMouseMove = _ref3.onMouseMove,
|
|
3470
|
-
onClick = _ref3.onClick
|
|
3471
|
-
|
|
3472
|
-
rest = _objectWithoutPropertiesLoose__default['default'](_ref3, ["item", "index", "refKey", "ref", "onMouseMove", "onClick", "onPress"]);
|
|
3488
|
+
onClick = _ref3.onClick;
|
|
3489
|
+
_ref3.onPress;
|
|
3490
|
+
var rest = _objectWithoutPropertiesLoose__default['default'](_ref3, ["item", "index", "refKey", "ref", "onMouseMove", "onClick", "onPress"]);
|
|
3473
3491
|
|
|
3474
3492
|
var _latest$current = latest.current,
|
|
3475
3493
|
latestProps = _latest$current.props,
|
|
@@ -3480,8 +3498,8 @@ function useCombobox(userProps) {
|
|
|
3480
3498
|
throw new Error('Pass either item or item index in getItemProps!');
|
|
3481
3499
|
}
|
|
3482
3500
|
|
|
3483
|
-
var onSelectKey =
|
|
3484
|
-
var customClickHandler =
|
|
3501
|
+
var onSelectKey = 'onClick';
|
|
3502
|
+
var customClickHandler = onClick;
|
|
3485
3503
|
|
|
3486
3504
|
var itemHandleMouseMove = function itemHandleMouseMove() {
|
|
3487
3505
|
if (index === latestState.highlightedIndex) {
|
|
@@ -3490,14 +3508,14 @@ function useCombobox(userProps) {
|
|
|
3490
3508
|
|
|
3491
3509
|
shouldScrollRef.current = false;
|
|
3492
3510
|
dispatch({
|
|
3493
|
-
type: ItemMouseMove
|
|
3511
|
+
type: ItemMouseMove,
|
|
3494
3512
|
index: index
|
|
3495
3513
|
});
|
|
3496
3514
|
};
|
|
3497
3515
|
|
|
3498
3516
|
var itemHandleClick = function itemHandleClick() {
|
|
3499
3517
|
dispatch({
|
|
3500
|
-
type: ItemClick
|
|
3518
|
+
type: ItemClick,
|
|
3501
3519
|
index: index
|
|
3502
3520
|
});
|
|
3503
3521
|
|
|
@@ -3518,16 +3536,16 @@ function useCombobox(userProps) {
|
|
|
3518
3536
|
var _extends4;
|
|
3519
3537
|
|
|
3520
3538
|
var _ref5 = _temp4 === void 0 ? {} : _temp4,
|
|
3521
|
-
onClick = _ref5.onClick
|
|
3522
|
-
|
|
3523
|
-
_ref5$refKey = _ref5.refKey,
|
|
3539
|
+
onClick = _ref5.onClick;
|
|
3540
|
+
_ref5.onPress;
|
|
3541
|
+
var _ref5$refKey = _ref5.refKey,
|
|
3524
3542
|
refKey = _ref5$refKey === void 0 ? 'ref' : _ref5$refKey,
|
|
3525
3543
|
ref = _ref5.ref,
|
|
3526
3544
|
rest = _objectWithoutPropertiesLoose__default['default'](_ref5, ["onClick", "onPress", "refKey", "ref"]);
|
|
3527
3545
|
|
|
3528
3546
|
var toggleButtonHandleClick = function toggleButtonHandleClick() {
|
|
3529
3547
|
dispatch({
|
|
3530
|
-
type: ToggleButtonClick
|
|
3548
|
+
type: ToggleButtonClick
|
|
3531
3549
|
});
|
|
3532
3550
|
|
|
3533
3551
|
if (!latest.current.state.isOpen && inputRef.current) {
|
|
@@ -3537,7 +3555,7 @@ function useCombobox(userProps) {
|
|
|
3537
3555
|
|
|
3538
3556
|
return _extends__default['default']((_extends4 = {}, _extends4[refKey] = handleRefs(ref, function (toggleButtonNode) {
|
|
3539
3557
|
toggleButtonRef.current = toggleButtonNode;
|
|
3540
|
-
}), _extends4.id = elementIds.toggleButtonId, _extends4.tabIndex = -1, _extends4), !rest.disabled && _extends__default['default']({},
|
|
3558
|
+
}), _extends4.id = elementIds.toggleButtonId, _extends4.tabIndex = -1, _extends4), !rest.disabled && _extends__default['default']({}, {
|
|
3541
3559
|
onClick: callAllEventHandlers(onClick, toggleButtonHandleClick)
|
|
3542
3560
|
}), rest);
|
|
3543
3561
|
}, [dispatch, latest, elementIds]);
|
|
@@ -3548,9 +3566,9 @@ function useCombobox(userProps) {
|
|
|
3548
3566
|
onKeyDown = _ref6.onKeyDown,
|
|
3549
3567
|
onChange = _ref6.onChange,
|
|
3550
3568
|
onInput = _ref6.onInput,
|
|
3551
|
-
onBlur = _ref6.onBlur
|
|
3552
|
-
|
|
3553
|
-
_ref6$refKey = _ref6.refKey,
|
|
3569
|
+
onBlur = _ref6.onBlur;
|
|
3570
|
+
_ref6.onChangeText;
|
|
3571
|
+
var _ref6$refKey = _ref6.refKey,
|
|
3554
3572
|
refKey = _ref6$refKey === void 0 ? 'ref' : _ref6$refKey,
|
|
3555
3573
|
ref = _ref6.ref,
|
|
3556
3574
|
rest = _objectWithoutPropertiesLoose__default['default'](_ref6, ["onKeyDown", "onChange", "onInput", "onBlur", "onChangeText", "refKey", "ref"]);
|
|
@@ -3573,13 +3591,13 @@ function useCombobox(userProps) {
|
|
|
3573
3591
|
var inputHandleChange = function inputHandleChange(event) {
|
|
3574
3592
|
dispatch({
|
|
3575
3593
|
type: InputChange,
|
|
3576
|
-
inputValue:
|
|
3594
|
+
inputValue: event.target.value
|
|
3577
3595
|
});
|
|
3578
3596
|
};
|
|
3579
3597
|
|
|
3580
3598
|
var inputHandleBlur = function inputHandleBlur() {
|
|
3581
3599
|
/* istanbul ignore else */
|
|
3582
|
-
if (!mouseAndTouchTrackersRef.current.isMouseDown) {
|
|
3600
|
+
if (latestState.isOpen && !mouseAndTouchTrackersRef.current.isMouseDown) {
|
|
3583
3601
|
dispatch({
|
|
3584
3602
|
type: InputBlur,
|
|
3585
3603
|
selectItem: true
|
|
@@ -3589,7 +3607,7 @@ function useCombobox(userProps) {
|
|
|
3589
3607
|
/* istanbul ignore next (preact) */
|
|
3590
3608
|
|
|
3591
3609
|
|
|
3592
|
-
var onChangeKey =
|
|
3610
|
+
var onChangeKey = 'onChange';
|
|
3593
3611
|
var eventHandlers = {};
|
|
3594
3612
|
|
|
3595
3613
|
if (!rest.disabled) {
|
|
@@ -3631,34 +3649,34 @@ function useCombobox(userProps) {
|
|
|
3631
3649
|
|
|
3632
3650
|
var toggleMenu = react.useCallback(function () {
|
|
3633
3651
|
dispatch({
|
|
3634
|
-
type: FunctionToggleMenu
|
|
3652
|
+
type: FunctionToggleMenu
|
|
3635
3653
|
});
|
|
3636
3654
|
}, [dispatch]);
|
|
3637
3655
|
var closeMenu = react.useCallback(function () {
|
|
3638
3656
|
dispatch({
|
|
3639
|
-
type: FunctionCloseMenu
|
|
3657
|
+
type: FunctionCloseMenu
|
|
3640
3658
|
});
|
|
3641
3659
|
}, [dispatch]);
|
|
3642
3660
|
var openMenu = react.useCallback(function () {
|
|
3643
3661
|
dispatch({
|
|
3644
|
-
type: FunctionOpenMenu
|
|
3662
|
+
type: FunctionOpenMenu
|
|
3645
3663
|
});
|
|
3646
3664
|
}, [dispatch]);
|
|
3647
3665
|
var setHighlightedIndex = react.useCallback(function (newHighlightedIndex) {
|
|
3648
3666
|
dispatch({
|
|
3649
|
-
type: FunctionSetHighlightedIndex
|
|
3667
|
+
type: FunctionSetHighlightedIndex,
|
|
3650
3668
|
highlightedIndex: newHighlightedIndex
|
|
3651
3669
|
});
|
|
3652
3670
|
}, [dispatch]);
|
|
3653
3671
|
var selectItem = react.useCallback(function (newSelectedItem) {
|
|
3654
3672
|
dispatch({
|
|
3655
|
-
type: FunctionSelectItem
|
|
3673
|
+
type: FunctionSelectItem,
|
|
3656
3674
|
selectedItem: newSelectedItem
|
|
3657
3675
|
});
|
|
3658
3676
|
}, [dispatch]);
|
|
3659
3677
|
var setInputValue = react.useCallback(function (newInputValue) {
|
|
3660
3678
|
dispatch({
|
|
3661
|
-
type: FunctionSetInputValue
|
|
3679
|
+
type: FunctionSetInputValue,
|
|
3662
3680
|
inputValue: newInputValue
|
|
3663
3681
|
});
|
|
3664
3682
|
}, [dispatch]);
|
|
@@ -3705,8 +3723,8 @@ var defaultStateValues = {
|
|
|
3705
3723
|
* @returns {any} The initial value for that prop.
|
|
3706
3724
|
*/
|
|
3707
3725
|
|
|
3708
|
-
function getInitialValue
|
|
3709
|
-
return getInitialValue(props, propKey, defaultStateValues);
|
|
3726
|
+
function getInitialValue(props, propKey) {
|
|
3727
|
+
return getInitialValue$1(props, propKey, defaultStateValues);
|
|
3710
3728
|
}
|
|
3711
3729
|
/**
|
|
3712
3730
|
* Returns the default value for a state key in the following order:
|
|
@@ -3718,8 +3736,8 @@ function getInitialValue$1(props, propKey) {
|
|
|
3718
3736
|
*/
|
|
3719
3737
|
|
|
3720
3738
|
|
|
3721
|
-
function getDefaultValue
|
|
3722
|
-
return getDefaultValue(props, propKey, defaultStateValues);
|
|
3739
|
+
function getDefaultValue(props, propKey) {
|
|
3740
|
+
return getDefaultValue$1(props, propKey, defaultStateValues);
|
|
3723
3741
|
}
|
|
3724
3742
|
/**
|
|
3725
3743
|
* Gets the initial state based on the provided props. It uses initial, default
|
|
@@ -3730,9 +3748,9 @@ function getDefaultValue$1(props, propKey) {
|
|
|
3730
3748
|
*/
|
|
3731
3749
|
|
|
3732
3750
|
|
|
3733
|
-
function getInitialState
|
|
3734
|
-
var activeIndex = getInitialValue
|
|
3735
|
-
var selectedItems = getInitialValue
|
|
3751
|
+
function getInitialState(props) {
|
|
3752
|
+
var activeIndex = getInitialValue(props, 'activeIndex');
|
|
3753
|
+
var selectedItems = getInitialValue(props, 'selectedItems');
|
|
3736
3754
|
return {
|
|
3737
3755
|
activeIndex: activeIndex,
|
|
3738
3756
|
selectedItems: selectedItems
|
|
@@ -3779,7 +3797,7 @@ function getA11yRemovalMessage(selectionParameters) {
|
|
|
3779
3797
|
return itemToStringLocal(removedSelectedItem) + " has been removed.";
|
|
3780
3798
|
}
|
|
3781
3799
|
|
|
3782
|
-
var propTypes
|
|
3800
|
+
var propTypes = {
|
|
3783
3801
|
selectedItems: PropTypes__default['default'].array,
|
|
3784
3802
|
initialSelectedItems: PropTypes__default['default'].array,
|
|
3785
3803
|
defaultSelectedItems: PropTypes__default['default'].array,
|
|
@@ -3803,21 +3821,21 @@ var propTypes$2 = {
|
|
|
3803
3821
|
})
|
|
3804
3822
|
})
|
|
3805
3823
|
};
|
|
3806
|
-
var defaultProps
|
|
3807
|
-
itemToString: defaultProps.itemToString,
|
|
3808
|
-
stateReducer: defaultProps.stateReducer,
|
|
3809
|
-
environment: defaultProps.environment,
|
|
3824
|
+
var defaultProps = {
|
|
3825
|
+
itemToString: defaultProps$3.itemToString,
|
|
3826
|
+
stateReducer: defaultProps$3.stateReducer,
|
|
3827
|
+
environment: defaultProps$3.environment,
|
|
3810
3828
|
getA11yRemovalMessage: getA11yRemovalMessage,
|
|
3811
3829
|
keyNavigationNext: 'ArrowRight',
|
|
3812
3830
|
keyNavigationPrevious: 'ArrowLeft'
|
|
3813
3831
|
}; // eslint-disable-next-line import/no-mutable-exports
|
|
3814
3832
|
|
|
3815
|
-
var validatePropTypes
|
|
3833
|
+
var validatePropTypes = noop;
|
|
3816
3834
|
/* istanbul ignore next */
|
|
3817
3835
|
|
|
3818
3836
|
if (process.env.NODE_ENV !== 'production') {
|
|
3819
|
-
validatePropTypes
|
|
3820
|
-
PropTypes__default['default'].checkPropTypes(propTypes
|
|
3837
|
+
validatePropTypes = function validatePropTypes(options, caller) {
|
|
3838
|
+
PropTypes__default['default'].checkPropTypes(propTypes, options, 'prop', caller.name);
|
|
3821
3839
|
};
|
|
3822
3840
|
}
|
|
3823
3841
|
|
|
@@ -3833,9 +3851,9 @@ var FunctionAddSelectedItem = process.env.NODE_ENV !== "production" ? '__functio
|
|
|
3833
3851
|
var FunctionRemoveSelectedItem = process.env.NODE_ENV !== "production" ? '__function_remove_selected_item__' : 9;
|
|
3834
3852
|
var FunctionSetSelectedItems = process.env.NODE_ENV !== "production" ? '__function_set_selected_items__' : 10;
|
|
3835
3853
|
var FunctionSetActiveIndex = process.env.NODE_ENV !== "production" ? '__function_set_active_index__' : 11;
|
|
3836
|
-
var FunctionReset
|
|
3854
|
+
var FunctionReset = process.env.NODE_ENV !== "production" ? '__function_reset__' : 12;
|
|
3837
3855
|
|
|
3838
|
-
var stateChangeTypes
|
|
3856
|
+
var stateChangeTypes = /*#__PURE__*/Object.freeze({
|
|
3839
3857
|
__proto__: null,
|
|
3840
3858
|
SelectedItemClick: SelectedItemClick,
|
|
3841
3859
|
SelectedItemKeyDownDelete: SelectedItemKeyDownDelete,
|
|
@@ -3849,7 +3867,7 @@ var stateChangeTypes$3 = /*#__PURE__*/Object.freeze({
|
|
|
3849
3867
|
FunctionRemoveSelectedItem: FunctionRemoveSelectedItem,
|
|
3850
3868
|
FunctionSetSelectedItems: FunctionSetSelectedItems,
|
|
3851
3869
|
FunctionSetActiveIndex: FunctionSetActiveIndex,
|
|
3852
|
-
FunctionReset: FunctionReset
|
|
3870
|
+
FunctionReset: FunctionReset
|
|
3853
3871
|
});
|
|
3854
3872
|
|
|
3855
3873
|
/* eslint-disable complexity */
|
|
@@ -3962,10 +3980,10 @@ function downshiftMultipleSelectionReducer(state, action) {
|
|
|
3962
3980
|
break;
|
|
3963
3981
|
}
|
|
3964
3982
|
|
|
3965
|
-
case FunctionReset
|
|
3983
|
+
case FunctionReset:
|
|
3966
3984
|
changes = {
|
|
3967
|
-
activeIndex: getDefaultValue
|
|
3968
|
-
selectedItems: getDefaultValue
|
|
3985
|
+
activeIndex: getDefaultValue(props, 'activeIndex'),
|
|
3986
|
+
selectedItems: getDefaultValue(props, 'selectedItems')
|
|
3969
3987
|
};
|
|
3970
3988
|
break;
|
|
3971
3989
|
|
|
@@ -3976,16 +3994,16 @@ function downshiftMultipleSelectionReducer(state, action) {
|
|
|
3976
3994
|
return _extends__default['default']({}, state, changes);
|
|
3977
3995
|
}
|
|
3978
3996
|
|
|
3979
|
-
useMultipleSelection.stateChangeTypes = stateChangeTypes
|
|
3997
|
+
useMultipleSelection.stateChangeTypes = stateChangeTypes;
|
|
3980
3998
|
|
|
3981
3999
|
function useMultipleSelection(userProps) {
|
|
3982
4000
|
if (userProps === void 0) {
|
|
3983
4001
|
userProps = {};
|
|
3984
4002
|
}
|
|
3985
4003
|
|
|
3986
|
-
validatePropTypes
|
|
4004
|
+
validatePropTypes(userProps, useMultipleSelection); // Props defaults and destructuring.
|
|
3987
4005
|
|
|
3988
|
-
var props = _extends__default['default']({}, defaultProps
|
|
4006
|
+
var props = _extends__default['default']({}, defaultProps, userProps);
|
|
3989
4007
|
|
|
3990
4008
|
var getA11yRemovalMessage = props.getA11yRemovalMessage,
|
|
3991
4009
|
itemToString = props.itemToString,
|
|
@@ -3993,7 +4011,7 @@ function useMultipleSelection(userProps) {
|
|
|
3993
4011
|
keyNavigationNext = props.keyNavigationNext,
|
|
3994
4012
|
keyNavigationPrevious = props.keyNavigationPrevious; // Reducer init.
|
|
3995
4013
|
|
|
3996
|
-
var _useControlledReducer = useControlledReducer(downshiftMultipleSelectionReducer, getInitialState
|
|
4014
|
+
var _useControlledReducer = useControlledReducer$1(downshiftMultipleSelectionReducer, getInitialState(props), props),
|
|
3997
4015
|
state = _useControlledReducer[0],
|
|
3998
4016
|
dispatch = _useControlledReducer[1];
|
|
3999
4017
|
|
|
@@ -4204,7 +4222,7 @@ function useMultipleSelection(userProps) {
|
|
|
4204
4222
|
}, [dispatch]);
|
|
4205
4223
|
var reset = react.useCallback(function () {
|
|
4206
4224
|
dispatch({
|
|
4207
|
-
type: FunctionReset
|
|
4225
|
+
type: FunctionReset
|
|
4208
4226
|
});
|
|
4209
4227
|
}, [dispatch]);
|
|
4210
4228
|
return {
|