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;
|
|
@@ -531,7 +531,7 @@ var blurButton = process.env.NODE_ENV !== "production" ? '__autocomplete_blur_bu
|
|
|
531
531
|
var controlledPropUpdatedSelectedItem = process.env.NODE_ENV !== "production" ? '__autocomplete_controlled_prop_updated_selected_item__' : 15;
|
|
532
532
|
var touchEnd = process.env.NODE_ENV !== "production" ? '__autocomplete_touchend__' : 16;
|
|
533
533
|
|
|
534
|
-
var stateChangeTypes = /*#__PURE__*/Object.freeze({
|
|
534
|
+
var stateChangeTypes$3 = /*#__PURE__*/Object.freeze({
|
|
535
535
|
__proto__: null,
|
|
536
536
|
unknown: unknown,
|
|
537
537
|
mouseUp: mouseUp,
|
|
@@ -873,12 +873,16 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
873
873
|
Home: function Home(event) {
|
|
874
874
|
var _this4 = this;
|
|
875
875
|
|
|
876
|
-
event.preventDefault();
|
|
877
|
-
var itemCount = this.getItemCount();
|
|
878
|
-
|
|
879
876
|
var _this$getState3 = this.getState(),
|
|
880
877
|
isOpen = _this$getState3.isOpen;
|
|
881
878
|
|
|
879
|
+
if (!isOpen) {
|
|
880
|
+
return;
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
event.preventDefault();
|
|
884
|
+
var itemCount = this.getItemCount();
|
|
885
|
+
|
|
882
886
|
if (itemCount <= 0 || !isOpen) {
|
|
883
887
|
return;
|
|
884
888
|
} // get next non-disabled starting downwards from 0 if that's disabled.
|
|
@@ -894,12 +898,16 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
894
898
|
End: function End(event) {
|
|
895
899
|
var _this5 = this;
|
|
896
900
|
|
|
897
|
-
event.preventDefault();
|
|
898
|
-
var itemCount = this.getItemCount();
|
|
899
|
-
|
|
900
901
|
var _this$getState4 = this.getState(),
|
|
901
902
|
isOpen = _this$getState4.isOpen;
|
|
902
903
|
|
|
904
|
+
if (!isOpen) {
|
|
905
|
+
return;
|
|
906
|
+
}
|
|
907
|
+
|
|
908
|
+
event.preventDefault();
|
|
909
|
+
var itemCount = this.getItemCount();
|
|
910
|
+
|
|
903
911
|
if (itemCount <= 0 || !isOpen) {
|
|
904
912
|
return;
|
|
905
913
|
} // get next non-disabled starting upwards from last index if that's disabled.
|
|
@@ -916,9 +924,9 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
916
924
|
|
|
917
925
|
_this.getToggleButtonProps = function (_temp3) {
|
|
918
926
|
var _ref3 = _temp3 === void 0 ? {} : _temp3,
|
|
919
|
-
onClick = _ref3.onClick
|
|
920
|
-
|
|
921
|
-
onKeyDown = _ref3.onKeyDown,
|
|
927
|
+
onClick = _ref3.onClick;
|
|
928
|
+
_ref3.onPress;
|
|
929
|
+
var onKeyDown = _ref3.onKeyDown,
|
|
922
930
|
onKeyUp = _ref3.onKeyUp,
|
|
923
931
|
onBlur = _ref3.onBlur,
|
|
924
932
|
rest = _objectWithoutPropertiesLoose__default['default'](_ref3, ["onClick", "onPress", "onKeyDown", "onKeyUp", "onBlur"]);
|
|
@@ -926,7 +934,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
926
934
|
var _this$getState5 = _this.getState(),
|
|
927
935
|
isOpen = _this$getState5.isOpen;
|
|
928
936
|
|
|
929
|
-
var enabledEventHandlers =
|
|
937
|
+
var enabledEventHandlers = {
|
|
930
938
|
onClick: callAllEventHandlers(onClick, _this.buttonHandleClick),
|
|
931
939
|
onKeyDown: callAllEventHandlers(onKeyDown, _this.buttonHandleKeyDown),
|
|
932
940
|
onKeyUp: callAllEventHandlers(onKeyUp, _this.buttonHandleKeyUp),
|
|
@@ -961,7 +969,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
961
969
|
|
|
962
970
|
/* istanbul ignore if (can't reasonably test this) */
|
|
963
971
|
|
|
964
|
-
if (
|
|
972
|
+
if (_this.props.environment.document.activeElement === _this.props.environment.document.body) {
|
|
965
973
|
event.target.focus();
|
|
966
974
|
} // to simplify testing components that use downshift, we'll not wrap this in a setTimeout
|
|
967
975
|
// if the NODE_ENV is test. With the proper build system, this should be dead code eliminated
|
|
@@ -1008,9 +1016,9 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1008
1016
|
onKeyDown = _ref4.onKeyDown,
|
|
1009
1017
|
onBlur = _ref4.onBlur,
|
|
1010
1018
|
onChange = _ref4.onChange,
|
|
1011
|
-
onInput = _ref4.onInput
|
|
1012
|
-
|
|
1013
|
-
rest = _objectWithoutPropertiesLoose__default['default'](_ref4, ["onKeyDown", "onBlur", "onChange", "onInput", "onChangeText"]);
|
|
1019
|
+
onInput = _ref4.onInput;
|
|
1020
|
+
_ref4.onChangeText;
|
|
1021
|
+
var rest = _objectWithoutPropertiesLoose__default['default'](_ref4, ["onKeyDown", "onBlur", "onChange", "onInput", "onChangeText"]);
|
|
1014
1022
|
|
|
1015
1023
|
var onChangeKey;
|
|
1016
1024
|
var eventHandlers = {};
|
|
@@ -1056,7 +1064,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1056
1064
|
_this.internalSetState({
|
|
1057
1065
|
type: changeInput,
|
|
1058
1066
|
isOpen: true,
|
|
1059
|
-
inputValue:
|
|
1067
|
+
inputValue: event.target.value,
|
|
1060
1068
|
highlightedIndex: _this.props.defaultHighlightedIndex
|
|
1061
1069
|
});
|
|
1062
1070
|
};
|
|
@@ -1103,9 +1111,9 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1103
1111
|
var _ref7 = _temp7 === void 0 ? {} : _temp7,
|
|
1104
1112
|
onMouseMove = _ref7.onMouseMove,
|
|
1105
1113
|
onMouseDown = _ref7.onMouseDown,
|
|
1106
|
-
onClick = _ref7.onClick
|
|
1107
|
-
|
|
1108
|
-
index = _ref7.index,
|
|
1114
|
+
onClick = _ref7.onClick;
|
|
1115
|
+
_ref7.onPress;
|
|
1116
|
+
var index = _ref7.index,
|
|
1109
1117
|
_ref7$item = _ref7.item,
|
|
1110
1118
|
item = _ref7$item === void 0 ? process.env.NODE_ENV === 'production' ?
|
|
1111
1119
|
/* istanbul ignore next */
|
|
@@ -1120,8 +1128,8 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1120
1128
|
_this.items[index] = item;
|
|
1121
1129
|
}
|
|
1122
1130
|
|
|
1123
|
-
var onSelectKey =
|
|
1124
|
-
var customClickHandler =
|
|
1131
|
+
var onSelectKey = 'onClick';
|
|
1132
|
+
var customClickHandler = onClick;
|
|
1125
1133
|
var enabledEventHandlers = (_enabledEventHandlers = {
|
|
1126
1134
|
// onMouseMove is used over onMouseEnter here. onMouseMove
|
|
1127
1135
|
// is only triggered on actual mouse movement while onMouseEnter
|
|
@@ -1511,7 +1519,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1511
1519
|
validateControlledUnchanged(this.state, prevProps, this.props);
|
|
1512
1520
|
/* istanbul ignore if (react-native) */
|
|
1513
1521
|
|
|
1514
|
-
if (
|
|
1522
|
+
if (this.getMenuProps.called && !this.getMenuProps.suppressRefError) {
|
|
1515
1523
|
validateGetMenuPropsCalledCorrectly(this._menuNode, this.getMenuProps);
|
|
1516
1524
|
}
|
|
1517
1525
|
}
|
|
@@ -1596,7 +1604,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1596
1604
|
Downshift.defaultProps = {
|
|
1597
1605
|
defaultHighlightedIndex: null,
|
|
1598
1606
|
defaultIsOpen: false,
|
|
1599
|
-
getA11yStatusMessage: getA11yStatusMessage,
|
|
1607
|
+
getA11yStatusMessage: getA11yStatusMessage$1,
|
|
1600
1608
|
itemToString: function itemToString(i) {
|
|
1601
1609
|
if (i == null) {
|
|
1602
1610
|
return '';
|
|
@@ -1627,7 +1635,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1627
1635
|
suppressRefError: false,
|
|
1628
1636
|
scrollIntoView: scrollIntoView
|
|
1629
1637
|
};
|
|
1630
|
-
Downshift.stateChangeTypes = stateChangeTypes;
|
|
1638
|
+
Downshift.stateChangeTypes = stateChangeTypes$3;
|
|
1631
1639
|
return Downshift;
|
|
1632
1640
|
}();
|
|
1633
1641
|
|
|
@@ -1842,7 +1850,7 @@ function useEnhancedReducer(reducer, initialState, props) {
|
|
|
1842
1850
|
*/
|
|
1843
1851
|
|
|
1844
1852
|
|
|
1845
|
-
function useControlledReducer(reducer, initialState, props) {
|
|
1853
|
+
function useControlledReducer$1(reducer, initialState, props) {
|
|
1846
1854
|
var _useEnhancedReducer = useEnhancedReducer(reducer, initialState, props),
|
|
1847
1855
|
state = _useEnhancedReducer[0],
|
|
1848
1856
|
dispatch = _useEnhancedReducer[1];
|
|
@@ -1850,7 +1858,7 @@ function useControlledReducer(reducer, initialState, props) {
|
|
|
1850
1858
|
return [getState(state, props), dispatch];
|
|
1851
1859
|
}
|
|
1852
1860
|
|
|
1853
|
-
var defaultProps = {
|
|
1861
|
+
var defaultProps$3 = {
|
|
1854
1862
|
itemToString: itemToString,
|
|
1855
1863
|
stateReducer: stateReducer,
|
|
1856
1864
|
getA11ySelectionMessage: getA11ySelectionMessage,
|
|
@@ -1861,7 +1869,7 @@ var defaultProps = {
|
|
|
1861
1869
|
? {} : window
|
|
1862
1870
|
};
|
|
1863
1871
|
|
|
1864
|
-
function getDefaultValue(props, propKey, defaultStateValues) {
|
|
1872
|
+
function getDefaultValue$1(props, propKey, defaultStateValues) {
|
|
1865
1873
|
if (defaultStateValues === void 0) {
|
|
1866
1874
|
defaultStateValues = dropdownDefaultStateValues;
|
|
1867
1875
|
}
|
|
@@ -1875,7 +1883,7 @@ function getDefaultValue(props, propKey, defaultStateValues) {
|
|
|
1875
1883
|
return defaultStateValues[propKey];
|
|
1876
1884
|
}
|
|
1877
1885
|
|
|
1878
|
-
function getInitialValue(props, propKey, defaultStateValues) {
|
|
1886
|
+
function getInitialValue$1(props, propKey, defaultStateValues) {
|
|
1879
1887
|
if (defaultStateValues === void 0) {
|
|
1880
1888
|
defaultStateValues = dropdownDefaultStateValues;
|
|
1881
1889
|
}
|
|
@@ -1890,14 +1898,14 @@ function getInitialValue(props, propKey, defaultStateValues) {
|
|
|
1890
1898
|
return props[initialPropKey];
|
|
1891
1899
|
}
|
|
1892
1900
|
|
|
1893
|
-
return getDefaultValue(props, propKey, defaultStateValues);
|
|
1901
|
+
return getDefaultValue$1(props, propKey, defaultStateValues);
|
|
1894
1902
|
}
|
|
1895
1903
|
|
|
1896
|
-
function getInitialState(props) {
|
|
1897
|
-
var selectedItem = getInitialValue(props, 'selectedItem');
|
|
1898
|
-
var isOpen = getInitialValue(props, 'isOpen');
|
|
1899
|
-
var highlightedIndex = getInitialValue(props, 'highlightedIndex');
|
|
1900
|
-
var inputValue = getInitialValue(props, 'inputValue');
|
|
1904
|
+
function getInitialState$2(props) {
|
|
1905
|
+
var selectedItem = getInitialValue$1(props, 'selectedItem');
|
|
1906
|
+
var isOpen = getInitialValue$1(props, 'isOpen');
|
|
1907
|
+
var highlightedIndex = getInitialValue$1(props, 'highlightedIndex');
|
|
1908
|
+
var inputValue = getInitialValue$1(props, 'inputValue');
|
|
1901
1909
|
return {
|
|
1902
1910
|
highlightedIndex: highlightedIndex < 0 && selectedItem && isOpen ? props.items.indexOf(selectedItem) : highlightedIndex,
|
|
1903
1911
|
isOpen: isOpen,
|
|
@@ -2192,10 +2200,10 @@ function downshiftCommonReducer(state, action, stateChangeTypes) {
|
|
|
2192
2200
|
|
|
2193
2201
|
case stateChangeTypes.FunctionReset:
|
|
2194
2202
|
changes = {
|
|
2195
|
-
highlightedIndex: getDefaultValue(props, 'highlightedIndex'),
|
|
2196
|
-
isOpen: getDefaultValue(props, 'isOpen'),
|
|
2197
|
-
selectedItem: getDefaultValue(props, 'selectedItem'),
|
|
2198
|
-
inputValue: getDefaultValue(props, 'inputValue')
|
|
2203
|
+
highlightedIndex: getDefaultValue$1(props, 'highlightedIndex'),
|
|
2204
|
+
isOpen: getDefaultValue$1(props, 'isOpen'),
|
|
2205
|
+
selectedItem: getDefaultValue$1(props, 'selectedItem'),
|
|
2206
|
+
inputValue: getDefaultValue$1(props, 'inputValue')
|
|
2199
2207
|
};
|
|
2200
2208
|
break;
|
|
2201
2209
|
|
|
@@ -2225,7 +2233,7 @@ function getItemIndexByCharacterKey(keysSoFar, highlightedIndex, items, itemToSt
|
|
|
2225
2233
|
return highlightedIndex;
|
|
2226
2234
|
}
|
|
2227
2235
|
|
|
2228
|
-
var propTypes = {
|
|
2236
|
+
var propTypes$2 = {
|
|
2229
2237
|
items: PropTypes__default['default'].array.isRequired,
|
|
2230
2238
|
itemToString: PropTypes__default['default'].func,
|
|
2231
2239
|
getA11yStatusMessage: PropTypes__default['default'].func,
|
|
@@ -2269,7 +2277,7 @@ var propTypes = {
|
|
|
2269
2277
|
* @return {String} the a11y status message
|
|
2270
2278
|
*/
|
|
2271
2279
|
|
|
2272
|
-
function getA11yStatusMessage
|
|
2280
|
+
function getA11yStatusMessage(_ref) {
|
|
2273
2281
|
var isOpen = _ref.isOpen,
|
|
2274
2282
|
resultCount = _ref.resultCount,
|
|
2275
2283
|
previousResultCount = _ref.previousResultCount;
|
|
@@ -2289,17 +2297,17 @@ function getA11yStatusMessage$1(_ref) {
|
|
|
2289
2297
|
return '';
|
|
2290
2298
|
}
|
|
2291
2299
|
|
|
2292
|
-
var defaultProps$
|
|
2293
|
-
getA11yStatusMessage: getA11yStatusMessage
|
|
2300
|
+
var defaultProps$2 = _extends__default['default']({}, defaultProps$3, {
|
|
2301
|
+
getA11yStatusMessage: getA11yStatusMessage
|
|
2294
2302
|
}); // eslint-disable-next-line import/no-mutable-exports
|
|
2295
2303
|
|
|
2296
2304
|
|
|
2297
|
-
var validatePropTypes = noop;
|
|
2305
|
+
var validatePropTypes$2 = noop;
|
|
2298
2306
|
/* istanbul ignore next */
|
|
2299
2307
|
|
|
2300
2308
|
if (process.env.NODE_ENV !== 'production') {
|
|
2301
|
-
validatePropTypes = function validatePropTypes(options, caller) {
|
|
2302
|
-
PropTypes__default['default'].checkPropTypes(propTypes, options, 'prop', caller.name);
|
|
2309
|
+
validatePropTypes$2 = function validatePropTypes(options, caller) {
|
|
2310
|
+
PropTypes__default['default'].checkPropTypes(propTypes$2, options, 'prop', caller.name);
|
|
2303
2311
|
};
|
|
2304
2312
|
}
|
|
2305
2313
|
|
|
@@ -2312,22 +2320,22 @@ var MenuKeyDownEnter = process.env.NODE_ENV !== "production" ? '__menu_keydown_e
|
|
|
2312
2320
|
var MenuKeyDownSpaceButton = process.env.NODE_ENV !== "production" ? '__menu_keydown_space_button__' : 6;
|
|
2313
2321
|
var MenuKeyDownCharacter = process.env.NODE_ENV !== "production" ? '__menu_keydown_character__' : 7;
|
|
2314
2322
|
var MenuBlur = process.env.NODE_ENV !== "production" ? '__menu_blur__' : 8;
|
|
2315
|
-
var MenuMouseLeave = process.env.NODE_ENV !== "production" ? '__menu_mouse_leave__' : 9;
|
|
2316
|
-
var ItemMouseMove = process.env.NODE_ENV !== "production" ? '__item_mouse_move__' : 10;
|
|
2317
|
-
var ItemClick = process.env.NODE_ENV !== "production" ? '__item_click__' : 11;
|
|
2318
|
-
var ToggleButtonClick = process.env.NODE_ENV !== "production" ? '__togglebutton_click__' : 12;
|
|
2323
|
+
var MenuMouseLeave$1 = process.env.NODE_ENV !== "production" ? '__menu_mouse_leave__' : 9;
|
|
2324
|
+
var ItemMouseMove$1 = process.env.NODE_ENV !== "production" ? '__item_mouse_move__' : 10;
|
|
2325
|
+
var ItemClick$1 = process.env.NODE_ENV !== "production" ? '__item_click__' : 11;
|
|
2326
|
+
var ToggleButtonClick$1 = process.env.NODE_ENV !== "production" ? '__togglebutton_click__' : 12;
|
|
2319
2327
|
var ToggleButtonKeyDownArrowDown = process.env.NODE_ENV !== "production" ? '__togglebutton_keydown_arrow_down__' : 13;
|
|
2320
2328
|
var ToggleButtonKeyDownArrowUp = process.env.NODE_ENV !== "production" ? '__togglebutton_keydown_arrow_up__' : 14;
|
|
2321
2329
|
var ToggleButtonKeyDownCharacter = process.env.NODE_ENV !== "production" ? '__togglebutton_keydown_character__' : 15;
|
|
2322
|
-
var FunctionToggleMenu = process.env.NODE_ENV !== "production" ? '__function_toggle_menu__' : 16;
|
|
2323
|
-
var FunctionOpenMenu = process.env.NODE_ENV !== "production" ? '__function_open_menu__' : 17;
|
|
2324
|
-
var FunctionCloseMenu = process.env.NODE_ENV !== "production" ? '__function_close_menu__' : 18;
|
|
2325
|
-
var FunctionSetHighlightedIndex = process.env.NODE_ENV !== "production" ? '__function_set_highlighted_index__' : 19;
|
|
2326
|
-
var FunctionSelectItem = process.env.NODE_ENV !== "production" ? '__function_select_item__' : 20;
|
|
2327
|
-
var FunctionSetInputValue = process.env.NODE_ENV !== "production" ? '__function_set_input_value__' : 21;
|
|
2328
|
-
var FunctionReset = process.env.NODE_ENV !== "production" ? '__function_reset__' : 22;
|
|
2330
|
+
var FunctionToggleMenu$1 = process.env.NODE_ENV !== "production" ? '__function_toggle_menu__' : 16;
|
|
2331
|
+
var FunctionOpenMenu$1 = process.env.NODE_ENV !== "production" ? '__function_open_menu__' : 17;
|
|
2332
|
+
var FunctionCloseMenu$1 = process.env.NODE_ENV !== "production" ? '__function_close_menu__' : 18;
|
|
2333
|
+
var FunctionSetHighlightedIndex$1 = process.env.NODE_ENV !== "production" ? '__function_set_highlighted_index__' : 19;
|
|
2334
|
+
var FunctionSelectItem$1 = process.env.NODE_ENV !== "production" ? '__function_select_item__' : 20;
|
|
2335
|
+
var FunctionSetInputValue$1 = process.env.NODE_ENV !== "production" ? '__function_set_input_value__' : 21;
|
|
2336
|
+
var FunctionReset$2 = process.env.NODE_ENV !== "production" ? '__function_reset__' : 22;
|
|
2329
2337
|
|
|
2330
|
-
var stateChangeTypes$
|
|
2338
|
+
var stateChangeTypes$2 = /*#__PURE__*/Object.freeze({
|
|
2331
2339
|
__proto__: null,
|
|
2332
2340
|
MenuKeyDownArrowDown: MenuKeyDownArrowDown,
|
|
2333
2341
|
MenuKeyDownArrowUp: MenuKeyDownArrowUp,
|
|
@@ -2338,20 +2346,20 @@ var stateChangeTypes$1 = /*#__PURE__*/Object.freeze({
|
|
|
2338
2346
|
MenuKeyDownSpaceButton: MenuKeyDownSpaceButton,
|
|
2339
2347
|
MenuKeyDownCharacter: MenuKeyDownCharacter,
|
|
2340
2348
|
MenuBlur: MenuBlur,
|
|
2341
|
-
MenuMouseLeave: MenuMouseLeave,
|
|
2342
|
-
ItemMouseMove: ItemMouseMove,
|
|
2343
|
-
ItemClick: ItemClick,
|
|
2344
|
-
ToggleButtonClick: ToggleButtonClick,
|
|
2349
|
+
MenuMouseLeave: MenuMouseLeave$1,
|
|
2350
|
+
ItemMouseMove: ItemMouseMove$1,
|
|
2351
|
+
ItemClick: ItemClick$1,
|
|
2352
|
+
ToggleButtonClick: ToggleButtonClick$1,
|
|
2345
2353
|
ToggleButtonKeyDownArrowDown: ToggleButtonKeyDownArrowDown,
|
|
2346
2354
|
ToggleButtonKeyDownArrowUp: ToggleButtonKeyDownArrowUp,
|
|
2347
2355
|
ToggleButtonKeyDownCharacter: ToggleButtonKeyDownCharacter,
|
|
2348
|
-
FunctionToggleMenu: FunctionToggleMenu,
|
|
2349
|
-
FunctionOpenMenu: FunctionOpenMenu,
|
|
2350
|
-
FunctionCloseMenu: FunctionCloseMenu,
|
|
2351
|
-
FunctionSetHighlightedIndex: FunctionSetHighlightedIndex,
|
|
2352
|
-
FunctionSelectItem: FunctionSelectItem,
|
|
2353
|
-
FunctionSetInputValue: FunctionSetInputValue,
|
|
2354
|
-
FunctionReset: FunctionReset
|
|
2356
|
+
FunctionToggleMenu: FunctionToggleMenu$1,
|
|
2357
|
+
FunctionOpenMenu: FunctionOpenMenu$1,
|
|
2358
|
+
FunctionCloseMenu: FunctionCloseMenu$1,
|
|
2359
|
+
FunctionSetHighlightedIndex: FunctionSetHighlightedIndex$1,
|
|
2360
|
+
FunctionSelectItem: FunctionSelectItem$1,
|
|
2361
|
+
FunctionSetInputValue: FunctionSetInputValue$1,
|
|
2362
|
+
FunctionReset: FunctionReset$2
|
|
2355
2363
|
});
|
|
2356
2364
|
|
|
2357
2365
|
/* eslint-disable complexity */
|
|
@@ -2363,10 +2371,10 @@ function downshiftSelectReducer(state, action) {
|
|
|
2363
2371
|
var changes;
|
|
2364
2372
|
|
|
2365
2373
|
switch (type) {
|
|
2366
|
-
case ItemClick:
|
|
2374
|
+
case ItemClick$1:
|
|
2367
2375
|
changes = {
|
|
2368
|
-
isOpen: getDefaultValue(props, 'isOpen'),
|
|
2369
|
-
highlightedIndex: getDefaultValue(props, 'highlightedIndex'),
|
|
2376
|
+
isOpen: getDefaultValue$1(props, 'isOpen'),
|
|
2377
|
+
highlightedIndex: getDefaultValue$1(props, 'highlightedIndex'),
|
|
2370
2378
|
selectedItem: props.items[action.index]
|
|
2371
2379
|
};
|
|
2372
2380
|
break;
|
|
@@ -2401,8 +2409,8 @@ function downshiftSelectReducer(state, action) {
|
|
|
2401
2409
|
case MenuKeyDownEnter:
|
|
2402
2410
|
case MenuKeyDownSpaceButton:
|
|
2403
2411
|
changes = _extends__default['default']({
|
|
2404
|
-
isOpen: getDefaultValue(props, 'isOpen'),
|
|
2405
|
-
highlightedIndex: getDefaultValue(props, 'highlightedIndex')
|
|
2412
|
+
isOpen: getDefaultValue$1(props, 'isOpen'),
|
|
2413
|
+
highlightedIndex: getDefaultValue$1(props, 'highlightedIndex')
|
|
2406
2414
|
}, state.highlightedIndex >= 0 && {
|
|
2407
2415
|
selectedItem: props.items[state.highlightedIndex]
|
|
2408
2416
|
});
|
|
@@ -2461,30 +2469,30 @@ function downshiftSelectReducer(state, action) {
|
|
|
2461
2469
|
};
|
|
2462
2470
|
break;
|
|
2463
2471
|
|
|
2464
|
-
case FunctionSelectItem:
|
|
2472
|
+
case FunctionSelectItem$1:
|
|
2465
2473
|
changes = {
|
|
2466
2474
|
selectedItem: action.selectedItem
|
|
2467
2475
|
};
|
|
2468
2476
|
break;
|
|
2469
2477
|
|
|
2470
2478
|
default:
|
|
2471
|
-
return downshiftCommonReducer(state, action, stateChangeTypes$
|
|
2479
|
+
return downshiftCommonReducer(state, action, stateChangeTypes$2);
|
|
2472
2480
|
}
|
|
2473
2481
|
|
|
2474
2482
|
return _extends__default['default']({}, state, changes);
|
|
2475
2483
|
}
|
|
2476
2484
|
/* eslint-enable complexity */
|
|
2477
2485
|
|
|
2478
|
-
useSelect.stateChangeTypes = stateChangeTypes$
|
|
2486
|
+
useSelect.stateChangeTypes = stateChangeTypes$2;
|
|
2479
2487
|
|
|
2480
2488
|
function useSelect(userProps) {
|
|
2481
2489
|
if (userProps === void 0) {
|
|
2482
2490
|
userProps = {};
|
|
2483
2491
|
}
|
|
2484
2492
|
|
|
2485
|
-
validatePropTypes(userProps, useSelect); // Props defaults and destructuring.
|
|
2493
|
+
validatePropTypes$2(userProps, useSelect); // Props defaults and destructuring.
|
|
2486
2494
|
|
|
2487
|
-
var props = _extends__default['default']({}, defaultProps$
|
|
2495
|
+
var props = _extends__default['default']({}, defaultProps$2, userProps);
|
|
2488
2496
|
|
|
2489
2497
|
var items = props.items,
|
|
2490
2498
|
scrollIntoView = props.scrollIntoView,
|
|
@@ -2495,9 +2503,9 @@ function useSelect(userProps) {
|
|
|
2495
2503
|
getA11ySelectionMessage = props.getA11ySelectionMessage,
|
|
2496
2504
|
getA11yStatusMessage = props.getA11yStatusMessage; // Initial state depending on controlled props.
|
|
2497
2505
|
|
|
2498
|
-
var initialState = getInitialState(props);
|
|
2506
|
+
var initialState = getInitialState$2(props);
|
|
2499
2507
|
|
|
2500
|
-
var _useControlledReducer = useControlledReducer(downshiftSelectReducer, initialState, props),
|
|
2508
|
+
var _useControlledReducer = useControlledReducer$1(downshiftSelectReducer, initialState, props),
|
|
2501
2509
|
state = _useControlledReducer[0],
|
|
2502
2510
|
dispatch = _useControlledReducer[1];
|
|
2503
2511
|
|
|
@@ -2552,19 +2560,23 @@ function useSelect(userProps) {
|
|
|
2552
2560
|
itemRefs: itemRefs,
|
|
2553
2561
|
scrollIntoView: scrollIntoView,
|
|
2554
2562
|
getItemNodeFromIndex: getItemNodeFromIndex
|
|
2555
|
-
}); // Sets cleanup for the keysSoFar after 500ms.
|
|
2563
|
+
}); // Sets cleanup for the keysSoFar callback, debounded after 500ms.
|
|
2556
2564
|
|
|
2557
2565
|
preact.useEffect(function () {
|
|
2558
2566
|
// init the clean function here as we need access to dispatch.
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
+
clearTimeoutRef.current = debounce(function (outerDispatch) {
|
|
2568
|
+
outerDispatch({
|
|
2569
|
+
type: FunctionSetInputValue$1,
|
|
2570
|
+
inputValue: ''
|
|
2571
|
+
});
|
|
2572
|
+
}, 500); // Cancel any pending debounced calls on mount
|
|
2573
|
+
|
|
2574
|
+
return function () {
|
|
2575
|
+
clearTimeoutRef.current.cancel();
|
|
2576
|
+
};
|
|
2577
|
+
}, []); // Invokes the keysSoFar callback set up above.
|
|
2567
2578
|
|
|
2579
|
+
preact.useEffect(function () {
|
|
2568
2580
|
if (!inputValue) {
|
|
2569
2581
|
return;
|
|
2570
2582
|
}
|
|
@@ -2708,39 +2720,39 @@ function useSelect(userProps) {
|
|
|
2708
2720
|
|
|
2709
2721
|
var toggleMenu = preact.useCallback(function () {
|
|
2710
2722
|
dispatch({
|
|
2711
|
-
type: FunctionToggleMenu
|
|
2723
|
+
type: FunctionToggleMenu$1
|
|
2712
2724
|
});
|
|
2713
2725
|
}, [dispatch]);
|
|
2714
2726
|
var closeMenu = preact.useCallback(function () {
|
|
2715
2727
|
dispatch({
|
|
2716
|
-
type: FunctionCloseMenu
|
|
2728
|
+
type: FunctionCloseMenu$1
|
|
2717
2729
|
});
|
|
2718
2730
|
}, [dispatch]);
|
|
2719
2731
|
var openMenu = preact.useCallback(function () {
|
|
2720
2732
|
dispatch({
|
|
2721
|
-
type: FunctionOpenMenu
|
|
2733
|
+
type: FunctionOpenMenu$1
|
|
2722
2734
|
});
|
|
2723
2735
|
}, [dispatch]);
|
|
2724
2736
|
var setHighlightedIndex = preact.useCallback(function (newHighlightedIndex) {
|
|
2725
2737
|
dispatch({
|
|
2726
|
-
type: FunctionSetHighlightedIndex,
|
|
2738
|
+
type: FunctionSetHighlightedIndex$1,
|
|
2727
2739
|
highlightedIndex: newHighlightedIndex
|
|
2728
2740
|
});
|
|
2729
2741
|
}, [dispatch]);
|
|
2730
2742
|
var selectItem = preact.useCallback(function (newSelectedItem) {
|
|
2731
2743
|
dispatch({
|
|
2732
|
-
type: FunctionSelectItem,
|
|
2744
|
+
type: FunctionSelectItem$1,
|
|
2733
2745
|
selectedItem: newSelectedItem
|
|
2734
2746
|
});
|
|
2735
2747
|
}, [dispatch]);
|
|
2736
2748
|
var reset = preact.useCallback(function () {
|
|
2737
2749
|
dispatch({
|
|
2738
|
-
type: FunctionReset
|
|
2750
|
+
type: FunctionReset$2
|
|
2739
2751
|
});
|
|
2740
2752
|
}, [dispatch]);
|
|
2741
2753
|
var setInputValue = preact.useCallback(function (newInputValue) {
|
|
2742
2754
|
dispatch({
|
|
2743
|
-
type: FunctionSetInputValue,
|
|
2755
|
+
type: FunctionSetInputValue$1,
|
|
2744
2756
|
inputValue: newInputValue
|
|
2745
2757
|
});
|
|
2746
2758
|
}, [dispatch]); // Getter functions.
|
|
@@ -2802,7 +2814,7 @@ function useSelect(userProps) {
|
|
|
2802
2814
|
|
|
2803
2815
|
var menuHandleMouseLeave = function menuHandleMouseLeave() {
|
|
2804
2816
|
dispatch({
|
|
2805
|
-
type: MenuMouseLeave
|
|
2817
|
+
type: MenuMouseLeave$1
|
|
2806
2818
|
});
|
|
2807
2819
|
};
|
|
2808
2820
|
|
|
@@ -2834,7 +2846,7 @@ function useSelect(userProps) {
|
|
|
2834
2846
|
|
|
2835
2847
|
var toggleButtonHandleClick = function toggleButtonHandleClick() {
|
|
2836
2848
|
dispatch({
|
|
2837
|
-
type: ToggleButtonClick
|
|
2849
|
+
type: ToggleButtonClick$1
|
|
2838
2850
|
});
|
|
2839
2851
|
};
|
|
2840
2852
|
|
|
@@ -2888,14 +2900,14 @@ function useSelect(userProps) {
|
|
|
2888
2900
|
|
|
2889
2901
|
shouldScrollRef.current = false;
|
|
2890
2902
|
dispatch({
|
|
2891
|
-
type: ItemMouseMove,
|
|
2903
|
+
type: ItemMouseMove$1,
|
|
2892
2904
|
index: index
|
|
2893
2905
|
});
|
|
2894
2906
|
};
|
|
2895
2907
|
|
|
2896
2908
|
var itemHandleClick = function itemHandleClick() {
|
|
2897
2909
|
dispatch({
|
|
2898
|
-
type: ItemClick,
|
|
2910
|
+
type: ItemClick$1,
|
|
2899
2911
|
index: index
|
|
2900
2912
|
});
|
|
2901
2913
|
};
|
|
@@ -2953,20 +2965,20 @@ var InputKeyDownEnd = process.env.NODE_ENV !== "production" ? '__input_keydown_e
|
|
|
2953
2965
|
var InputKeyDownEnter = process.env.NODE_ENV !== "production" ? '__input_keydown_enter__' : 5;
|
|
2954
2966
|
var InputChange = process.env.NODE_ENV !== "production" ? '__input_change__' : 6;
|
|
2955
2967
|
var InputBlur = process.env.NODE_ENV !== "production" ? '__input_blur__' : 7;
|
|
2956
|
-
var MenuMouseLeave
|
|
2957
|
-
var ItemMouseMove
|
|
2958
|
-
var ItemClick
|
|
2959
|
-
var ToggleButtonClick
|
|
2960
|
-
var FunctionToggleMenu
|
|
2961
|
-
var FunctionOpenMenu
|
|
2962
|
-
var FunctionCloseMenu
|
|
2963
|
-
var FunctionSetHighlightedIndex
|
|
2964
|
-
var FunctionSelectItem
|
|
2965
|
-
var FunctionSetInputValue
|
|
2968
|
+
var MenuMouseLeave = process.env.NODE_ENV !== "production" ? '__menu_mouse_leave__' : 8;
|
|
2969
|
+
var ItemMouseMove = process.env.NODE_ENV !== "production" ? '__item_mouse_move__' : 9;
|
|
2970
|
+
var ItemClick = process.env.NODE_ENV !== "production" ? '__item_click__' : 10;
|
|
2971
|
+
var ToggleButtonClick = process.env.NODE_ENV !== "production" ? '__togglebutton_click__' : 11;
|
|
2972
|
+
var FunctionToggleMenu = process.env.NODE_ENV !== "production" ? '__function_toggle_menu__' : 12;
|
|
2973
|
+
var FunctionOpenMenu = process.env.NODE_ENV !== "production" ? '__function_open_menu__' : 13;
|
|
2974
|
+
var FunctionCloseMenu = process.env.NODE_ENV !== "production" ? '__function_close_menu__' : 14;
|
|
2975
|
+
var FunctionSetHighlightedIndex = process.env.NODE_ENV !== "production" ? '__function_set_highlighted_index__' : 15;
|
|
2976
|
+
var FunctionSelectItem = process.env.NODE_ENV !== "production" ? '__function_select_item__' : 16;
|
|
2977
|
+
var FunctionSetInputValue = process.env.NODE_ENV !== "production" ? '__function_set_input_value__' : 17;
|
|
2966
2978
|
var FunctionReset$1 = process.env.NODE_ENV !== "production" ? '__function_reset__' : 18;
|
|
2967
2979
|
var ControlledPropUpdatedSelectedItem = process.env.NODE_ENV !== "production" ? '__controlled_prop_updated_selected_item__' : 19;
|
|
2968
2980
|
|
|
2969
|
-
var stateChangeTypes$
|
|
2981
|
+
var stateChangeTypes$1 = /*#__PURE__*/Object.freeze({
|
|
2970
2982
|
__proto__: null,
|
|
2971
2983
|
InputKeyDownArrowDown: InputKeyDownArrowDown,
|
|
2972
2984
|
InputKeyDownArrowUp: InputKeyDownArrowUp,
|
|
@@ -2976,22 +2988,22 @@ var stateChangeTypes$2 = /*#__PURE__*/Object.freeze({
|
|
|
2976
2988
|
InputKeyDownEnter: InputKeyDownEnter,
|
|
2977
2989
|
InputChange: InputChange,
|
|
2978
2990
|
InputBlur: InputBlur,
|
|
2979
|
-
MenuMouseLeave: MenuMouseLeave
|
|
2980
|
-
ItemMouseMove: ItemMouseMove
|
|
2981
|
-
ItemClick: ItemClick
|
|
2982
|
-
ToggleButtonClick: ToggleButtonClick
|
|
2983
|
-
FunctionToggleMenu: FunctionToggleMenu
|
|
2984
|
-
FunctionOpenMenu: FunctionOpenMenu
|
|
2985
|
-
FunctionCloseMenu: FunctionCloseMenu
|
|
2986
|
-
FunctionSetHighlightedIndex: FunctionSetHighlightedIndex
|
|
2987
|
-
FunctionSelectItem: FunctionSelectItem
|
|
2988
|
-
FunctionSetInputValue: FunctionSetInputValue
|
|
2991
|
+
MenuMouseLeave: MenuMouseLeave,
|
|
2992
|
+
ItemMouseMove: ItemMouseMove,
|
|
2993
|
+
ItemClick: ItemClick,
|
|
2994
|
+
ToggleButtonClick: ToggleButtonClick,
|
|
2995
|
+
FunctionToggleMenu: FunctionToggleMenu,
|
|
2996
|
+
FunctionOpenMenu: FunctionOpenMenu,
|
|
2997
|
+
FunctionCloseMenu: FunctionCloseMenu,
|
|
2998
|
+
FunctionSetHighlightedIndex: FunctionSetHighlightedIndex,
|
|
2999
|
+
FunctionSelectItem: FunctionSelectItem,
|
|
3000
|
+
FunctionSetInputValue: FunctionSetInputValue,
|
|
2989
3001
|
FunctionReset: FunctionReset$1,
|
|
2990
3002
|
ControlledPropUpdatedSelectedItem: ControlledPropUpdatedSelectedItem
|
|
2991
3003
|
});
|
|
2992
3004
|
|
|
2993
3005
|
function getInitialState$1(props) {
|
|
2994
|
-
var initialState = getInitialState(props);
|
|
3006
|
+
var initialState = getInitialState$2(props);
|
|
2995
3007
|
var selectedItem = initialState.selectedItem;
|
|
2996
3008
|
var inputValue = initialState.inputValue;
|
|
2997
3009
|
|
|
@@ -3057,7 +3069,7 @@ var propTypes$1 = {
|
|
|
3057
3069
|
* @returns {Array} An array with the state and an action dispatcher.
|
|
3058
3070
|
*/
|
|
3059
3071
|
|
|
3060
|
-
function useControlledReducer
|
|
3072
|
+
function useControlledReducer(reducer, initialState, props) {
|
|
3061
3073
|
var previousSelectedItemRef = preact.useRef();
|
|
3062
3074
|
|
|
3063
3075
|
var _useEnhancedReducer = useEnhancedReducer(reducer, initialState, props),
|
|
@@ -3090,8 +3102,8 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
3090
3102
|
};
|
|
3091
3103
|
}
|
|
3092
3104
|
|
|
3093
|
-
var defaultProps$
|
|
3094
|
-
getA11yStatusMessage: getA11yStatusMessage,
|
|
3105
|
+
var defaultProps$1 = _extends__default['default']({}, defaultProps$3, {
|
|
3106
|
+
getA11yStatusMessage: getA11yStatusMessage$1,
|
|
3095
3107
|
circularNavigation: true
|
|
3096
3108
|
});
|
|
3097
3109
|
|
|
@@ -3104,10 +3116,10 @@ function downshiftUseComboboxReducer(state, action) {
|
|
|
3104
3116
|
var changes;
|
|
3105
3117
|
|
|
3106
3118
|
switch (type) {
|
|
3107
|
-
case ItemClick
|
|
3119
|
+
case ItemClick:
|
|
3108
3120
|
changes = {
|
|
3109
|
-
isOpen: getDefaultValue(props, 'isOpen'),
|
|
3110
|
-
highlightedIndex: getDefaultValue(props, 'highlightedIndex'),
|
|
3121
|
+
isOpen: getDefaultValue$1(props, 'isOpen'),
|
|
3122
|
+
highlightedIndex: getDefaultValue$1(props, 'highlightedIndex'),
|
|
3111
3123
|
selectedItem: props.items[action.index],
|
|
3112
3124
|
inputValue: props.itemToString(props.items[action.index])
|
|
3113
3125
|
};
|
|
@@ -3121,7 +3133,7 @@ function downshiftUseComboboxReducer(state, action) {
|
|
|
3121
3133
|
} else {
|
|
3122
3134
|
changes = {
|
|
3123
3135
|
highlightedIndex: getHighlightedIndexOnOpen(props, state, 1, action.getItemNodeFromIndex),
|
|
3124
|
-
isOpen:
|
|
3136
|
+
isOpen: props.items.length >= 0
|
|
3125
3137
|
};
|
|
3126
3138
|
}
|
|
3127
3139
|
|
|
@@ -3135,7 +3147,7 @@ function downshiftUseComboboxReducer(state, action) {
|
|
|
3135
3147
|
} else {
|
|
3136
3148
|
changes = {
|
|
3137
3149
|
highlightedIndex: getHighlightedIndexOnOpen(props, state, -1, action.getItemNodeFromIndex),
|
|
3138
|
-
isOpen:
|
|
3150
|
+
isOpen: props.items.length >= 0
|
|
3139
3151
|
};
|
|
3140
3152
|
}
|
|
3141
3153
|
|
|
@@ -3144,8 +3156,8 @@ function downshiftUseComboboxReducer(state, action) {
|
|
|
3144
3156
|
case InputKeyDownEnter:
|
|
3145
3157
|
changes = _extends__default['default']({}, state.isOpen && state.highlightedIndex >= 0 && {
|
|
3146
3158
|
selectedItem: props.items[state.highlightedIndex],
|
|
3147
|
-
isOpen: getDefaultValue(props, 'isOpen'),
|
|
3148
|
-
highlightedIndex: getDefaultValue(props, 'highlightedIndex'),
|
|
3159
|
+
isOpen: getDefaultValue$1(props, 'isOpen'),
|
|
3160
|
+
highlightedIndex: getDefaultValue$1(props, 'highlightedIndex'),
|
|
3149
3161
|
inputValue: props.itemToString(props.items[state.highlightedIndex])
|
|
3150
3162
|
});
|
|
3151
3163
|
break;
|
|
@@ -3161,39 +3173,36 @@ function downshiftUseComboboxReducer(state, action) {
|
|
|
3161
3173
|
break;
|
|
3162
3174
|
|
|
3163
3175
|
case InputKeyDownHome:
|
|
3164
|
-
changes =
|
|
3176
|
+
changes = {
|
|
3165
3177
|
highlightedIndex: getNextNonDisabledIndex(1, 0, props.items.length, action.getItemNodeFromIndex, false)
|
|
3166
|
-
}
|
|
3178
|
+
};
|
|
3167
3179
|
break;
|
|
3168
3180
|
|
|
3169
3181
|
case InputKeyDownEnd:
|
|
3170
|
-
changes =
|
|
3182
|
+
changes = {
|
|
3171
3183
|
highlightedIndex: getNextNonDisabledIndex(-1, props.items.length - 1, props.items.length, action.getItemNodeFromIndex, false)
|
|
3172
|
-
}
|
|
3184
|
+
};
|
|
3173
3185
|
break;
|
|
3174
3186
|
|
|
3175
3187
|
case InputBlur:
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
|
|
3183
|
-
});
|
|
3184
|
-
}
|
|
3185
|
-
|
|
3188
|
+
changes = _extends__default['default']({
|
|
3189
|
+
isOpen: false,
|
|
3190
|
+
highlightedIndex: -1
|
|
3191
|
+
}, state.highlightedIndex >= 0 && action.selectItem && {
|
|
3192
|
+
selectedItem: props.items[state.highlightedIndex],
|
|
3193
|
+
inputValue: props.itemToString(props.items[state.highlightedIndex])
|
|
3194
|
+
});
|
|
3186
3195
|
break;
|
|
3187
3196
|
|
|
3188
3197
|
case InputChange:
|
|
3189
3198
|
changes = {
|
|
3190
3199
|
isOpen: true,
|
|
3191
|
-
highlightedIndex: getDefaultValue(props, 'highlightedIndex'),
|
|
3200
|
+
highlightedIndex: getDefaultValue$1(props, 'highlightedIndex'),
|
|
3192
3201
|
inputValue: action.inputValue
|
|
3193
3202
|
};
|
|
3194
3203
|
break;
|
|
3195
3204
|
|
|
3196
|
-
case FunctionSelectItem
|
|
3205
|
+
case FunctionSelectItem:
|
|
3197
3206
|
changes = {
|
|
3198
3207
|
selectedItem: action.selectedItem,
|
|
3199
3208
|
inputValue: props.itemToString(action.selectedItem)
|
|
@@ -3207,14 +3216,14 @@ function downshiftUseComboboxReducer(state, action) {
|
|
|
3207
3216
|
break;
|
|
3208
3217
|
|
|
3209
3218
|
default:
|
|
3210
|
-
return downshiftCommonReducer(state, action, stateChangeTypes$
|
|
3219
|
+
return downshiftCommonReducer(state, action, stateChangeTypes$1);
|
|
3211
3220
|
}
|
|
3212
3221
|
|
|
3213
3222
|
return _extends__default['default']({}, state, changes);
|
|
3214
3223
|
}
|
|
3215
3224
|
/* eslint-enable complexity */
|
|
3216
3225
|
|
|
3217
|
-
useCombobox.stateChangeTypes = stateChangeTypes$
|
|
3226
|
+
useCombobox.stateChangeTypes = stateChangeTypes$1;
|
|
3218
3227
|
|
|
3219
3228
|
function useCombobox(userProps) {
|
|
3220
3229
|
if (userProps === void 0) {
|
|
@@ -3223,7 +3232,7 @@ function useCombobox(userProps) {
|
|
|
3223
3232
|
|
|
3224
3233
|
validatePropTypes$1(userProps, useCombobox); // Props defaults and destructuring.
|
|
3225
3234
|
|
|
3226
|
-
var props = _extends__default['default']({}, defaultProps$
|
|
3235
|
+
var props = _extends__default['default']({}, defaultProps$1, userProps);
|
|
3227
3236
|
|
|
3228
3237
|
var initialIsOpen = props.initialIsOpen,
|
|
3229
3238
|
defaultIsOpen = props.defaultIsOpen,
|
|
@@ -3236,7 +3245,7 @@ function useCombobox(userProps) {
|
|
|
3236
3245
|
|
|
3237
3246
|
var initialState = getInitialState$1(props);
|
|
3238
3247
|
|
|
3239
|
-
var _useControlledReducer = useControlledReducer
|
|
3248
|
+
var _useControlledReducer = useControlledReducer(downshiftUseComboboxReducer, initialState, props),
|
|
3240
3249
|
state = _useControlledReducer[0],
|
|
3241
3250
|
dispatch = _useControlledReducer[1];
|
|
3242
3251
|
|
|
@@ -3349,6 +3358,10 @@ function useCombobox(userProps) {
|
|
|
3349
3358
|
});
|
|
3350
3359
|
},
|
|
3351
3360
|
Home: function Home(event) {
|
|
3361
|
+
if (!latest.current.state.isOpen) {
|
|
3362
|
+
return;
|
|
3363
|
+
}
|
|
3364
|
+
|
|
3352
3365
|
event.preventDefault();
|
|
3353
3366
|
dispatch({
|
|
3354
3367
|
type: InputKeyDownHome,
|
|
@@ -3356,6 +3369,10 @@ function useCombobox(userProps) {
|
|
|
3356
3369
|
});
|
|
3357
3370
|
},
|
|
3358
3371
|
End: function End(event) {
|
|
3372
|
+
if (!latest.current.state.isOpen) {
|
|
3373
|
+
return;
|
|
3374
|
+
}
|
|
3375
|
+
|
|
3359
3376
|
event.preventDefault();
|
|
3360
3377
|
dispatch({
|
|
3361
3378
|
type: InputKeyDownEnd,
|
|
@@ -3363,22 +3380,23 @@ function useCombobox(userProps) {
|
|
|
3363
3380
|
});
|
|
3364
3381
|
},
|
|
3365
3382
|
Escape: function Escape() {
|
|
3366
|
-
dispatch({
|
|
3367
|
-
type: InputKeyDownEscape
|
|
3368
|
-
});
|
|
3369
|
-
},
|
|
3370
|
-
Enter: function Enter(event) {
|
|
3371
|
-
// if IME composing, wait for next Enter keydown event.
|
|
3372
|
-
if (event.which === 229) {
|
|
3373
|
-
return;
|
|
3374
|
-
}
|
|
3375
|
-
|
|
3376
3383
|
var latestState = latest.current.state;
|
|
3377
3384
|
|
|
3378
|
-
if (latestState.isOpen) {
|
|
3379
|
-
|
|
3385
|
+
if (latestState.isOpen || latestState.inputValue || latestState.selectedItem || latestState.highlightedIndex > -1) {
|
|
3386
|
+
dispatch({
|
|
3387
|
+
type: InputKeyDownEscape
|
|
3388
|
+
});
|
|
3380
3389
|
}
|
|
3390
|
+
},
|
|
3391
|
+
Enter: function Enter(event) {
|
|
3392
|
+
var latestState = latest.current.state; // if closed or no highlighted index, do nothing.
|
|
3381
3393
|
|
|
3394
|
+
if (!latestState.isOpen || latestState.highlightedIndex < 0 || event.which === 229 // if IME composing, wait for next Enter keydown event.
|
|
3395
|
+
) {
|
|
3396
|
+
return;
|
|
3397
|
+
}
|
|
3398
|
+
|
|
3399
|
+
event.preventDefault();
|
|
3382
3400
|
dispatch({
|
|
3383
3401
|
type: InputKeyDownEnter,
|
|
3384
3402
|
getItemNodeFromIndex: getItemNodeFromIndex
|
|
@@ -3412,7 +3430,7 @@ function useCombobox(userProps) {
|
|
|
3412
3430
|
menuRef.current = menuNode;
|
|
3413
3431
|
}), _extends2.id = elementIds.menuId, _extends2.role = 'listbox', _extends2['aria-labelledby'] = elementIds.labelId, _extends2.onMouseLeave = callAllEventHandlers(onMouseLeave, function () {
|
|
3414
3432
|
dispatch({
|
|
3415
|
-
type: MenuMouseLeave
|
|
3433
|
+
type: MenuMouseLeave
|
|
3416
3434
|
});
|
|
3417
3435
|
}), _extends2), rest);
|
|
3418
3436
|
}, [dispatch, setGetterPropCallInfo, elementIds]);
|
|
@@ -3426,9 +3444,9 @@ function useCombobox(userProps) {
|
|
|
3426
3444
|
refKey = _ref3$refKey === void 0 ? 'ref' : _ref3$refKey,
|
|
3427
3445
|
ref = _ref3.ref,
|
|
3428
3446
|
onMouseMove = _ref3.onMouseMove,
|
|
3429
|
-
onClick = _ref3.onClick
|
|
3430
|
-
|
|
3431
|
-
rest = _objectWithoutPropertiesLoose__default['default'](_ref3, ["item", "index", "refKey", "ref", "onMouseMove", "onClick", "onPress"]);
|
|
3447
|
+
onClick = _ref3.onClick;
|
|
3448
|
+
_ref3.onPress;
|
|
3449
|
+
var rest = _objectWithoutPropertiesLoose__default['default'](_ref3, ["item", "index", "refKey", "ref", "onMouseMove", "onClick", "onPress"]);
|
|
3432
3450
|
|
|
3433
3451
|
var _latest$current = latest.current,
|
|
3434
3452
|
latestProps = _latest$current.props,
|
|
@@ -3439,8 +3457,8 @@ function useCombobox(userProps) {
|
|
|
3439
3457
|
throw new Error('Pass either item or item index in getItemProps!');
|
|
3440
3458
|
}
|
|
3441
3459
|
|
|
3442
|
-
var onSelectKey =
|
|
3443
|
-
var customClickHandler =
|
|
3460
|
+
var onSelectKey = 'onClick';
|
|
3461
|
+
var customClickHandler = onClick;
|
|
3444
3462
|
|
|
3445
3463
|
var itemHandleMouseMove = function itemHandleMouseMove() {
|
|
3446
3464
|
if (index === latestState.highlightedIndex) {
|
|
@@ -3449,14 +3467,14 @@ function useCombobox(userProps) {
|
|
|
3449
3467
|
|
|
3450
3468
|
shouldScrollRef.current = false;
|
|
3451
3469
|
dispatch({
|
|
3452
|
-
type: ItemMouseMove
|
|
3470
|
+
type: ItemMouseMove,
|
|
3453
3471
|
index: index
|
|
3454
3472
|
});
|
|
3455
3473
|
};
|
|
3456
3474
|
|
|
3457
3475
|
var itemHandleClick = function itemHandleClick() {
|
|
3458
3476
|
dispatch({
|
|
3459
|
-
type: ItemClick
|
|
3477
|
+
type: ItemClick,
|
|
3460
3478
|
index: index
|
|
3461
3479
|
});
|
|
3462
3480
|
|
|
@@ -3477,16 +3495,16 @@ function useCombobox(userProps) {
|
|
|
3477
3495
|
var _extends4;
|
|
3478
3496
|
|
|
3479
3497
|
var _ref5 = _temp4 === void 0 ? {} : _temp4,
|
|
3480
|
-
onClick = _ref5.onClick
|
|
3481
|
-
|
|
3482
|
-
_ref5$refKey = _ref5.refKey,
|
|
3498
|
+
onClick = _ref5.onClick;
|
|
3499
|
+
_ref5.onPress;
|
|
3500
|
+
var _ref5$refKey = _ref5.refKey,
|
|
3483
3501
|
refKey = _ref5$refKey === void 0 ? 'ref' : _ref5$refKey,
|
|
3484
3502
|
ref = _ref5.ref,
|
|
3485
3503
|
rest = _objectWithoutPropertiesLoose__default['default'](_ref5, ["onClick", "onPress", "refKey", "ref"]);
|
|
3486
3504
|
|
|
3487
3505
|
var toggleButtonHandleClick = function toggleButtonHandleClick() {
|
|
3488
3506
|
dispatch({
|
|
3489
|
-
type: ToggleButtonClick
|
|
3507
|
+
type: ToggleButtonClick
|
|
3490
3508
|
});
|
|
3491
3509
|
|
|
3492
3510
|
if (!latest.current.state.isOpen && inputRef.current) {
|
|
@@ -3496,7 +3514,7 @@ function useCombobox(userProps) {
|
|
|
3496
3514
|
|
|
3497
3515
|
return _extends__default['default']((_extends4 = {}, _extends4[refKey] = handleRefs(ref, function (toggleButtonNode) {
|
|
3498
3516
|
toggleButtonRef.current = toggleButtonNode;
|
|
3499
|
-
}), _extends4.id = elementIds.toggleButtonId, _extends4.tabIndex = -1, _extends4), !rest.disabled && _extends__default['default']({},
|
|
3517
|
+
}), _extends4.id = elementIds.toggleButtonId, _extends4.tabIndex = -1, _extends4), !rest.disabled && _extends__default['default']({}, {
|
|
3500
3518
|
onClick: callAllEventHandlers(onClick, toggleButtonHandleClick)
|
|
3501
3519
|
}), rest);
|
|
3502
3520
|
}, [dispatch, latest, elementIds]);
|
|
@@ -3507,9 +3525,9 @@ function useCombobox(userProps) {
|
|
|
3507
3525
|
onKeyDown = _ref6.onKeyDown,
|
|
3508
3526
|
onChange = _ref6.onChange,
|
|
3509
3527
|
onInput = _ref6.onInput,
|
|
3510
|
-
onBlur = _ref6.onBlur
|
|
3511
|
-
|
|
3512
|
-
_ref6$refKey = _ref6.refKey,
|
|
3528
|
+
onBlur = _ref6.onBlur;
|
|
3529
|
+
_ref6.onChangeText;
|
|
3530
|
+
var _ref6$refKey = _ref6.refKey,
|
|
3513
3531
|
refKey = _ref6$refKey === void 0 ? 'ref' : _ref6$refKey,
|
|
3514
3532
|
ref = _ref6.ref,
|
|
3515
3533
|
rest = _objectWithoutPropertiesLoose__default['default'](_ref6, ["onKeyDown", "onChange", "onInput", "onBlur", "onChangeText", "refKey", "ref"]);
|
|
@@ -3532,13 +3550,13 @@ function useCombobox(userProps) {
|
|
|
3532
3550
|
var inputHandleChange = function inputHandleChange(event) {
|
|
3533
3551
|
dispatch({
|
|
3534
3552
|
type: InputChange,
|
|
3535
|
-
inputValue:
|
|
3553
|
+
inputValue: event.target.value
|
|
3536
3554
|
});
|
|
3537
3555
|
};
|
|
3538
3556
|
|
|
3539
3557
|
var inputHandleBlur = function inputHandleBlur() {
|
|
3540
3558
|
/* istanbul ignore else */
|
|
3541
|
-
if (!mouseAndTouchTrackersRef.current.isMouseDown) {
|
|
3559
|
+
if (latestState.isOpen && !mouseAndTouchTrackersRef.current.isMouseDown) {
|
|
3542
3560
|
dispatch({
|
|
3543
3561
|
type: InputBlur,
|
|
3544
3562
|
selectItem: true
|
|
@@ -3548,7 +3566,7 @@ function useCombobox(userProps) {
|
|
|
3548
3566
|
/* istanbul ignore next (preact) */
|
|
3549
3567
|
|
|
3550
3568
|
|
|
3551
|
-
var onChangeKey =
|
|
3569
|
+
var onChangeKey = 'onInput' ;
|
|
3552
3570
|
var eventHandlers = {};
|
|
3553
3571
|
|
|
3554
3572
|
if (!rest.disabled) {
|
|
@@ -3590,34 +3608,34 @@ function useCombobox(userProps) {
|
|
|
3590
3608
|
|
|
3591
3609
|
var toggleMenu = preact.useCallback(function () {
|
|
3592
3610
|
dispatch({
|
|
3593
|
-
type: FunctionToggleMenu
|
|
3611
|
+
type: FunctionToggleMenu
|
|
3594
3612
|
});
|
|
3595
3613
|
}, [dispatch]);
|
|
3596
3614
|
var closeMenu = preact.useCallback(function () {
|
|
3597
3615
|
dispatch({
|
|
3598
|
-
type: FunctionCloseMenu
|
|
3616
|
+
type: FunctionCloseMenu
|
|
3599
3617
|
});
|
|
3600
3618
|
}, [dispatch]);
|
|
3601
3619
|
var openMenu = preact.useCallback(function () {
|
|
3602
3620
|
dispatch({
|
|
3603
|
-
type: FunctionOpenMenu
|
|
3621
|
+
type: FunctionOpenMenu
|
|
3604
3622
|
});
|
|
3605
3623
|
}, [dispatch]);
|
|
3606
3624
|
var setHighlightedIndex = preact.useCallback(function (newHighlightedIndex) {
|
|
3607
3625
|
dispatch({
|
|
3608
|
-
type: FunctionSetHighlightedIndex
|
|
3626
|
+
type: FunctionSetHighlightedIndex,
|
|
3609
3627
|
highlightedIndex: newHighlightedIndex
|
|
3610
3628
|
});
|
|
3611
3629
|
}, [dispatch]);
|
|
3612
3630
|
var selectItem = preact.useCallback(function (newSelectedItem) {
|
|
3613
3631
|
dispatch({
|
|
3614
|
-
type: FunctionSelectItem
|
|
3632
|
+
type: FunctionSelectItem,
|
|
3615
3633
|
selectedItem: newSelectedItem
|
|
3616
3634
|
});
|
|
3617
3635
|
}, [dispatch]);
|
|
3618
3636
|
var setInputValue = preact.useCallback(function (newInputValue) {
|
|
3619
3637
|
dispatch({
|
|
3620
|
-
type: FunctionSetInputValue
|
|
3638
|
+
type: FunctionSetInputValue,
|
|
3621
3639
|
inputValue: newInputValue
|
|
3622
3640
|
});
|
|
3623
3641
|
}, [dispatch]);
|
|
@@ -3664,8 +3682,8 @@ var defaultStateValues = {
|
|
|
3664
3682
|
* @returns {any} The initial value for that prop.
|
|
3665
3683
|
*/
|
|
3666
3684
|
|
|
3667
|
-
function getInitialValue
|
|
3668
|
-
return getInitialValue(props, propKey, defaultStateValues);
|
|
3685
|
+
function getInitialValue(props, propKey) {
|
|
3686
|
+
return getInitialValue$1(props, propKey, defaultStateValues);
|
|
3669
3687
|
}
|
|
3670
3688
|
/**
|
|
3671
3689
|
* Returns the default value for a state key in the following order:
|
|
@@ -3677,8 +3695,8 @@ function getInitialValue$1(props, propKey) {
|
|
|
3677
3695
|
*/
|
|
3678
3696
|
|
|
3679
3697
|
|
|
3680
|
-
function getDefaultValue
|
|
3681
|
-
return getDefaultValue(props, propKey, defaultStateValues);
|
|
3698
|
+
function getDefaultValue(props, propKey) {
|
|
3699
|
+
return getDefaultValue$1(props, propKey, defaultStateValues);
|
|
3682
3700
|
}
|
|
3683
3701
|
/**
|
|
3684
3702
|
* Gets the initial state based on the provided props. It uses initial, default
|
|
@@ -3689,9 +3707,9 @@ function getDefaultValue$1(props, propKey) {
|
|
|
3689
3707
|
*/
|
|
3690
3708
|
|
|
3691
3709
|
|
|
3692
|
-
function getInitialState
|
|
3693
|
-
var activeIndex = getInitialValue
|
|
3694
|
-
var selectedItems = getInitialValue
|
|
3710
|
+
function getInitialState(props) {
|
|
3711
|
+
var activeIndex = getInitialValue(props, 'activeIndex');
|
|
3712
|
+
var selectedItems = getInitialValue(props, 'selectedItems');
|
|
3695
3713
|
return {
|
|
3696
3714
|
activeIndex: activeIndex,
|
|
3697
3715
|
selectedItems: selectedItems
|
|
@@ -3738,7 +3756,7 @@ function getA11yRemovalMessage(selectionParameters) {
|
|
|
3738
3756
|
return itemToStringLocal(removedSelectedItem) + " has been removed.";
|
|
3739
3757
|
}
|
|
3740
3758
|
|
|
3741
|
-
var propTypes
|
|
3759
|
+
var propTypes = {
|
|
3742
3760
|
selectedItems: PropTypes__default['default'].array,
|
|
3743
3761
|
initialSelectedItems: PropTypes__default['default'].array,
|
|
3744
3762
|
defaultSelectedItems: PropTypes__default['default'].array,
|
|
@@ -3762,21 +3780,21 @@ var propTypes$2 = {
|
|
|
3762
3780
|
})
|
|
3763
3781
|
})
|
|
3764
3782
|
};
|
|
3765
|
-
var defaultProps
|
|
3766
|
-
itemToString: defaultProps.itemToString,
|
|
3767
|
-
stateReducer: defaultProps.stateReducer,
|
|
3768
|
-
environment: defaultProps.environment,
|
|
3783
|
+
var defaultProps = {
|
|
3784
|
+
itemToString: defaultProps$3.itemToString,
|
|
3785
|
+
stateReducer: defaultProps$3.stateReducer,
|
|
3786
|
+
environment: defaultProps$3.environment,
|
|
3769
3787
|
getA11yRemovalMessage: getA11yRemovalMessage,
|
|
3770
3788
|
keyNavigationNext: 'ArrowRight',
|
|
3771
3789
|
keyNavigationPrevious: 'ArrowLeft'
|
|
3772
3790
|
}; // eslint-disable-next-line import/no-mutable-exports
|
|
3773
3791
|
|
|
3774
|
-
var validatePropTypes
|
|
3792
|
+
var validatePropTypes = noop;
|
|
3775
3793
|
/* istanbul ignore next */
|
|
3776
3794
|
|
|
3777
3795
|
if (process.env.NODE_ENV !== 'production') {
|
|
3778
|
-
validatePropTypes
|
|
3779
|
-
PropTypes__default['default'].checkPropTypes(propTypes
|
|
3796
|
+
validatePropTypes = function validatePropTypes(options, caller) {
|
|
3797
|
+
PropTypes__default['default'].checkPropTypes(propTypes, options, 'prop', caller.name);
|
|
3780
3798
|
};
|
|
3781
3799
|
}
|
|
3782
3800
|
|
|
@@ -3792,9 +3810,9 @@ var FunctionAddSelectedItem = process.env.NODE_ENV !== "production" ? '__functio
|
|
|
3792
3810
|
var FunctionRemoveSelectedItem = process.env.NODE_ENV !== "production" ? '__function_remove_selected_item__' : 9;
|
|
3793
3811
|
var FunctionSetSelectedItems = process.env.NODE_ENV !== "production" ? '__function_set_selected_items__' : 10;
|
|
3794
3812
|
var FunctionSetActiveIndex = process.env.NODE_ENV !== "production" ? '__function_set_active_index__' : 11;
|
|
3795
|
-
var FunctionReset
|
|
3813
|
+
var FunctionReset = process.env.NODE_ENV !== "production" ? '__function_reset__' : 12;
|
|
3796
3814
|
|
|
3797
|
-
var stateChangeTypes
|
|
3815
|
+
var stateChangeTypes = /*#__PURE__*/Object.freeze({
|
|
3798
3816
|
__proto__: null,
|
|
3799
3817
|
SelectedItemClick: SelectedItemClick,
|
|
3800
3818
|
SelectedItemKeyDownDelete: SelectedItemKeyDownDelete,
|
|
@@ -3808,7 +3826,7 @@ var stateChangeTypes$3 = /*#__PURE__*/Object.freeze({
|
|
|
3808
3826
|
FunctionRemoveSelectedItem: FunctionRemoveSelectedItem,
|
|
3809
3827
|
FunctionSetSelectedItems: FunctionSetSelectedItems,
|
|
3810
3828
|
FunctionSetActiveIndex: FunctionSetActiveIndex,
|
|
3811
|
-
FunctionReset: FunctionReset
|
|
3829
|
+
FunctionReset: FunctionReset
|
|
3812
3830
|
});
|
|
3813
3831
|
|
|
3814
3832
|
/* eslint-disable complexity */
|
|
@@ -3921,10 +3939,10 @@ function downshiftMultipleSelectionReducer(state, action) {
|
|
|
3921
3939
|
break;
|
|
3922
3940
|
}
|
|
3923
3941
|
|
|
3924
|
-
case FunctionReset
|
|
3942
|
+
case FunctionReset:
|
|
3925
3943
|
changes = {
|
|
3926
|
-
activeIndex: getDefaultValue
|
|
3927
|
-
selectedItems: getDefaultValue
|
|
3944
|
+
activeIndex: getDefaultValue(props, 'activeIndex'),
|
|
3945
|
+
selectedItems: getDefaultValue(props, 'selectedItems')
|
|
3928
3946
|
};
|
|
3929
3947
|
break;
|
|
3930
3948
|
|
|
@@ -3935,16 +3953,16 @@ function downshiftMultipleSelectionReducer(state, action) {
|
|
|
3935
3953
|
return _extends__default['default']({}, state, changes);
|
|
3936
3954
|
}
|
|
3937
3955
|
|
|
3938
|
-
useMultipleSelection.stateChangeTypes = stateChangeTypes
|
|
3956
|
+
useMultipleSelection.stateChangeTypes = stateChangeTypes;
|
|
3939
3957
|
|
|
3940
3958
|
function useMultipleSelection(userProps) {
|
|
3941
3959
|
if (userProps === void 0) {
|
|
3942
3960
|
userProps = {};
|
|
3943
3961
|
}
|
|
3944
3962
|
|
|
3945
|
-
validatePropTypes
|
|
3963
|
+
validatePropTypes(userProps, useMultipleSelection); // Props defaults and destructuring.
|
|
3946
3964
|
|
|
3947
|
-
var props = _extends__default['default']({}, defaultProps
|
|
3965
|
+
var props = _extends__default['default']({}, defaultProps, userProps);
|
|
3948
3966
|
|
|
3949
3967
|
var getA11yRemovalMessage = props.getA11yRemovalMessage,
|
|
3950
3968
|
itemToString = props.itemToString,
|
|
@@ -3952,7 +3970,7 @@ function useMultipleSelection(userProps) {
|
|
|
3952
3970
|
keyNavigationNext = props.keyNavigationNext,
|
|
3953
3971
|
keyNavigationPrevious = props.keyNavigationPrevious; // Reducer init.
|
|
3954
3972
|
|
|
3955
|
-
var _useControlledReducer = useControlledReducer(downshiftMultipleSelectionReducer, getInitialState
|
|
3973
|
+
var _useControlledReducer = useControlledReducer$1(downshiftMultipleSelectionReducer, getInitialState(props), props),
|
|
3956
3974
|
state = _useControlledReducer[0],
|
|
3957
3975
|
dispatch = _useControlledReducer[1];
|
|
3958
3976
|
|
|
@@ -4163,7 +4181,7 @@ function useMultipleSelection(userProps) {
|
|
|
4163
4181
|
}, [dispatch]);
|
|
4164
4182
|
var reset = preact.useCallback(function () {
|
|
4165
4183
|
dispatch({
|
|
4166
|
-
type: FunctionReset
|
|
4184
|
+
type: FunctionReset
|
|
4167
4185
|
});
|
|
4168
4186
|
}, [dispatch]);
|
|
4169
4187
|
return {
|