downshift 6.1.0 → 6.1.3
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 +196 -190
- package/dist/downshift.esm.js +196 -190
- package/dist/downshift.native.cjs.js +190 -192
- package/dist/downshift.umd.js +437 -422
- 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 +38 -26
- package/preact/dist/downshift.cjs.js +196 -190
- package/preact/dist/downshift.esm.js +196 -190
- package/preact/dist/downshift.umd.js +280 -265
- package/preact/dist/downshift.umd.js.map +1 -1
- package/preact/dist/downshift.umd.min.js +12 -3
- package/preact/dist/downshift.umd.min.js.map +1 -1
- package/dist/downshift.cjs.d.ts +0 -1
- package/dist/downshift.esm.d.ts +0 -1
- package/dist/downshift.native.cjs.d.ts +0 -1
- package/dist/downshift.umd.d.ts +0 -1
- package/dist/downshift.umd.min.d.ts +0 -1
package/dist/downshift.esm.js
CHANGED
|
@@ -50,12 +50,14 @@ function scrollIntoView(node, menuNode) {
|
|
|
50
50
|
/**
|
|
51
51
|
* @param {HTMLElement} parent the parent node
|
|
52
52
|
* @param {HTMLElement} child the child node
|
|
53
|
+
* @param {Window} environment The window context where downshift renders.
|
|
53
54
|
* @return {Boolean} whether the parent is the child or the child is in the parent
|
|
54
55
|
*/
|
|
55
56
|
|
|
56
57
|
|
|
57
|
-
function isOrContainsNode(parent, child) {
|
|
58
|
-
|
|
58
|
+
function isOrContainsNode(parent, child, environment) {
|
|
59
|
+
var result = parent === child || child instanceof environment.Node && parent.contains && parent.contains(child);
|
|
60
|
+
return result;
|
|
59
61
|
}
|
|
60
62
|
/**
|
|
61
63
|
* Simple debounce implementation. Will call the given
|
|
@@ -162,7 +164,7 @@ function resetIdCounter() {
|
|
|
162
164
|
*/
|
|
163
165
|
|
|
164
166
|
|
|
165
|
-
function getA11yStatusMessage(_ref2) {
|
|
167
|
+
function getA11yStatusMessage$1(_ref2) {
|
|
166
168
|
var isOpen = _ref2.isOpen,
|
|
167
169
|
resultCount = _ref2.resultCount,
|
|
168
170
|
previousResultCount = _ref2.previousResultCount;
|
|
@@ -403,20 +405,20 @@ function getNextNonDisabledIndex(moveAmount, baseIndex, itemCount, getItemNodeFr
|
|
|
403
405
|
*
|
|
404
406
|
* @param {EventTarget} target Target to check.
|
|
405
407
|
* @param {HTMLElement[]} downshiftElements The elements that form downshift (list, toggle button etc).
|
|
406
|
-
* @param {
|
|
408
|
+
* @param {Window} environment The window context where downshift renders.
|
|
407
409
|
* @param {boolean} checkActiveElement Whether to also check activeElement.
|
|
408
410
|
*
|
|
409
411
|
* @returns {boolean} Whether or not the target is within downshift elements.
|
|
410
412
|
*/
|
|
411
413
|
|
|
412
414
|
|
|
413
|
-
function targetWithinDownshift(target, downshiftElements,
|
|
415
|
+
function targetWithinDownshift(target, downshiftElements, environment, checkActiveElement) {
|
|
414
416
|
if (checkActiveElement === void 0) {
|
|
415
417
|
checkActiveElement = true;
|
|
416
418
|
}
|
|
417
419
|
|
|
418
420
|
return downshiftElements.some(function (contextNode) {
|
|
419
|
-
return contextNode && (isOrContainsNode(contextNode, target) || checkActiveElement && isOrContainsNode(contextNode, document.activeElement));
|
|
421
|
+
return contextNode && (isOrContainsNode(contextNode, target, environment) || checkActiveElement && isOrContainsNode(contextNode, environment.document.activeElement, environment));
|
|
420
422
|
});
|
|
421
423
|
} // eslint-disable-next-line import/no-mutable-exports
|
|
422
424
|
|
|
@@ -512,7 +514,7 @@ var blurButton = process.env.NODE_ENV !== "production" ? '__autocomplete_blur_bu
|
|
|
512
514
|
var controlledPropUpdatedSelectedItem = process.env.NODE_ENV !== "production" ? '__autocomplete_controlled_prop_updated_selected_item__' : 15;
|
|
513
515
|
var touchEnd = process.env.NODE_ENV !== "production" ? '__autocomplete_touchend__' : 16;
|
|
514
516
|
|
|
515
|
-
var stateChangeTypes = /*#__PURE__*/Object.freeze({
|
|
517
|
+
var stateChangeTypes$3 = /*#__PURE__*/Object.freeze({
|
|
516
518
|
__proto__: null,
|
|
517
519
|
unknown: unknown,
|
|
518
520
|
mouseUp: mouseUp,
|
|
@@ -905,9 +907,9 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
905
907
|
|
|
906
908
|
_this.getToggleButtonProps = function (_temp3) {
|
|
907
909
|
var _ref3 = _temp3 === void 0 ? {} : _temp3,
|
|
908
|
-
onClick = _ref3.onClick
|
|
909
|
-
|
|
910
|
-
onKeyDown = _ref3.onKeyDown,
|
|
910
|
+
onClick = _ref3.onClick;
|
|
911
|
+
_ref3.onPress;
|
|
912
|
+
var onKeyDown = _ref3.onKeyDown,
|
|
911
913
|
onKeyUp = _ref3.onKeyUp,
|
|
912
914
|
onBlur = _ref3.onBlur,
|
|
913
915
|
rest = _objectWithoutPropertiesLoose(_ref3, ["onClick", "onPress", "onKeyDown", "onKeyUp", "onBlur"]);
|
|
@@ -915,7 +917,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
915
917
|
var _this$getState5 = _this.getState(),
|
|
916
918
|
isOpen = _this$getState5.isOpen;
|
|
917
919
|
|
|
918
|
-
var enabledEventHandlers =
|
|
920
|
+
var enabledEventHandlers = {
|
|
919
921
|
onClick: callAllEventHandlers(onClick, _this.buttonHandleClick),
|
|
920
922
|
onKeyDown: callAllEventHandlers(onKeyDown, _this.buttonHandleKeyDown),
|
|
921
923
|
onKeyUp: callAllEventHandlers(onKeyUp, _this.buttonHandleKeyUp),
|
|
@@ -950,7 +952,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
950
952
|
|
|
951
953
|
/* istanbul ignore if (can't reasonably test this) */
|
|
952
954
|
|
|
953
|
-
if (
|
|
955
|
+
if (_this.props.environment.document.activeElement === _this.props.environment.document.body) {
|
|
954
956
|
event.target.focus();
|
|
955
957
|
} // to simplify testing components that use downshift, we'll not wrap this in a setTimeout
|
|
956
958
|
// if the NODE_ENV is test. With the proper build system, this should be dead code eliminated
|
|
@@ -997,9 +999,9 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
997
999
|
onKeyDown = _ref4.onKeyDown,
|
|
998
1000
|
onBlur = _ref4.onBlur,
|
|
999
1001
|
onChange = _ref4.onChange,
|
|
1000
|
-
onInput = _ref4.onInput
|
|
1001
|
-
|
|
1002
|
-
rest = _objectWithoutPropertiesLoose(_ref4, ["onKeyDown", "onBlur", "onChange", "onInput", "onChangeText"]);
|
|
1002
|
+
onInput = _ref4.onInput;
|
|
1003
|
+
_ref4.onChangeText;
|
|
1004
|
+
var rest = _objectWithoutPropertiesLoose(_ref4, ["onKeyDown", "onBlur", "onChange", "onInput", "onChangeText"]);
|
|
1003
1005
|
|
|
1004
1006
|
var onChangeKey;
|
|
1005
1007
|
var eventHandlers = {};
|
|
@@ -1045,7 +1047,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1045
1047
|
_this.internalSetState({
|
|
1046
1048
|
type: changeInput,
|
|
1047
1049
|
isOpen: true,
|
|
1048
|
-
inputValue:
|
|
1050
|
+
inputValue: event.target.value,
|
|
1049
1051
|
highlightedIndex: _this.props.defaultHighlightedIndex
|
|
1050
1052
|
});
|
|
1051
1053
|
};
|
|
@@ -1092,9 +1094,9 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1092
1094
|
var _ref7 = _temp7 === void 0 ? {} : _temp7,
|
|
1093
1095
|
onMouseMove = _ref7.onMouseMove,
|
|
1094
1096
|
onMouseDown = _ref7.onMouseDown,
|
|
1095
|
-
onClick = _ref7.onClick
|
|
1096
|
-
|
|
1097
|
-
index = _ref7.index,
|
|
1097
|
+
onClick = _ref7.onClick;
|
|
1098
|
+
_ref7.onPress;
|
|
1099
|
+
var index = _ref7.index,
|
|
1098
1100
|
_ref7$item = _ref7.item,
|
|
1099
1101
|
item = _ref7$item === void 0 ? process.env.NODE_ENV === 'production' ?
|
|
1100
1102
|
/* istanbul ignore next */
|
|
@@ -1109,8 +1111,8 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1109
1111
|
_this.items[index] = item;
|
|
1110
1112
|
}
|
|
1111
1113
|
|
|
1112
|
-
var onSelectKey =
|
|
1113
|
-
var customClickHandler =
|
|
1114
|
+
var onSelectKey = 'onClick';
|
|
1115
|
+
var customClickHandler = onClick;
|
|
1114
1116
|
var enabledEventHandlers = (_enabledEventHandlers = {
|
|
1115
1117
|
// onMouseMove is used over onMouseEnter here. onMouseMove
|
|
1116
1118
|
// is only triggered on actual mouse movement while onMouseEnter
|
|
@@ -1425,7 +1427,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1425
1427
|
_this7.isMouseDown = false; // if the target element or the activeElement is within a downshift node
|
|
1426
1428
|
// then we don't want to reset downshift
|
|
1427
1429
|
|
|
1428
|
-
var contextWithinDownshift = targetWithinDownshift(event.target, [_this7._rootNode, _this7._menuNode], _this7.props.environment
|
|
1430
|
+
var contextWithinDownshift = targetWithinDownshift(event.target, [_this7._rootNode, _this7._menuNode], _this7.props.environment);
|
|
1429
1431
|
|
|
1430
1432
|
if (!contextWithinDownshift && _this7.getState().isOpen) {
|
|
1431
1433
|
_this7.reset({
|
|
@@ -1451,7 +1453,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1451
1453
|
};
|
|
1452
1454
|
|
|
1453
1455
|
var onTouchEnd = function onTouchEnd(event) {
|
|
1454
|
-
var contextWithinDownshift = targetWithinDownshift(event.target, [_this7._rootNode, _this7._menuNode], _this7.props.environment
|
|
1456
|
+
var contextWithinDownshift = targetWithinDownshift(event.target, [_this7._rootNode, _this7._menuNode], _this7.props.environment, false);
|
|
1455
1457
|
|
|
1456
1458
|
if (!_this7.isTouchMove && !contextWithinDownshift && _this7.getState().isOpen) {
|
|
1457
1459
|
_this7.reset({
|
|
@@ -1500,7 +1502,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1500
1502
|
validateControlledUnchanged(this.state, prevProps, this.props);
|
|
1501
1503
|
/* istanbul ignore if (react-native) */
|
|
1502
1504
|
|
|
1503
|
-
if (
|
|
1505
|
+
if (this.getMenuProps.called && !this.getMenuProps.suppressRefError) {
|
|
1504
1506
|
validateGetMenuPropsCalledCorrectly(this._menuNode, this.getMenuProps);
|
|
1505
1507
|
}
|
|
1506
1508
|
}
|
|
@@ -1585,7 +1587,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1585
1587
|
Downshift.defaultProps = {
|
|
1586
1588
|
defaultHighlightedIndex: null,
|
|
1587
1589
|
defaultIsOpen: false,
|
|
1588
|
-
getA11yStatusMessage: getA11yStatusMessage,
|
|
1590
|
+
getA11yStatusMessage: getA11yStatusMessage$1,
|
|
1589
1591
|
itemToString: function itemToString(i) {
|
|
1590
1592
|
if (i == null) {
|
|
1591
1593
|
return '';
|
|
@@ -1616,7 +1618,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1616
1618
|
suppressRefError: false,
|
|
1617
1619
|
scrollIntoView: scrollIntoView
|
|
1618
1620
|
};
|
|
1619
|
-
Downshift.stateChangeTypes = stateChangeTypes;
|
|
1621
|
+
Downshift.stateChangeTypes = stateChangeTypes$3;
|
|
1620
1622
|
return Downshift;
|
|
1621
1623
|
}();
|
|
1622
1624
|
|
|
@@ -1878,7 +1880,7 @@ function useEnhancedReducer(reducer, initialState, props) {
|
|
|
1878
1880
|
*/
|
|
1879
1881
|
|
|
1880
1882
|
|
|
1881
|
-
function useControlledReducer(reducer, initialState, props) {
|
|
1883
|
+
function useControlledReducer$1(reducer, initialState, props) {
|
|
1882
1884
|
var _useEnhancedReducer = useEnhancedReducer(reducer, initialState, props),
|
|
1883
1885
|
state = _useEnhancedReducer[0],
|
|
1884
1886
|
dispatch = _useEnhancedReducer[1];
|
|
@@ -1886,7 +1888,7 @@ function useControlledReducer(reducer, initialState, props) {
|
|
|
1886
1888
|
return [getState(state, props), dispatch];
|
|
1887
1889
|
}
|
|
1888
1890
|
|
|
1889
|
-
var defaultProps = {
|
|
1891
|
+
var defaultProps$3 = {
|
|
1890
1892
|
itemToString: itemToString,
|
|
1891
1893
|
stateReducer: stateReducer,
|
|
1892
1894
|
getA11ySelectionMessage: getA11ySelectionMessage,
|
|
@@ -1897,7 +1899,7 @@ var defaultProps = {
|
|
|
1897
1899
|
? {} : window
|
|
1898
1900
|
};
|
|
1899
1901
|
|
|
1900
|
-
function getDefaultValue(props, propKey, defaultStateValues) {
|
|
1902
|
+
function getDefaultValue$1(props, propKey, defaultStateValues) {
|
|
1901
1903
|
if (defaultStateValues === void 0) {
|
|
1902
1904
|
defaultStateValues = dropdownDefaultStateValues;
|
|
1903
1905
|
}
|
|
@@ -1911,7 +1913,7 @@ function getDefaultValue(props, propKey, defaultStateValues) {
|
|
|
1911
1913
|
return defaultStateValues[propKey];
|
|
1912
1914
|
}
|
|
1913
1915
|
|
|
1914
|
-
function getInitialValue(props, propKey, defaultStateValues) {
|
|
1916
|
+
function getInitialValue$1(props, propKey, defaultStateValues) {
|
|
1915
1917
|
if (defaultStateValues === void 0) {
|
|
1916
1918
|
defaultStateValues = dropdownDefaultStateValues;
|
|
1917
1919
|
}
|
|
@@ -1926,14 +1928,14 @@ function getInitialValue(props, propKey, defaultStateValues) {
|
|
|
1926
1928
|
return props[initialPropKey];
|
|
1927
1929
|
}
|
|
1928
1930
|
|
|
1929
|
-
return getDefaultValue(props, propKey, defaultStateValues);
|
|
1931
|
+
return getDefaultValue$1(props, propKey, defaultStateValues);
|
|
1930
1932
|
}
|
|
1931
1933
|
|
|
1932
|
-
function getInitialState(props) {
|
|
1933
|
-
var selectedItem = getInitialValue(props, 'selectedItem');
|
|
1934
|
-
var isOpen = getInitialValue(props, 'isOpen');
|
|
1935
|
-
var highlightedIndex = getInitialValue(props, 'highlightedIndex');
|
|
1936
|
-
var inputValue = getInitialValue(props, 'inputValue');
|
|
1934
|
+
function getInitialState$2(props) {
|
|
1935
|
+
var selectedItem = getInitialValue$1(props, 'selectedItem');
|
|
1936
|
+
var isOpen = getInitialValue$1(props, 'isOpen');
|
|
1937
|
+
var highlightedIndex = getInitialValue$1(props, 'highlightedIndex');
|
|
1938
|
+
var inputValue = getInitialValue$1(props, 'inputValue');
|
|
1937
1939
|
return {
|
|
1938
1940
|
highlightedIndex: highlightedIndex < 0 && selectedItem && isOpen ? props.items.indexOf(selectedItem) : highlightedIndex,
|
|
1939
1941
|
isOpen: isOpen,
|
|
@@ -2004,7 +2006,7 @@ function useMouseAndTouchTracker(isOpen, downshiftElementRefs, environment, hand
|
|
|
2004
2006
|
|
|
2005
2007
|
if (isOpen && !targetWithinDownshift(event.target, downshiftElementRefs.map(function (ref) {
|
|
2006
2008
|
return ref.current;
|
|
2007
|
-
}), environment
|
|
2009
|
+
}), environment)) {
|
|
2008
2010
|
handleBlur();
|
|
2009
2011
|
}
|
|
2010
2012
|
};
|
|
@@ -2020,7 +2022,7 @@ function useMouseAndTouchTracker(isOpen, downshiftElementRefs, environment, hand
|
|
|
2020
2022
|
var onTouchEnd = function onTouchEnd(event) {
|
|
2021
2023
|
if (isOpen && !mouseAndTouchTrackersRef.current.isTouchMove && !targetWithinDownshift(event.target, downshiftElementRefs.map(function (ref) {
|
|
2022
2024
|
return ref.current;
|
|
2023
|
-
}), environment
|
|
2025
|
+
}), environment, false)) {
|
|
2024
2026
|
handleBlur();
|
|
2025
2027
|
}
|
|
2026
2028
|
};
|
|
@@ -2228,10 +2230,10 @@ function downshiftCommonReducer(state, action, stateChangeTypes) {
|
|
|
2228
2230
|
|
|
2229
2231
|
case stateChangeTypes.FunctionReset:
|
|
2230
2232
|
changes = {
|
|
2231
|
-
highlightedIndex: getDefaultValue(props, 'highlightedIndex'),
|
|
2232
|
-
isOpen: getDefaultValue(props, 'isOpen'),
|
|
2233
|
-
selectedItem: getDefaultValue(props, 'selectedItem'),
|
|
2234
|
-
inputValue: getDefaultValue(props, 'inputValue')
|
|
2233
|
+
highlightedIndex: getDefaultValue$1(props, 'highlightedIndex'),
|
|
2234
|
+
isOpen: getDefaultValue$1(props, 'isOpen'),
|
|
2235
|
+
selectedItem: getDefaultValue$1(props, 'selectedItem'),
|
|
2236
|
+
inputValue: getDefaultValue$1(props, 'inputValue')
|
|
2235
2237
|
};
|
|
2236
2238
|
break;
|
|
2237
2239
|
|
|
@@ -2261,7 +2263,7 @@ function getItemIndexByCharacterKey(keysSoFar, highlightedIndex, items, itemToSt
|
|
|
2261
2263
|
return highlightedIndex;
|
|
2262
2264
|
}
|
|
2263
2265
|
|
|
2264
|
-
var propTypes = {
|
|
2266
|
+
var propTypes$2 = {
|
|
2265
2267
|
items: PropTypes.array.isRequired,
|
|
2266
2268
|
itemToString: PropTypes.func,
|
|
2267
2269
|
getA11yStatusMessage: PropTypes.func,
|
|
@@ -2305,7 +2307,7 @@ var propTypes = {
|
|
|
2305
2307
|
* @return {String} the a11y status message
|
|
2306
2308
|
*/
|
|
2307
2309
|
|
|
2308
|
-
function getA11yStatusMessage
|
|
2310
|
+
function getA11yStatusMessage(_ref) {
|
|
2309
2311
|
var isOpen = _ref.isOpen,
|
|
2310
2312
|
resultCount = _ref.resultCount,
|
|
2311
2313
|
previousResultCount = _ref.previousResultCount;
|
|
@@ -2325,17 +2327,17 @@ function getA11yStatusMessage$1(_ref) {
|
|
|
2325
2327
|
return '';
|
|
2326
2328
|
}
|
|
2327
2329
|
|
|
2328
|
-
var defaultProps$
|
|
2329
|
-
getA11yStatusMessage: getA11yStatusMessage
|
|
2330
|
+
var defaultProps$2 = _extends({}, defaultProps$3, {
|
|
2331
|
+
getA11yStatusMessage: getA11yStatusMessage
|
|
2330
2332
|
}); // eslint-disable-next-line import/no-mutable-exports
|
|
2331
2333
|
|
|
2332
2334
|
|
|
2333
|
-
var validatePropTypes = noop;
|
|
2335
|
+
var validatePropTypes$2 = noop;
|
|
2334
2336
|
/* istanbul ignore next */
|
|
2335
2337
|
|
|
2336
2338
|
if (process.env.NODE_ENV !== 'production') {
|
|
2337
|
-
validatePropTypes = function validatePropTypes(options, caller) {
|
|
2338
|
-
PropTypes.checkPropTypes(propTypes, options, 'prop', caller.name);
|
|
2339
|
+
validatePropTypes$2 = function validatePropTypes(options, caller) {
|
|
2340
|
+
PropTypes.checkPropTypes(propTypes$2, options, 'prop', caller.name);
|
|
2339
2341
|
};
|
|
2340
2342
|
}
|
|
2341
2343
|
|
|
@@ -2348,22 +2350,22 @@ var MenuKeyDownEnter = process.env.NODE_ENV !== "production" ? '__menu_keydown_e
|
|
|
2348
2350
|
var MenuKeyDownSpaceButton = process.env.NODE_ENV !== "production" ? '__menu_keydown_space_button__' : 6;
|
|
2349
2351
|
var MenuKeyDownCharacter = process.env.NODE_ENV !== "production" ? '__menu_keydown_character__' : 7;
|
|
2350
2352
|
var MenuBlur = process.env.NODE_ENV !== "production" ? '__menu_blur__' : 8;
|
|
2351
|
-
var MenuMouseLeave = process.env.NODE_ENV !== "production" ? '__menu_mouse_leave__' : 9;
|
|
2352
|
-
var ItemMouseMove = process.env.NODE_ENV !== "production" ? '__item_mouse_move__' : 10;
|
|
2353
|
-
var ItemClick = process.env.NODE_ENV !== "production" ? '__item_click__' : 11;
|
|
2354
|
-
var ToggleButtonClick = process.env.NODE_ENV !== "production" ? '__togglebutton_click__' : 12;
|
|
2353
|
+
var MenuMouseLeave$1 = process.env.NODE_ENV !== "production" ? '__menu_mouse_leave__' : 9;
|
|
2354
|
+
var ItemMouseMove$1 = process.env.NODE_ENV !== "production" ? '__item_mouse_move__' : 10;
|
|
2355
|
+
var ItemClick$1 = process.env.NODE_ENV !== "production" ? '__item_click__' : 11;
|
|
2356
|
+
var ToggleButtonClick$1 = process.env.NODE_ENV !== "production" ? '__togglebutton_click__' : 12;
|
|
2355
2357
|
var ToggleButtonKeyDownArrowDown = process.env.NODE_ENV !== "production" ? '__togglebutton_keydown_arrow_down__' : 13;
|
|
2356
2358
|
var ToggleButtonKeyDownArrowUp = process.env.NODE_ENV !== "production" ? '__togglebutton_keydown_arrow_up__' : 14;
|
|
2357
2359
|
var ToggleButtonKeyDownCharacter = process.env.NODE_ENV !== "production" ? '__togglebutton_keydown_character__' : 15;
|
|
2358
|
-
var FunctionToggleMenu = process.env.NODE_ENV !== "production" ? '__function_toggle_menu__' : 16;
|
|
2359
|
-
var FunctionOpenMenu = process.env.NODE_ENV !== "production" ? '__function_open_menu__' : 17;
|
|
2360
|
-
var FunctionCloseMenu = process.env.NODE_ENV !== "production" ? '__function_close_menu__' : 18;
|
|
2361
|
-
var FunctionSetHighlightedIndex = process.env.NODE_ENV !== "production" ? '__function_set_highlighted_index__' : 19;
|
|
2362
|
-
var FunctionSelectItem = process.env.NODE_ENV !== "production" ? '__function_select_item__' : 20;
|
|
2363
|
-
var FunctionSetInputValue = process.env.NODE_ENV !== "production" ? '__function_set_input_value__' : 21;
|
|
2364
|
-
var FunctionReset = process.env.NODE_ENV !== "production" ? '__function_reset__' : 22;
|
|
2360
|
+
var FunctionToggleMenu$1 = process.env.NODE_ENV !== "production" ? '__function_toggle_menu__' : 16;
|
|
2361
|
+
var FunctionOpenMenu$1 = process.env.NODE_ENV !== "production" ? '__function_open_menu__' : 17;
|
|
2362
|
+
var FunctionCloseMenu$1 = process.env.NODE_ENV !== "production" ? '__function_close_menu__' : 18;
|
|
2363
|
+
var FunctionSetHighlightedIndex$1 = process.env.NODE_ENV !== "production" ? '__function_set_highlighted_index__' : 19;
|
|
2364
|
+
var FunctionSelectItem$1 = process.env.NODE_ENV !== "production" ? '__function_select_item__' : 20;
|
|
2365
|
+
var FunctionSetInputValue$1 = process.env.NODE_ENV !== "production" ? '__function_set_input_value__' : 21;
|
|
2366
|
+
var FunctionReset$2 = process.env.NODE_ENV !== "production" ? '__function_reset__' : 22;
|
|
2365
2367
|
|
|
2366
|
-
var stateChangeTypes$
|
|
2368
|
+
var stateChangeTypes$2 = /*#__PURE__*/Object.freeze({
|
|
2367
2369
|
__proto__: null,
|
|
2368
2370
|
MenuKeyDownArrowDown: MenuKeyDownArrowDown,
|
|
2369
2371
|
MenuKeyDownArrowUp: MenuKeyDownArrowUp,
|
|
@@ -2374,20 +2376,20 @@ var stateChangeTypes$1 = /*#__PURE__*/Object.freeze({
|
|
|
2374
2376
|
MenuKeyDownSpaceButton: MenuKeyDownSpaceButton,
|
|
2375
2377
|
MenuKeyDownCharacter: MenuKeyDownCharacter,
|
|
2376
2378
|
MenuBlur: MenuBlur,
|
|
2377
|
-
MenuMouseLeave: MenuMouseLeave,
|
|
2378
|
-
ItemMouseMove: ItemMouseMove,
|
|
2379
|
-
ItemClick: ItemClick,
|
|
2380
|
-
ToggleButtonClick: ToggleButtonClick,
|
|
2379
|
+
MenuMouseLeave: MenuMouseLeave$1,
|
|
2380
|
+
ItemMouseMove: ItemMouseMove$1,
|
|
2381
|
+
ItemClick: ItemClick$1,
|
|
2382
|
+
ToggleButtonClick: ToggleButtonClick$1,
|
|
2381
2383
|
ToggleButtonKeyDownArrowDown: ToggleButtonKeyDownArrowDown,
|
|
2382
2384
|
ToggleButtonKeyDownArrowUp: ToggleButtonKeyDownArrowUp,
|
|
2383
2385
|
ToggleButtonKeyDownCharacter: ToggleButtonKeyDownCharacter,
|
|
2384
|
-
FunctionToggleMenu: FunctionToggleMenu,
|
|
2385
|
-
FunctionOpenMenu: FunctionOpenMenu,
|
|
2386
|
-
FunctionCloseMenu: FunctionCloseMenu,
|
|
2387
|
-
FunctionSetHighlightedIndex: FunctionSetHighlightedIndex,
|
|
2388
|
-
FunctionSelectItem: FunctionSelectItem,
|
|
2389
|
-
FunctionSetInputValue: FunctionSetInputValue,
|
|
2390
|
-
FunctionReset: FunctionReset
|
|
2386
|
+
FunctionToggleMenu: FunctionToggleMenu$1,
|
|
2387
|
+
FunctionOpenMenu: FunctionOpenMenu$1,
|
|
2388
|
+
FunctionCloseMenu: FunctionCloseMenu$1,
|
|
2389
|
+
FunctionSetHighlightedIndex: FunctionSetHighlightedIndex$1,
|
|
2390
|
+
FunctionSelectItem: FunctionSelectItem$1,
|
|
2391
|
+
FunctionSetInputValue: FunctionSetInputValue$1,
|
|
2392
|
+
FunctionReset: FunctionReset$2
|
|
2391
2393
|
});
|
|
2392
2394
|
|
|
2393
2395
|
/* eslint-disable complexity */
|
|
@@ -2399,10 +2401,10 @@ function downshiftSelectReducer(state, action) {
|
|
|
2399
2401
|
var changes;
|
|
2400
2402
|
|
|
2401
2403
|
switch (type) {
|
|
2402
|
-
case ItemClick:
|
|
2404
|
+
case ItemClick$1:
|
|
2403
2405
|
changes = {
|
|
2404
|
-
isOpen: getDefaultValue(props, 'isOpen'),
|
|
2405
|
-
highlightedIndex: getDefaultValue(props, 'highlightedIndex'),
|
|
2406
|
+
isOpen: getDefaultValue$1(props, 'isOpen'),
|
|
2407
|
+
highlightedIndex: getDefaultValue$1(props, 'highlightedIndex'),
|
|
2406
2408
|
selectedItem: props.items[action.index]
|
|
2407
2409
|
};
|
|
2408
2410
|
break;
|
|
@@ -2437,8 +2439,8 @@ function downshiftSelectReducer(state, action) {
|
|
|
2437
2439
|
case MenuKeyDownEnter:
|
|
2438
2440
|
case MenuKeyDownSpaceButton:
|
|
2439
2441
|
changes = _extends({
|
|
2440
|
-
isOpen: getDefaultValue(props, 'isOpen'),
|
|
2441
|
-
highlightedIndex: getDefaultValue(props, 'highlightedIndex')
|
|
2442
|
+
isOpen: getDefaultValue$1(props, 'isOpen'),
|
|
2443
|
+
highlightedIndex: getDefaultValue$1(props, 'highlightedIndex')
|
|
2442
2444
|
}, state.highlightedIndex >= 0 && {
|
|
2443
2445
|
selectedItem: props.items[state.highlightedIndex]
|
|
2444
2446
|
});
|
|
@@ -2497,30 +2499,30 @@ function downshiftSelectReducer(state, action) {
|
|
|
2497
2499
|
};
|
|
2498
2500
|
break;
|
|
2499
2501
|
|
|
2500
|
-
case FunctionSelectItem:
|
|
2502
|
+
case FunctionSelectItem$1:
|
|
2501
2503
|
changes = {
|
|
2502
2504
|
selectedItem: action.selectedItem
|
|
2503
2505
|
};
|
|
2504
2506
|
break;
|
|
2505
2507
|
|
|
2506
2508
|
default:
|
|
2507
|
-
return downshiftCommonReducer(state, action, stateChangeTypes$
|
|
2509
|
+
return downshiftCommonReducer(state, action, stateChangeTypes$2);
|
|
2508
2510
|
}
|
|
2509
2511
|
|
|
2510
2512
|
return _extends({}, state, changes);
|
|
2511
2513
|
}
|
|
2512
2514
|
/* eslint-enable complexity */
|
|
2513
2515
|
|
|
2514
|
-
useSelect.stateChangeTypes = stateChangeTypes$
|
|
2516
|
+
useSelect.stateChangeTypes = stateChangeTypes$2;
|
|
2515
2517
|
|
|
2516
2518
|
function useSelect(userProps) {
|
|
2517
2519
|
if (userProps === void 0) {
|
|
2518
2520
|
userProps = {};
|
|
2519
2521
|
}
|
|
2520
2522
|
|
|
2521
|
-
validatePropTypes(userProps, useSelect); // Props defaults and destructuring.
|
|
2523
|
+
validatePropTypes$2(userProps, useSelect); // Props defaults and destructuring.
|
|
2522
2524
|
|
|
2523
|
-
var props = _extends({}, defaultProps$
|
|
2525
|
+
var props = _extends({}, defaultProps$2, userProps);
|
|
2524
2526
|
|
|
2525
2527
|
var items = props.items,
|
|
2526
2528
|
scrollIntoView = props.scrollIntoView,
|
|
@@ -2531,9 +2533,9 @@ function useSelect(userProps) {
|
|
|
2531
2533
|
getA11ySelectionMessage = props.getA11ySelectionMessage,
|
|
2532
2534
|
getA11yStatusMessage = props.getA11yStatusMessage; // Initial state depending on controlled props.
|
|
2533
2535
|
|
|
2534
|
-
var initialState = getInitialState(props);
|
|
2536
|
+
var initialState = getInitialState$2(props);
|
|
2535
2537
|
|
|
2536
|
-
var _useControlledReducer = useControlledReducer(downshiftSelectReducer, initialState, props),
|
|
2538
|
+
var _useControlledReducer = useControlledReducer$1(downshiftSelectReducer, initialState, props),
|
|
2537
2539
|
state = _useControlledReducer[0],
|
|
2538
2540
|
dispatch = _useControlledReducer[1];
|
|
2539
2541
|
|
|
@@ -2588,19 +2590,23 @@ function useSelect(userProps) {
|
|
|
2588
2590
|
itemRefs: itemRefs,
|
|
2589
2591
|
scrollIntoView: scrollIntoView,
|
|
2590
2592
|
getItemNodeFromIndex: getItemNodeFromIndex
|
|
2591
|
-
}); // Sets cleanup for the keysSoFar after 500ms.
|
|
2593
|
+
}); // Sets cleanup for the keysSoFar callback, debounded after 500ms.
|
|
2592
2594
|
|
|
2593
2595
|
useEffect(function () {
|
|
2594
2596
|
// init the clean function here as we need access to dispatch.
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2597
|
+
clearTimeoutRef.current = debounce(function (outerDispatch) {
|
|
2598
|
+
outerDispatch({
|
|
2599
|
+
type: FunctionSetInputValue$1,
|
|
2600
|
+
inputValue: ''
|
|
2601
|
+
});
|
|
2602
|
+
}, 500); // Cancel any pending debounced calls on mount
|
|
2603
|
+
|
|
2604
|
+
return function () {
|
|
2605
|
+
clearTimeoutRef.current.cancel();
|
|
2606
|
+
};
|
|
2607
|
+
}, []); // Invokes the keysSoFar callback set up above.
|
|
2603
2608
|
|
|
2609
|
+
useEffect(function () {
|
|
2604
2610
|
if (!inputValue) {
|
|
2605
2611
|
return;
|
|
2606
2612
|
}
|
|
@@ -2744,39 +2750,39 @@ function useSelect(userProps) {
|
|
|
2744
2750
|
|
|
2745
2751
|
var toggleMenu = useCallback(function () {
|
|
2746
2752
|
dispatch({
|
|
2747
|
-
type: FunctionToggleMenu
|
|
2753
|
+
type: FunctionToggleMenu$1
|
|
2748
2754
|
});
|
|
2749
2755
|
}, [dispatch]);
|
|
2750
2756
|
var closeMenu = useCallback(function () {
|
|
2751
2757
|
dispatch({
|
|
2752
|
-
type: FunctionCloseMenu
|
|
2758
|
+
type: FunctionCloseMenu$1
|
|
2753
2759
|
});
|
|
2754
2760
|
}, [dispatch]);
|
|
2755
2761
|
var openMenu = useCallback(function () {
|
|
2756
2762
|
dispatch({
|
|
2757
|
-
type: FunctionOpenMenu
|
|
2763
|
+
type: FunctionOpenMenu$1
|
|
2758
2764
|
});
|
|
2759
2765
|
}, [dispatch]);
|
|
2760
2766
|
var setHighlightedIndex = useCallback(function (newHighlightedIndex) {
|
|
2761
2767
|
dispatch({
|
|
2762
|
-
type: FunctionSetHighlightedIndex,
|
|
2768
|
+
type: FunctionSetHighlightedIndex$1,
|
|
2763
2769
|
highlightedIndex: newHighlightedIndex
|
|
2764
2770
|
});
|
|
2765
2771
|
}, [dispatch]);
|
|
2766
2772
|
var selectItem = useCallback(function (newSelectedItem) {
|
|
2767
2773
|
dispatch({
|
|
2768
|
-
type: FunctionSelectItem,
|
|
2774
|
+
type: FunctionSelectItem$1,
|
|
2769
2775
|
selectedItem: newSelectedItem
|
|
2770
2776
|
});
|
|
2771
2777
|
}, [dispatch]);
|
|
2772
2778
|
var reset = useCallback(function () {
|
|
2773
2779
|
dispatch({
|
|
2774
|
-
type: FunctionReset
|
|
2780
|
+
type: FunctionReset$2
|
|
2775
2781
|
});
|
|
2776
2782
|
}, [dispatch]);
|
|
2777
2783
|
var setInputValue = useCallback(function (newInputValue) {
|
|
2778
2784
|
dispatch({
|
|
2779
|
-
type: FunctionSetInputValue,
|
|
2785
|
+
type: FunctionSetInputValue$1,
|
|
2780
2786
|
inputValue: newInputValue
|
|
2781
2787
|
});
|
|
2782
2788
|
}, [dispatch]); // Getter functions.
|
|
@@ -2838,7 +2844,7 @@ function useSelect(userProps) {
|
|
|
2838
2844
|
|
|
2839
2845
|
var menuHandleMouseLeave = function menuHandleMouseLeave() {
|
|
2840
2846
|
dispatch({
|
|
2841
|
-
type: MenuMouseLeave
|
|
2847
|
+
type: MenuMouseLeave$1
|
|
2842
2848
|
});
|
|
2843
2849
|
};
|
|
2844
2850
|
|
|
@@ -2870,7 +2876,7 @@ function useSelect(userProps) {
|
|
|
2870
2876
|
|
|
2871
2877
|
var toggleButtonHandleClick = function toggleButtonHandleClick() {
|
|
2872
2878
|
dispatch({
|
|
2873
|
-
type: ToggleButtonClick
|
|
2879
|
+
type: ToggleButtonClick$1
|
|
2874
2880
|
});
|
|
2875
2881
|
};
|
|
2876
2882
|
|
|
@@ -2924,14 +2930,14 @@ function useSelect(userProps) {
|
|
|
2924
2930
|
|
|
2925
2931
|
shouldScrollRef.current = false;
|
|
2926
2932
|
dispatch({
|
|
2927
|
-
type: ItemMouseMove,
|
|
2933
|
+
type: ItemMouseMove$1,
|
|
2928
2934
|
index: index
|
|
2929
2935
|
});
|
|
2930
2936
|
};
|
|
2931
2937
|
|
|
2932
2938
|
var itemHandleClick = function itemHandleClick() {
|
|
2933
2939
|
dispatch({
|
|
2934
|
-
type: ItemClick,
|
|
2940
|
+
type: ItemClick$1,
|
|
2935
2941
|
index: index
|
|
2936
2942
|
});
|
|
2937
2943
|
};
|
|
@@ -2989,20 +2995,20 @@ var InputKeyDownEnd = process.env.NODE_ENV !== "production" ? '__input_keydown_e
|
|
|
2989
2995
|
var InputKeyDownEnter = process.env.NODE_ENV !== "production" ? '__input_keydown_enter__' : 5;
|
|
2990
2996
|
var InputChange = process.env.NODE_ENV !== "production" ? '__input_change__' : 6;
|
|
2991
2997
|
var InputBlur = process.env.NODE_ENV !== "production" ? '__input_blur__' : 7;
|
|
2992
|
-
var MenuMouseLeave
|
|
2993
|
-
var ItemMouseMove
|
|
2994
|
-
var ItemClick
|
|
2995
|
-
var ToggleButtonClick
|
|
2996
|
-
var FunctionToggleMenu
|
|
2997
|
-
var FunctionOpenMenu
|
|
2998
|
-
var FunctionCloseMenu
|
|
2999
|
-
var FunctionSetHighlightedIndex
|
|
3000
|
-
var FunctionSelectItem
|
|
3001
|
-
var FunctionSetInputValue
|
|
2998
|
+
var MenuMouseLeave = process.env.NODE_ENV !== "production" ? '__menu_mouse_leave__' : 8;
|
|
2999
|
+
var ItemMouseMove = process.env.NODE_ENV !== "production" ? '__item_mouse_move__' : 9;
|
|
3000
|
+
var ItemClick = process.env.NODE_ENV !== "production" ? '__item_click__' : 10;
|
|
3001
|
+
var ToggleButtonClick = process.env.NODE_ENV !== "production" ? '__togglebutton_click__' : 11;
|
|
3002
|
+
var FunctionToggleMenu = process.env.NODE_ENV !== "production" ? '__function_toggle_menu__' : 12;
|
|
3003
|
+
var FunctionOpenMenu = process.env.NODE_ENV !== "production" ? '__function_open_menu__' : 13;
|
|
3004
|
+
var FunctionCloseMenu = process.env.NODE_ENV !== "production" ? '__function_close_menu__' : 14;
|
|
3005
|
+
var FunctionSetHighlightedIndex = process.env.NODE_ENV !== "production" ? '__function_set_highlighted_index__' : 15;
|
|
3006
|
+
var FunctionSelectItem = process.env.NODE_ENV !== "production" ? '__function_select_item__' : 16;
|
|
3007
|
+
var FunctionSetInputValue = process.env.NODE_ENV !== "production" ? '__function_set_input_value__' : 17;
|
|
3002
3008
|
var FunctionReset$1 = process.env.NODE_ENV !== "production" ? '__function_reset__' : 18;
|
|
3003
3009
|
var ControlledPropUpdatedSelectedItem = process.env.NODE_ENV !== "production" ? '__controlled_prop_updated_selected_item__' : 19;
|
|
3004
3010
|
|
|
3005
|
-
var stateChangeTypes$
|
|
3011
|
+
var stateChangeTypes$1 = /*#__PURE__*/Object.freeze({
|
|
3006
3012
|
__proto__: null,
|
|
3007
3013
|
InputKeyDownArrowDown: InputKeyDownArrowDown,
|
|
3008
3014
|
InputKeyDownArrowUp: InputKeyDownArrowUp,
|
|
@@ -3012,22 +3018,22 @@ var stateChangeTypes$2 = /*#__PURE__*/Object.freeze({
|
|
|
3012
3018
|
InputKeyDownEnter: InputKeyDownEnter,
|
|
3013
3019
|
InputChange: InputChange,
|
|
3014
3020
|
InputBlur: InputBlur,
|
|
3015
|
-
MenuMouseLeave: MenuMouseLeave
|
|
3016
|
-
ItemMouseMove: ItemMouseMove
|
|
3017
|
-
ItemClick: ItemClick
|
|
3018
|
-
ToggleButtonClick: ToggleButtonClick
|
|
3019
|
-
FunctionToggleMenu: FunctionToggleMenu
|
|
3020
|
-
FunctionOpenMenu: FunctionOpenMenu
|
|
3021
|
-
FunctionCloseMenu: FunctionCloseMenu
|
|
3022
|
-
FunctionSetHighlightedIndex: FunctionSetHighlightedIndex
|
|
3023
|
-
FunctionSelectItem: FunctionSelectItem
|
|
3024
|
-
FunctionSetInputValue: FunctionSetInputValue
|
|
3021
|
+
MenuMouseLeave: MenuMouseLeave,
|
|
3022
|
+
ItemMouseMove: ItemMouseMove,
|
|
3023
|
+
ItemClick: ItemClick,
|
|
3024
|
+
ToggleButtonClick: ToggleButtonClick,
|
|
3025
|
+
FunctionToggleMenu: FunctionToggleMenu,
|
|
3026
|
+
FunctionOpenMenu: FunctionOpenMenu,
|
|
3027
|
+
FunctionCloseMenu: FunctionCloseMenu,
|
|
3028
|
+
FunctionSetHighlightedIndex: FunctionSetHighlightedIndex,
|
|
3029
|
+
FunctionSelectItem: FunctionSelectItem,
|
|
3030
|
+
FunctionSetInputValue: FunctionSetInputValue,
|
|
3025
3031
|
FunctionReset: FunctionReset$1,
|
|
3026
3032
|
ControlledPropUpdatedSelectedItem: ControlledPropUpdatedSelectedItem
|
|
3027
3033
|
});
|
|
3028
3034
|
|
|
3029
3035
|
function getInitialState$1(props) {
|
|
3030
|
-
var initialState = getInitialState(props);
|
|
3036
|
+
var initialState = getInitialState$2(props);
|
|
3031
3037
|
var selectedItem = initialState.selectedItem;
|
|
3032
3038
|
var inputValue = initialState.inputValue;
|
|
3033
3039
|
|
|
@@ -3093,7 +3099,7 @@ var propTypes$1 = {
|
|
|
3093
3099
|
* @returns {Array} An array with the state and an action dispatcher.
|
|
3094
3100
|
*/
|
|
3095
3101
|
|
|
3096
|
-
function useControlledReducer
|
|
3102
|
+
function useControlledReducer(reducer, initialState, props) {
|
|
3097
3103
|
var previousSelectedItemRef = useRef();
|
|
3098
3104
|
|
|
3099
3105
|
var _useEnhancedReducer = useEnhancedReducer(reducer, initialState, props),
|
|
@@ -3126,8 +3132,8 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
3126
3132
|
};
|
|
3127
3133
|
}
|
|
3128
3134
|
|
|
3129
|
-
var defaultProps$
|
|
3130
|
-
getA11yStatusMessage: getA11yStatusMessage,
|
|
3135
|
+
var defaultProps$1 = _extends({}, defaultProps$3, {
|
|
3136
|
+
getA11yStatusMessage: getA11yStatusMessage$1,
|
|
3131
3137
|
circularNavigation: true
|
|
3132
3138
|
});
|
|
3133
3139
|
|
|
@@ -3140,10 +3146,10 @@ function downshiftUseComboboxReducer(state, action) {
|
|
|
3140
3146
|
var changes;
|
|
3141
3147
|
|
|
3142
3148
|
switch (type) {
|
|
3143
|
-
case ItemClick
|
|
3149
|
+
case ItemClick:
|
|
3144
3150
|
changes = {
|
|
3145
|
-
isOpen: getDefaultValue(props, 'isOpen'),
|
|
3146
|
-
highlightedIndex: getDefaultValue(props, 'highlightedIndex'),
|
|
3151
|
+
isOpen: getDefaultValue$1(props, 'isOpen'),
|
|
3152
|
+
highlightedIndex: getDefaultValue$1(props, 'highlightedIndex'),
|
|
3147
3153
|
selectedItem: props.items[action.index],
|
|
3148
3154
|
inputValue: props.itemToString(props.items[action.index])
|
|
3149
3155
|
};
|
|
@@ -3180,8 +3186,8 @@ function downshiftUseComboboxReducer(state, action) {
|
|
|
3180
3186
|
case InputKeyDownEnter:
|
|
3181
3187
|
changes = _extends({}, state.isOpen && state.highlightedIndex >= 0 && {
|
|
3182
3188
|
selectedItem: props.items[state.highlightedIndex],
|
|
3183
|
-
isOpen: getDefaultValue(props, 'isOpen'),
|
|
3184
|
-
highlightedIndex: getDefaultValue(props, 'highlightedIndex'),
|
|
3189
|
+
isOpen: getDefaultValue$1(props, 'isOpen'),
|
|
3190
|
+
highlightedIndex: getDefaultValue$1(props, 'highlightedIndex'),
|
|
3185
3191
|
inputValue: props.itemToString(props.items[state.highlightedIndex])
|
|
3186
3192
|
});
|
|
3187
3193
|
break;
|
|
@@ -3221,12 +3227,12 @@ function downshiftUseComboboxReducer(state, action) {
|
|
|
3221
3227
|
case InputChange:
|
|
3222
3228
|
changes = {
|
|
3223
3229
|
isOpen: true,
|
|
3224
|
-
highlightedIndex: getDefaultValue(props, 'highlightedIndex'),
|
|
3230
|
+
highlightedIndex: getDefaultValue$1(props, 'highlightedIndex'),
|
|
3225
3231
|
inputValue: action.inputValue
|
|
3226
3232
|
};
|
|
3227
3233
|
break;
|
|
3228
3234
|
|
|
3229
|
-
case FunctionSelectItem
|
|
3235
|
+
case FunctionSelectItem:
|
|
3230
3236
|
changes = {
|
|
3231
3237
|
selectedItem: action.selectedItem,
|
|
3232
3238
|
inputValue: props.itemToString(action.selectedItem)
|
|
@@ -3240,14 +3246,14 @@ function downshiftUseComboboxReducer(state, action) {
|
|
|
3240
3246
|
break;
|
|
3241
3247
|
|
|
3242
3248
|
default:
|
|
3243
|
-
return downshiftCommonReducer(state, action, stateChangeTypes$
|
|
3249
|
+
return downshiftCommonReducer(state, action, stateChangeTypes$1);
|
|
3244
3250
|
}
|
|
3245
3251
|
|
|
3246
3252
|
return _extends({}, state, changes);
|
|
3247
3253
|
}
|
|
3248
3254
|
/* eslint-enable complexity */
|
|
3249
3255
|
|
|
3250
|
-
useCombobox.stateChangeTypes = stateChangeTypes$
|
|
3256
|
+
useCombobox.stateChangeTypes = stateChangeTypes$1;
|
|
3251
3257
|
|
|
3252
3258
|
function useCombobox(userProps) {
|
|
3253
3259
|
if (userProps === void 0) {
|
|
@@ -3256,7 +3262,7 @@ function useCombobox(userProps) {
|
|
|
3256
3262
|
|
|
3257
3263
|
validatePropTypes$1(userProps, useCombobox); // Props defaults and destructuring.
|
|
3258
3264
|
|
|
3259
|
-
var props = _extends({}, defaultProps$
|
|
3265
|
+
var props = _extends({}, defaultProps$1, userProps);
|
|
3260
3266
|
|
|
3261
3267
|
var initialIsOpen = props.initialIsOpen,
|
|
3262
3268
|
defaultIsOpen = props.defaultIsOpen,
|
|
@@ -3269,7 +3275,7 @@ function useCombobox(userProps) {
|
|
|
3269
3275
|
|
|
3270
3276
|
var initialState = getInitialState$1(props);
|
|
3271
3277
|
|
|
3272
|
-
var _useControlledReducer = useControlledReducer
|
|
3278
|
+
var _useControlledReducer = useControlledReducer(downshiftUseComboboxReducer, initialState, props),
|
|
3273
3279
|
state = _useControlledReducer[0],
|
|
3274
3280
|
dispatch = _useControlledReducer[1];
|
|
3275
3281
|
|
|
@@ -3454,7 +3460,7 @@ function useCombobox(userProps) {
|
|
|
3454
3460
|
menuRef.current = menuNode;
|
|
3455
3461
|
}), _extends2.id = elementIds.menuId, _extends2.role = 'listbox', _extends2['aria-labelledby'] = elementIds.labelId, _extends2.onMouseLeave = callAllEventHandlers(onMouseLeave, function () {
|
|
3456
3462
|
dispatch({
|
|
3457
|
-
type: MenuMouseLeave
|
|
3463
|
+
type: MenuMouseLeave
|
|
3458
3464
|
});
|
|
3459
3465
|
}), _extends2), rest);
|
|
3460
3466
|
}, [dispatch, setGetterPropCallInfo, elementIds]);
|
|
@@ -3468,9 +3474,9 @@ function useCombobox(userProps) {
|
|
|
3468
3474
|
refKey = _ref3$refKey === void 0 ? 'ref' : _ref3$refKey,
|
|
3469
3475
|
ref = _ref3.ref,
|
|
3470
3476
|
onMouseMove = _ref3.onMouseMove,
|
|
3471
|
-
onClick = _ref3.onClick
|
|
3472
|
-
|
|
3473
|
-
rest = _objectWithoutPropertiesLoose(_ref3, ["item", "index", "refKey", "ref", "onMouseMove", "onClick", "onPress"]);
|
|
3477
|
+
onClick = _ref3.onClick;
|
|
3478
|
+
_ref3.onPress;
|
|
3479
|
+
var rest = _objectWithoutPropertiesLoose(_ref3, ["item", "index", "refKey", "ref", "onMouseMove", "onClick", "onPress"]);
|
|
3474
3480
|
|
|
3475
3481
|
var _latest$current = latest.current,
|
|
3476
3482
|
latestProps = _latest$current.props,
|
|
@@ -3481,8 +3487,8 @@ function useCombobox(userProps) {
|
|
|
3481
3487
|
throw new Error('Pass either item or item index in getItemProps!');
|
|
3482
3488
|
}
|
|
3483
3489
|
|
|
3484
|
-
var onSelectKey =
|
|
3485
|
-
var customClickHandler =
|
|
3490
|
+
var onSelectKey = 'onClick';
|
|
3491
|
+
var customClickHandler = onClick;
|
|
3486
3492
|
|
|
3487
3493
|
var itemHandleMouseMove = function itemHandleMouseMove() {
|
|
3488
3494
|
if (index === latestState.highlightedIndex) {
|
|
@@ -3491,14 +3497,14 @@ function useCombobox(userProps) {
|
|
|
3491
3497
|
|
|
3492
3498
|
shouldScrollRef.current = false;
|
|
3493
3499
|
dispatch({
|
|
3494
|
-
type: ItemMouseMove
|
|
3500
|
+
type: ItemMouseMove,
|
|
3495
3501
|
index: index
|
|
3496
3502
|
});
|
|
3497
3503
|
};
|
|
3498
3504
|
|
|
3499
3505
|
var itemHandleClick = function itemHandleClick() {
|
|
3500
3506
|
dispatch({
|
|
3501
|
-
type: ItemClick
|
|
3507
|
+
type: ItemClick,
|
|
3502
3508
|
index: index
|
|
3503
3509
|
});
|
|
3504
3510
|
|
|
@@ -3519,16 +3525,16 @@ function useCombobox(userProps) {
|
|
|
3519
3525
|
var _extends4;
|
|
3520
3526
|
|
|
3521
3527
|
var _ref5 = _temp4 === void 0 ? {} : _temp4,
|
|
3522
|
-
onClick = _ref5.onClick
|
|
3523
|
-
|
|
3524
|
-
_ref5$refKey = _ref5.refKey,
|
|
3528
|
+
onClick = _ref5.onClick;
|
|
3529
|
+
_ref5.onPress;
|
|
3530
|
+
var _ref5$refKey = _ref5.refKey,
|
|
3525
3531
|
refKey = _ref5$refKey === void 0 ? 'ref' : _ref5$refKey,
|
|
3526
3532
|
ref = _ref5.ref,
|
|
3527
3533
|
rest = _objectWithoutPropertiesLoose(_ref5, ["onClick", "onPress", "refKey", "ref"]);
|
|
3528
3534
|
|
|
3529
3535
|
var toggleButtonHandleClick = function toggleButtonHandleClick() {
|
|
3530
3536
|
dispatch({
|
|
3531
|
-
type: ToggleButtonClick
|
|
3537
|
+
type: ToggleButtonClick
|
|
3532
3538
|
});
|
|
3533
3539
|
|
|
3534
3540
|
if (!latest.current.state.isOpen && inputRef.current) {
|
|
@@ -3538,7 +3544,7 @@ function useCombobox(userProps) {
|
|
|
3538
3544
|
|
|
3539
3545
|
return _extends((_extends4 = {}, _extends4[refKey] = handleRefs(ref, function (toggleButtonNode) {
|
|
3540
3546
|
toggleButtonRef.current = toggleButtonNode;
|
|
3541
|
-
}), _extends4.id = elementIds.toggleButtonId, _extends4.tabIndex = -1, _extends4), !rest.disabled && _extends({},
|
|
3547
|
+
}), _extends4.id = elementIds.toggleButtonId, _extends4.tabIndex = -1, _extends4), !rest.disabled && _extends({}, {
|
|
3542
3548
|
onClick: callAllEventHandlers(onClick, toggleButtonHandleClick)
|
|
3543
3549
|
}), rest);
|
|
3544
3550
|
}, [dispatch, latest, elementIds]);
|
|
@@ -3549,9 +3555,9 @@ function useCombobox(userProps) {
|
|
|
3549
3555
|
onKeyDown = _ref6.onKeyDown,
|
|
3550
3556
|
onChange = _ref6.onChange,
|
|
3551
3557
|
onInput = _ref6.onInput,
|
|
3552
|
-
onBlur = _ref6.onBlur
|
|
3553
|
-
|
|
3554
|
-
_ref6$refKey = _ref6.refKey,
|
|
3558
|
+
onBlur = _ref6.onBlur;
|
|
3559
|
+
_ref6.onChangeText;
|
|
3560
|
+
var _ref6$refKey = _ref6.refKey,
|
|
3555
3561
|
refKey = _ref6$refKey === void 0 ? 'ref' : _ref6$refKey,
|
|
3556
3562
|
ref = _ref6.ref,
|
|
3557
3563
|
rest = _objectWithoutPropertiesLoose(_ref6, ["onKeyDown", "onChange", "onInput", "onBlur", "onChangeText", "refKey", "ref"]);
|
|
@@ -3574,7 +3580,7 @@ function useCombobox(userProps) {
|
|
|
3574
3580
|
var inputHandleChange = function inputHandleChange(event) {
|
|
3575
3581
|
dispatch({
|
|
3576
3582
|
type: InputChange,
|
|
3577
|
-
inputValue:
|
|
3583
|
+
inputValue: event.target.value
|
|
3578
3584
|
});
|
|
3579
3585
|
};
|
|
3580
3586
|
|
|
@@ -3590,7 +3596,7 @@ function useCombobox(userProps) {
|
|
|
3590
3596
|
/* istanbul ignore next (preact) */
|
|
3591
3597
|
|
|
3592
3598
|
|
|
3593
|
-
var onChangeKey =
|
|
3599
|
+
var onChangeKey = 'onChange';
|
|
3594
3600
|
var eventHandlers = {};
|
|
3595
3601
|
|
|
3596
3602
|
if (!rest.disabled) {
|
|
@@ -3632,34 +3638,34 @@ function useCombobox(userProps) {
|
|
|
3632
3638
|
|
|
3633
3639
|
var toggleMenu = useCallback(function () {
|
|
3634
3640
|
dispatch({
|
|
3635
|
-
type: FunctionToggleMenu
|
|
3641
|
+
type: FunctionToggleMenu
|
|
3636
3642
|
});
|
|
3637
3643
|
}, [dispatch]);
|
|
3638
3644
|
var closeMenu = useCallback(function () {
|
|
3639
3645
|
dispatch({
|
|
3640
|
-
type: FunctionCloseMenu
|
|
3646
|
+
type: FunctionCloseMenu
|
|
3641
3647
|
});
|
|
3642
3648
|
}, [dispatch]);
|
|
3643
3649
|
var openMenu = useCallback(function () {
|
|
3644
3650
|
dispatch({
|
|
3645
|
-
type: FunctionOpenMenu
|
|
3651
|
+
type: FunctionOpenMenu
|
|
3646
3652
|
});
|
|
3647
3653
|
}, [dispatch]);
|
|
3648
3654
|
var setHighlightedIndex = useCallback(function (newHighlightedIndex) {
|
|
3649
3655
|
dispatch({
|
|
3650
|
-
type: FunctionSetHighlightedIndex
|
|
3656
|
+
type: FunctionSetHighlightedIndex,
|
|
3651
3657
|
highlightedIndex: newHighlightedIndex
|
|
3652
3658
|
});
|
|
3653
3659
|
}, [dispatch]);
|
|
3654
3660
|
var selectItem = useCallback(function (newSelectedItem) {
|
|
3655
3661
|
dispatch({
|
|
3656
|
-
type: FunctionSelectItem
|
|
3662
|
+
type: FunctionSelectItem,
|
|
3657
3663
|
selectedItem: newSelectedItem
|
|
3658
3664
|
});
|
|
3659
3665
|
}, [dispatch]);
|
|
3660
3666
|
var setInputValue = useCallback(function (newInputValue) {
|
|
3661
3667
|
dispatch({
|
|
3662
|
-
type: FunctionSetInputValue
|
|
3668
|
+
type: FunctionSetInputValue,
|
|
3663
3669
|
inputValue: newInputValue
|
|
3664
3670
|
});
|
|
3665
3671
|
}, [dispatch]);
|
|
@@ -3706,8 +3712,8 @@ var defaultStateValues = {
|
|
|
3706
3712
|
* @returns {any} The initial value for that prop.
|
|
3707
3713
|
*/
|
|
3708
3714
|
|
|
3709
|
-
function getInitialValue
|
|
3710
|
-
return getInitialValue(props, propKey, defaultStateValues);
|
|
3715
|
+
function getInitialValue(props, propKey) {
|
|
3716
|
+
return getInitialValue$1(props, propKey, defaultStateValues);
|
|
3711
3717
|
}
|
|
3712
3718
|
/**
|
|
3713
3719
|
* Returns the default value for a state key in the following order:
|
|
@@ -3719,8 +3725,8 @@ function getInitialValue$1(props, propKey) {
|
|
|
3719
3725
|
*/
|
|
3720
3726
|
|
|
3721
3727
|
|
|
3722
|
-
function getDefaultValue
|
|
3723
|
-
return getDefaultValue(props, propKey, defaultStateValues);
|
|
3728
|
+
function getDefaultValue(props, propKey) {
|
|
3729
|
+
return getDefaultValue$1(props, propKey, defaultStateValues);
|
|
3724
3730
|
}
|
|
3725
3731
|
/**
|
|
3726
3732
|
* Gets the initial state based on the provided props. It uses initial, default
|
|
@@ -3731,9 +3737,9 @@ function getDefaultValue$1(props, propKey) {
|
|
|
3731
3737
|
*/
|
|
3732
3738
|
|
|
3733
3739
|
|
|
3734
|
-
function getInitialState
|
|
3735
|
-
var activeIndex = getInitialValue
|
|
3736
|
-
var selectedItems = getInitialValue
|
|
3740
|
+
function getInitialState(props) {
|
|
3741
|
+
var activeIndex = getInitialValue(props, 'activeIndex');
|
|
3742
|
+
var selectedItems = getInitialValue(props, 'selectedItems');
|
|
3737
3743
|
return {
|
|
3738
3744
|
activeIndex: activeIndex,
|
|
3739
3745
|
selectedItems: selectedItems
|
|
@@ -3780,7 +3786,7 @@ function getA11yRemovalMessage(selectionParameters) {
|
|
|
3780
3786
|
return itemToStringLocal(removedSelectedItem) + " has been removed.";
|
|
3781
3787
|
}
|
|
3782
3788
|
|
|
3783
|
-
var propTypes
|
|
3789
|
+
var propTypes = {
|
|
3784
3790
|
selectedItems: PropTypes.array,
|
|
3785
3791
|
initialSelectedItems: PropTypes.array,
|
|
3786
3792
|
defaultSelectedItems: PropTypes.array,
|
|
@@ -3804,21 +3810,21 @@ var propTypes$2 = {
|
|
|
3804
3810
|
})
|
|
3805
3811
|
})
|
|
3806
3812
|
};
|
|
3807
|
-
var defaultProps
|
|
3808
|
-
itemToString: defaultProps.itemToString,
|
|
3809
|
-
stateReducer: defaultProps.stateReducer,
|
|
3810
|
-
environment: defaultProps.environment,
|
|
3813
|
+
var defaultProps = {
|
|
3814
|
+
itemToString: defaultProps$3.itemToString,
|
|
3815
|
+
stateReducer: defaultProps$3.stateReducer,
|
|
3816
|
+
environment: defaultProps$3.environment,
|
|
3811
3817
|
getA11yRemovalMessage: getA11yRemovalMessage,
|
|
3812
3818
|
keyNavigationNext: 'ArrowRight',
|
|
3813
3819
|
keyNavigationPrevious: 'ArrowLeft'
|
|
3814
3820
|
}; // eslint-disable-next-line import/no-mutable-exports
|
|
3815
3821
|
|
|
3816
|
-
var validatePropTypes
|
|
3822
|
+
var validatePropTypes = noop;
|
|
3817
3823
|
/* istanbul ignore next */
|
|
3818
3824
|
|
|
3819
3825
|
if (process.env.NODE_ENV !== 'production') {
|
|
3820
|
-
validatePropTypes
|
|
3821
|
-
PropTypes.checkPropTypes(propTypes
|
|
3826
|
+
validatePropTypes = function validatePropTypes(options, caller) {
|
|
3827
|
+
PropTypes.checkPropTypes(propTypes, options, 'prop', caller.name);
|
|
3822
3828
|
};
|
|
3823
3829
|
}
|
|
3824
3830
|
|
|
@@ -3834,9 +3840,9 @@ var FunctionAddSelectedItem = process.env.NODE_ENV !== "production" ? '__functio
|
|
|
3834
3840
|
var FunctionRemoveSelectedItem = process.env.NODE_ENV !== "production" ? '__function_remove_selected_item__' : 9;
|
|
3835
3841
|
var FunctionSetSelectedItems = process.env.NODE_ENV !== "production" ? '__function_set_selected_items__' : 10;
|
|
3836
3842
|
var FunctionSetActiveIndex = process.env.NODE_ENV !== "production" ? '__function_set_active_index__' : 11;
|
|
3837
|
-
var FunctionReset
|
|
3843
|
+
var FunctionReset = process.env.NODE_ENV !== "production" ? '__function_reset__' : 12;
|
|
3838
3844
|
|
|
3839
|
-
var stateChangeTypes
|
|
3845
|
+
var stateChangeTypes = /*#__PURE__*/Object.freeze({
|
|
3840
3846
|
__proto__: null,
|
|
3841
3847
|
SelectedItemClick: SelectedItemClick,
|
|
3842
3848
|
SelectedItemKeyDownDelete: SelectedItemKeyDownDelete,
|
|
@@ -3850,7 +3856,7 @@ var stateChangeTypes$3 = /*#__PURE__*/Object.freeze({
|
|
|
3850
3856
|
FunctionRemoveSelectedItem: FunctionRemoveSelectedItem,
|
|
3851
3857
|
FunctionSetSelectedItems: FunctionSetSelectedItems,
|
|
3852
3858
|
FunctionSetActiveIndex: FunctionSetActiveIndex,
|
|
3853
|
-
FunctionReset: FunctionReset
|
|
3859
|
+
FunctionReset: FunctionReset
|
|
3854
3860
|
});
|
|
3855
3861
|
|
|
3856
3862
|
/* eslint-disable complexity */
|
|
@@ -3963,10 +3969,10 @@ function downshiftMultipleSelectionReducer(state, action) {
|
|
|
3963
3969
|
break;
|
|
3964
3970
|
}
|
|
3965
3971
|
|
|
3966
|
-
case FunctionReset
|
|
3972
|
+
case FunctionReset:
|
|
3967
3973
|
changes = {
|
|
3968
|
-
activeIndex: getDefaultValue
|
|
3969
|
-
selectedItems: getDefaultValue
|
|
3974
|
+
activeIndex: getDefaultValue(props, 'activeIndex'),
|
|
3975
|
+
selectedItems: getDefaultValue(props, 'selectedItems')
|
|
3970
3976
|
};
|
|
3971
3977
|
break;
|
|
3972
3978
|
|
|
@@ -3977,16 +3983,16 @@ function downshiftMultipleSelectionReducer(state, action) {
|
|
|
3977
3983
|
return _extends({}, state, changes);
|
|
3978
3984
|
}
|
|
3979
3985
|
|
|
3980
|
-
useMultipleSelection.stateChangeTypes = stateChangeTypes
|
|
3986
|
+
useMultipleSelection.stateChangeTypes = stateChangeTypes;
|
|
3981
3987
|
|
|
3982
3988
|
function useMultipleSelection(userProps) {
|
|
3983
3989
|
if (userProps === void 0) {
|
|
3984
3990
|
userProps = {};
|
|
3985
3991
|
}
|
|
3986
3992
|
|
|
3987
|
-
validatePropTypes
|
|
3993
|
+
validatePropTypes(userProps, useMultipleSelection); // Props defaults and destructuring.
|
|
3988
3994
|
|
|
3989
|
-
var props = _extends({}, defaultProps
|
|
3995
|
+
var props = _extends({}, defaultProps, userProps);
|
|
3990
3996
|
|
|
3991
3997
|
var getA11yRemovalMessage = props.getA11yRemovalMessage,
|
|
3992
3998
|
itemToString = props.itemToString,
|
|
@@ -3994,7 +4000,7 @@ function useMultipleSelection(userProps) {
|
|
|
3994
4000
|
keyNavigationNext = props.keyNavigationNext,
|
|
3995
4001
|
keyNavigationPrevious = props.keyNavigationPrevious; // Reducer init.
|
|
3996
4002
|
|
|
3997
|
-
var _useControlledReducer = useControlledReducer(downshiftMultipleSelectionReducer, getInitialState
|
|
4003
|
+
var _useControlledReducer = useControlledReducer$1(downshiftMultipleSelectionReducer, getInitialState(props), props),
|
|
3998
4004
|
state = _useControlledReducer[0],
|
|
3999
4005
|
dispatch = _useControlledReducer[1];
|
|
4000
4006
|
|
|
@@ -4205,7 +4211,7 @@ function useMultipleSelection(userProps) {
|
|
|
4205
4211
|
}, [dispatch]);
|
|
4206
4212
|
var reset = useCallback(function () {
|
|
4207
4213
|
dispatch({
|
|
4208
|
-
type: FunctionReset
|
|
4214
|
+
type: FunctionReset
|
|
4209
4215
|
});
|
|
4210
4216
|
}, [dispatch]);
|
|
4211
4217
|
return {
|