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.cjs.js
CHANGED
|
@@ -63,12 +63,14 @@ function scrollIntoView(node, menuNode) {
|
|
|
63
63
|
/**
|
|
64
64
|
* @param {HTMLElement} parent the parent node
|
|
65
65
|
* @param {HTMLElement} child the child node
|
|
66
|
+
* @param {Window} environment The window context where downshift renders.
|
|
66
67
|
* @return {Boolean} whether the parent is the child or the child is in the parent
|
|
67
68
|
*/
|
|
68
69
|
|
|
69
70
|
|
|
70
|
-
function isOrContainsNode(parent, child) {
|
|
71
|
-
|
|
71
|
+
function isOrContainsNode(parent, child, environment) {
|
|
72
|
+
var result = parent === child || child instanceof environment.Node && parent.contains && parent.contains(child);
|
|
73
|
+
return result;
|
|
72
74
|
}
|
|
73
75
|
/**
|
|
74
76
|
* Simple debounce implementation. Will call the given
|
|
@@ -175,7 +177,7 @@ function resetIdCounter() {
|
|
|
175
177
|
*/
|
|
176
178
|
|
|
177
179
|
|
|
178
|
-
function getA11yStatusMessage(_ref2) {
|
|
180
|
+
function getA11yStatusMessage$1(_ref2) {
|
|
179
181
|
var isOpen = _ref2.isOpen,
|
|
180
182
|
resultCount = _ref2.resultCount,
|
|
181
183
|
previousResultCount = _ref2.previousResultCount;
|
|
@@ -416,20 +418,20 @@ function getNextNonDisabledIndex(moveAmount, baseIndex, itemCount, getItemNodeFr
|
|
|
416
418
|
*
|
|
417
419
|
* @param {EventTarget} target Target to check.
|
|
418
420
|
* @param {HTMLElement[]} downshiftElements The elements that form downshift (list, toggle button etc).
|
|
419
|
-
* @param {
|
|
421
|
+
* @param {Window} environment The window context where downshift renders.
|
|
420
422
|
* @param {boolean} checkActiveElement Whether to also check activeElement.
|
|
421
423
|
*
|
|
422
424
|
* @returns {boolean} Whether or not the target is within downshift elements.
|
|
423
425
|
*/
|
|
424
426
|
|
|
425
427
|
|
|
426
|
-
function targetWithinDownshift(target, downshiftElements,
|
|
428
|
+
function targetWithinDownshift(target, downshiftElements, environment, checkActiveElement) {
|
|
427
429
|
if (checkActiveElement === void 0) {
|
|
428
430
|
checkActiveElement = true;
|
|
429
431
|
}
|
|
430
432
|
|
|
431
433
|
return downshiftElements.some(function (contextNode) {
|
|
432
|
-
return contextNode && (isOrContainsNode(contextNode, target) || checkActiveElement && isOrContainsNode(contextNode, document.activeElement));
|
|
434
|
+
return contextNode && (isOrContainsNode(contextNode, target, environment) || checkActiveElement && isOrContainsNode(contextNode, environment.document.activeElement, environment));
|
|
433
435
|
});
|
|
434
436
|
} // eslint-disable-next-line import/no-mutable-exports
|
|
435
437
|
|
|
@@ -525,7 +527,7 @@ var blurButton = process.env.NODE_ENV !== "production" ? '__autocomplete_blur_bu
|
|
|
525
527
|
var controlledPropUpdatedSelectedItem = process.env.NODE_ENV !== "production" ? '__autocomplete_controlled_prop_updated_selected_item__' : 15;
|
|
526
528
|
var touchEnd = process.env.NODE_ENV !== "production" ? '__autocomplete_touchend__' : 16;
|
|
527
529
|
|
|
528
|
-
var stateChangeTypes = /*#__PURE__*/Object.freeze({
|
|
530
|
+
var stateChangeTypes$3 = /*#__PURE__*/Object.freeze({
|
|
529
531
|
__proto__: null,
|
|
530
532
|
unknown: unknown,
|
|
531
533
|
mouseUp: mouseUp,
|
|
@@ -918,9 +920,9 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
918
920
|
|
|
919
921
|
_this.getToggleButtonProps = function (_temp3) {
|
|
920
922
|
var _ref3 = _temp3 === void 0 ? {} : _temp3,
|
|
921
|
-
onClick = _ref3.onClick
|
|
922
|
-
|
|
923
|
-
onKeyDown = _ref3.onKeyDown,
|
|
923
|
+
onClick = _ref3.onClick;
|
|
924
|
+
_ref3.onPress;
|
|
925
|
+
var onKeyDown = _ref3.onKeyDown,
|
|
924
926
|
onKeyUp = _ref3.onKeyUp,
|
|
925
927
|
onBlur = _ref3.onBlur,
|
|
926
928
|
rest = _objectWithoutPropertiesLoose__default['default'](_ref3, ["onClick", "onPress", "onKeyDown", "onKeyUp", "onBlur"]);
|
|
@@ -928,7 +930,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
928
930
|
var _this$getState5 = _this.getState(),
|
|
929
931
|
isOpen = _this$getState5.isOpen;
|
|
930
932
|
|
|
931
|
-
var enabledEventHandlers =
|
|
933
|
+
var enabledEventHandlers = {
|
|
932
934
|
onClick: callAllEventHandlers(onClick, _this.buttonHandleClick),
|
|
933
935
|
onKeyDown: callAllEventHandlers(onKeyDown, _this.buttonHandleKeyDown),
|
|
934
936
|
onKeyUp: callAllEventHandlers(onKeyUp, _this.buttonHandleKeyUp),
|
|
@@ -963,7 +965,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
963
965
|
|
|
964
966
|
/* istanbul ignore if (can't reasonably test this) */
|
|
965
967
|
|
|
966
|
-
if (
|
|
968
|
+
if (_this.props.environment.document.activeElement === _this.props.environment.document.body) {
|
|
967
969
|
event.target.focus();
|
|
968
970
|
} // to simplify testing components that use downshift, we'll not wrap this in a setTimeout
|
|
969
971
|
// if the NODE_ENV is test. With the proper build system, this should be dead code eliminated
|
|
@@ -1010,9 +1012,9 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1010
1012
|
onKeyDown = _ref4.onKeyDown,
|
|
1011
1013
|
onBlur = _ref4.onBlur,
|
|
1012
1014
|
onChange = _ref4.onChange,
|
|
1013
|
-
onInput = _ref4.onInput
|
|
1014
|
-
|
|
1015
|
-
rest = _objectWithoutPropertiesLoose__default['default'](_ref4, ["onKeyDown", "onBlur", "onChange", "onInput", "onChangeText"]);
|
|
1015
|
+
onInput = _ref4.onInput;
|
|
1016
|
+
_ref4.onChangeText;
|
|
1017
|
+
var rest = _objectWithoutPropertiesLoose__default['default'](_ref4, ["onKeyDown", "onBlur", "onChange", "onInput", "onChangeText"]);
|
|
1016
1018
|
|
|
1017
1019
|
var onChangeKey;
|
|
1018
1020
|
var eventHandlers = {};
|
|
@@ -1058,7 +1060,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1058
1060
|
_this.internalSetState({
|
|
1059
1061
|
type: changeInput,
|
|
1060
1062
|
isOpen: true,
|
|
1061
|
-
inputValue:
|
|
1063
|
+
inputValue: event.target.value,
|
|
1062
1064
|
highlightedIndex: _this.props.defaultHighlightedIndex
|
|
1063
1065
|
});
|
|
1064
1066
|
};
|
|
@@ -1105,9 +1107,9 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1105
1107
|
var _ref7 = _temp7 === void 0 ? {} : _temp7,
|
|
1106
1108
|
onMouseMove = _ref7.onMouseMove,
|
|
1107
1109
|
onMouseDown = _ref7.onMouseDown,
|
|
1108
|
-
onClick = _ref7.onClick
|
|
1109
|
-
|
|
1110
|
-
index = _ref7.index,
|
|
1110
|
+
onClick = _ref7.onClick;
|
|
1111
|
+
_ref7.onPress;
|
|
1112
|
+
var index = _ref7.index,
|
|
1111
1113
|
_ref7$item = _ref7.item,
|
|
1112
1114
|
item = _ref7$item === void 0 ? process.env.NODE_ENV === 'production' ?
|
|
1113
1115
|
/* istanbul ignore next */
|
|
@@ -1122,8 +1124,8 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1122
1124
|
_this.items[index] = item;
|
|
1123
1125
|
}
|
|
1124
1126
|
|
|
1125
|
-
var onSelectKey =
|
|
1126
|
-
var customClickHandler =
|
|
1127
|
+
var onSelectKey = 'onClick';
|
|
1128
|
+
var customClickHandler = onClick;
|
|
1127
1129
|
var enabledEventHandlers = (_enabledEventHandlers = {
|
|
1128
1130
|
// onMouseMove is used over onMouseEnter here. onMouseMove
|
|
1129
1131
|
// is only triggered on actual mouse movement while onMouseEnter
|
|
@@ -1438,7 +1440,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1438
1440
|
_this7.isMouseDown = false; // if the target element or the activeElement is within a downshift node
|
|
1439
1441
|
// then we don't want to reset downshift
|
|
1440
1442
|
|
|
1441
|
-
var contextWithinDownshift = targetWithinDownshift(event.target, [_this7._rootNode, _this7._menuNode], _this7.props.environment
|
|
1443
|
+
var contextWithinDownshift = targetWithinDownshift(event.target, [_this7._rootNode, _this7._menuNode], _this7.props.environment);
|
|
1442
1444
|
|
|
1443
1445
|
if (!contextWithinDownshift && _this7.getState().isOpen) {
|
|
1444
1446
|
_this7.reset({
|
|
@@ -1464,7 +1466,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1464
1466
|
};
|
|
1465
1467
|
|
|
1466
1468
|
var onTouchEnd = function onTouchEnd(event) {
|
|
1467
|
-
var contextWithinDownshift = targetWithinDownshift(event.target, [_this7._rootNode, _this7._menuNode], _this7.props.environment
|
|
1469
|
+
var contextWithinDownshift = targetWithinDownshift(event.target, [_this7._rootNode, _this7._menuNode], _this7.props.environment, false);
|
|
1468
1470
|
|
|
1469
1471
|
if (!_this7.isTouchMove && !contextWithinDownshift && _this7.getState().isOpen) {
|
|
1470
1472
|
_this7.reset({
|
|
@@ -1513,7 +1515,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1513
1515
|
validateControlledUnchanged(this.state, prevProps, this.props);
|
|
1514
1516
|
/* istanbul ignore if (react-native) */
|
|
1515
1517
|
|
|
1516
|
-
if (
|
|
1518
|
+
if (this.getMenuProps.called && !this.getMenuProps.suppressRefError) {
|
|
1517
1519
|
validateGetMenuPropsCalledCorrectly(this._menuNode, this.getMenuProps);
|
|
1518
1520
|
}
|
|
1519
1521
|
}
|
|
@@ -1598,7 +1600,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1598
1600
|
Downshift.defaultProps = {
|
|
1599
1601
|
defaultHighlightedIndex: null,
|
|
1600
1602
|
defaultIsOpen: false,
|
|
1601
|
-
getA11yStatusMessage: getA11yStatusMessage,
|
|
1603
|
+
getA11yStatusMessage: getA11yStatusMessage$1,
|
|
1602
1604
|
itemToString: function itemToString(i) {
|
|
1603
1605
|
if (i == null) {
|
|
1604
1606
|
return '';
|
|
@@ -1629,7 +1631,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1629
1631
|
suppressRefError: false,
|
|
1630
1632
|
scrollIntoView: scrollIntoView
|
|
1631
1633
|
};
|
|
1632
|
-
Downshift.stateChangeTypes = stateChangeTypes;
|
|
1634
|
+
Downshift.stateChangeTypes = stateChangeTypes$3;
|
|
1633
1635
|
return Downshift;
|
|
1634
1636
|
}();
|
|
1635
1637
|
|
|
@@ -1891,7 +1893,7 @@ function useEnhancedReducer(reducer, initialState, props) {
|
|
|
1891
1893
|
*/
|
|
1892
1894
|
|
|
1893
1895
|
|
|
1894
|
-
function useControlledReducer(reducer, initialState, props) {
|
|
1896
|
+
function useControlledReducer$1(reducer, initialState, props) {
|
|
1895
1897
|
var _useEnhancedReducer = useEnhancedReducer(reducer, initialState, props),
|
|
1896
1898
|
state = _useEnhancedReducer[0],
|
|
1897
1899
|
dispatch = _useEnhancedReducer[1];
|
|
@@ -1899,7 +1901,7 @@ function useControlledReducer(reducer, initialState, props) {
|
|
|
1899
1901
|
return [getState(state, props), dispatch];
|
|
1900
1902
|
}
|
|
1901
1903
|
|
|
1902
|
-
var defaultProps = {
|
|
1904
|
+
var defaultProps$3 = {
|
|
1903
1905
|
itemToString: itemToString,
|
|
1904
1906
|
stateReducer: stateReducer,
|
|
1905
1907
|
getA11ySelectionMessage: getA11ySelectionMessage,
|
|
@@ -1910,7 +1912,7 @@ var defaultProps = {
|
|
|
1910
1912
|
? {} : window
|
|
1911
1913
|
};
|
|
1912
1914
|
|
|
1913
|
-
function getDefaultValue(props, propKey, defaultStateValues) {
|
|
1915
|
+
function getDefaultValue$1(props, propKey, defaultStateValues) {
|
|
1914
1916
|
if (defaultStateValues === void 0) {
|
|
1915
1917
|
defaultStateValues = dropdownDefaultStateValues;
|
|
1916
1918
|
}
|
|
@@ -1924,7 +1926,7 @@ function getDefaultValue(props, propKey, defaultStateValues) {
|
|
|
1924
1926
|
return defaultStateValues[propKey];
|
|
1925
1927
|
}
|
|
1926
1928
|
|
|
1927
|
-
function getInitialValue(props, propKey, defaultStateValues) {
|
|
1929
|
+
function getInitialValue$1(props, propKey, defaultStateValues) {
|
|
1928
1930
|
if (defaultStateValues === void 0) {
|
|
1929
1931
|
defaultStateValues = dropdownDefaultStateValues;
|
|
1930
1932
|
}
|
|
@@ -1939,14 +1941,14 @@ function getInitialValue(props, propKey, defaultStateValues) {
|
|
|
1939
1941
|
return props[initialPropKey];
|
|
1940
1942
|
}
|
|
1941
1943
|
|
|
1942
|
-
return getDefaultValue(props, propKey, defaultStateValues);
|
|
1944
|
+
return getDefaultValue$1(props, propKey, defaultStateValues);
|
|
1943
1945
|
}
|
|
1944
1946
|
|
|
1945
|
-
function getInitialState(props) {
|
|
1946
|
-
var selectedItem = getInitialValue(props, 'selectedItem');
|
|
1947
|
-
var isOpen = getInitialValue(props, 'isOpen');
|
|
1948
|
-
var highlightedIndex = getInitialValue(props, 'highlightedIndex');
|
|
1949
|
-
var inputValue = getInitialValue(props, 'inputValue');
|
|
1947
|
+
function getInitialState$2(props) {
|
|
1948
|
+
var selectedItem = getInitialValue$1(props, 'selectedItem');
|
|
1949
|
+
var isOpen = getInitialValue$1(props, 'isOpen');
|
|
1950
|
+
var highlightedIndex = getInitialValue$1(props, 'highlightedIndex');
|
|
1951
|
+
var inputValue = getInitialValue$1(props, 'inputValue');
|
|
1950
1952
|
return {
|
|
1951
1953
|
highlightedIndex: highlightedIndex < 0 && selectedItem && isOpen ? props.items.indexOf(selectedItem) : highlightedIndex,
|
|
1952
1954
|
isOpen: isOpen,
|
|
@@ -2017,7 +2019,7 @@ function useMouseAndTouchTracker(isOpen, downshiftElementRefs, environment, hand
|
|
|
2017
2019
|
|
|
2018
2020
|
if (isOpen && !targetWithinDownshift(event.target, downshiftElementRefs.map(function (ref) {
|
|
2019
2021
|
return ref.current;
|
|
2020
|
-
}), environment
|
|
2022
|
+
}), environment)) {
|
|
2021
2023
|
handleBlur();
|
|
2022
2024
|
}
|
|
2023
2025
|
};
|
|
@@ -2033,7 +2035,7 @@ function useMouseAndTouchTracker(isOpen, downshiftElementRefs, environment, hand
|
|
|
2033
2035
|
var onTouchEnd = function onTouchEnd(event) {
|
|
2034
2036
|
if (isOpen && !mouseAndTouchTrackersRef.current.isTouchMove && !targetWithinDownshift(event.target, downshiftElementRefs.map(function (ref) {
|
|
2035
2037
|
return ref.current;
|
|
2036
|
-
}), environment
|
|
2038
|
+
}), environment, false)) {
|
|
2037
2039
|
handleBlur();
|
|
2038
2040
|
}
|
|
2039
2041
|
};
|
|
@@ -2241,10 +2243,10 @@ function downshiftCommonReducer(state, action, stateChangeTypes) {
|
|
|
2241
2243
|
|
|
2242
2244
|
case stateChangeTypes.FunctionReset:
|
|
2243
2245
|
changes = {
|
|
2244
|
-
highlightedIndex: getDefaultValue(props, 'highlightedIndex'),
|
|
2245
|
-
isOpen: getDefaultValue(props, 'isOpen'),
|
|
2246
|
-
selectedItem: getDefaultValue(props, 'selectedItem'),
|
|
2247
|
-
inputValue: getDefaultValue(props, 'inputValue')
|
|
2246
|
+
highlightedIndex: getDefaultValue$1(props, 'highlightedIndex'),
|
|
2247
|
+
isOpen: getDefaultValue$1(props, 'isOpen'),
|
|
2248
|
+
selectedItem: getDefaultValue$1(props, 'selectedItem'),
|
|
2249
|
+
inputValue: getDefaultValue$1(props, 'inputValue')
|
|
2248
2250
|
};
|
|
2249
2251
|
break;
|
|
2250
2252
|
|
|
@@ -2274,7 +2276,7 @@ function getItemIndexByCharacterKey(keysSoFar, highlightedIndex, items, itemToSt
|
|
|
2274
2276
|
return highlightedIndex;
|
|
2275
2277
|
}
|
|
2276
2278
|
|
|
2277
|
-
var propTypes = {
|
|
2279
|
+
var propTypes$2 = {
|
|
2278
2280
|
items: PropTypes__default['default'].array.isRequired,
|
|
2279
2281
|
itemToString: PropTypes__default['default'].func,
|
|
2280
2282
|
getA11yStatusMessage: PropTypes__default['default'].func,
|
|
@@ -2318,7 +2320,7 @@ var propTypes = {
|
|
|
2318
2320
|
* @return {String} the a11y status message
|
|
2319
2321
|
*/
|
|
2320
2322
|
|
|
2321
|
-
function getA11yStatusMessage
|
|
2323
|
+
function getA11yStatusMessage(_ref) {
|
|
2322
2324
|
var isOpen = _ref.isOpen,
|
|
2323
2325
|
resultCount = _ref.resultCount,
|
|
2324
2326
|
previousResultCount = _ref.previousResultCount;
|
|
@@ -2338,17 +2340,17 @@ function getA11yStatusMessage$1(_ref) {
|
|
|
2338
2340
|
return '';
|
|
2339
2341
|
}
|
|
2340
2342
|
|
|
2341
|
-
var defaultProps$
|
|
2342
|
-
getA11yStatusMessage: getA11yStatusMessage
|
|
2343
|
+
var defaultProps$2 = _extends__default['default']({}, defaultProps$3, {
|
|
2344
|
+
getA11yStatusMessage: getA11yStatusMessage
|
|
2343
2345
|
}); // eslint-disable-next-line import/no-mutable-exports
|
|
2344
2346
|
|
|
2345
2347
|
|
|
2346
|
-
var validatePropTypes = noop;
|
|
2348
|
+
var validatePropTypes$2 = noop;
|
|
2347
2349
|
/* istanbul ignore next */
|
|
2348
2350
|
|
|
2349
2351
|
if (process.env.NODE_ENV !== 'production') {
|
|
2350
|
-
validatePropTypes = function validatePropTypes(options, caller) {
|
|
2351
|
-
PropTypes__default['default'].checkPropTypes(propTypes, options, 'prop', caller.name);
|
|
2352
|
+
validatePropTypes$2 = function validatePropTypes(options, caller) {
|
|
2353
|
+
PropTypes__default['default'].checkPropTypes(propTypes$2, options, 'prop', caller.name);
|
|
2352
2354
|
};
|
|
2353
2355
|
}
|
|
2354
2356
|
|
|
@@ -2361,22 +2363,22 @@ var MenuKeyDownEnter = process.env.NODE_ENV !== "production" ? '__menu_keydown_e
|
|
|
2361
2363
|
var MenuKeyDownSpaceButton = process.env.NODE_ENV !== "production" ? '__menu_keydown_space_button__' : 6;
|
|
2362
2364
|
var MenuKeyDownCharacter = process.env.NODE_ENV !== "production" ? '__menu_keydown_character__' : 7;
|
|
2363
2365
|
var MenuBlur = process.env.NODE_ENV !== "production" ? '__menu_blur__' : 8;
|
|
2364
|
-
var MenuMouseLeave = process.env.NODE_ENV !== "production" ? '__menu_mouse_leave__' : 9;
|
|
2365
|
-
var ItemMouseMove = process.env.NODE_ENV !== "production" ? '__item_mouse_move__' : 10;
|
|
2366
|
-
var ItemClick = process.env.NODE_ENV !== "production" ? '__item_click__' : 11;
|
|
2367
|
-
var ToggleButtonClick = process.env.NODE_ENV !== "production" ? '__togglebutton_click__' : 12;
|
|
2366
|
+
var MenuMouseLeave$1 = process.env.NODE_ENV !== "production" ? '__menu_mouse_leave__' : 9;
|
|
2367
|
+
var ItemMouseMove$1 = process.env.NODE_ENV !== "production" ? '__item_mouse_move__' : 10;
|
|
2368
|
+
var ItemClick$1 = process.env.NODE_ENV !== "production" ? '__item_click__' : 11;
|
|
2369
|
+
var ToggleButtonClick$1 = process.env.NODE_ENV !== "production" ? '__togglebutton_click__' : 12;
|
|
2368
2370
|
var ToggleButtonKeyDownArrowDown = process.env.NODE_ENV !== "production" ? '__togglebutton_keydown_arrow_down__' : 13;
|
|
2369
2371
|
var ToggleButtonKeyDownArrowUp = process.env.NODE_ENV !== "production" ? '__togglebutton_keydown_arrow_up__' : 14;
|
|
2370
2372
|
var ToggleButtonKeyDownCharacter = process.env.NODE_ENV !== "production" ? '__togglebutton_keydown_character__' : 15;
|
|
2371
|
-
var FunctionToggleMenu = process.env.NODE_ENV !== "production" ? '__function_toggle_menu__' : 16;
|
|
2372
|
-
var FunctionOpenMenu = process.env.NODE_ENV !== "production" ? '__function_open_menu__' : 17;
|
|
2373
|
-
var FunctionCloseMenu = process.env.NODE_ENV !== "production" ? '__function_close_menu__' : 18;
|
|
2374
|
-
var FunctionSetHighlightedIndex = process.env.NODE_ENV !== "production" ? '__function_set_highlighted_index__' : 19;
|
|
2375
|
-
var FunctionSelectItem = process.env.NODE_ENV !== "production" ? '__function_select_item__' : 20;
|
|
2376
|
-
var FunctionSetInputValue = process.env.NODE_ENV !== "production" ? '__function_set_input_value__' : 21;
|
|
2377
|
-
var FunctionReset = process.env.NODE_ENV !== "production" ? '__function_reset__' : 22;
|
|
2373
|
+
var FunctionToggleMenu$1 = process.env.NODE_ENV !== "production" ? '__function_toggle_menu__' : 16;
|
|
2374
|
+
var FunctionOpenMenu$1 = process.env.NODE_ENV !== "production" ? '__function_open_menu__' : 17;
|
|
2375
|
+
var FunctionCloseMenu$1 = process.env.NODE_ENV !== "production" ? '__function_close_menu__' : 18;
|
|
2376
|
+
var FunctionSetHighlightedIndex$1 = process.env.NODE_ENV !== "production" ? '__function_set_highlighted_index__' : 19;
|
|
2377
|
+
var FunctionSelectItem$1 = process.env.NODE_ENV !== "production" ? '__function_select_item__' : 20;
|
|
2378
|
+
var FunctionSetInputValue$1 = process.env.NODE_ENV !== "production" ? '__function_set_input_value__' : 21;
|
|
2379
|
+
var FunctionReset$2 = process.env.NODE_ENV !== "production" ? '__function_reset__' : 22;
|
|
2378
2380
|
|
|
2379
|
-
var stateChangeTypes$
|
|
2381
|
+
var stateChangeTypes$2 = /*#__PURE__*/Object.freeze({
|
|
2380
2382
|
__proto__: null,
|
|
2381
2383
|
MenuKeyDownArrowDown: MenuKeyDownArrowDown,
|
|
2382
2384
|
MenuKeyDownArrowUp: MenuKeyDownArrowUp,
|
|
@@ -2387,20 +2389,20 @@ var stateChangeTypes$1 = /*#__PURE__*/Object.freeze({
|
|
|
2387
2389
|
MenuKeyDownSpaceButton: MenuKeyDownSpaceButton,
|
|
2388
2390
|
MenuKeyDownCharacter: MenuKeyDownCharacter,
|
|
2389
2391
|
MenuBlur: MenuBlur,
|
|
2390
|
-
MenuMouseLeave: MenuMouseLeave,
|
|
2391
|
-
ItemMouseMove: ItemMouseMove,
|
|
2392
|
-
ItemClick: ItemClick,
|
|
2393
|
-
ToggleButtonClick: ToggleButtonClick,
|
|
2392
|
+
MenuMouseLeave: MenuMouseLeave$1,
|
|
2393
|
+
ItemMouseMove: ItemMouseMove$1,
|
|
2394
|
+
ItemClick: ItemClick$1,
|
|
2395
|
+
ToggleButtonClick: ToggleButtonClick$1,
|
|
2394
2396
|
ToggleButtonKeyDownArrowDown: ToggleButtonKeyDownArrowDown,
|
|
2395
2397
|
ToggleButtonKeyDownArrowUp: ToggleButtonKeyDownArrowUp,
|
|
2396
2398
|
ToggleButtonKeyDownCharacter: ToggleButtonKeyDownCharacter,
|
|
2397
|
-
FunctionToggleMenu: FunctionToggleMenu,
|
|
2398
|
-
FunctionOpenMenu: FunctionOpenMenu,
|
|
2399
|
-
FunctionCloseMenu: FunctionCloseMenu,
|
|
2400
|
-
FunctionSetHighlightedIndex: FunctionSetHighlightedIndex,
|
|
2401
|
-
FunctionSelectItem: FunctionSelectItem,
|
|
2402
|
-
FunctionSetInputValue: FunctionSetInputValue,
|
|
2403
|
-
FunctionReset: FunctionReset
|
|
2399
|
+
FunctionToggleMenu: FunctionToggleMenu$1,
|
|
2400
|
+
FunctionOpenMenu: FunctionOpenMenu$1,
|
|
2401
|
+
FunctionCloseMenu: FunctionCloseMenu$1,
|
|
2402
|
+
FunctionSetHighlightedIndex: FunctionSetHighlightedIndex$1,
|
|
2403
|
+
FunctionSelectItem: FunctionSelectItem$1,
|
|
2404
|
+
FunctionSetInputValue: FunctionSetInputValue$1,
|
|
2405
|
+
FunctionReset: FunctionReset$2
|
|
2404
2406
|
});
|
|
2405
2407
|
|
|
2406
2408
|
/* eslint-disable complexity */
|
|
@@ -2412,10 +2414,10 @@ function downshiftSelectReducer(state, action) {
|
|
|
2412
2414
|
var changes;
|
|
2413
2415
|
|
|
2414
2416
|
switch (type) {
|
|
2415
|
-
case ItemClick:
|
|
2417
|
+
case ItemClick$1:
|
|
2416
2418
|
changes = {
|
|
2417
|
-
isOpen: getDefaultValue(props, 'isOpen'),
|
|
2418
|
-
highlightedIndex: getDefaultValue(props, 'highlightedIndex'),
|
|
2419
|
+
isOpen: getDefaultValue$1(props, 'isOpen'),
|
|
2420
|
+
highlightedIndex: getDefaultValue$1(props, 'highlightedIndex'),
|
|
2419
2421
|
selectedItem: props.items[action.index]
|
|
2420
2422
|
};
|
|
2421
2423
|
break;
|
|
@@ -2450,8 +2452,8 @@ function downshiftSelectReducer(state, action) {
|
|
|
2450
2452
|
case MenuKeyDownEnter:
|
|
2451
2453
|
case MenuKeyDownSpaceButton:
|
|
2452
2454
|
changes = _extends__default['default']({
|
|
2453
|
-
isOpen: getDefaultValue(props, 'isOpen'),
|
|
2454
|
-
highlightedIndex: getDefaultValue(props, 'highlightedIndex')
|
|
2455
|
+
isOpen: getDefaultValue$1(props, 'isOpen'),
|
|
2456
|
+
highlightedIndex: getDefaultValue$1(props, 'highlightedIndex')
|
|
2455
2457
|
}, state.highlightedIndex >= 0 && {
|
|
2456
2458
|
selectedItem: props.items[state.highlightedIndex]
|
|
2457
2459
|
});
|
|
@@ -2510,30 +2512,30 @@ function downshiftSelectReducer(state, action) {
|
|
|
2510
2512
|
};
|
|
2511
2513
|
break;
|
|
2512
2514
|
|
|
2513
|
-
case FunctionSelectItem:
|
|
2515
|
+
case FunctionSelectItem$1:
|
|
2514
2516
|
changes = {
|
|
2515
2517
|
selectedItem: action.selectedItem
|
|
2516
2518
|
};
|
|
2517
2519
|
break;
|
|
2518
2520
|
|
|
2519
2521
|
default:
|
|
2520
|
-
return downshiftCommonReducer(state, action, stateChangeTypes$
|
|
2522
|
+
return downshiftCommonReducer(state, action, stateChangeTypes$2);
|
|
2521
2523
|
}
|
|
2522
2524
|
|
|
2523
2525
|
return _extends__default['default']({}, state, changes);
|
|
2524
2526
|
}
|
|
2525
2527
|
/* eslint-enable complexity */
|
|
2526
2528
|
|
|
2527
|
-
useSelect.stateChangeTypes = stateChangeTypes$
|
|
2529
|
+
useSelect.stateChangeTypes = stateChangeTypes$2;
|
|
2528
2530
|
|
|
2529
2531
|
function useSelect(userProps) {
|
|
2530
2532
|
if (userProps === void 0) {
|
|
2531
2533
|
userProps = {};
|
|
2532
2534
|
}
|
|
2533
2535
|
|
|
2534
|
-
validatePropTypes(userProps, useSelect); // Props defaults and destructuring.
|
|
2536
|
+
validatePropTypes$2(userProps, useSelect); // Props defaults and destructuring.
|
|
2535
2537
|
|
|
2536
|
-
var props = _extends__default['default']({}, defaultProps$
|
|
2538
|
+
var props = _extends__default['default']({}, defaultProps$2, userProps);
|
|
2537
2539
|
|
|
2538
2540
|
var items = props.items,
|
|
2539
2541
|
scrollIntoView = props.scrollIntoView,
|
|
@@ -2544,9 +2546,9 @@ function useSelect(userProps) {
|
|
|
2544
2546
|
getA11ySelectionMessage = props.getA11ySelectionMessage,
|
|
2545
2547
|
getA11yStatusMessage = props.getA11yStatusMessage; // Initial state depending on controlled props.
|
|
2546
2548
|
|
|
2547
|
-
var initialState = getInitialState(props);
|
|
2549
|
+
var initialState = getInitialState$2(props);
|
|
2548
2550
|
|
|
2549
|
-
var _useControlledReducer = useControlledReducer(downshiftSelectReducer, initialState, props),
|
|
2551
|
+
var _useControlledReducer = useControlledReducer$1(downshiftSelectReducer, initialState, props),
|
|
2550
2552
|
state = _useControlledReducer[0],
|
|
2551
2553
|
dispatch = _useControlledReducer[1];
|
|
2552
2554
|
|
|
@@ -2601,19 +2603,23 @@ function useSelect(userProps) {
|
|
|
2601
2603
|
itemRefs: itemRefs,
|
|
2602
2604
|
scrollIntoView: scrollIntoView,
|
|
2603
2605
|
getItemNodeFromIndex: getItemNodeFromIndex
|
|
2604
|
-
}); // Sets cleanup for the keysSoFar after 500ms.
|
|
2606
|
+
}); // Sets cleanup for the keysSoFar callback, debounded after 500ms.
|
|
2605
2607
|
|
|
2606
2608
|
react.useEffect(function () {
|
|
2607
2609
|
// init the clean function here as we need access to dispatch.
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2610
|
+
clearTimeoutRef.current = debounce(function (outerDispatch) {
|
|
2611
|
+
outerDispatch({
|
|
2612
|
+
type: FunctionSetInputValue$1,
|
|
2613
|
+
inputValue: ''
|
|
2614
|
+
});
|
|
2615
|
+
}, 500); // Cancel any pending debounced calls on mount
|
|
2616
|
+
|
|
2617
|
+
return function () {
|
|
2618
|
+
clearTimeoutRef.current.cancel();
|
|
2619
|
+
};
|
|
2620
|
+
}, []); // Invokes the keysSoFar callback set up above.
|
|
2616
2621
|
|
|
2622
|
+
react.useEffect(function () {
|
|
2617
2623
|
if (!inputValue) {
|
|
2618
2624
|
return;
|
|
2619
2625
|
}
|
|
@@ -2757,39 +2763,39 @@ function useSelect(userProps) {
|
|
|
2757
2763
|
|
|
2758
2764
|
var toggleMenu = react.useCallback(function () {
|
|
2759
2765
|
dispatch({
|
|
2760
|
-
type: FunctionToggleMenu
|
|
2766
|
+
type: FunctionToggleMenu$1
|
|
2761
2767
|
});
|
|
2762
2768
|
}, [dispatch]);
|
|
2763
2769
|
var closeMenu = react.useCallback(function () {
|
|
2764
2770
|
dispatch({
|
|
2765
|
-
type: FunctionCloseMenu
|
|
2771
|
+
type: FunctionCloseMenu$1
|
|
2766
2772
|
});
|
|
2767
2773
|
}, [dispatch]);
|
|
2768
2774
|
var openMenu = react.useCallback(function () {
|
|
2769
2775
|
dispatch({
|
|
2770
|
-
type: FunctionOpenMenu
|
|
2776
|
+
type: FunctionOpenMenu$1
|
|
2771
2777
|
});
|
|
2772
2778
|
}, [dispatch]);
|
|
2773
2779
|
var setHighlightedIndex = react.useCallback(function (newHighlightedIndex) {
|
|
2774
2780
|
dispatch({
|
|
2775
|
-
type: FunctionSetHighlightedIndex,
|
|
2781
|
+
type: FunctionSetHighlightedIndex$1,
|
|
2776
2782
|
highlightedIndex: newHighlightedIndex
|
|
2777
2783
|
});
|
|
2778
2784
|
}, [dispatch]);
|
|
2779
2785
|
var selectItem = react.useCallback(function (newSelectedItem) {
|
|
2780
2786
|
dispatch({
|
|
2781
|
-
type: FunctionSelectItem,
|
|
2787
|
+
type: FunctionSelectItem$1,
|
|
2782
2788
|
selectedItem: newSelectedItem
|
|
2783
2789
|
});
|
|
2784
2790
|
}, [dispatch]);
|
|
2785
2791
|
var reset = react.useCallback(function () {
|
|
2786
2792
|
dispatch({
|
|
2787
|
-
type: FunctionReset
|
|
2793
|
+
type: FunctionReset$2
|
|
2788
2794
|
});
|
|
2789
2795
|
}, [dispatch]);
|
|
2790
2796
|
var setInputValue = react.useCallback(function (newInputValue) {
|
|
2791
2797
|
dispatch({
|
|
2792
|
-
type: FunctionSetInputValue,
|
|
2798
|
+
type: FunctionSetInputValue$1,
|
|
2793
2799
|
inputValue: newInputValue
|
|
2794
2800
|
});
|
|
2795
2801
|
}, [dispatch]); // Getter functions.
|
|
@@ -2851,7 +2857,7 @@ function useSelect(userProps) {
|
|
|
2851
2857
|
|
|
2852
2858
|
var menuHandleMouseLeave = function menuHandleMouseLeave() {
|
|
2853
2859
|
dispatch({
|
|
2854
|
-
type: MenuMouseLeave
|
|
2860
|
+
type: MenuMouseLeave$1
|
|
2855
2861
|
});
|
|
2856
2862
|
};
|
|
2857
2863
|
|
|
@@ -2883,7 +2889,7 @@ function useSelect(userProps) {
|
|
|
2883
2889
|
|
|
2884
2890
|
var toggleButtonHandleClick = function toggleButtonHandleClick() {
|
|
2885
2891
|
dispatch({
|
|
2886
|
-
type: ToggleButtonClick
|
|
2892
|
+
type: ToggleButtonClick$1
|
|
2887
2893
|
});
|
|
2888
2894
|
};
|
|
2889
2895
|
|
|
@@ -2937,14 +2943,14 @@ function useSelect(userProps) {
|
|
|
2937
2943
|
|
|
2938
2944
|
shouldScrollRef.current = false;
|
|
2939
2945
|
dispatch({
|
|
2940
|
-
type: ItemMouseMove,
|
|
2946
|
+
type: ItemMouseMove$1,
|
|
2941
2947
|
index: index
|
|
2942
2948
|
});
|
|
2943
2949
|
};
|
|
2944
2950
|
|
|
2945
2951
|
var itemHandleClick = function itemHandleClick() {
|
|
2946
2952
|
dispatch({
|
|
2947
|
-
type: ItemClick,
|
|
2953
|
+
type: ItemClick$1,
|
|
2948
2954
|
index: index
|
|
2949
2955
|
});
|
|
2950
2956
|
};
|
|
@@ -3002,20 +3008,20 @@ var InputKeyDownEnd = process.env.NODE_ENV !== "production" ? '__input_keydown_e
|
|
|
3002
3008
|
var InputKeyDownEnter = process.env.NODE_ENV !== "production" ? '__input_keydown_enter__' : 5;
|
|
3003
3009
|
var InputChange = process.env.NODE_ENV !== "production" ? '__input_change__' : 6;
|
|
3004
3010
|
var InputBlur = process.env.NODE_ENV !== "production" ? '__input_blur__' : 7;
|
|
3005
|
-
var MenuMouseLeave
|
|
3006
|
-
var ItemMouseMove
|
|
3007
|
-
var ItemClick
|
|
3008
|
-
var ToggleButtonClick
|
|
3009
|
-
var FunctionToggleMenu
|
|
3010
|
-
var FunctionOpenMenu
|
|
3011
|
-
var FunctionCloseMenu
|
|
3012
|
-
var FunctionSetHighlightedIndex
|
|
3013
|
-
var FunctionSelectItem
|
|
3014
|
-
var FunctionSetInputValue
|
|
3011
|
+
var MenuMouseLeave = process.env.NODE_ENV !== "production" ? '__menu_mouse_leave__' : 8;
|
|
3012
|
+
var ItemMouseMove = process.env.NODE_ENV !== "production" ? '__item_mouse_move__' : 9;
|
|
3013
|
+
var ItemClick = process.env.NODE_ENV !== "production" ? '__item_click__' : 10;
|
|
3014
|
+
var ToggleButtonClick = process.env.NODE_ENV !== "production" ? '__togglebutton_click__' : 11;
|
|
3015
|
+
var FunctionToggleMenu = process.env.NODE_ENV !== "production" ? '__function_toggle_menu__' : 12;
|
|
3016
|
+
var FunctionOpenMenu = process.env.NODE_ENV !== "production" ? '__function_open_menu__' : 13;
|
|
3017
|
+
var FunctionCloseMenu = process.env.NODE_ENV !== "production" ? '__function_close_menu__' : 14;
|
|
3018
|
+
var FunctionSetHighlightedIndex = process.env.NODE_ENV !== "production" ? '__function_set_highlighted_index__' : 15;
|
|
3019
|
+
var FunctionSelectItem = process.env.NODE_ENV !== "production" ? '__function_select_item__' : 16;
|
|
3020
|
+
var FunctionSetInputValue = process.env.NODE_ENV !== "production" ? '__function_set_input_value__' : 17;
|
|
3015
3021
|
var FunctionReset$1 = process.env.NODE_ENV !== "production" ? '__function_reset__' : 18;
|
|
3016
3022
|
var ControlledPropUpdatedSelectedItem = process.env.NODE_ENV !== "production" ? '__controlled_prop_updated_selected_item__' : 19;
|
|
3017
3023
|
|
|
3018
|
-
var stateChangeTypes$
|
|
3024
|
+
var stateChangeTypes$1 = /*#__PURE__*/Object.freeze({
|
|
3019
3025
|
__proto__: null,
|
|
3020
3026
|
InputKeyDownArrowDown: InputKeyDownArrowDown,
|
|
3021
3027
|
InputKeyDownArrowUp: InputKeyDownArrowUp,
|
|
@@ -3025,22 +3031,22 @@ var stateChangeTypes$2 = /*#__PURE__*/Object.freeze({
|
|
|
3025
3031
|
InputKeyDownEnter: InputKeyDownEnter,
|
|
3026
3032
|
InputChange: InputChange,
|
|
3027
3033
|
InputBlur: InputBlur,
|
|
3028
|
-
MenuMouseLeave: MenuMouseLeave
|
|
3029
|
-
ItemMouseMove: ItemMouseMove
|
|
3030
|
-
ItemClick: ItemClick
|
|
3031
|
-
ToggleButtonClick: ToggleButtonClick
|
|
3032
|
-
FunctionToggleMenu: FunctionToggleMenu
|
|
3033
|
-
FunctionOpenMenu: FunctionOpenMenu
|
|
3034
|
-
FunctionCloseMenu: FunctionCloseMenu
|
|
3035
|
-
FunctionSetHighlightedIndex: FunctionSetHighlightedIndex
|
|
3036
|
-
FunctionSelectItem: FunctionSelectItem
|
|
3037
|
-
FunctionSetInputValue: FunctionSetInputValue
|
|
3034
|
+
MenuMouseLeave: MenuMouseLeave,
|
|
3035
|
+
ItemMouseMove: ItemMouseMove,
|
|
3036
|
+
ItemClick: ItemClick,
|
|
3037
|
+
ToggleButtonClick: ToggleButtonClick,
|
|
3038
|
+
FunctionToggleMenu: FunctionToggleMenu,
|
|
3039
|
+
FunctionOpenMenu: FunctionOpenMenu,
|
|
3040
|
+
FunctionCloseMenu: FunctionCloseMenu,
|
|
3041
|
+
FunctionSetHighlightedIndex: FunctionSetHighlightedIndex,
|
|
3042
|
+
FunctionSelectItem: FunctionSelectItem,
|
|
3043
|
+
FunctionSetInputValue: FunctionSetInputValue,
|
|
3038
3044
|
FunctionReset: FunctionReset$1,
|
|
3039
3045
|
ControlledPropUpdatedSelectedItem: ControlledPropUpdatedSelectedItem
|
|
3040
3046
|
});
|
|
3041
3047
|
|
|
3042
3048
|
function getInitialState$1(props) {
|
|
3043
|
-
var initialState = getInitialState(props);
|
|
3049
|
+
var initialState = getInitialState$2(props);
|
|
3044
3050
|
var selectedItem = initialState.selectedItem;
|
|
3045
3051
|
var inputValue = initialState.inputValue;
|
|
3046
3052
|
|
|
@@ -3106,7 +3112,7 @@ var propTypes$1 = {
|
|
|
3106
3112
|
* @returns {Array} An array with the state and an action dispatcher.
|
|
3107
3113
|
*/
|
|
3108
3114
|
|
|
3109
|
-
function useControlledReducer
|
|
3115
|
+
function useControlledReducer(reducer, initialState, props) {
|
|
3110
3116
|
var previousSelectedItemRef = react.useRef();
|
|
3111
3117
|
|
|
3112
3118
|
var _useEnhancedReducer = useEnhancedReducer(reducer, initialState, props),
|
|
@@ -3139,8 +3145,8 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
3139
3145
|
};
|
|
3140
3146
|
}
|
|
3141
3147
|
|
|
3142
|
-
var defaultProps$
|
|
3143
|
-
getA11yStatusMessage: getA11yStatusMessage,
|
|
3148
|
+
var defaultProps$1 = _extends__default['default']({}, defaultProps$3, {
|
|
3149
|
+
getA11yStatusMessage: getA11yStatusMessage$1,
|
|
3144
3150
|
circularNavigation: true
|
|
3145
3151
|
});
|
|
3146
3152
|
|
|
@@ -3153,10 +3159,10 @@ function downshiftUseComboboxReducer(state, action) {
|
|
|
3153
3159
|
var changes;
|
|
3154
3160
|
|
|
3155
3161
|
switch (type) {
|
|
3156
|
-
case ItemClick
|
|
3162
|
+
case ItemClick:
|
|
3157
3163
|
changes = {
|
|
3158
|
-
isOpen: getDefaultValue(props, 'isOpen'),
|
|
3159
|
-
highlightedIndex: getDefaultValue(props, 'highlightedIndex'),
|
|
3164
|
+
isOpen: getDefaultValue$1(props, 'isOpen'),
|
|
3165
|
+
highlightedIndex: getDefaultValue$1(props, 'highlightedIndex'),
|
|
3160
3166
|
selectedItem: props.items[action.index],
|
|
3161
3167
|
inputValue: props.itemToString(props.items[action.index])
|
|
3162
3168
|
};
|
|
@@ -3193,8 +3199,8 @@ function downshiftUseComboboxReducer(state, action) {
|
|
|
3193
3199
|
case InputKeyDownEnter:
|
|
3194
3200
|
changes = _extends__default['default']({}, state.isOpen && state.highlightedIndex >= 0 && {
|
|
3195
3201
|
selectedItem: props.items[state.highlightedIndex],
|
|
3196
|
-
isOpen: getDefaultValue(props, 'isOpen'),
|
|
3197
|
-
highlightedIndex: getDefaultValue(props, 'highlightedIndex'),
|
|
3202
|
+
isOpen: getDefaultValue$1(props, 'isOpen'),
|
|
3203
|
+
highlightedIndex: getDefaultValue$1(props, 'highlightedIndex'),
|
|
3198
3204
|
inputValue: props.itemToString(props.items[state.highlightedIndex])
|
|
3199
3205
|
});
|
|
3200
3206
|
break;
|
|
@@ -3234,12 +3240,12 @@ function downshiftUseComboboxReducer(state, action) {
|
|
|
3234
3240
|
case InputChange:
|
|
3235
3241
|
changes = {
|
|
3236
3242
|
isOpen: true,
|
|
3237
|
-
highlightedIndex: getDefaultValue(props, 'highlightedIndex'),
|
|
3243
|
+
highlightedIndex: getDefaultValue$1(props, 'highlightedIndex'),
|
|
3238
3244
|
inputValue: action.inputValue
|
|
3239
3245
|
};
|
|
3240
3246
|
break;
|
|
3241
3247
|
|
|
3242
|
-
case FunctionSelectItem
|
|
3248
|
+
case FunctionSelectItem:
|
|
3243
3249
|
changes = {
|
|
3244
3250
|
selectedItem: action.selectedItem,
|
|
3245
3251
|
inputValue: props.itemToString(action.selectedItem)
|
|
@@ -3253,14 +3259,14 @@ function downshiftUseComboboxReducer(state, action) {
|
|
|
3253
3259
|
break;
|
|
3254
3260
|
|
|
3255
3261
|
default:
|
|
3256
|
-
return downshiftCommonReducer(state, action, stateChangeTypes$
|
|
3262
|
+
return downshiftCommonReducer(state, action, stateChangeTypes$1);
|
|
3257
3263
|
}
|
|
3258
3264
|
|
|
3259
3265
|
return _extends__default['default']({}, state, changes);
|
|
3260
3266
|
}
|
|
3261
3267
|
/* eslint-enable complexity */
|
|
3262
3268
|
|
|
3263
|
-
useCombobox.stateChangeTypes = stateChangeTypes$
|
|
3269
|
+
useCombobox.stateChangeTypes = stateChangeTypes$1;
|
|
3264
3270
|
|
|
3265
3271
|
function useCombobox(userProps) {
|
|
3266
3272
|
if (userProps === void 0) {
|
|
@@ -3269,7 +3275,7 @@ function useCombobox(userProps) {
|
|
|
3269
3275
|
|
|
3270
3276
|
validatePropTypes$1(userProps, useCombobox); // Props defaults and destructuring.
|
|
3271
3277
|
|
|
3272
|
-
var props = _extends__default['default']({}, defaultProps$
|
|
3278
|
+
var props = _extends__default['default']({}, defaultProps$1, userProps);
|
|
3273
3279
|
|
|
3274
3280
|
var initialIsOpen = props.initialIsOpen,
|
|
3275
3281
|
defaultIsOpen = props.defaultIsOpen,
|
|
@@ -3282,7 +3288,7 @@ function useCombobox(userProps) {
|
|
|
3282
3288
|
|
|
3283
3289
|
var initialState = getInitialState$1(props);
|
|
3284
3290
|
|
|
3285
|
-
var _useControlledReducer = useControlledReducer
|
|
3291
|
+
var _useControlledReducer = useControlledReducer(downshiftUseComboboxReducer, initialState, props),
|
|
3286
3292
|
state = _useControlledReducer[0],
|
|
3287
3293
|
dispatch = _useControlledReducer[1];
|
|
3288
3294
|
|
|
@@ -3467,7 +3473,7 @@ function useCombobox(userProps) {
|
|
|
3467
3473
|
menuRef.current = menuNode;
|
|
3468
3474
|
}), _extends2.id = elementIds.menuId, _extends2.role = 'listbox', _extends2['aria-labelledby'] = elementIds.labelId, _extends2.onMouseLeave = callAllEventHandlers(onMouseLeave, function () {
|
|
3469
3475
|
dispatch({
|
|
3470
|
-
type: MenuMouseLeave
|
|
3476
|
+
type: MenuMouseLeave
|
|
3471
3477
|
});
|
|
3472
3478
|
}), _extends2), rest);
|
|
3473
3479
|
}, [dispatch, setGetterPropCallInfo, elementIds]);
|
|
@@ -3481,9 +3487,9 @@ function useCombobox(userProps) {
|
|
|
3481
3487
|
refKey = _ref3$refKey === void 0 ? 'ref' : _ref3$refKey,
|
|
3482
3488
|
ref = _ref3.ref,
|
|
3483
3489
|
onMouseMove = _ref3.onMouseMove,
|
|
3484
|
-
onClick = _ref3.onClick
|
|
3485
|
-
|
|
3486
|
-
rest = _objectWithoutPropertiesLoose__default['default'](_ref3, ["item", "index", "refKey", "ref", "onMouseMove", "onClick", "onPress"]);
|
|
3490
|
+
onClick = _ref3.onClick;
|
|
3491
|
+
_ref3.onPress;
|
|
3492
|
+
var rest = _objectWithoutPropertiesLoose__default['default'](_ref3, ["item", "index", "refKey", "ref", "onMouseMove", "onClick", "onPress"]);
|
|
3487
3493
|
|
|
3488
3494
|
var _latest$current = latest.current,
|
|
3489
3495
|
latestProps = _latest$current.props,
|
|
@@ -3494,8 +3500,8 @@ function useCombobox(userProps) {
|
|
|
3494
3500
|
throw new Error('Pass either item or item index in getItemProps!');
|
|
3495
3501
|
}
|
|
3496
3502
|
|
|
3497
|
-
var onSelectKey =
|
|
3498
|
-
var customClickHandler =
|
|
3503
|
+
var onSelectKey = 'onClick';
|
|
3504
|
+
var customClickHandler = onClick;
|
|
3499
3505
|
|
|
3500
3506
|
var itemHandleMouseMove = function itemHandleMouseMove() {
|
|
3501
3507
|
if (index === latestState.highlightedIndex) {
|
|
@@ -3504,14 +3510,14 @@ function useCombobox(userProps) {
|
|
|
3504
3510
|
|
|
3505
3511
|
shouldScrollRef.current = false;
|
|
3506
3512
|
dispatch({
|
|
3507
|
-
type: ItemMouseMove
|
|
3513
|
+
type: ItemMouseMove,
|
|
3508
3514
|
index: index
|
|
3509
3515
|
});
|
|
3510
3516
|
};
|
|
3511
3517
|
|
|
3512
3518
|
var itemHandleClick = function itemHandleClick() {
|
|
3513
3519
|
dispatch({
|
|
3514
|
-
type: ItemClick
|
|
3520
|
+
type: ItemClick,
|
|
3515
3521
|
index: index
|
|
3516
3522
|
});
|
|
3517
3523
|
|
|
@@ -3532,16 +3538,16 @@ function useCombobox(userProps) {
|
|
|
3532
3538
|
var _extends4;
|
|
3533
3539
|
|
|
3534
3540
|
var _ref5 = _temp4 === void 0 ? {} : _temp4,
|
|
3535
|
-
onClick = _ref5.onClick
|
|
3536
|
-
|
|
3537
|
-
_ref5$refKey = _ref5.refKey,
|
|
3541
|
+
onClick = _ref5.onClick;
|
|
3542
|
+
_ref5.onPress;
|
|
3543
|
+
var _ref5$refKey = _ref5.refKey,
|
|
3538
3544
|
refKey = _ref5$refKey === void 0 ? 'ref' : _ref5$refKey,
|
|
3539
3545
|
ref = _ref5.ref,
|
|
3540
3546
|
rest = _objectWithoutPropertiesLoose__default['default'](_ref5, ["onClick", "onPress", "refKey", "ref"]);
|
|
3541
3547
|
|
|
3542
3548
|
var toggleButtonHandleClick = function toggleButtonHandleClick() {
|
|
3543
3549
|
dispatch({
|
|
3544
|
-
type: ToggleButtonClick
|
|
3550
|
+
type: ToggleButtonClick
|
|
3545
3551
|
});
|
|
3546
3552
|
|
|
3547
3553
|
if (!latest.current.state.isOpen && inputRef.current) {
|
|
@@ -3551,7 +3557,7 @@ function useCombobox(userProps) {
|
|
|
3551
3557
|
|
|
3552
3558
|
return _extends__default['default']((_extends4 = {}, _extends4[refKey] = handleRefs(ref, function (toggleButtonNode) {
|
|
3553
3559
|
toggleButtonRef.current = toggleButtonNode;
|
|
3554
|
-
}), _extends4.id = elementIds.toggleButtonId, _extends4.tabIndex = -1, _extends4), !rest.disabled && _extends__default['default']({},
|
|
3560
|
+
}), _extends4.id = elementIds.toggleButtonId, _extends4.tabIndex = -1, _extends4), !rest.disabled && _extends__default['default']({}, {
|
|
3555
3561
|
onClick: callAllEventHandlers(onClick, toggleButtonHandleClick)
|
|
3556
3562
|
}), rest);
|
|
3557
3563
|
}, [dispatch, latest, elementIds]);
|
|
@@ -3562,9 +3568,9 @@ function useCombobox(userProps) {
|
|
|
3562
3568
|
onKeyDown = _ref6.onKeyDown,
|
|
3563
3569
|
onChange = _ref6.onChange,
|
|
3564
3570
|
onInput = _ref6.onInput,
|
|
3565
|
-
onBlur = _ref6.onBlur
|
|
3566
|
-
|
|
3567
|
-
_ref6$refKey = _ref6.refKey,
|
|
3571
|
+
onBlur = _ref6.onBlur;
|
|
3572
|
+
_ref6.onChangeText;
|
|
3573
|
+
var _ref6$refKey = _ref6.refKey,
|
|
3568
3574
|
refKey = _ref6$refKey === void 0 ? 'ref' : _ref6$refKey,
|
|
3569
3575
|
ref = _ref6.ref,
|
|
3570
3576
|
rest = _objectWithoutPropertiesLoose__default['default'](_ref6, ["onKeyDown", "onChange", "onInput", "onBlur", "onChangeText", "refKey", "ref"]);
|
|
@@ -3587,7 +3593,7 @@ function useCombobox(userProps) {
|
|
|
3587
3593
|
var inputHandleChange = function inputHandleChange(event) {
|
|
3588
3594
|
dispatch({
|
|
3589
3595
|
type: InputChange,
|
|
3590
|
-
inputValue:
|
|
3596
|
+
inputValue: event.target.value
|
|
3591
3597
|
});
|
|
3592
3598
|
};
|
|
3593
3599
|
|
|
@@ -3603,7 +3609,7 @@ function useCombobox(userProps) {
|
|
|
3603
3609
|
/* istanbul ignore next (preact) */
|
|
3604
3610
|
|
|
3605
3611
|
|
|
3606
|
-
var onChangeKey =
|
|
3612
|
+
var onChangeKey = 'onChange';
|
|
3607
3613
|
var eventHandlers = {};
|
|
3608
3614
|
|
|
3609
3615
|
if (!rest.disabled) {
|
|
@@ -3645,34 +3651,34 @@ function useCombobox(userProps) {
|
|
|
3645
3651
|
|
|
3646
3652
|
var toggleMenu = react.useCallback(function () {
|
|
3647
3653
|
dispatch({
|
|
3648
|
-
type: FunctionToggleMenu
|
|
3654
|
+
type: FunctionToggleMenu
|
|
3649
3655
|
});
|
|
3650
3656
|
}, [dispatch]);
|
|
3651
3657
|
var closeMenu = react.useCallback(function () {
|
|
3652
3658
|
dispatch({
|
|
3653
|
-
type: FunctionCloseMenu
|
|
3659
|
+
type: FunctionCloseMenu
|
|
3654
3660
|
});
|
|
3655
3661
|
}, [dispatch]);
|
|
3656
3662
|
var openMenu = react.useCallback(function () {
|
|
3657
3663
|
dispatch({
|
|
3658
|
-
type: FunctionOpenMenu
|
|
3664
|
+
type: FunctionOpenMenu
|
|
3659
3665
|
});
|
|
3660
3666
|
}, [dispatch]);
|
|
3661
3667
|
var setHighlightedIndex = react.useCallback(function (newHighlightedIndex) {
|
|
3662
3668
|
dispatch({
|
|
3663
|
-
type: FunctionSetHighlightedIndex
|
|
3669
|
+
type: FunctionSetHighlightedIndex,
|
|
3664
3670
|
highlightedIndex: newHighlightedIndex
|
|
3665
3671
|
});
|
|
3666
3672
|
}, [dispatch]);
|
|
3667
3673
|
var selectItem = react.useCallback(function (newSelectedItem) {
|
|
3668
3674
|
dispatch({
|
|
3669
|
-
type: FunctionSelectItem
|
|
3675
|
+
type: FunctionSelectItem,
|
|
3670
3676
|
selectedItem: newSelectedItem
|
|
3671
3677
|
});
|
|
3672
3678
|
}, [dispatch]);
|
|
3673
3679
|
var setInputValue = react.useCallback(function (newInputValue) {
|
|
3674
3680
|
dispatch({
|
|
3675
|
-
type: FunctionSetInputValue
|
|
3681
|
+
type: FunctionSetInputValue,
|
|
3676
3682
|
inputValue: newInputValue
|
|
3677
3683
|
});
|
|
3678
3684
|
}, [dispatch]);
|
|
@@ -3719,8 +3725,8 @@ var defaultStateValues = {
|
|
|
3719
3725
|
* @returns {any} The initial value for that prop.
|
|
3720
3726
|
*/
|
|
3721
3727
|
|
|
3722
|
-
function getInitialValue
|
|
3723
|
-
return getInitialValue(props, propKey, defaultStateValues);
|
|
3728
|
+
function getInitialValue(props, propKey) {
|
|
3729
|
+
return getInitialValue$1(props, propKey, defaultStateValues);
|
|
3724
3730
|
}
|
|
3725
3731
|
/**
|
|
3726
3732
|
* Returns the default value for a state key in the following order:
|
|
@@ -3732,8 +3738,8 @@ function getInitialValue$1(props, propKey) {
|
|
|
3732
3738
|
*/
|
|
3733
3739
|
|
|
3734
3740
|
|
|
3735
|
-
function getDefaultValue
|
|
3736
|
-
return getDefaultValue(props, propKey, defaultStateValues);
|
|
3741
|
+
function getDefaultValue(props, propKey) {
|
|
3742
|
+
return getDefaultValue$1(props, propKey, defaultStateValues);
|
|
3737
3743
|
}
|
|
3738
3744
|
/**
|
|
3739
3745
|
* Gets the initial state based on the provided props. It uses initial, default
|
|
@@ -3744,9 +3750,9 @@ function getDefaultValue$1(props, propKey) {
|
|
|
3744
3750
|
*/
|
|
3745
3751
|
|
|
3746
3752
|
|
|
3747
|
-
function getInitialState
|
|
3748
|
-
var activeIndex = getInitialValue
|
|
3749
|
-
var selectedItems = getInitialValue
|
|
3753
|
+
function getInitialState(props) {
|
|
3754
|
+
var activeIndex = getInitialValue(props, 'activeIndex');
|
|
3755
|
+
var selectedItems = getInitialValue(props, 'selectedItems');
|
|
3750
3756
|
return {
|
|
3751
3757
|
activeIndex: activeIndex,
|
|
3752
3758
|
selectedItems: selectedItems
|
|
@@ -3793,7 +3799,7 @@ function getA11yRemovalMessage(selectionParameters) {
|
|
|
3793
3799
|
return itemToStringLocal(removedSelectedItem) + " has been removed.";
|
|
3794
3800
|
}
|
|
3795
3801
|
|
|
3796
|
-
var propTypes
|
|
3802
|
+
var propTypes = {
|
|
3797
3803
|
selectedItems: PropTypes__default['default'].array,
|
|
3798
3804
|
initialSelectedItems: PropTypes__default['default'].array,
|
|
3799
3805
|
defaultSelectedItems: PropTypes__default['default'].array,
|
|
@@ -3817,21 +3823,21 @@ var propTypes$2 = {
|
|
|
3817
3823
|
})
|
|
3818
3824
|
})
|
|
3819
3825
|
};
|
|
3820
|
-
var defaultProps
|
|
3821
|
-
itemToString: defaultProps.itemToString,
|
|
3822
|
-
stateReducer: defaultProps.stateReducer,
|
|
3823
|
-
environment: defaultProps.environment,
|
|
3826
|
+
var defaultProps = {
|
|
3827
|
+
itemToString: defaultProps$3.itemToString,
|
|
3828
|
+
stateReducer: defaultProps$3.stateReducer,
|
|
3829
|
+
environment: defaultProps$3.environment,
|
|
3824
3830
|
getA11yRemovalMessage: getA11yRemovalMessage,
|
|
3825
3831
|
keyNavigationNext: 'ArrowRight',
|
|
3826
3832
|
keyNavigationPrevious: 'ArrowLeft'
|
|
3827
3833
|
}; // eslint-disable-next-line import/no-mutable-exports
|
|
3828
3834
|
|
|
3829
|
-
var validatePropTypes
|
|
3835
|
+
var validatePropTypes = noop;
|
|
3830
3836
|
/* istanbul ignore next */
|
|
3831
3837
|
|
|
3832
3838
|
if (process.env.NODE_ENV !== 'production') {
|
|
3833
|
-
validatePropTypes
|
|
3834
|
-
PropTypes__default['default'].checkPropTypes(propTypes
|
|
3839
|
+
validatePropTypes = function validatePropTypes(options, caller) {
|
|
3840
|
+
PropTypes__default['default'].checkPropTypes(propTypes, options, 'prop', caller.name);
|
|
3835
3841
|
};
|
|
3836
3842
|
}
|
|
3837
3843
|
|
|
@@ -3847,9 +3853,9 @@ var FunctionAddSelectedItem = process.env.NODE_ENV !== "production" ? '__functio
|
|
|
3847
3853
|
var FunctionRemoveSelectedItem = process.env.NODE_ENV !== "production" ? '__function_remove_selected_item__' : 9;
|
|
3848
3854
|
var FunctionSetSelectedItems = process.env.NODE_ENV !== "production" ? '__function_set_selected_items__' : 10;
|
|
3849
3855
|
var FunctionSetActiveIndex = process.env.NODE_ENV !== "production" ? '__function_set_active_index__' : 11;
|
|
3850
|
-
var FunctionReset
|
|
3856
|
+
var FunctionReset = process.env.NODE_ENV !== "production" ? '__function_reset__' : 12;
|
|
3851
3857
|
|
|
3852
|
-
var stateChangeTypes
|
|
3858
|
+
var stateChangeTypes = /*#__PURE__*/Object.freeze({
|
|
3853
3859
|
__proto__: null,
|
|
3854
3860
|
SelectedItemClick: SelectedItemClick,
|
|
3855
3861
|
SelectedItemKeyDownDelete: SelectedItemKeyDownDelete,
|
|
@@ -3863,7 +3869,7 @@ var stateChangeTypes$3 = /*#__PURE__*/Object.freeze({
|
|
|
3863
3869
|
FunctionRemoveSelectedItem: FunctionRemoveSelectedItem,
|
|
3864
3870
|
FunctionSetSelectedItems: FunctionSetSelectedItems,
|
|
3865
3871
|
FunctionSetActiveIndex: FunctionSetActiveIndex,
|
|
3866
|
-
FunctionReset: FunctionReset
|
|
3872
|
+
FunctionReset: FunctionReset
|
|
3867
3873
|
});
|
|
3868
3874
|
|
|
3869
3875
|
/* eslint-disable complexity */
|
|
@@ -3976,10 +3982,10 @@ function downshiftMultipleSelectionReducer(state, action) {
|
|
|
3976
3982
|
break;
|
|
3977
3983
|
}
|
|
3978
3984
|
|
|
3979
|
-
case FunctionReset
|
|
3985
|
+
case FunctionReset:
|
|
3980
3986
|
changes = {
|
|
3981
|
-
activeIndex: getDefaultValue
|
|
3982
|
-
selectedItems: getDefaultValue
|
|
3987
|
+
activeIndex: getDefaultValue(props, 'activeIndex'),
|
|
3988
|
+
selectedItems: getDefaultValue(props, 'selectedItems')
|
|
3983
3989
|
};
|
|
3984
3990
|
break;
|
|
3985
3991
|
|
|
@@ -3990,16 +3996,16 @@ function downshiftMultipleSelectionReducer(state, action) {
|
|
|
3990
3996
|
return _extends__default['default']({}, state, changes);
|
|
3991
3997
|
}
|
|
3992
3998
|
|
|
3993
|
-
useMultipleSelection.stateChangeTypes = stateChangeTypes
|
|
3999
|
+
useMultipleSelection.stateChangeTypes = stateChangeTypes;
|
|
3994
4000
|
|
|
3995
4001
|
function useMultipleSelection(userProps) {
|
|
3996
4002
|
if (userProps === void 0) {
|
|
3997
4003
|
userProps = {};
|
|
3998
4004
|
}
|
|
3999
4005
|
|
|
4000
|
-
validatePropTypes
|
|
4006
|
+
validatePropTypes(userProps, useMultipleSelection); // Props defaults and destructuring.
|
|
4001
4007
|
|
|
4002
|
-
var props = _extends__default['default']({}, defaultProps
|
|
4008
|
+
var props = _extends__default['default']({}, defaultProps, userProps);
|
|
4003
4009
|
|
|
4004
4010
|
var getA11yRemovalMessage = props.getA11yRemovalMessage,
|
|
4005
4011
|
itemToString = props.itemToString,
|
|
@@ -4007,7 +4013,7 @@ function useMultipleSelection(userProps) {
|
|
|
4007
4013
|
keyNavigationNext = props.keyNavigationNext,
|
|
4008
4014
|
keyNavigationPrevious = props.keyNavigationPrevious; // Reducer init.
|
|
4009
4015
|
|
|
4010
|
-
var _useControlledReducer = useControlledReducer(downshiftMultipleSelectionReducer, getInitialState
|
|
4016
|
+
var _useControlledReducer = useControlledReducer$1(downshiftMultipleSelectionReducer, getInitialState(props), props),
|
|
4011
4017
|
state = _useControlledReducer[0],
|
|
4012
4018
|
dispatch = _useControlledReducer[1];
|
|
4013
4019
|
|
|
@@ -4218,7 +4224,7 @@ function useMultipleSelection(userProps) {
|
|
|
4218
4224
|
}, [dispatch]);
|
|
4219
4225
|
var reset = react.useCallback(function () {
|
|
4220
4226
|
dispatch({
|
|
4221
|
-
type: FunctionReset
|
|
4227
|
+
type: FunctionReset
|
|
4222
4228
|
});
|
|
4223
4229
|
}, [dispatch]);
|
|
4224
4230
|
return {
|