downshift 6.1.0 → 6.1.1
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/dist/downshift.cjs.js +173 -173
- package/dist/downshift.esm.js +173 -173
- package/dist/downshift.native.cjs.js +169 -177
- package/dist/downshift.umd.js +412 -403
- 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 +2 -2
- package/preact/dist/downshift.cjs.js +173 -173
- package/preact/dist/downshift.esm.js +173 -173
- package/preact/dist/downshift.umd.js +255 -246
- package/preact/dist/downshift.umd.js.map +1 -1
- package/preact/dist/downshift.umd.min.js +11 -2
- package/preact/dist/downshift.umd.min.js.map +1 -1
|
@@ -175,7 +175,7 @@ function resetIdCounter() {
|
|
|
175
175
|
*/
|
|
176
176
|
|
|
177
177
|
|
|
178
|
-
function getA11yStatusMessage(_ref2) {
|
|
178
|
+
function getA11yStatusMessage$1(_ref2) {
|
|
179
179
|
var isOpen = _ref2.isOpen,
|
|
180
180
|
resultCount = _ref2.resultCount,
|
|
181
181
|
previousResultCount = _ref2.previousResultCount;
|
|
@@ -525,7 +525,7 @@ var blurButton = process.env.NODE_ENV !== "production" ? '__autocomplete_blur_bu
|
|
|
525
525
|
var controlledPropUpdatedSelectedItem = process.env.NODE_ENV !== "production" ? '__autocomplete_controlled_prop_updated_selected_item__' : 15;
|
|
526
526
|
var touchEnd = process.env.NODE_ENV !== "production" ? '__autocomplete_touchend__' : 16;
|
|
527
527
|
|
|
528
|
-
var stateChangeTypes = /*#__PURE__*/Object.freeze({
|
|
528
|
+
var stateChangeTypes$3 = /*#__PURE__*/Object.freeze({
|
|
529
529
|
__proto__: null,
|
|
530
530
|
unknown: unknown,
|
|
531
531
|
mouseUp: mouseUp,
|
|
@@ -917,19 +917,18 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
917
917
|
});
|
|
918
918
|
|
|
919
919
|
_this.getToggleButtonProps = function (_temp3) {
|
|
920
|
-
var _ref3 = _temp3 === void 0 ? {} : _temp3
|
|
921
|
-
|
|
922
|
-
onPress = _ref3.onPress
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
rest = _objectWithoutPropertiesLoose__default['default'](_ref3, ["onClick", "onPress", "onKeyDown", "onKeyUp", "onBlur"]);
|
|
920
|
+
var _ref3 = _temp3 === void 0 ? {} : _temp3;
|
|
921
|
+
_ref3.onClick;
|
|
922
|
+
var onPress = _ref3.onPress;
|
|
923
|
+
_ref3.onKeyDown;
|
|
924
|
+
_ref3.onKeyUp;
|
|
925
|
+
_ref3.onBlur;
|
|
926
|
+
var rest = _objectWithoutPropertiesLoose__default['default'](_ref3, ["onClick", "onPress", "onKeyDown", "onKeyUp", "onBlur"]);
|
|
927
927
|
|
|
928
928
|
var _this$getState5 = _this.getState(),
|
|
929
929
|
isOpen = _this$getState5.isOpen;
|
|
930
930
|
|
|
931
|
-
var enabledEventHandlers =
|
|
932
|
-
/* istanbul ignore next (react-native) */
|
|
931
|
+
var enabledEventHandlers = /* istanbul ignore next (react-native) */
|
|
933
932
|
{
|
|
934
933
|
onPress: callAllEventHandlers(onPress, _this.buttonHandleClick)
|
|
935
934
|
} ;
|
|
@@ -1066,8 +1065,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1066
1065
|
_this.internalSetState({
|
|
1067
1066
|
type: changeInput,
|
|
1068
1067
|
isOpen: true,
|
|
1069
|
-
inputValue:
|
|
1070
|
-
/* istanbul ignore next (react-native) */
|
|
1068
|
+
inputValue: /* istanbul ignore next (react-native) */
|
|
1071
1069
|
event.nativeEvent.text ,
|
|
1072
1070
|
highlightedIndex: _this.props.defaultHighlightedIndex
|
|
1073
1071
|
});
|
|
@@ -1114,9 +1112,9 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1114
1112
|
|
|
1115
1113
|
var _ref7 = _temp7 === void 0 ? {} : _temp7,
|
|
1116
1114
|
onMouseMove = _ref7.onMouseMove,
|
|
1117
|
-
onMouseDown = _ref7.onMouseDown
|
|
1118
|
-
|
|
1119
|
-
onPress = _ref7.onPress,
|
|
1115
|
+
onMouseDown = _ref7.onMouseDown;
|
|
1116
|
+
_ref7.onClick;
|
|
1117
|
+
var onPress = _ref7.onPress,
|
|
1120
1118
|
index = _ref7.index,
|
|
1121
1119
|
_ref7$item = _ref7.item,
|
|
1122
1120
|
item = _ref7$item === void 0 ? process.env.NODE_ENV === 'production' ?
|
|
@@ -1132,11 +1130,9 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1132
1130
|
_this.items[index] = item;
|
|
1133
1131
|
}
|
|
1134
1132
|
|
|
1135
|
-
var onSelectKey =
|
|
1136
|
-
/* istanbul ignore next (react-native) */
|
|
1133
|
+
var onSelectKey = /* istanbul ignore next (react-native) */
|
|
1137
1134
|
'onPress' ;
|
|
1138
|
-
var customClickHandler =
|
|
1139
|
-
/* istanbul ignore next (react-native) */
|
|
1135
|
+
var customClickHandler = /* istanbul ignore next (react-native) */
|
|
1140
1136
|
onPress ;
|
|
1141
1137
|
var enabledEventHandlers = (_enabledEventHandlers = {
|
|
1142
1138
|
// onMouseMove is used over onMouseEnter here. onMouseMove
|
|
@@ -1531,7 +1527,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1531
1527
|
Downshift.defaultProps = {
|
|
1532
1528
|
defaultHighlightedIndex: null,
|
|
1533
1529
|
defaultIsOpen: false,
|
|
1534
|
-
getA11yStatusMessage: getA11yStatusMessage,
|
|
1530
|
+
getA11yStatusMessage: getA11yStatusMessage$1,
|
|
1535
1531
|
itemToString: function itemToString(i) {
|
|
1536
1532
|
if (i == null) {
|
|
1537
1533
|
return '';
|
|
@@ -1562,7 +1558,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1562
1558
|
suppressRefError: false,
|
|
1563
1559
|
scrollIntoView: scrollIntoView
|
|
1564
1560
|
};
|
|
1565
|
-
Downshift.stateChangeTypes = stateChangeTypes;
|
|
1561
|
+
Downshift.stateChangeTypes = stateChangeTypes$3;
|
|
1566
1562
|
return Downshift;
|
|
1567
1563
|
}();
|
|
1568
1564
|
|
|
@@ -1824,7 +1820,7 @@ function useEnhancedReducer(reducer, initialState, props) {
|
|
|
1824
1820
|
*/
|
|
1825
1821
|
|
|
1826
1822
|
|
|
1827
|
-
function useControlledReducer(reducer, initialState, props) {
|
|
1823
|
+
function useControlledReducer$1(reducer, initialState, props) {
|
|
1828
1824
|
var _useEnhancedReducer = useEnhancedReducer(reducer, initialState, props),
|
|
1829
1825
|
state = _useEnhancedReducer[0],
|
|
1830
1826
|
dispatch = _useEnhancedReducer[1];
|
|
@@ -1832,7 +1828,7 @@ function useControlledReducer(reducer, initialState, props) {
|
|
|
1832
1828
|
return [getState(state, props), dispatch];
|
|
1833
1829
|
}
|
|
1834
1830
|
|
|
1835
|
-
var defaultProps = {
|
|
1831
|
+
var defaultProps$3 = {
|
|
1836
1832
|
itemToString: itemToString,
|
|
1837
1833
|
stateReducer: stateReducer,
|
|
1838
1834
|
getA11ySelectionMessage: getA11ySelectionMessage,
|
|
@@ -1843,7 +1839,7 @@ var defaultProps = {
|
|
|
1843
1839
|
? {} : window
|
|
1844
1840
|
};
|
|
1845
1841
|
|
|
1846
|
-
function getDefaultValue(props, propKey, defaultStateValues) {
|
|
1842
|
+
function getDefaultValue$1(props, propKey, defaultStateValues) {
|
|
1847
1843
|
if (defaultStateValues === void 0) {
|
|
1848
1844
|
defaultStateValues = dropdownDefaultStateValues;
|
|
1849
1845
|
}
|
|
@@ -1857,7 +1853,7 @@ function getDefaultValue(props, propKey, defaultStateValues) {
|
|
|
1857
1853
|
return defaultStateValues[propKey];
|
|
1858
1854
|
}
|
|
1859
1855
|
|
|
1860
|
-
function getInitialValue(props, propKey, defaultStateValues) {
|
|
1856
|
+
function getInitialValue$1(props, propKey, defaultStateValues) {
|
|
1861
1857
|
if (defaultStateValues === void 0) {
|
|
1862
1858
|
defaultStateValues = dropdownDefaultStateValues;
|
|
1863
1859
|
}
|
|
@@ -1872,14 +1868,14 @@ function getInitialValue(props, propKey, defaultStateValues) {
|
|
|
1872
1868
|
return props[initialPropKey];
|
|
1873
1869
|
}
|
|
1874
1870
|
|
|
1875
|
-
return getDefaultValue(props, propKey, defaultStateValues);
|
|
1871
|
+
return getDefaultValue$1(props, propKey, defaultStateValues);
|
|
1876
1872
|
}
|
|
1877
1873
|
|
|
1878
|
-
function getInitialState(props) {
|
|
1879
|
-
var selectedItem = getInitialValue(props, 'selectedItem');
|
|
1880
|
-
var isOpen = getInitialValue(props, 'isOpen');
|
|
1881
|
-
var highlightedIndex = getInitialValue(props, 'highlightedIndex');
|
|
1882
|
-
var inputValue = getInitialValue(props, 'inputValue');
|
|
1874
|
+
function getInitialState$2(props) {
|
|
1875
|
+
var selectedItem = getInitialValue$1(props, 'selectedItem');
|
|
1876
|
+
var isOpen = getInitialValue$1(props, 'isOpen');
|
|
1877
|
+
var highlightedIndex = getInitialValue$1(props, 'highlightedIndex');
|
|
1878
|
+
var inputValue = getInitialValue$1(props, 'inputValue');
|
|
1883
1879
|
return {
|
|
1884
1880
|
highlightedIndex: highlightedIndex < 0 && selectedItem && isOpen ? props.items.indexOf(selectedItem) : highlightedIndex,
|
|
1885
1881
|
isOpen: isOpen,
|
|
@@ -2174,10 +2170,10 @@ function downshiftCommonReducer(state, action, stateChangeTypes) {
|
|
|
2174
2170
|
|
|
2175
2171
|
case stateChangeTypes.FunctionReset:
|
|
2176
2172
|
changes = {
|
|
2177
|
-
highlightedIndex: getDefaultValue(props, 'highlightedIndex'),
|
|
2178
|
-
isOpen: getDefaultValue(props, 'isOpen'),
|
|
2179
|
-
selectedItem: getDefaultValue(props, 'selectedItem'),
|
|
2180
|
-
inputValue: getDefaultValue(props, 'inputValue')
|
|
2173
|
+
highlightedIndex: getDefaultValue$1(props, 'highlightedIndex'),
|
|
2174
|
+
isOpen: getDefaultValue$1(props, 'isOpen'),
|
|
2175
|
+
selectedItem: getDefaultValue$1(props, 'selectedItem'),
|
|
2176
|
+
inputValue: getDefaultValue$1(props, 'inputValue')
|
|
2181
2177
|
};
|
|
2182
2178
|
break;
|
|
2183
2179
|
|
|
@@ -2207,7 +2203,7 @@ function getItemIndexByCharacterKey(keysSoFar, highlightedIndex, items, itemToSt
|
|
|
2207
2203
|
return highlightedIndex;
|
|
2208
2204
|
}
|
|
2209
2205
|
|
|
2210
|
-
var propTypes = {
|
|
2206
|
+
var propTypes$2 = {
|
|
2211
2207
|
items: PropTypes__default['default'].array.isRequired,
|
|
2212
2208
|
itemToString: PropTypes__default['default'].func,
|
|
2213
2209
|
getA11yStatusMessage: PropTypes__default['default'].func,
|
|
@@ -2251,7 +2247,7 @@ var propTypes = {
|
|
|
2251
2247
|
* @return {String} the a11y status message
|
|
2252
2248
|
*/
|
|
2253
2249
|
|
|
2254
|
-
function getA11yStatusMessage
|
|
2250
|
+
function getA11yStatusMessage(_ref) {
|
|
2255
2251
|
var isOpen = _ref.isOpen,
|
|
2256
2252
|
resultCount = _ref.resultCount,
|
|
2257
2253
|
previousResultCount = _ref.previousResultCount;
|
|
@@ -2271,17 +2267,17 @@ function getA11yStatusMessage$1(_ref) {
|
|
|
2271
2267
|
return '';
|
|
2272
2268
|
}
|
|
2273
2269
|
|
|
2274
|
-
var defaultProps$
|
|
2275
|
-
getA11yStatusMessage: getA11yStatusMessage
|
|
2270
|
+
var defaultProps$2 = _extends__default['default']({}, defaultProps$3, {
|
|
2271
|
+
getA11yStatusMessage: getA11yStatusMessage
|
|
2276
2272
|
}); // eslint-disable-next-line import/no-mutable-exports
|
|
2277
2273
|
|
|
2278
2274
|
|
|
2279
|
-
var validatePropTypes = noop;
|
|
2275
|
+
var validatePropTypes$2 = noop;
|
|
2280
2276
|
/* istanbul ignore next */
|
|
2281
2277
|
|
|
2282
2278
|
if (process.env.NODE_ENV !== 'production') {
|
|
2283
|
-
validatePropTypes = function validatePropTypes(options, caller) {
|
|
2284
|
-
PropTypes__default['default'].checkPropTypes(propTypes, options, 'prop', caller.name);
|
|
2279
|
+
validatePropTypes$2 = function validatePropTypes(options, caller) {
|
|
2280
|
+
PropTypes__default['default'].checkPropTypes(propTypes$2, options, 'prop', caller.name);
|
|
2285
2281
|
};
|
|
2286
2282
|
}
|
|
2287
2283
|
|
|
@@ -2294,22 +2290,22 @@ var MenuKeyDownEnter = process.env.NODE_ENV !== "production" ? '__menu_keydown_e
|
|
|
2294
2290
|
var MenuKeyDownSpaceButton = process.env.NODE_ENV !== "production" ? '__menu_keydown_space_button__' : 6;
|
|
2295
2291
|
var MenuKeyDownCharacter = process.env.NODE_ENV !== "production" ? '__menu_keydown_character__' : 7;
|
|
2296
2292
|
var MenuBlur = process.env.NODE_ENV !== "production" ? '__menu_blur__' : 8;
|
|
2297
|
-
var MenuMouseLeave = process.env.NODE_ENV !== "production" ? '__menu_mouse_leave__' : 9;
|
|
2298
|
-
var ItemMouseMove = process.env.NODE_ENV !== "production" ? '__item_mouse_move__' : 10;
|
|
2299
|
-
var ItemClick = process.env.NODE_ENV !== "production" ? '__item_click__' : 11;
|
|
2300
|
-
var ToggleButtonClick = process.env.NODE_ENV !== "production" ? '__togglebutton_click__' : 12;
|
|
2293
|
+
var MenuMouseLeave$1 = process.env.NODE_ENV !== "production" ? '__menu_mouse_leave__' : 9;
|
|
2294
|
+
var ItemMouseMove$1 = process.env.NODE_ENV !== "production" ? '__item_mouse_move__' : 10;
|
|
2295
|
+
var ItemClick$1 = process.env.NODE_ENV !== "production" ? '__item_click__' : 11;
|
|
2296
|
+
var ToggleButtonClick$1 = process.env.NODE_ENV !== "production" ? '__togglebutton_click__' : 12;
|
|
2301
2297
|
var ToggleButtonKeyDownArrowDown = process.env.NODE_ENV !== "production" ? '__togglebutton_keydown_arrow_down__' : 13;
|
|
2302
2298
|
var ToggleButtonKeyDownArrowUp = process.env.NODE_ENV !== "production" ? '__togglebutton_keydown_arrow_up__' : 14;
|
|
2303
2299
|
var ToggleButtonKeyDownCharacter = process.env.NODE_ENV !== "production" ? '__togglebutton_keydown_character__' : 15;
|
|
2304
|
-
var FunctionToggleMenu = process.env.NODE_ENV !== "production" ? '__function_toggle_menu__' : 16;
|
|
2305
|
-
var FunctionOpenMenu = process.env.NODE_ENV !== "production" ? '__function_open_menu__' : 17;
|
|
2306
|
-
var FunctionCloseMenu = process.env.NODE_ENV !== "production" ? '__function_close_menu__' : 18;
|
|
2307
|
-
var FunctionSetHighlightedIndex = process.env.NODE_ENV !== "production" ? '__function_set_highlighted_index__' : 19;
|
|
2308
|
-
var FunctionSelectItem = process.env.NODE_ENV !== "production" ? '__function_select_item__' : 20;
|
|
2309
|
-
var FunctionSetInputValue = process.env.NODE_ENV !== "production" ? '__function_set_input_value__' : 21;
|
|
2310
|
-
var FunctionReset = process.env.NODE_ENV !== "production" ? '__function_reset__' : 22;
|
|
2300
|
+
var FunctionToggleMenu$1 = process.env.NODE_ENV !== "production" ? '__function_toggle_menu__' : 16;
|
|
2301
|
+
var FunctionOpenMenu$1 = process.env.NODE_ENV !== "production" ? '__function_open_menu__' : 17;
|
|
2302
|
+
var FunctionCloseMenu$1 = process.env.NODE_ENV !== "production" ? '__function_close_menu__' : 18;
|
|
2303
|
+
var FunctionSetHighlightedIndex$1 = process.env.NODE_ENV !== "production" ? '__function_set_highlighted_index__' : 19;
|
|
2304
|
+
var FunctionSelectItem$1 = process.env.NODE_ENV !== "production" ? '__function_select_item__' : 20;
|
|
2305
|
+
var FunctionSetInputValue$1 = process.env.NODE_ENV !== "production" ? '__function_set_input_value__' : 21;
|
|
2306
|
+
var FunctionReset$2 = process.env.NODE_ENV !== "production" ? '__function_reset__' : 22;
|
|
2311
2307
|
|
|
2312
|
-
var stateChangeTypes$
|
|
2308
|
+
var stateChangeTypes$2 = /*#__PURE__*/Object.freeze({
|
|
2313
2309
|
__proto__: null,
|
|
2314
2310
|
MenuKeyDownArrowDown: MenuKeyDownArrowDown,
|
|
2315
2311
|
MenuKeyDownArrowUp: MenuKeyDownArrowUp,
|
|
@@ -2320,20 +2316,20 @@ var stateChangeTypes$1 = /*#__PURE__*/Object.freeze({
|
|
|
2320
2316
|
MenuKeyDownSpaceButton: MenuKeyDownSpaceButton,
|
|
2321
2317
|
MenuKeyDownCharacter: MenuKeyDownCharacter,
|
|
2322
2318
|
MenuBlur: MenuBlur,
|
|
2323
|
-
MenuMouseLeave: MenuMouseLeave,
|
|
2324
|
-
ItemMouseMove: ItemMouseMove,
|
|
2325
|
-
ItemClick: ItemClick,
|
|
2326
|
-
ToggleButtonClick: ToggleButtonClick,
|
|
2319
|
+
MenuMouseLeave: MenuMouseLeave$1,
|
|
2320
|
+
ItemMouseMove: ItemMouseMove$1,
|
|
2321
|
+
ItemClick: ItemClick$1,
|
|
2322
|
+
ToggleButtonClick: ToggleButtonClick$1,
|
|
2327
2323
|
ToggleButtonKeyDownArrowDown: ToggleButtonKeyDownArrowDown,
|
|
2328
2324
|
ToggleButtonKeyDownArrowUp: ToggleButtonKeyDownArrowUp,
|
|
2329
2325
|
ToggleButtonKeyDownCharacter: ToggleButtonKeyDownCharacter,
|
|
2330
|
-
FunctionToggleMenu: FunctionToggleMenu,
|
|
2331
|
-
FunctionOpenMenu: FunctionOpenMenu,
|
|
2332
|
-
FunctionCloseMenu: FunctionCloseMenu,
|
|
2333
|
-
FunctionSetHighlightedIndex: FunctionSetHighlightedIndex,
|
|
2334
|
-
FunctionSelectItem: FunctionSelectItem,
|
|
2335
|
-
FunctionSetInputValue: FunctionSetInputValue,
|
|
2336
|
-
FunctionReset: FunctionReset
|
|
2326
|
+
FunctionToggleMenu: FunctionToggleMenu$1,
|
|
2327
|
+
FunctionOpenMenu: FunctionOpenMenu$1,
|
|
2328
|
+
FunctionCloseMenu: FunctionCloseMenu$1,
|
|
2329
|
+
FunctionSetHighlightedIndex: FunctionSetHighlightedIndex$1,
|
|
2330
|
+
FunctionSelectItem: FunctionSelectItem$1,
|
|
2331
|
+
FunctionSetInputValue: FunctionSetInputValue$1,
|
|
2332
|
+
FunctionReset: FunctionReset$2
|
|
2337
2333
|
});
|
|
2338
2334
|
|
|
2339
2335
|
/* eslint-disable complexity */
|
|
@@ -2345,10 +2341,10 @@ function downshiftSelectReducer(state, action) {
|
|
|
2345
2341
|
var changes;
|
|
2346
2342
|
|
|
2347
2343
|
switch (type) {
|
|
2348
|
-
case ItemClick:
|
|
2344
|
+
case ItemClick$1:
|
|
2349
2345
|
changes = {
|
|
2350
|
-
isOpen: getDefaultValue(props, 'isOpen'),
|
|
2351
|
-
highlightedIndex: getDefaultValue(props, 'highlightedIndex'),
|
|
2346
|
+
isOpen: getDefaultValue$1(props, 'isOpen'),
|
|
2347
|
+
highlightedIndex: getDefaultValue$1(props, 'highlightedIndex'),
|
|
2352
2348
|
selectedItem: props.items[action.index]
|
|
2353
2349
|
};
|
|
2354
2350
|
break;
|
|
@@ -2383,8 +2379,8 @@ function downshiftSelectReducer(state, action) {
|
|
|
2383
2379
|
case MenuKeyDownEnter:
|
|
2384
2380
|
case MenuKeyDownSpaceButton:
|
|
2385
2381
|
changes = _extends__default['default']({
|
|
2386
|
-
isOpen: getDefaultValue(props, 'isOpen'),
|
|
2387
|
-
highlightedIndex: getDefaultValue(props, 'highlightedIndex')
|
|
2382
|
+
isOpen: getDefaultValue$1(props, 'isOpen'),
|
|
2383
|
+
highlightedIndex: getDefaultValue$1(props, 'highlightedIndex')
|
|
2388
2384
|
}, state.highlightedIndex >= 0 && {
|
|
2389
2385
|
selectedItem: props.items[state.highlightedIndex]
|
|
2390
2386
|
});
|
|
@@ -2443,30 +2439,30 @@ function downshiftSelectReducer(state, action) {
|
|
|
2443
2439
|
};
|
|
2444
2440
|
break;
|
|
2445
2441
|
|
|
2446
|
-
case FunctionSelectItem:
|
|
2442
|
+
case FunctionSelectItem$1:
|
|
2447
2443
|
changes = {
|
|
2448
2444
|
selectedItem: action.selectedItem
|
|
2449
2445
|
};
|
|
2450
2446
|
break;
|
|
2451
2447
|
|
|
2452
2448
|
default:
|
|
2453
|
-
return downshiftCommonReducer(state, action, stateChangeTypes$
|
|
2449
|
+
return downshiftCommonReducer(state, action, stateChangeTypes$2);
|
|
2454
2450
|
}
|
|
2455
2451
|
|
|
2456
2452
|
return _extends__default['default']({}, state, changes);
|
|
2457
2453
|
}
|
|
2458
2454
|
/* eslint-enable complexity */
|
|
2459
2455
|
|
|
2460
|
-
useSelect.stateChangeTypes = stateChangeTypes$
|
|
2456
|
+
useSelect.stateChangeTypes = stateChangeTypes$2;
|
|
2461
2457
|
|
|
2462
2458
|
function useSelect(userProps) {
|
|
2463
2459
|
if (userProps === void 0) {
|
|
2464
2460
|
userProps = {};
|
|
2465
2461
|
}
|
|
2466
2462
|
|
|
2467
|
-
validatePropTypes(userProps, useSelect); // Props defaults and destructuring.
|
|
2463
|
+
validatePropTypes$2(userProps, useSelect); // Props defaults and destructuring.
|
|
2468
2464
|
|
|
2469
|
-
var props = _extends__default['default']({}, defaultProps$
|
|
2465
|
+
var props = _extends__default['default']({}, defaultProps$2, userProps);
|
|
2470
2466
|
|
|
2471
2467
|
var items = props.items,
|
|
2472
2468
|
scrollIntoView = props.scrollIntoView,
|
|
@@ -2477,9 +2473,9 @@ function useSelect(userProps) {
|
|
|
2477
2473
|
getA11ySelectionMessage = props.getA11ySelectionMessage,
|
|
2478
2474
|
getA11yStatusMessage = props.getA11yStatusMessage; // Initial state depending on controlled props.
|
|
2479
2475
|
|
|
2480
|
-
var initialState = getInitialState(props);
|
|
2476
|
+
var initialState = getInitialState$2(props);
|
|
2481
2477
|
|
|
2482
|
-
var _useControlledReducer = useControlledReducer(downshiftSelectReducer, initialState, props),
|
|
2478
|
+
var _useControlledReducer = useControlledReducer$1(downshiftSelectReducer, initialState, props),
|
|
2483
2479
|
state = _useControlledReducer[0],
|
|
2484
2480
|
dispatch = _useControlledReducer[1];
|
|
2485
2481
|
|
|
@@ -2541,7 +2537,7 @@ function useSelect(userProps) {
|
|
|
2541
2537
|
if (isInitialMountRef.current) {
|
|
2542
2538
|
clearTimeoutRef.current = debounce(function (outerDispatch) {
|
|
2543
2539
|
outerDispatch({
|
|
2544
|
-
type: FunctionSetInputValue,
|
|
2540
|
+
type: FunctionSetInputValue$1,
|
|
2545
2541
|
inputValue: ''
|
|
2546
2542
|
});
|
|
2547
2543
|
}, 500);
|
|
@@ -2690,39 +2686,39 @@ function useSelect(userProps) {
|
|
|
2690
2686
|
|
|
2691
2687
|
var toggleMenu = react.useCallback(function () {
|
|
2692
2688
|
dispatch({
|
|
2693
|
-
type: FunctionToggleMenu
|
|
2689
|
+
type: FunctionToggleMenu$1
|
|
2694
2690
|
});
|
|
2695
2691
|
}, [dispatch]);
|
|
2696
2692
|
var closeMenu = react.useCallback(function () {
|
|
2697
2693
|
dispatch({
|
|
2698
|
-
type: FunctionCloseMenu
|
|
2694
|
+
type: FunctionCloseMenu$1
|
|
2699
2695
|
});
|
|
2700
2696
|
}, [dispatch]);
|
|
2701
2697
|
var openMenu = react.useCallback(function () {
|
|
2702
2698
|
dispatch({
|
|
2703
|
-
type: FunctionOpenMenu
|
|
2699
|
+
type: FunctionOpenMenu$1
|
|
2704
2700
|
});
|
|
2705
2701
|
}, [dispatch]);
|
|
2706
2702
|
var setHighlightedIndex = react.useCallback(function (newHighlightedIndex) {
|
|
2707
2703
|
dispatch({
|
|
2708
|
-
type: FunctionSetHighlightedIndex,
|
|
2704
|
+
type: FunctionSetHighlightedIndex$1,
|
|
2709
2705
|
highlightedIndex: newHighlightedIndex
|
|
2710
2706
|
});
|
|
2711
2707
|
}, [dispatch]);
|
|
2712
2708
|
var selectItem = react.useCallback(function (newSelectedItem) {
|
|
2713
2709
|
dispatch({
|
|
2714
|
-
type: FunctionSelectItem,
|
|
2710
|
+
type: FunctionSelectItem$1,
|
|
2715
2711
|
selectedItem: newSelectedItem
|
|
2716
2712
|
});
|
|
2717
2713
|
}, [dispatch]);
|
|
2718
2714
|
var reset = react.useCallback(function () {
|
|
2719
2715
|
dispatch({
|
|
2720
|
-
type: FunctionReset
|
|
2716
|
+
type: FunctionReset$2
|
|
2721
2717
|
});
|
|
2722
2718
|
}, [dispatch]);
|
|
2723
2719
|
var setInputValue = react.useCallback(function (newInputValue) {
|
|
2724
2720
|
dispatch({
|
|
2725
|
-
type: FunctionSetInputValue,
|
|
2721
|
+
type: FunctionSetInputValue$1,
|
|
2726
2722
|
inputValue: newInputValue
|
|
2727
2723
|
});
|
|
2728
2724
|
}, [dispatch]); // Getter functions.
|
|
@@ -2784,7 +2780,7 @@ function useSelect(userProps) {
|
|
|
2784
2780
|
|
|
2785
2781
|
var menuHandleMouseLeave = function menuHandleMouseLeave() {
|
|
2786
2782
|
dispatch({
|
|
2787
|
-
type: MenuMouseLeave
|
|
2783
|
+
type: MenuMouseLeave$1
|
|
2788
2784
|
});
|
|
2789
2785
|
};
|
|
2790
2786
|
|
|
@@ -2816,7 +2812,7 @@ function useSelect(userProps) {
|
|
|
2816
2812
|
|
|
2817
2813
|
var toggleButtonHandleClick = function toggleButtonHandleClick() {
|
|
2818
2814
|
dispatch({
|
|
2819
|
-
type: ToggleButtonClick
|
|
2815
|
+
type: ToggleButtonClick$1
|
|
2820
2816
|
});
|
|
2821
2817
|
};
|
|
2822
2818
|
|
|
@@ -2870,14 +2866,14 @@ function useSelect(userProps) {
|
|
|
2870
2866
|
|
|
2871
2867
|
shouldScrollRef.current = false;
|
|
2872
2868
|
dispatch({
|
|
2873
|
-
type: ItemMouseMove,
|
|
2869
|
+
type: ItemMouseMove$1,
|
|
2874
2870
|
index: index
|
|
2875
2871
|
});
|
|
2876
2872
|
};
|
|
2877
2873
|
|
|
2878
2874
|
var itemHandleClick = function itemHandleClick() {
|
|
2879
2875
|
dispatch({
|
|
2880
|
-
type: ItemClick,
|
|
2876
|
+
type: ItemClick$1,
|
|
2881
2877
|
index: index
|
|
2882
2878
|
});
|
|
2883
2879
|
};
|
|
@@ -2935,20 +2931,20 @@ var InputKeyDownEnd = process.env.NODE_ENV !== "production" ? '__input_keydown_e
|
|
|
2935
2931
|
var InputKeyDownEnter = process.env.NODE_ENV !== "production" ? '__input_keydown_enter__' : 5;
|
|
2936
2932
|
var InputChange = process.env.NODE_ENV !== "production" ? '__input_change__' : 6;
|
|
2937
2933
|
var InputBlur = process.env.NODE_ENV !== "production" ? '__input_blur__' : 7;
|
|
2938
|
-
var MenuMouseLeave
|
|
2939
|
-
var ItemMouseMove
|
|
2940
|
-
var ItemClick
|
|
2941
|
-
var ToggleButtonClick
|
|
2942
|
-
var FunctionToggleMenu
|
|
2943
|
-
var FunctionOpenMenu
|
|
2944
|
-
var FunctionCloseMenu
|
|
2945
|
-
var FunctionSetHighlightedIndex
|
|
2946
|
-
var FunctionSelectItem
|
|
2947
|
-
var FunctionSetInputValue
|
|
2934
|
+
var MenuMouseLeave = process.env.NODE_ENV !== "production" ? '__menu_mouse_leave__' : 8;
|
|
2935
|
+
var ItemMouseMove = process.env.NODE_ENV !== "production" ? '__item_mouse_move__' : 9;
|
|
2936
|
+
var ItemClick = process.env.NODE_ENV !== "production" ? '__item_click__' : 10;
|
|
2937
|
+
var ToggleButtonClick = process.env.NODE_ENV !== "production" ? '__togglebutton_click__' : 11;
|
|
2938
|
+
var FunctionToggleMenu = process.env.NODE_ENV !== "production" ? '__function_toggle_menu__' : 12;
|
|
2939
|
+
var FunctionOpenMenu = process.env.NODE_ENV !== "production" ? '__function_open_menu__' : 13;
|
|
2940
|
+
var FunctionCloseMenu = process.env.NODE_ENV !== "production" ? '__function_close_menu__' : 14;
|
|
2941
|
+
var FunctionSetHighlightedIndex = process.env.NODE_ENV !== "production" ? '__function_set_highlighted_index__' : 15;
|
|
2942
|
+
var FunctionSelectItem = process.env.NODE_ENV !== "production" ? '__function_select_item__' : 16;
|
|
2943
|
+
var FunctionSetInputValue = process.env.NODE_ENV !== "production" ? '__function_set_input_value__' : 17;
|
|
2948
2944
|
var FunctionReset$1 = process.env.NODE_ENV !== "production" ? '__function_reset__' : 18;
|
|
2949
2945
|
var ControlledPropUpdatedSelectedItem = process.env.NODE_ENV !== "production" ? '__controlled_prop_updated_selected_item__' : 19;
|
|
2950
2946
|
|
|
2951
|
-
var stateChangeTypes$
|
|
2947
|
+
var stateChangeTypes$1 = /*#__PURE__*/Object.freeze({
|
|
2952
2948
|
__proto__: null,
|
|
2953
2949
|
InputKeyDownArrowDown: InputKeyDownArrowDown,
|
|
2954
2950
|
InputKeyDownArrowUp: InputKeyDownArrowUp,
|
|
@@ -2958,22 +2954,22 @@ var stateChangeTypes$2 = /*#__PURE__*/Object.freeze({
|
|
|
2958
2954
|
InputKeyDownEnter: InputKeyDownEnter,
|
|
2959
2955
|
InputChange: InputChange,
|
|
2960
2956
|
InputBlur: InputBlur,
|
|
2961
|
-
MenuMouseLeave: MenuMouseLeave
|
|
2962
|
-
ItemMouseMove: ItemMouseMove
|
|
2963
|
-
ItemClick: ItemClick
|
|
2964
|
-
ToggleButtonClick: ToggleButtonClick
|
|
2965
|
-
FunctionToggleMenu: FunctionToggleMenu
|
|
2966
|
-
FunctionOpenMenu: FunctionOpenMenu
|
|
2967
|
-
FunctionCloseMenu: FunctionCloseMenu
|
|
2968
|
-
FunctionSetHighlightedIndex: FunctionSetHighlightedIndex
|
|
2969
|
-
FunctionSelectItem: FunctionSelectItem
|
|
2970
|
-
FunctionSetInputValue: FunctionSetInputValue
|
|
2957
|
+
MenuMouseLeave: MenuMouseLeave,
|
|
2958
|
+
ItemMouseMove: ItemMouseMove,
|
|
2959
|
+
ItemClick: ItemClick,
|
|
2960
|
+
ToggleButtonClick: ToggleButtonClick,
|
|
2961
|
+
FunctionToggleMenu: FunctionToggleMenu,
|
|
2962
|
+
FunctionOpenMenu: FunctionOpenMenu,
|
|
2963
|
+
FunctionCloseMenu: FunctionCloseMenu,
|
|
2964
|
+
FunctionSetHighlightedIndex: FunctionSetHighlightedIndex,
|
|
2965
|
+
FunctionSelectItem: FunctionSelectItem,
|
|
2966
|
+
FunctionSetInputValue: FunctionSetInputValue,
|
|
2971
2967
|
FunctionReset: FunctionReset$1,
|
|
2972
2968
|
ControlledPropUpdatedSelectedItem: ControlledPropUpdatedSelectedItem
|
|
2973
2969
|
});
|
|
2974
2970
|
|
|
2975
2971
|
function getInitialState$1(props) {
|
|
2976
|
-
var initialState = getInitialState(props);
|
|
2972
|
+
var initialState = getInitialState$2(props);
|
|
2977
2973
|
var selectedItem = initialState.selectedItem;
|
|
2978
2974
|
var inputValue = initialState.inputValue;
|
|
2979
2975
|
|
|
@@ -3039,7 +3035,7 @@ var propTypes$1 = {
|
|
|
3039
3035
|
* @returns {Array} An array with the state and an action dispatcher.
|
|
3040
3036
|
*/
|
|
3041
3037
|
|
|
3042
|
-
function useControlledReducer
|
|
3038
|
+
function useControlledReducer(reducer, initialState, props) {
|
|
3043
3039
|
var previousSelectedItemRef = react.useRef();
|
|
3044
3040
|
|
|
3045
3041
|
var _useEnhancedReducer = useEnhancedReducer(reducer, initialState, props),
|
|
@@ -3072,8 +3068,8 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
3072
3068
|
};
|
|
3073
3069
|
}
|
|
3074
3070
|
|
|
3075
|
-
var defaultProps$
|
|
3076
|
-
getA11yStatusMessage: getA11yStatusMessage,
|
|
3071
|
+
var defaultProps$1 = _extends__default['default']({}, defaultProps$3, {
|
|
3072
|
+
getA11yStatusMessage: getA11yStatusMessage$1,
|
|
3077
3073
|
circularNavigation: true
|
|
3078
3074
|
});
|
|
3079
3075
|
|
|
@@ -3086,10 +3082,10 @@ function downshiftUseComboboxReducer(state, action) {
|
|
|
3086
3082
|
var changes;
|
|
3087
3083
|
|
|
3088
3084
|
switch (type) {
|
|
3089
|
-
case ItemClick
|
|
3085
|
+
case ItemClick:
|
|
3090
3086
|
changes = {
|
|
3091
|
-
isOpen: getDefaultValue(props, 'isOpen'),
|
|
3092
|
-
highlightedIndex: getDefaultValue(props, 'highlightedIndex'),
|
|
3087
|
+
isOpen: getDefaultValue$1(props, 'isOpen'),
|
|
3088
|
+
highlightedIndex: getDefaultValue$1(props, 'highlightedIndex'),
|
|
3093
3089
|
selectedItem: props.items[action.index],
|
|
3094
3090
|
inputValue: props.itemToString(props.items[action.index])
|
|
3095
3091
|
};
|
|
@@ -3126,8 +3122,8 @@ function downshiftUseComboboxReducer(state, action) {
|
|
|
3126
3122
|
case InputKeyDownEnter:
|
|
3127
3123
|
changes = _extends__default['default']({}, state.isOpen && state.highlightedIndex >= 0 && {
|
|
3128
3124
|
selectedItem: props.items[state.highlightedIndex],
|
|
3129
|
-
isOpen: getDefaultValue(props, 'isOpen'),
|
|
3130
|
-
highlightedIndex: getDefaultValue(props, 'highlightedIndex'),
|
|
3125
|
+
isOpen: getDefaultValue$1(props, 'isOpen'),
|
|
3126
|
+
highlightedIndex: getDefaultValue$1(props, 'highlightedIndex'),
|
|
3131
3127
|
inputValue: props.itemToString(props.items[state.highlightedIndex])
|
|
3132
3128
|
});
|
|
3133
3129
|
break;
|
|
@@ -3167,12 +3163,12 @@ function downshiftUseComboboxReducer(state, action) {
|
|
|
3167
3163
|
case InputChange:
|
|
3168
3164
|
changes = {
|
|
3169
3165
|
isOpen: true,
|
|
3170
|
-
highlightedIndex: getDefaultValue(props, 'highlightedIndex'),
|
|
3166
|
+
highlightedIndex: getDefaultValue$1(props, 'highlightedIndex'),
|
|
3171
3167
|
inputValue: action.inputValue
|
|
3172
3168
|
};
|
|
3173
3169
|
break;
|
|
3174
3170
|
|
|
3175
|
-
case FunctionSelectItem
|
|
3171
|
+
case FunctionSelectItem:
|
|
3176
3172
|
changes = {
|
|
3177
3173
|
selectedItem: action.selectedItem,
|
|
3178
3174
|
inputValue: props.itemToString(action.selectedItem)
|
|
@@ -3186,14 +3182,14 @@ function downshiftUseComboboxReducer(state, action) {
|
|
|
3186
3182
|
break;
|
|
3187
3183
|
|
|
3188
3184
|
default:
|
|
3189
|
-
return downshiftCommonReducer(state, action, stateChangeTypes$
|
|
3185
|
+
return downshiftCommonReducer(state, action, stateChangeTypes$1);
|
|
3190
3186
|
}
|
|
3191
3187
|
|
|
3192
3188
|
return _extends__default['default']({}, state, changes);
|
|
3193
3189
|
}
|
|
3194
3190
|
/* eslint-enable complexity */
|
|
3195
3191
|
|
|
3196
|
-
useCombobox.stateChangeTypes = stateChangeTypes$
|
|
3192
|
+
useCombobox.stateChangeTypes = stateChangeTypes$1;
|
|
3197
3193
|
|
|
3198
3194
|
function useCombobox(userProps) {
|
|
3199
3195
|
if (userProps === void 0) {
|
|
@@ -3202,7 +3198,7 @@ function useCombobox(userProps) {
|
|
|
3202
3198
|
|
|
3203
3199
|
validatePropTypes$1(userProps, useCombobox); // Props defaults and destructuring.
|
|
3204
3200
|
|
|
3205
|
-
var props = _extends__default['default']({}, defaultProps$
|
|
3201
|
+
var props = _extends__default['default']({}, defaultProps$1, userProps);
|
|
3206
3202
|
|
|
3207
3203
|
var initialIsOpen = props.initialIsOpen,
|
|
3208
3204
|
defaultIsOpen = props.defaultIsOpen,
|
|
@@ -3215,7 +3211,7 @@ function useCombobox(userProps) {
|
|
|
3215
3211
|
|
|
3216
3212
|
var initialState = getInitialState$1(props);
|
|
3217
3213
|
|
|
3218
|
-
var _useControlledReducer = useControlledReducer
|
|
3214
|
+
var _useControlledReducer = useControlledReducer(downshiftUseComboboxReducer, initialState, props),
|
|
3219
3215
|
state = _useControlledReducer[0],
|
|
3220
3216
|
dispatch = _useControlledReducer[1];
|
|
3221
3217
|
|
|
@@ -3400,7 +3396,7 @@ function useCombobox(userProps) {
|
|
|
3400
3396
|
menuRef.current = menuNode;
|
|
3401
3397
|
}), _extends2.id = elementIds.menuId, _extends2.role = 'listbox', _extends2['aria-labelledby'] = elementIds.labelId, _extends2.onMouseLeave = callAllEventHandlers(onMouseLeave, function () {
|
|
3402
3398
|
dispatch({
|
|
3403
|
-
type: MenuMouseLeave
|
|
3399
|
+
type: MenuMouseLeave
|
|
3404
3400
|
});
|
|
3405
3401
|
}), _extends2), rest);
|
|
3406
3402
|
}, [dispatch, setGetterPropCallInfo, elementIds]);
|
|
@@ -3413,9 +3409,9 @@ function useCombobox(userProps) {
|
|
|
3413
3409
|
_ref3$refKey = _ref3.refKey,
|
|
3414
3410
|
refKey = _ref3$refKey === void 0 ? 'ref' : _ref3$refKey,
|
|
3415
3411
|
ref = _ref3.ref,
|
|
3416
|
-
onMouseMove = _ref3.onMouseMove
|
|
3417
|
-
|
|
3418
|
-
onPress = _ref3.onPress,
|
|
3412
|
+
onMouseMove = _ref3.onMouseMove;
|
|
3413
|
+
_ref3.onClick;
|
|
3414
|
+
var onPress = _ref3.onPress,
|
|
3419
3415
|
rest = _objectWithoutPropertiesLoose__default['default'](_ref3, ["item", "index", "refKey", "ref", "onMouseMove", "onClick", "onPress"]);
|
|
3420
3416
|
|
|
3421
3417
|
var _latest$current = latest.current,
|
|
@@ -3427,11 +3423,9 @@ function useCombobox(userProps) {
|
|
|
3427
3423
|
throw new Error('Pass either item or item index in getItemProps!');
|
|
3428
3424
|
}
|
|
3429
3425
|
|
|
3430
|
-
var onSelectKey =
|
|
3431
|
-
/* istanbul ignore next (react-native) */
|
|
3426
|
+
var onSelectKey = /* istanbul ignore next (react-native) */
|
|
3432
3427
|
'onPress' ;
|
|
3433
|
-
var customClickHandler =
|
|
3434
|
-
/* istanbul ignore next (react-native) */
|
|
3428
|
+
var customClickHandler = /* istanbul ignore next (react-native) */
|
|
3435
3429
|
onPress ;
|
|
3436
3430
|
|
|
3437
3431
|
var itemHandleMouseMove = function itemHandleMouseMove() {
|
|
@@ -3441,14 +3435,14 @@ function useCombobox(userProps) {
|
|
|
3441
3435
|
|
|
3442
3436
|
shouldScrollRef.current = false;
|
|
3443
3437
|
dispatch({
|
|
3444
|
-
type: ItemMouseMove
|
|
3438
|
+
type: ItemMouseMove,
|
|
3445
3439
|
index: index
|
|
3446
3440
|
});
|
|
3447
3441
|
};
|
|
3448
3442
|
|
|
3449
3443
|
var itemHandleClick = function itemHandleClick() {
|
|
3450
3444
|
dispatch({
|
|
3451
|
-
type: ItemClick
|
|
3445
|
+
type: ItemClick,
|
|
3452
3446
|
index: index
|
|
3453
3447
|
});
|
|
3454
3448
|
|
|
@@ -3468,9 +3462,9 @@ function useCombobox(userProps) {
|
|
|
3468
3462
|
var getToggleButtonProps = react.useCallback(function (_temp4) {
|
|
3469
3463
|
var _extends4;
|
|
3470
3464
|
|
|
3471
|
-
var _ref5 = _temp4 === void 0 ? {} : _temp4
|
|
3472
|
-
|
|
3473
|
-
onPress = _ref5.onPress,
|
|
3465
|
+
var _ref5 = _temp4 === void 0 ? {} : _temp4;
|
|
3466
|
+
_ref5.onClick;
|
|
3467
|
+
var onPress = _ref5.onPress,
|
|
3474
3468
|
_ref5$refKey = _ref5.refKey,
|
|
3475
3469
|
refKey = _ref5$refKey === void 0 ? 'ref' : _ref5$refKey,
|
|
3476
3470
|
ref = _ref5.ref,
|
|
@@ -3478,7 +3472,7 @@ function useCombobox(userProps) {
|
|
|
3478
3472
|
|
|
3479
3473
|
var toggleButtonHandleClick = function toggleButtonHandleClick() {
|
|
3480
3474
|
dispatch({
|
|
3481
|
-
type: ToggleButtonClick
|
|
3475
|
+
type: ToggleButtonClick
|
|
3482
3476
|
});
|
|
3483
3477
|
|
|
3484
3478
|
if (!latest.current.state.isOpen && inputRef.current) {
|
|
@@ -3488,8 +3482,7 @@ function useCombobox(userProps) {
|
|
|
3488
3482
|
|
|
3489
3483
|
return _extends__default['default']((_extends4 = {}, _extends4[refKey] = handleRefs(ref, function (toggleButtonNode) {
|
|
3490
3484
|
toggleButtonRef.current = toggleButtonNode;
|
|
3491
|
-
}), _extends4.id = elementIds.toggleButtonId, _extends4.tabIndex = -1, _extends4), !rest.disabled && _extends__default['default']({},
|
|
3492
|
-
/* istanbul ignore next (react-native) */
|
|
3485
|
+
}), _extends4.id = elementIds.toggleButtonId, _extends4.tabIndex = -1, _extends4), !rest.disabled && _extends__default['default']({}, /* istanbul ignore next (react-native) */
|
|
3493
3486
|
{
|
|
3494
3487
|
onPress: callAllEventHandlers(onPress, toggleButtonHandleClick)
|
|
3495
3488
|
} ), rest);
|
|
@@ -3526,8 +3519,7 @@ function useCombobox(userProps) {
|
|
|
3526
3519
|
var inputHandleChange = function inputHandleChange(event) {
|
|
3527
3520
|
dispatch({
|
|
3528
3521
|
type: InputChange,
|
|
3529
|
-
inputValue:
|
|
3530
|
-
/* istanbul ignore next (react-native) */
|
|
3522
|
+
inputValue: /* istanbul ignore next (react-native) */
|
|
3531
3523
|
event.nativeEvent.text
|
|
3532
3524
|
});
|
|
3533
3525
|
};
|
|
@@ -3544,7 +3536,7 @@ function useCombobox(userProps) {
|
|
|
3544
3536
|
/* istanbul ignore next (preact) */
|
|
3545
3537
|
|
|
3546
3538
|
|
|
3547
|
-
var onChangeKey =
|
|
3539
|
+
var onChangeKey = 'onChange';
|
|
3548
3540
|
var eventHandlers = {};
|
|
3549
3541
|
|
|
3550
3542
|
if (!rest.disabled) {
|
|
@@ -3599,34 +3591,34 @@ function useCombobox(userProps) {
|
|
|
3599
3591
|
|
|
3600
3592
|
var toggleMenu = react.useCallback(function () {
|
|
3601
3593
|
dispatch({
|
|
3602
|
-
type: FunctionToggleMenu
|
|
3594
|
+
type: FunctionToggleMenu
|
|
3603
3595
|
});
|
|
3604
3596
|
}, [dispatch]);
|
|
3605
3597
|
var closeMenu = react.useCallback(function () {
|
|
3606
3598
|
dispatch({
|
|
3607
|
-
type: FunctionCloseMenu
|
|
3599
|
+
type: FunctionCloseMenu
|
|
3608
3600
|
});
|
|
3609
3601
|
}, [dispatch]);
|
|
3610
3602
|
var openMenu = react.useCallback(function () {
|
|
3611
3603
|
dispatch({
|
|
3612
|
-
type: FunctionOpenMenu
|
|
3604
|
+
type: FunctionOpenMenu
|
|
3613
3605
|
});
|
|
3614
3606
|
}, [dispatch]);
|
|
3615
3607
|
var setHighlightedIndex = react.useCallback(function (newHighlightedIndex) {
|
|
3616
3608
|
dispatch({
|
|
3617
|
-
type: FunctionSetHighlightedIndex
|
|
3609
|
+
type: FunctionSetHighlightedIndex,
|
|
3618
3610
|
highlightedIndex: newHighlightedIndex
|
|
3619
3611
|
});
|
|
3620
3612
|
}, [dispatch]);
|
|
3621
3613
|
var selectItem = react.useCallback(function (newSelectedItem) {
|
|
3622
3614
|
dispatch({
|
|
3623
|
-
type: FunctionSelectItem
|
|
3615
|
+
type: FunctionSelectItem,
|
|
3624
3616
|
selectedItem: newSelectedItem
|
|
3625
3617
|
});
|
|
3626
3618
|
}, [dispatch]);
|
|
3627
3619
|
var setInputValue = react.useCallback(function (newInputValue) {
|
|
3628
3620
|
dispatch({
|
|
3629
|
-
type: FunctionSetInputValue
|
|
3621
|
+
type: FunctionSetInputValue,
|
|
3630
3622
|
inputValue: newInputValue
|
|
3631
3623
|
});
|
|
3632
3624
|
}, [dispatch]);
|
|
@@ -3673,8 +3665,8 @@ var defaultStateValues = {
|
|
|
3673
3665
|
* @returns {any} The initial value for that prop.
|
|
3674
3666
|
*/
|
|
3675
3667
|
|
|
3676
|
-
function getInitialValue
|
|
3677
|
-
return getInitialValue(props, propKey, defaultStateValues);
|
|
3668
|
+
function getInitialValue(props, propKey) {
|
|
3669
|
+
return getInitialValue$1(props, propKey, defaultStateValues);
|
|
3678
3670
|
}
|
|
3679
3671
|
/**
|
|
3680
3672
|
* Returns the default value for a state key in the following order:
|
|
@@ -3686,8 +3678,8 @@ function getInitialValue$1(props, propKey) {
|
|
|
3686
3678
|
*/
|
|
3687
3679
|
|
|
3688
3680
|
|
|
3689
|
-
function getDefaultValue
|
|
3690
|
-
return getDefaultValue(props, propKey, defaultStateValues);
|
|
3681
|
+
function getDefaultValue(props, propKey) {
|
|
3682
|
+
return getDefaultValue$1(props, propKey, defaultStateValues);
|
|
3691
3683
|
}
|
|
3692
3684
|
/**
|
|
3693
3685
|
* Gets the initial state based on the provided props. It uses initial, default
|
|
@@ -3698,9 +3690,9 @@ function getDefaultValue$1(props, propKey) {
|
|
|
3698
3690
|
*/
|
|
3699
3691
|
|
|
3700
3692
|
|
|
3701
|
-
function getInitialState
|
|
3702
|
-
var activeIndex = getInitialValue
|
|
3703
|
-
var selectedItems = getInitialValue
|
|
3693
|
+
function getInitialState(props) {
|
|
3694
|
+
var activeIndex = getInitialValue(props, 'activeIndex');
|
|
3695
|
+
var selectedItems = getInitialValue(props, 'selectedItems');
|
|
3704
3696
|
return {
|
|
3705
3697
|
activeIndex: activeIndex,
|
|
3706
3698
|
selectedItems: selectedItems
|
|
@@ -3747,7 +3739,7 @@ function getA11yRemovalMessage(selectionParameters) {
|
|
|
3747
3739
|
return itemToStringLocal(removedSelectedItem) + " has been removed.";
|
|
3748
3740
|
}
|
|
3749
3741
|
|
|
3750
|
-
var propTypes
|
|
3742
|
+
var propTypes = {
|
|
3751
3743
|
selectedItems: PropTypes__default['default'].array,
|
|
3752
3744
|
initialSelectedItems: PropTypes__default['default'].array,
|
|
3753
3745
|
defaultSelectedItems: PropTypes__default['default'].array,
|
|
@@ -3771,21 +3763,21 @@ var propTypes$2 = {
|
|
|
3771
3763
|
})
|
|
3772
3764
|
})
|
|
3773
3765
|
};
|
|
3774
|
-
var defaultProps
|
|
3775
|
-
itemToString: defaultProps.itemToString,
|
|
3776
|
-
stateReducer: defaultProps.stateReducer,
|
|
3777
|
-
environment: defaultProps.environment,
|
|
3766
|
+
var defaultProps = {
|
|
3767
|
+
itemToString: defaultProps$3.itemToString,
|
|
3768
|
+
stateReducer: defaultProps$3.stateReducer,
|
|
3769
|
+
environment: defaultProps$3.environment,
|
|
3778
3770
|
getA11yRemovalMessage: getA11yRemovalMessage,
|
|
3779
3771
|
keyNavigationNext: 'ArrowRight',
|
|
3780
3772
|
keyNavigationPrevious: 'ArrowLeft'
|
|
3781
3773
|
}; // eslint-disable-next-line import/no-mutable-exports
|
|
3782
3774
|
|
|
3783
|
-
var validatePropTypes
|
|
3775
|
+
var validatePropTypes = noop;
|
|
3784
3776
|
/* istanbul ignore next */
|
|
3785
3777
|
|
|
3786
3778
|
if (process.env.NODE_ENV !== 'production') {
|
|
3787
|
-
validatePropTypes
|
|
3788
|
-
PropTypes__default['default'].checkPropTypes(propTypes
|
|
3779
|
+
validatePropTypes = function validatePropTypes(options, caller) {
|
|
3780
|
+
PropTypes__default['default'].checkPropTypes(propTypes, options, 'prop', caller.name);
|
|
3789
3781
|
};
|
|
3790
3782
|
}
|
|
3791
3783
|
|
|
@@ -3801,9 +3793,9 @@ var FunctionAddSelectedItem = process.env.NODE_ENV !== "production" ? '__functio
|
|
|
3801
3793
|
var FunctionRemoveSelectedItem = process.env.NODE_ENV !== "production" ? '__function_remove_selected_item__' : 9;
|
|
3802
3794
|
var FunctionSetSelectedItems = process.env.NODE_ENV !== "production" ? '__function_set_selected_items__' : 10;
|
|
3803
3795
|
var FunctionSetActiveIndex = process.env.NODE_ENV !== "production" ? '__function_set_active_index__' : 11;
|
|
3804
|
-
var FunctionReset
|
|
3796
|
+
var FunctionReset = process.env.NODE_ENV !== "production" ? '__function_reset__' : 12;
|
|
3805
3797
|
|
|
3806
|
-
var stateChangeTypes
|
|
3798
|
+
var stateChangeTypes = /*#__PURE__*/Object.freeze({
|
|
3807
3799
|
__proto__: null,
|
|
3808
3800
|
SelectedItemClick: SelectedItemClick,
|
|
3809
3801
|
SelectedItemKeyDownDelete: SelectedItemKeyDownDelete,
|
|
@@ -3817,7 +3809,7 @@ var stateChangeTypes$3 = /*#__PURE__*/Object.freeze({
|
|
|
3817
3809
|
FunctionRemoveSelectedItem: FunctionRemoveSelectedItem,
|
|
3818
3810
|
FunctionSetSelectedItems: FunctionSetSelectedItems,
|
|
3819
3811
|
FunctionSetActiveIndex: FunctionSetActiveIndex,
|
|
3820
|
-
FunctionReset: FunctionReset
|
|
3812
|
+
FunctionReset: FunctionReset
|
|
3821
3813
|
});
|
|
3822
3814
|
|
|
3823
3815
|
/* eslint-disable complexity */
|
|
@@ -3930,10 +3922,10 @@ function downshiftMultipleSelectionReducer(state, action) {
|
|
|
3930
3922
|
break;
|
|
3931
3923
|
}
|
|
3932
3924
|
|
|
3933
|
-
case FunctionReset
|
|
3925
|
+
case FunctionReset:
|
|
3934
3926
|
changes = {
|
|
3935
|
-
activeIndex: getDefaultValue
|
|
3936
|
-
selectedItems: getDefaultValue
|
|
3927
|
+
activeIndex: getDefaultValue(props, 'activeIndex'),
|
|
3928
|
+
selectedItems: getDefaultValue(props, 'selectedItems')
|
|
3937
3929
|
};
|
|
3938
3930
|
break;
|
|
3939
3931
|
|
|
@@ -3944,16 +3936,16 @@ function downshiftMultipleSelectionReducer(state, action) {
|
|
|
3944
3936
|
return _extends__default['default']({}, state, changes);
|
|
3945
3937
|
}
|
|
3946
3938
|
|
|
3947
|
-
useMultipleSelection.stateChangeTypes = stateChangeTypes
|
|
3939
|
+
useMultipleSelection.stateChangeTypes = stateChangeTypes;
|
|
3948
3940
|
|
|
3949
3941
|
function useMultipleSelection(userProps) {
|
|
3950
3942
|
if (userProps === void 0) {
|
|
3951
3943
|
userProps = {};
|
|
3952
3944
|
}
|
|
3953
3945
|
|
|
3954
|
-
validatePropTypes
|
|
3946
|
+
validatePropTypes(userProps, useMultipleSelection); // Props defaults and destructuring.
|
|
3955
3947
|
|
|
3956
|
-
var props = _extends__default['default']({}, defaultProps
|
|
3948
|
+
var props = _extends__default['default']({}, defaultProps, userProps);
|
|
3957
3949
|
|
|
3958
3950
|
var getA11yRemovalMessage = props.getA11yRemovalMessage,
|
|
3959
3951
|
itemToString = props.itemToString,
|
|
@@ -3961,7 +3953,7 @@ function useMultipleSelection(userProps) {
|
|
|
3961
3953
|
keyNavigationNext = props.keyNavigationNext,
|
|
3962
3954
|
keyNavigationPrevious = props.keyNavigationPrevious; // Reducer init.
|
|
3963
3955
|
|
|
3964
|
-
var _useControlledReducer = useControlledReducer(downshiftMultipleSelectionReducer, getInitialState
|
|
3956
|
+
var _useControlledReducer = useControlledReducer$1(downshiftMultipleSelectionReducer, getInitialState(props), props),
|
|
3965
3957
|
state = _useControlledReducer[0],
|
|
3966
3958
|
dispatch = _useControlledReducer[1];
|
|
3967
3959
|
|
|
@@ -4172,7 +4164,7 @@ function useMultipleSelection(userProps) {
|
|
|
4172
4164
|
}, [dispatch]);
|
|
4173
4165
|
var reset = react.useCallback(function () {
|
|
4174
4166
|
dispatch({
|
|
4175
|
-
type: FunctionReset
|
|
4167
|
+
type: FunctionReset
|
|
4176
4168
|
});
|
|
4177
4169
|
}, [dispatch]);
|
|
4178
4170
|
return {
|