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
|
@@ -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;
|
|
@@ -409,20 +411,20 @@ function getNextNonDisabledIndex(moveAmount, baseIndex, itemCount, getItemNodeFr
|
|
|
409
411
|
*
|
|
410
412
|
* @param {EventTarget} target Target to check.
|
|
411
413
|
* @param {HTMLElement[]} downshiftElements The elements that form downshift (list, toggle button etc).
|
|
412
|
-
* @param {
|
|
414
|
+
* @param {Window} environment The window context where downshift renders.
|
|
413
415
|
* @param {boolean} checkActiveElement Whether to also check activeElement.
|
|
414
416
|
*
|
|
415
417
|
* @returns {boolean} Whether or not the target is within downshift elements.
|
|
416
418
|
*/
|
|
417
419
|
|
|
418
420
|
|
|
419
|
-
function targetWithinDownshift(target, downshiftElements,
|
|
421
|
+
function targetWithinDownshift(target, downshiftElements, environment, checkActiveElement) {
|
|
420
422
|
if (checkActiveElement === void 0) {
|
|
421
423
|
checkActiveElement = true;
|
|
422
424
|
}
|
|
423
425
|
|
|
424
426
|
return downshiftElements.some(function (contextNode) {
|
|
425
|
-
return contextNode && (isOrContainsNode(contextNode, target) || checkActiveElement && isOrContainsNode(contextNode, document.activeElement));
|
|
427
|
+
return contextNode && (isOrContainsNode(contextNode, target, environment) || checkActiveElement && isOrContainsNode(contextNode, environment.document.activeElement, environment));
|
|
426
428
|
});
|
|
427
429
|
} // eslint-disable-next-line import/no-mutable-exports
|
|
428
430
|
|
|
@@ -518,7 +520,7 @@ var blurButton = process.env.NODE_ENV !== "production" ? '__autocomplete_blur_bu
|
|
|
518
520
|
var controlledPropUpdatedSelectedItem = process.env.NODE_ENV !== "production" ? '__autocomplete_controlled_prop_updated_selected_item__' : 15;
|
|
519
521
|
var touchEnd = process.env.NODE_ENV !== "production" ? '__autocomplete_touchend__' : 16;
|
|
520
522
|
|
|
521
|
-
var stateChangeTypes = /*#__PURE__*/Object.freeze({
|
|
523
|
+
var stateChangeTypes$3 = /*#__PURE__*/Object.freeze({
|
|
522
524
|
__proto__: null,
|
|
523
525
|
unknown: unknown,
|
|
524
526
|
mouseUp: mouseUp,
|
|
@@ -911,9 +913,9 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
911
913
|
|
|
912
914
|
_this.getToggleButtonProps = function (_temp3) {
|
|
913
915
|
var _ref3 = _temp3 === void 0 ? {} : _temp3,
|
|
914
|
-
onClick = _ref3.onClick
|
|
915
|
-
|
|
916
|
-
onKeyDown = _ref3.onKeyDown,
|
|
916
|
+
onClick = _ref3.onClick;
|
|
917
|
+
_ref3.onPress;
|
|
918
|
+
var onKeyDown = _ref3.onKeyDown,
|
|
917
919
|
onKeyUp = _ref3.onKeyUp,
|
|
918
920
|
onBlur = _ref3.onBlur,
|
|
919
921
|
rest = _objectWithoutPropertiesLoose(_ref3, ["onClick", "onPress", "onKeyDown", "onKeyUp", "onBlur"]);
|
|
@@ -921,7 +923,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
921
923
|
var _this$getState5 = _this.getState(),
|
|
922
924
|
isOpen = _this$getState5.isOpen;
|
|
923
925
|
|
|
924
|
-
var enabledEventHandlers =
|
|
926
|
+
var enabledEventHandlers = {
|
|
925
927
|
onClick: callAllEventHandlers(onClick, _this.buttonHandleClick),
|
|
926
928
|
onKeyDown: callAllEventHandlers(onKeyDown, _this.buttonHandleKeyDown),
|
|
927
929
|
onKeyUp: callAllEventHandlers(onKeyUp, _this.buttonHandleKeyUp),
|
|
@@ -956,7 +958,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
956
958
|
|
|
957
959
|
/* istanbul ignore if (can't reasonably test this) */
|
|
958
960
|
|
|
959
|
-
if (
|
|
961
|
+
if (_this.props.environment.document.activeElement === _this.props.environment.document.body) {
|
|
960
962
|
event.target.focus();
|
|
961
963
|
} // to simplify testing components that use downshift, we'll not wrap this in a setTimeout
|
|
962
964
|
// if the NODE_ENV is test. With the proper build system, this should be dead code eliminated
|
|
@@ -1003,9 +1005,9 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1003
1005
|
onKeyDown = _ref4.onKeyDown,
|
|
1004
1006
|
onBlur = _ref4.onBlur,
|
|
1005
1007
|
onChange = _ref4.onChange,
|
|
1006
|
-
onInput = _ref4.onInput
|
|
1007
|
-
|
|
1008
|
-
rest = _objectWithoutPropertiesLoose(_ref4, ["onKeyDown", "onBlur", "onChange", "onInput", "onChangeText"]);
|
|
1008
|
+
onInput = _ref4.onInput;
|
|
1009
|
+
_ref4.onChangeText;
|
|
1010
|
+
var rest = _objectWithoutPropertiesLoose(_ref4, ["onKeyDown", "onBlur", "onChange", "onInput", "onChangeText"]);
|
|
1009
1011
|
|
|
1010
1012
|
var onChangeKey;
|
|
1011
1013
|
var eventHandlers = {};
|
|
@@ -1051,7 +1053,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1051
1053
|
_this.internalSetState({
|
|
1052
1054
|
type: changeInput,
|
|
1053
1055
|
isOpen: true,
|
|
1054
|
-
inputValue:
|
|
1056
|
+
inputValue: event.target.value,
|
|
1055
1057
|
highlightedIndex: _this.props.defaultHighlightedIndex
|
|
1056
1058
|
});
|
|
1057
1059
|
};
|
|
@@ -1098,9 +1100,9 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1098
1100
|
var _ref7 = _temp7 === void 0 ? {} : _temp7,
|
|
1099
1101
|
onMouseMove = _ref7.onMouseMove,
|
|
1100
1102
|
onMouseDown = _ref7.onMouseDown,
|
|
1101
|
-
onClick = _ref7.onClick
|
|
1102
|
-
|
|
1103
|
-
index = _ref7.index,
|
|
1103
|
+
onClick = _ref7.onClick;
|
|
1104
|
+
_ref7.onPress;
|
|
1105
|
+
var index = _ref7.index,
|
|
1104
1106
|
_ref7$item = _ref7.item,
|
|
1105
1107
|
item = _ref7$item === void 0 ? process.env.NODE_ENV === 'production' ?
|
|
1106
1108
|
/* istanbul ignore next */
|
|
@@ -1115,8 +1117,8 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1115
1117
|
_this.items[index] = item;
|
|
1116
1118
|
}
|
|
1117
1119
|
|
|
1118
|
-
var onSelectKey =
|
|
1119
|
-
var customClickHandler =
|
|
1120
|
+
var onSelectKey = 'onClick';
|
|
1121
|
+
var customClickHandler = onClick;
|
|
1120
1122
|
var enabledEventHandlers = (_enabledEventHandlers = {
|
|
1121
1123
|
// onMouseMove is used over onMouseEnter here. onMouseMove
|
|
1122
1124
|
// is only triggered on actual mouse movement while onMouseEnter
|
|
@@ -1431,7 +1433,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1431
1433
|
_this7.isMouseDown = false; // if the target element or the activeElement is within a downshift node
|
|
1432
1434
|
// then we don't want to reset downshift
|
|
1433
1435
|
|
|
1434
|
-
var contextWithinDownshift = targetWithinDownshift(event.target, [_this7._rootNode, _this7._menuNode], _this7.props.environment
|
|
1436
|
+
var contextWithinDownshift = targetWithinDownshift(event.target, [_this7._rootNode, _this7._menuNode], _this7.props.environment);
|
|
1435
1437
|
|
|
1436
1438
|
if (!contextWithinDownshift && _this7.getState().isOpen) {
|
|
1437
1439
|
_this7.reset({
|
|
@@ -1457,7 +1459,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1457
1459
|
};
|
|
1458
1460
|
|
|
1459
1461
|
var onTouchEnd = function onTouchEnd(event) {
|
|
1460
|
-
var contextWithinDownshift = targetWithinDownshift(event.target, [_this7._rootNode, _this7._menuNode], _this7.props.environment
|
|
1462
|
+
var contextWithinDownshift = targetWithinDownshift(event.target, [_this7._rootNode, _this7._menuNode], _this7.props.environment, false);
|
|
1461
1463
|
|
|
1462
1464
|
if (!_this7.isTouchMove && !contextWithinDownshift && _this7.getState().isOpen) {
|
|
1463
1465
|
_this7.reset({
|
|
@@ -1506,7 +1508,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1506
1508
|
validateControlledUnchanged(this.state, prevProps, this.props);
|
|
1507
1509
|
/* istanbul ignore if (react-native) */
|
|
1508
1510
|
|
|
1509
|
-
if (
|
|
1511
|
+
if (this.getMenuProps.called && !this.getMenuProps.suppressRefError) {
|
|
1510
1512
|
validateGetMenuPropsCalledCorrectly(this._menuNode, this.getMenuProps);
|
|
1511
1513
|
}
|
|
1512
1514
|
}
|
|
@@ -1591,7 +1593,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1591
1593
|
Downshift.defaultProps = {
|
|
1592
1594
|
defaultHighlightedIndex: null,
|
|
1593
1595
|
defaultIsOpen: false,
|
|
1594
|
-
getA11yStatusMessage: getA11yStatusMessage,
|
|
1596
|
+
getA11yStatusMessage: getA11yStatusMessage$1,
|
|
1595
1597
|
itemToString: function itemToString(i) {
|
|
1596
1598
|
if (i == null) {
|
|
1597
1599
|
return '';
|
|
@@ -1622,7 +1624,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1622
1624
|
suppressRefError: false,
|
|
1623
1625
|
scrollIntoView: scrollIntoView
|
|
1624
1626
|
};
|
|
1625
|
-
Downshift.stateChangeTypes = stateChangeTypes;
|
|
1627
|
+
Downshift.stateChangeTypes = stateChangeTypes$3;
|
|
1626
1628
|
return Downshift;
|
|
1627
1629
|
}();
|
|
1628
1630
|
|
|
@@ -1837,7 +1839,7 @@ function useEnhancedReducer(reducer, initialState, props) {
|
|
|
1837
1839
|
*/
|
|
1838
1840
|
|
|
1839
1841
|
|
|
1840
|
-
function useControlledReducer(reducer, initialState, props) {
|
|
1842
|
+
function useControlledReducer$1(reducer, initialState, props) {
|
|
1841
1843
|
var _useEnhancedReducer = useEnhancedReducer(reducer, initialState, props),
|
|
1842
1844
|
state = _useEnhancedReducer[0],
|
|
1843
1845
|
dispatch = _useEnhancedReducer[1];
|
|
@@ -1845,7 +1847,7 @@ function useControlledReducer(reducer, initialState, props) {
|
|
|
1845
1847
|
return [getState(state, props), dispatch];
|
|
1846
1848
|
}
|
|
1847
1849
|
|
|
1848
|
-
var defaultProps = {
|
|
1850
|
+
var defaultProps$3 = {
|
|
1849
1851
|
itemToString: itemToString,
|
|
1850
1852
|
stateReducer: stateReducer,
|
|
1851
1853
|
getA11ySelectionMessage: getA11ySelectionMessage,
|
|
@@ -1856,7 +1858,7 @@ var defaultProps = {
|
|
|
1856
1858
|
? {} : window
|
|
1857
1859
|
};
|
|
1858
1860
|
|
|
1859
|
-
function getDefaultValue(props, propKey, defaultStateValues) {
|
|
1861
|
+
function getDefaultValue$1(props, propKey, defaultStateValues) {
|
|
1860
1862
|
if (defaultStateValues === void 0) {
|
|
1861
1863
|
defaultStateValues = dropdownDefaultStateValues;
|
|
1862
1864
|
}
|
|
@@ -1870,7 +1872,7 @@ function getDefaultValue(props, propKey, defaultStateValues) {
|
|
|
1870
1872
|
return defaultStateValues[propKey];
|
|
1871
1873
|
}
|
|
1872
1874
|
|
|
1873
|
-
function getInitialValue(props, propKey, defaultStateValues) {
|
|
1875
|
+
function getInitialValue$1(props, propKey, defaultStateValues) {
|
|
1874
1876
|
if (defaultStateValues === void 0) {
|
|
1875
1877
|
defaultStateValues = dropdownDefaultStateValues;
|
|
1876
1878
|
}
|
|
@@ -1885,14 +1887,14 @@ function getInitialValue(props, propKey, defaultStateValues) {
|
|
|
1885
1887
|
return props[initialPropKey];
|
|
1886
1888
|
}
|
|
1887
1889
|
|
|
1888
|
-
return getDefaultValue(props, propKey, defaultStateValues);
|
|
1890
|
+
return getDefaultValue$1(props, propKey, defaultStateValues);
|
|
1889
1891
|
}
|
|
1890
1892
|
|
|
1891
|
-
function getInitialState(props) {
|
|
1892
|
-
var selectedItem = getInitialValue(props, 'selectedItem');
|
|
1893
|
-
var isOpen = getInitialValue(props, 'isOpen');
|
|
1894
|
-
var highlightedIndex = getInitialValue(props, 'highlightedIndex');
|
|
1895
|
-
var inputValue = getInitialValue(props, 'inputValue');
|
|
1893
|
+
function getInitialState$2(props) {
|
|
1894
|
+
var selectedItem = getInitialValue$1(props, 'selectedItem');
|
|
1895
|
+
var isOpen = getInitialValue$1(props, 'isOpen');
|
|
1896
|
+
var highlightedIndex = getInitialValue$1(props, 'highlightedIndex');
|
|
1897
|
+
var inputValue = getInitialValue$1(props, 'inputValue');
|
|
1896
1898
|
return {
|
|
1897
1899
|
highlightedIndex: highlightedIndex < 0 && selectedItem && isOpen ? props.items.indexOf(selectedItem) : highlightedIndex,
|
|
1898
1900
|
isOpen: isOpen,
|
|
@@ -1963,7 +1965,7 @@ function useMouseAndTouchTracker(isOpen, downshiftElementRefs, environment, hand
|
|
|
1963
1965
|
|
|
1964
1966
|
if (isOpen && !targetWithinDownshift(event.target, downshiftElementRefs.map(function (ref) {
|
|
1965
1967
|
return ref.current;
|
|
1966
|
-
}), environment
|
|
1968
|
+
}), environment)) {
|
|
1967
1969
|
handleBlur();
|
|
1968
1970
|
}
|
|
1969
1971
|
};
|
|
@@ -1979,7 +1981,7 @@ function useMouseAndTouchTracker(isOpen, downshiftElementRefs, environment, hand
|
|
|
1979
1981
|
var onTouchEnd = function onTouchEnd(event) {
|
|
1980
1982
|
if (isOpen && !mouseAndTouchTrackersRef.current.isTouchMove && !targetWithinDownshift(event.target, downshiftElementRefs.map(function (ref) {
|
|
1981
1983
|
return ref.current;
|
|
1982
|
-
}), environment
|
|
1984
|
+
}), environment, false)) {
|
|
1983
1985
|
handleBlur();
|
|
1984
1986
|
}
|
|
1985
1987
|
};
|
|
@@ -2187,10 +2189,10 @@ function downshiftCommonReducer(state, action, stateChangeTypes) {
|
|
|
2187
2189
|
|
|
2188
2190
|
case stateChangeTypes.FunctionReset:
|
|
2189
2191
|
changes = {
|
|
2190
|
-
highlightedIndex: getDefaultValue(props, 'highlightedIndex'),
|
|
2191
|
-
isOpen: getDefaultValue(props, 'isOpen'),
|
|
2192
|
-
selectedItem: getDefaultValue(props, 'selectedItem'),
|
|
2193
|
-
inputValue: getDefaultValue(props, 'inputValue')
|
|
2192
|
+
highlightedIndex: getDefaultValue$1(props, 'highlightedIndex'),
|
|
2193
|
+
isOpen: getDefaultValue$1(props, 'isOpen'),
|
|
2194
|
+
selectedItem: getDefaultValue$1(props, 'selectedItem'),
|
|
2195
|
+
inputValue: getDefaultValue$1(props, 'inputValue')
|
|
2194
2196
|
};
|
|
2195
2197
|
break;
|
|
2196
2198
|
|
|
@@ -2220,7 +2222,7 @@ function getItemIndexByCharacterKey(keysSoFar, highlightedIndex, items, itemToSt
|
|
|
2220
2222
|
return highlightedIndex;
|
|
2221
2223
|
}
|
|
2222
2224
|
|
|
2223
|
-
var propTypes = {
|
|
2225
|
+
var propTypes$2 = {
|
|
2224
2226
|
items: PropTypes.array.isRequired,
|
|
2225
2227
|
itemToString: PropTypes.func,
|
|
2226
2228
|
getA11yStatusMessage: PropTypes.func,
|
|
@@ -2264,7 +2266,7 @@ var propTypes = {
|
|
|
2264
2266
|
* @return {String} the a11y status message
|
|
2265
2267
|
*/
|
|
2266
2268
|
|
|
2267
|
-
function getA11yStatusMessage
|
|
2269
|
+
function getA11yStatusMessage(_ref) {
|
|
2268
2270
|
var isOpen = _ref.isOpen,
|
|
2269
2271
|
resultCount = _ref.resultCount,
|
|
2270
2272
|
previousResultCount = _ref.previousResultCount;
|
|
@@ -2284,17 +2286,17 @@ function getA11yStatusMessage$1(_ref) {
|
|
|
2284
2286
|
return '';
|
|
2285
2287
|
}
|
|
2286
2288
|
|
|
2287
|
-
var defaultProps$
|
|
2288
|
-
getA11yStatusMessage: getA11yStatusMessage
|
|
2289
|
+
var defaultProps$2 = _extends({}, defaultProps$3, {
|
|
2290
|
+
getA11yStatusMessage: getA11yStatusMessage
|
|
2289
2291
|
}); // eslint-disable-next-line import/no-mutable-exports
|
|
2290
2292
|
|
|
2291
2293
|
|
|
2292
|
-
var validatePropTypes = noop;
|
|
2294
|
+
var validatePropTypes$2 = noop;
|
|
2293
2295
|
/* istanbul ignore next */
|
|
2294
2296
|
|
|
2295
2297
|
if (process.env.NODE_ENV !== 'production') {
|
|
2296
|
-
validatePropTypes = function validatePropTypes(options, caller) {
|
|
2297
|
-
PropTypes.checkPropTypes(propTypes, options, 'prop', caller.name);
|
|
2298
|
+
validatePropTypes$2 = function validatePropTypes(options, caller) {
|
|
2299
|
+
PropTypes.checkPropTypes(propTypes$2, options, 'prop', caller.name);
|
|
2298
2300
|
};
|
|
2299
2301
|
}
|
|
2300
2302
|
|
|
@@ -2307,22 +2309,22 @@ var MenuKeyDownEnter = process.env.NODE_ENV !== "production" ? '__menu_keydown_e
|
|
|
2307
2309
|
var MenuKeyDownSpaceButton = process.env.NODE_ENV !== "production" ? '__menu_keydown_space_button__' : 6;
|
|
2308
2310
|
var MenuKeyDownCharacter = process.env.NODE_ENV !== "production" ? '__menu_keydown_character__' : 7;
|
|
2309
2311
|
var MenuBlur = process.env.NODE_ENV !== "production" ? '__menu_blur__' : 8;
|
|
2310
|
-
var MenuMouseLeave = process.env.NODE_ENV !== "production" ? '__menu_mouse_leave__' : 9;
|
|
2311
|
-
var ItemMouseMove = process.env.NODE_ENV !== "production" ? '__item_mouse_move__' : 10;
|
|
2312
|
-
var ItemClick = process.env.NODE_ENV !== "production" ? '__item_click__' : 11;
|
|
2313
|
-
var ToggleButtonClick = process.env.NODE_ENV !== "production" ? '__togglebutton_click__' : 12;
|
|
2312
|
+
var MenuMouseLeave$1 = process.env.NODE_ENV !== "production" ? '__menu_mouse_leave__' : 9;
|
|
2313
|
+
var ItemMouseMove$1 = process.env.NODE_ENV !== "production" ? '__item_mouse_move__' : 10;
|
|
2314
|
+
var ItemClick$1 = process.env.NODE_ENV !== "production" ? '__item_click__' : 11;
|
|
2315
|
+
var ToggleButtonClick$1 = process.env.NODE_ENV !== "production" ? '__togglebutton_click__' : 12;
|
|
2314
2316
|
var ToggleButtonKeyDownArrowDown = process.env.NODE_ENV !== "production" ? '__togglebutton_keydown_arrow_down__' : 13;
|
|
2315
2317
|
var ToggleButtonKeyDownArrowUp = process.env.NODE_ENV !== "production" ? '__togglebutton_keydown_arrow_up__' : 14;
|
|
2316
2318
|
var ToggleButtonKeyDownCharacter = process.env.NODE_ENV !== "production" ? '__togglebutton_keydown_character__' : 15;
|
|
2317
|
-
var FunctionToggleMenu = process.env.NODE_ENV !== "production" ? '__function_toggle_menu__' : 16;
|
|
2318
|
-
var FunctionOpenMenu = process.env.NODE_ENV !== "production" ? '__function_open_menu__' : 17;
|
|
2319
|
-
var FunctionCloseMenu = process.env.NODE_ENV !== "production" ? '__function_close_menu__' : 18;
|
|
2320
|
-
var FunctionSetHighlightedIndex = process.env.NODE_ENV !== "production" ? '__function_set_highlighted_index__' : 19;
|
|
2321
|
-
var FunctionSelectItem = process.env.NODE_ENV !== "production" ? '__function_select_item__' : 20;
|
|
2322
|
-
var FunctionSetInputValue = process.env.NODE_ENV !== "production" ? '__function_set_input_value__' : 21;
|
|
2323
|
-
var FunctionReset = process.env.NODE_ENV !== "production" ? '__function_reset__' : 22;
|
|
2319
|
+
var FunctionToggleMenu$1 = process.env.NODE_ENV !== "production" ? '__function_toggle_menu__' : 16;
|
|
2320
|
+
var FunctionOpenMenu$1 = process.env.NODE_ENV !== "production" ? '__function_open_menu__' : 17;
|
|
2321
|
+
var FunctionCloseMenu$1 = process.env.NODE_ENV !== "production" ? '__function_close_menu__' : 18;
|
|
2322
|
+
var FunctionSetHighlightedIndex$1 = process.env.NODE_ENV !== "production" ? '__function_set_highlighted_index__' : 19;
|
|
2323
|
+
var FunctionSelectItem$1 = process.env.NODE_ENV !== "production" ? '__function_select_item__' : 20;
|
|
2324
|
+
var FunctionSetInputValue$1 = process.env.NODE_ENV !== "production" ? '__function_set_input_value__' : 21;
|
|
2325
|
+
var FunctionReset$2 = process.env.NODE_ENV !== "production" ? '__function_reset__' : 22;
|
|
2324
2326
|
|
|
2325
|
-
var stateChangeTypes$
|
|
2327
|
+
var stateChangeTypes$2 = /*#__PURE__*/Object.freeze({
|
|
2326
2328
|
__proto__: null,
|
|
2327
2329
|
MenuKeyDownArrowDown: MenuKeyDownArrowDown,
|
|
2328
2330
|
MenuKeyDownArrowUp: MenuKeyDownArrowUp,
|
|
@@ -2333,20 +2335,20 @@ var stateChangeTypes$1 = /*#__PURE__*/Object.freeze({
|
|
|
2333
2335
|
MenuKeyDownSpaceButton: MenuKeyDownSpaceButton,
|
|
2334
2336
|
MenuKeyDownCharacter: MenuKeyDownCharacter,
|
|
2335
2337
|
MenuBlur: MenuBlur,
|
|
2336
|
-
MenuMouseLeave: MenuMouseLeave,
|
|
2337
|
-
ItemMouseMove: ItemMouseMove,
|
|
2338
|
-
ItemClick: ItemClick,
|
|
2339
|
-
ToggleButtonClick: ToggleButtonClick,
|
|
2338
|
+
MenuMouseLeave: MenuMouseLeave$1,
|
|
2339
|
+
ItemMouseMove: ItemMouseMove$1,
|
|
2340
|
+
ItemClick: ItemClick$1,
|
|
2341
|
+
ToggleButtonClick: ToggleButtonClick$1,
|
|
2340
2342
|
ToggleButtonKeyDownArrowDown: ToggleButtonKeyDownArrowDown,
|
|
2341
2343
|
ToggleButtonKeyDownArrowUp: ToggleButtonKeyDownArrowUp,
|
|
2342
2344
|
ToggleButtonKeyDownCharacter: ToggleButtonKeyDownCharacter,
|
|
2343
|
-
FunctionToggleMenu: FunctionToggleMenu,
|
|
2344
|
-
FunctionOpenMenu: FunctionOpenMenu,
|
|
2345
|
-
FunctionCloseMenu: FunctionCloseMenu,
|
|
2346
|
-
FunctionSetHighlightedIndex: FunctionSetHighlightedIndex,
|
|
2347
|
-
FunctionSelectItem: FunctionSelectItem,
|
|
2348
|
-
FunctionSetInputValue: FunctionSetInputValue,
|
|
2349
|
-
FunctionReset: FunctionReset
|
|
2345
|
+
FunctionToggleMenu: FunctionToggleMenu$1,
|
|
2346
|
+
FunctionOpenMenu: FunctionOpenMenu$1,
|
|
2347
|
+
FunctionCloseMenu: FunctionCloseMenu$1,
|
|
2348
|
+
FunctionSetHighlightedIndex: FunctionSetHighlightedIndex$1,
|
|
2349
|
+
FunctionSelectItem: FunctionSelectItem$1,
|
|
2350
|
+
FunctionSetInputValue: FunctionSetInputValue$1,
|
|
2351
|
+
FunctionReset: FunctionReset$2
|
|
2350
2352
|
});
|
|
2351
2353
|
|
|
2352
2354
|
/* eslint-disable complexity */
|
|
@@ -2358,10 +2360,10 @@ function downshiftSelectReducer(state, action) {
|
|
|
2358
2360
|
var changes;
|
|
2359
2361
|
|
|
2360
2362
|
switch (type) {
|
|
2361
|
-
case ItemClick:
|
|
2363
|
+
case ItemClick$1:
|
|
2362
2364
|
changes = {
|
|
2363
|
-
isOpen: getDefaultValue(props, 'isOpen'),
|
|
2364
|
-
highlightedIndex: getDefaultValue(props, 'highlightedIndex'),
|
|
2365
|
+
isOpen: getDefaultValue$1(props, 'isOpen'),
|
|
2366
|
+
highlightedIndex: getDefaultValue$1(props, 'highlightedIndex'),
|
|
2365
2367
|
selectedItem: props.items[action.index]
|
|
2366
2368
|
};
|
|
2367
2369
|
break;
|
|
@@ -2396,8 +2398,8 @@ function downshiftSelectReducer(state, action) {
|
|
|
2396
2398
|
case MenuKeyDownEnter:
|
|
2397
2399
|
case MenuKeyDownSpaceButton:
|
|
2398
2400
|
changes = _extends({
|
|
2399
|
-
isOpen: getDefaultValue(props, 'isOpen'),
|
|
2400
|
-
highlightedIndex: getDefaultValue(props, 'highlightedIndex')
|
|
2401
|
+
isOpen: getDefaultValue$1(props, 'isOpen'),
|
|
2402
|
+
highlightedIndex: getDefaultValue$1(props, 'highlightedIndex')
|
|
2401
2403
|
}, state.highlightedIndex >= 0 && {
|
|
2402
2404
|
selectedItem: props.items[state.highlightedIndex]
|
|
2403
2405
|
});
|
|
@@ -2456,30 +2458,30 @@ function downshiftSelectReducer(state, action) {
|
|
|
2456
2458
|
};
|
|
2457
2459
|
break;
|
|
2458
2460
|
|
|
2459
|
-
case FunctionSelectItem:
|
|
2461
|
+
case FunctionSelectItem$1:
|
|
2460
2462
|
changes = {
|
|
2461
2463
|
selectedItem: action.selectedItem
|
|
2462
2464
|
};
|
|
2463
2465
|
break;
|
|
2464
2466
|
|
|
2465
2467
|
default:
|
|
2466
|
-
return downshiftCommonReducer(state, action, stateChangeTypes$
|
|
2468
|
+
return downshiftCommonReducer(state, action, stateChangeTypes$2);
|
|
2467
2469
|
}
|
|
2468
2470
|
|
|
2469
2471
|
return _extends({}, state, changes);
|
|
2470
2472
|
}
|
|
2471
2473
|
/* eslint-enable complexity */
|
|
2472
2474
|
|
|
2473
|
-
useSelect.stateChangeTypes = stateChangeTypes$
|
|
2475
|
+
useSelect.stateChangeTypes = stateChangeTypes$2;
|
|
2474
2476
|
|
|
2475
2477
|
function useSelect(userProps) {
|
|
2476
2478
|
if (userProps === void 0) {
|
|
2477
2479
|
userProps = {};
|
|
2478
2480
|
}
|
|
2479
2481
|
|
|
2480
|
-
validatePropTypes(userProps, useSelect); // Props defaults and destructuring.
|
|
2482
|
+
validatePropTypes$2(userProps, useSelect); // Props defaults and destructuring.
|
|
2481
2483
|
|
|
2482
|
-
var props = _extends({}, defaultProps$
|
|
2484
|
+
var props = _extends({}, defaultProps$2, userProps);
|
|
2483
2485
|
|
|
2484
2486
|
var items = props.items,
|
|
2485
2487
|
scrollIntoView = props.scrollIntoView,
|
|
@@ -2490,9 +2492,9 @@ function useSelect(userProps) {
|
|
|
2490
2492
|
getA11ySelectionMessage = props.getA11ySelectionMessage,
|
|
2491
2493
|
getA11yStatusMessage = props.getA11yStatusMessage; // Initial state depending on controlled props.
|
|
2492
2494
|
|
|
2493
|
-
var initialState = getInitialState(props);
|
|
2495
|
+
var initialState = getInitialState$2(props);
|
|
2494
2496
|
|
|
2495
|
-
var _useControlledReducer = useControlledReducer(downshiftSelectReducer, initialState, props),
|
|
2497
|
+
var _useControlledReducer = useControlledReducer$1(downshiftSelectReducer, initialState, props),
|
|
2496
2498
|
state = _useControlledReducer[0],
|
|
2497
2499
|
dispatch = _useControlledReducer[1];
|
|
2498
2500
|
|
|
@@ -2547,19 +2549,23 @@ function useSelect(userProps) {
|
|
|
2547
2549
|
itemRefs: itemRefs,
|
|
2548
2550
|
scrollIntoView: scrollIntoView,
|
|
2549
2551
|
getItemNodeFromIndex: getItemNodeFromIndex
|
|
2550
|
-
}); // Sets cleanup for the keysSoFar after 500ms.
|
|
2552
|
+
}); // Sets cleanup for the keysSoFar callback, debounded after 500ms.
|
|
2551
2553
|
|
|
2552
2554
|
useEffect(function () {
|
|
2553
2555
|
// init the clean function here as we need access to dispatch.
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2556
|
+
clearTimeoutRef.current = debounce(function (outerDispatch) {
|
|
2557
|
+
outerDispatch({
|
|
2558
|
+
type: FunctionSetInputValue$1,
|
|
2559
|
+
inputValue: ''
|
|
2560
|
+
});
|
|
2561
|
+
}, 500); // Cancel any pending debounced calls on mount
|
|
2562
|
+
|
|
2563
|
+
return function () {
|
|
2564
|
+
clearTimeoutRef.current.cancel();
|
|
2565
|
+
};
|
|
2566
|
+
}, []); // Invokes the keysSoFar callback set up above.
|
|
2562
2567
|
|
|
2568
|
+
useEffect(function () {
|
|
2563
2569
|
if (!inputValue) {
|
|
2564
2570
|
return;
|
|
2565
2571
|
}
|
|
@@ -2703,39 +2709,39 @@ function useSelect(userProps) {
|
|
|
2703
2709
|
|
|
2704
2710
|
var toggleMenu = useCallback(function () {
|
|
2705
2711
|
dispatch({
|
|
2706
|
-
type: FunctionToggleMenu
|
|
2712
|
+
type: FunctionToggleMenu$1
|
|
2707
2713
|
});
|
|
2708
2714
|
}, [dispatch]);
|
|
2709
2715
|
var closeMenu = useCallback(function () {
|
|
2710
2716
|
dispatch({
|
|
2711
|
-
type: FunctionCloseMenu
|
|
2717
|
+
type: FunctionCloseMenu$1
|
|
2712
2718
|
});
|
|
2713
2719
|
}, [dispatch]);
|
|
2714
2720
|
var openMenu = useCallback(function () {
|
|
2715
2721
|
dispatch({
|
|
2716
|
-
type: FunctionOpenMenu
|
|
2722
|
+
type: FunctionOpenMenu$1
|
|
2717
2723
|
});
|
|
2718
2724
|
}, [dispatch]);
|
|
2719
2725
|
var setHighlightedIndex = useCallback(function (newHighlightedIndex) {
|
|
2720
2726
|
dispatch({
|
|
2721
|
-
type: FunctionSetHighlightedIndex,
|
|
2727
|
+
type: FunctionSetHighlightedIndex$1,
|
|
2722
2728
|
highlightedIndex: newHighlightedIndex
|
|
2723
2729
|
});
|
|
2724
2730
|
}, [dispatch]);
|
|
2725
2731
|
var selectItem = useCallback(function (newSelectedItem) {
|
|
2726
2732
|
dispatch({
|
|
2727
|
-
type: FunctionSelectItem,
|
|
2733
|
+
type: FunctionSelectItem$1,
|
|
2728
2734
|
selectedItem: newSelectedItem
|
|
2729
2735
|
});
|
|
2730
2736
|
}, [dispatch]);
|
|
2731
2737
|
var reset = useCallback(function () {
|
|
2732
2738
|
dispatch({
|
|
2733
|
-
type: FunctionReset
|
|
2739
|
+
type: FunctionReset$2
|
|
2734
2740
|
});
|
|
2735
2741
|
}, [dispatch]);
|
|
2736
2742
|
var setInputValue = useCallback(function (newInputValue) {
|
|
2737
2743
|
dispatch({
|
|
2738
|
-
type: FunctionSetInputValue,
|
|
2744
|
+
type: FunctionSetInputValue$1,
|
|
2739
2745
|
inputValue: newInputValue
|
|
2740
2746
|
});
|
|
2741
2747
|
}, [dispatch]); // Getter functions.
|
|
@@ -2797,7 +2803,7 @@ function useSelect(userProps) {
|
|
|
2797
2803
|
|
|
2798
2804
|
var menuHandleMouseLeave = function menuHandleMouseLeave() {
|
|
2799
2805
|
dispatch({
|
|
2800
|
-
type: MenuMouseLeave
|
|
2806
|
+
type: MenuMouseLeave$1
|
|
2801
2807
|
});
|
|
2802
2808
|
};
|
|
2803
2809
|
|
|
@@ -2829,7 +2835,7 @@ function useSelect(userProps) {
|
|
|
2829
2835
|
|
|
2830
2836
|
var toggleButtonHandleClick = function toggleButtonHandleClick() {
|
|
2831
2837
|
dispatch({
|
|
2832
|
-
type: ToggleButtonClick
|
|
2838
|
+
type: ToggleButtonClick$1
|
|
2833
2839
|
});
|
|
2834
2840
|
};
|
|
2835
2841
|
|
|
@@ -2883,14 +2889,14 @@ function useSelect(userProps) {
|
|
|
2883
2889
|
|
|
2884
2890
|
shouldScrollRef.current = false;
|
|
2885
2891
|
dispatch({
|
|
2886
|
-
type: ItemMouseMove,
|
|
2892
|
+
type: ItemMouseMove$1,
|
|
2887
2893
|
index: index
|
|
2888
2894
|
});
|
|
2889
2895
|
};
|
|
2890
2896
|
|
|
2891
2897
|
var itemHandleClick = function itemHandleClick() {
|
|
2892
2898
|
dispatch({
|
|
2893
|
-
type: ItemClick,
|
|
2899
|
+
type: ItemClick$1,
|
|
2894
2900
|
index: index
|
|
2895
2901
|
});
|
|
2896
2902
|
};
|
|
@@ -2948,20 +2954,20 @@ var InputKeyDownEnd = process.env.NODE_ENV !== "production" ? '__input_keydown_e
|
|
|
2948
2954
|
var InputKeyDownEnter = process.env.NODE_ENV !== "production" ? '__input_keydown_enter__' : 5;
|
|
2949
2955
|
var InputChange = process.env.NODE_ENV !== "production" ? '__input_change__' : 6;
|
|
2950
2956
|
var InputBlur = process.env.NODE_ENV !== "production" ? '__input_blur__' : 7;
|
|
2951
|
-
var MenuMouseLeave
|
|
2952
|
-
var ItemMouseMove
|
|
2953
|
-
var ItemClick
|
|
2954
|
-
var ToggleButtonClick
|
|
2955
|
-
var FunctionToggleMenu
|
|
2956
|
-
var FunctionOpenMenu
|
|
2957
|
-
var FunctionCloseMenu
|
|
2958
|
-
var FunctionSetHighlightedIndex
|
|
2959
|
-
var FunctionSelectItem
|
|
2960
|
-
var FunctionSetInputValue
|
|
2957
|
+
var MenuMouseLeave = process.env.NODE_ENV !== "production" ? '__menu_mouse_leave__' : 8;
|
|
2958
|
+
var ItemMouseMove = process.env.NODE_ENV !== "production" ? '__item_mouse_move__' : 9;
|
|
2959
|
+
var ItemClick = process.env.NODE_ENV !== "production" ? '__item_click__' : 10;
|
|
2960
|
+
var ToggleButtonClick = process.env.NODE_ENV !== "production" ? '__togglebutton_click__' : 11;
|
|
2961
|
+
var FunctionToggleMenu = process.env.NODE_ENV !== "production" ? '__function_toggle_menu__' : 12;
|
|
2962
|
+
var FunctionOpenMenu = process.env.NODE_ENV !== "production" ? '__function_open_menu__' : 13;
|
|
2963
|
+
var FunctionCloseMenu = process.env.NODE_ENV !== "production" ? '__function_close_menu__' : 14;
|
|
2964
|
+
var FunctionSetHighlightedIndex = process.env.NODE_ENV !== "production" ? '__function_set_highlighted_index__' : 15;
|
|
2965
|
+
var FunctionSelectItem = process.env.NODE_ENV !== "production" ? '__function_select_item__' : 16;
|
|
2966
|
+
var FunctionSetInputValue = process.env.NODE_ENV !== "production" ? '__function_set_input_value__' : 17;
|
|
2961
2967
|
var FunctionReset$1 = process.env.NODE_ENV !== "production" ? '__function_reset__' : 18;
|
|
2962
2968
|
var ControlledPropUpdatedSelectedItem = process.env.NODE_ENV !== "production" ? '__controlled_prop_updated_selected_item__' : 19;
|
|
2963
2969
|
|
|
2964
|
-
var stateChangeTypes$
|
|
2970
|
+
var stateChangeTypes$1 = /*#__PURE__*/Object.freeze({
|
|
2965
2971
|
__proto__: null,
|
|
2966
2972
|
InputKeyDownArrowDown: InputKeyDownArrowDown,
|
|
2967
2973
|
InputKeyDownArrowUp: InputKeyDownArrowUp,
|
|
@@ -2971,22 +2977,22 @@ var stateChangeTypes$2 = /*#__PURE__*/Object.freeze({
|
|
|
2971
2977
|
InputKeyDownEnter: InputKeyDownEnter,
|
|
2972
2978
|
InputChange: InputChange,
|
|
2973
2979
|
InputBlur: InputBlur,
|
|
2974
|
-
MenuMouseLeave: MenuMouseLeave
|
|
2975
|
-
ItemMouseMove: ItemMouseMove
|
|
2976
|
-
ItemClick: ItemClick
|
|
2977
|
-
ToggleButtonClick: ToggleButtonClick
|
|
2978
|
-
FunctionToggleMenu: FunctionToggleMenu
|
|
2979
|
-
FunctionOpenMenu: FunctionOpenMenu
|
|
2980
|
-
FunctionCloseMenu: FunctionCloseMenu
|
|
2981
|
-
FunctionSetHighlightedIndex: FunctionSetHighlightedIndex
|
|
2982
|
-
FunctionSelectItem: FunctionSelectItem
|
|
2983
|
-
FunctionSetInputValue: FunctionSetInputValue
|
|
2980
|
+
MenuMouseLeave: MenuMouseLeave,
|
|
2981
|
+
ItemMouseMove: ItemMouseMove,
|
|
2982
|
+
ItemClick: ItemClick,
|
|
2983
|
+
ToggleButtonClick: ToggleButtonClick,
|
|
2984
|
+
FunctionToggleMenu: FunctionToggleMenu,
|
|
2985
|
+
FunctionOpenMenu: FunctionOpenMenu,
|
|
2986
|
+
FunctionCloseMenu: FunctionCloseMenu,
|
|
2987
|
+
FunctionSetHighlightedIndex: FunctionSetHighlightedIndex,
|
|
2988
|
+
FunctionSelectItem: FunctionSelectItem,
|
|
2989
|
+
FunctionSetInputValue: FunctionSetInputValue,
|
|
2984
2990
|
FunctionReset: FunctionReset$1,
|
|
2985
2991
|
ControlledPropUpdatedSelectedItem: ControlledPropUpdatedSelectedItem
|
|
2986
2992
|
});
|
|
2987
2993
|
|
|
2988
2994
|
function getInitialState$1(props) {
|
|
2989
|
-
var initialState = getInitialState(props);
|
|
2995
|
+
var initialState = getInitialState$2(props);
|
|
2990
2996
|
var selectedItem = initialState.selectedItem;
|
|
2991
2997
|
var inputValue = initialState.inputValue;
|
|
2992
2998
|
|
|
@@ -3052,7 +3058,7 @@ var propTypes$1 = {
|
|
|
3052
3058
|
* @returns {Array} An array with the state and an action dispatcher.
|
|
3053
3059
|
*/
|
|
3054
3060
|
|
|
3055
|
-
function useControlledReducer
|
|
3061
|
+
function useControlledReducer(reducer, initialState, props) {
|
|
3056
3062
|
var previousSelectedItemRef = useRef();
|
|
3057
3063
|
|
|
3058
3064
|
var _useEnhancedReducer = useEnhancedReducer(reducer, initialState, props),
|
|
@@ -3085,8 +3091,8 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
3085
3091
|
};
|
|
3086
3092
|
}
|
|
3087
3093
|
|
|
3088
|
-
var defaultProps$
|
|
3089
|
-
getA11yStatusMessage: getA11yStatusMessage,
|
|
3094
|
+
var defaultProps$1 = _extends({}, defaultProps$3, {
|
|
3095
|
+
getA11yStatusMessage: getA11yStatusMessage$1,
|
|
3090
3096
|
circularNavigation: true
|
|
3091
3097
|
});
|
|
3092
3098
|
|
|
@@ -3099,10 +3105,10 @@ function downshiftUseComboboxReducer(state, action) {
|
|
|
3099
3105
|
var changes;
|
|
3100
3106
|
|
|
3101
3107
|
switch (type) {
|
|
3102
|
-
case ItemClick
|
|
3108
|
+
case ItemClick:
|
|
3103
3109
|
changes = {
|
|
3104
|
-
isOpen: getDefaultValue(props, 'isOpen'),
|
|
3105
|
-
highlightedIndex: getDefaultValue(props, 'highlightedIndex'),
|
|
3110
|
+
isOpen: getDefaultValue$1(props, 'isOpen'),
|
|
3111
|
+
highlightedIndex: getDefaultValue$1(props, 'highlightedIndex'),
|
|
3106
3112
|
selectedItem: props.items[action.index],
|
|
3107
3113
|
inputValue: props.itemToString(props.items[action.index])
|
|
3108
3114
|
};
|
|
@@ -3139,8 +3145,8 @@ function downshiftUseComboboxReducer(state, action) {
|
|
|
3139
3145
|
case InputKeyDownEnter:
|
|
3140
3146
|
changes = _extends({}, state.isOpen && state.highlightedIndex >= 0 && {
|
|
3141
3147
|
selectedItem: props.items[state.highlightedIndex],
|
|
3142
|
-
isOpen: getDefaultValue(props, 'isOpen'),
|
|
3143
|
-
highlightedIndex: getDefaultValue(props, 'highlightedIndex'),
|
|
3148
|
+
isOpen: getDefaultValue$1(props, 'isOpen'),
|
|
3149
|
+
highlightedIndex: getDefaultValue$1(props, 'highlightedIndex'),
|
|
3144
3150
|
inputValue: props.itemToString(props.items[state.highlightedIndex])
|
|
3145
3151
|
});
|
|
3146
3152
|
break;
|
|
@@ -3180,12 +3186,12 @@ function downshiftUseComboboxReducer(state, action) {
|
|
|
3180
3186
|
case InputChange:
|
|
3181
3187
|
changes = {
|
|
3182
3188
|
isOpen: true,
|
|
3183
|
-
highlightedIndex: getDefaultValue(props, 'highlightedIndex'),
|
|
3189
|
+
highlightedIndex: getDefaultValue$1(props, 'highlightedIndex'),
|
|
3184
3190
|
inputValue: action.inputValue
|
|
3185
3191
|
};
|
|
3186
3192
|
break;
|
|
3187
3193
|
|
|
3188
|
-
case FunctionSelectItem
|
|
3194
|
+
case FunctionSelectItem:
|
|
3189
3195
|
changes = {
|
|
3190
3196
|
selectedItem: action.selectedItem,
|
|
3191
3197
|
inputValue: props.itemToString(action.selectedItem)
|
|
@@ -3199,14 +3205,14 @@ function downshiftUseComboboxReducer(state, action) {
|
|
|
3199
3205
|
break;
|
|
3200
3206
|
|
|
3201
3207
|
default:
|
|
3202
|
-
return downshiftCommonReducer(state, action, stateChangeTypes$
|
|
3208
|
+
return downshiftCommonReducer(state, action, stateChangeTypes$1);
|
|
3203
3209
|
}
|
|
3204
3210
|
|
|
3205
3211
|
return _extends({}, state, changes);
|
|
3206
3212
|
}
|
|
3207
3213
|
/* eslint-enable complexity */
|
|
3208
3214
|
|
|
3209
|
-
useCombobox.stateChangeTypes = stateChangeTypes$
|
|
3215
|
+
useCombobox.stateChangeTypes = stateChangeTypes$1;
|
|
3210
3216
|
|
|
3211
3217
|
function useCombobox(userProps) {
|
|
3212
3218
|
if (userProps === void 0) {
|
|
@@ -3215,7 +3221,7 @@ function useCombobox(userProps) {
|
|
|
3215
3221
|
|
|
3216
3222
|
validatePropTypes$1(userProps, useCombobox); // Props defaults and destructuring.
|
|
3217
3223
|
|
|
3218
|
-
var props = _extends({}, defaultProps$
|
|
3224
|
+
var props = _extends({}, defaultProps$1, userProps);
|
|
3219
3225
|
|
|
3220
3226
|
var initialIsOpen = props.initialIsOpen,
|
|
3221
3227
|
defaultIsOpen = props.defaultIsOpen,
|
|
@@ -3228,7 +3234,7 @@ function useCombobox(userProps) {
|
|
|
3228
3234
|
|
|
3229
3235
|
var initialState = getInitialState$1(props);
|
|
3230
3236
|
|
|
3231
|
-
var _useControlledReducer = useControlledReducer
|
|
3237
|
+
var _useControlledReducer = useControlledReducer(downshiftUseComboboxReducer, initialState, props),
|
|
3232
3238
|
state = _useControlledReducer[0],
|
|
3233
3239
|
dispatch = _useControlledReducer[1];
|
|
3234
3240
|
|
|
@@ -3413,7 +3419,7 @@ function useCombobox(userProps) {
|
|
|
3413
3419
|
menuRef.current = menuNode;
|
|
3414
3420
|
}), _extends2.id = elementIds.menuId, _extends2.role = 'listbox', _extends2['aria-labelledby'] = elementIds.labelId, _extends2.onMouseLeave = callAllEventHandlers(onMouseLeave, function () {
|
|
3415
3421
|
dispatch({
|
|
3416
|
-
type: MenuMouseLeave
|
|
3422
|
+
type: MenuMouseLeave
|
|
3417
3423
|
});
|
|
3418
3424
|
}), _extends2), rest);
|
|
3419
3425
|
}, [dispatch, setGetterPropCallInfo, elementIds]);
|
|
@@ -3427,9 +3433,9 @@ function useCombobox(userProps) {
|
|
|
3427
3433
|
refKey = _ref3$refKey === void 0 ? 'ref' : _ref3$refKey,
|
|
3428
3434
|
ref = _ref3.ref,
|
|
3429
3435
|
onMouseMove = _ref3.onMouseMove,
|
|
3430
|
-
onClick = _ref3.onClick
|
|
3431
|
-
|
|
3432
|
-
rest = _objectWithoutPropertiesLoose(_ref3, ["item", "index", "refKey", "ref", "onMouseMove", "onClick", "onPress"]);
|
|
3436
|
+
onClick = _ref3.onClick;
|
|
3437
|
+
_ref3.onPress;
|
|
3438
|
+
var rest = _objectWithoutPropertiesLoose(_ref3, ["item", "index", "refKey", "ref", "onMouseMove", "onClick", "onPress"]);
|
|
3433
3439
|
|
|
3434
3440
|
var _latest$current = latest.current,
|
|
3435
3441
|
latestProps = _latest$current.props,
|
|
@@ -3440,8 +3446,8 @@ function useCombobox(userProps) {
|
|
|
3440
3446
|
throw new Error('Pass either item or item index in getItemProps!');
|
|
3441
3447
|
}
|
|
3442
3448
|
|
|
3443
|
-
var onSelectKey =
|
|
3444
|
-
var customClickHandler =
|
|
3449
|
+
var onSelectKey = 'onClick';
|
|
3450
|
+
var customClickHandler = onClick;
|
|
3445
3451
|
|
|
3446
3452
|
var itemHandleMouseMove = function itemHandleMouseMove() {
|
|
3447
3453
|
if (index === latestState.highlightedIndex) {
|
|
@@ -3450,14 +3456,14 @@ function useCombobox(userProps) {
|
|
|
3450
3456
|
|
|
3451
3457
|
shouldScrollRef.current = false;
|
|
3452
3458
|
dispatch({
|
|
3453
|
-
type: ItemMouseMove
|
|
3459
|
+
type: ItemMouseMove,
|
|
3454
3460
|
index: index
|
|
3455
3461
|
});
|
|
3456
3462
|
};
|
|
3457
3463
|
|
|
3458
3464
|
var itemHandleClick = function itemHandleClick() {
|
|
3459
3465
|
dispatch({
|
|
3460
|
-
type: ItemClick
|
|
3466
|
+
type: ItemClick,
|
|
3461
3467
|
index: index
|
|
3462
3468
|
});
|
|
3463
3469
|
|
|
@@ -3478,16 +3484,16 @@ function useCombobox(userProps) {
|
|
|
3478
3484
|
var _extends4;
|
|
3479
3485
|
|
|
3480
3486
|
var _ref5 = _temp4 === void 0 ? {} : _temp4,
|
|
3481
|
-
onClick = _ref5.onClick
|
|
3482
|
-
|
|
3483
|
-
_ref5$refKey = _ref5.refKey,
|
|
3487
|
+
onClick = _ref5.onClick;
|
|
3488
|
+
_ref5.onPress;
|
|
3489
|
+
var _ref5$refKey = _ref5.refKey,
|
|
3484
3490
|
refKey = _ref5$refKey === void 0 ? 'ref' : _ref5$refKey,
|
|
3485
3491
|
ref = _ref5.ref,
|
|
3486
3492
|
rest = _objectWithoutPropertiesLoose(_ref5, ["onClick", "onPress", "refKey", "ref"]);
|
|
3487
3493
|
|
|
3488
3494
|
var toggleButtonHandleClick = function toggleButtonHandleClick() {
|
|
3489
3495
|
dispatch({
|
|
3490
|
-
type: ToggleButtonClick
|
|
3496
|
+
type: ToggleButtonClick
|
|
3491
3497
|
});
|
|
3492
3498
|
|
|
3493
3499
|
if (!latest.current.state.isOpen && inputRef.current) {
|
|
@@ -3497,7 +3503,7 @@ function useCombobox(userProps) {
|
|
|
3497
3503
|
|
|
3498
3504
|
return _extends((_extends4 = {}, _extends4[refKey] = handleRefs(ref, function (toggleButtonNode) {
|
|
3499
3505
|
toggleButtonRef.current = toggleButtonNode;
|
|
3500
|
-
}), _extends4.id = elementIds.toggleButtonId, _extends4.tabIndex = -1, _extends4), !rest.disabled && _extends({},
|
|
3506
|
+
}), _extends4.id = elementIds.toggleButtonId, _extends4.tabIndex = -1, _extends4), !rest.disabled && _extends({}, {
|
|
3501
3507
|
onClick: callAllEventHandlers(onClick, toggleButtonHandleClick)
|
|
3502
3508
|
}), rest);
|
|
3503
3509
|
}, [dispatch, latest, elementIds]);
|
|
@@ -3508,9 +3514,9 @@ function useCombobox(userProps) {
|
|
|
3508
3514
|
onKeyDown = _ref6.onKeyDown,
|
|
3509
3515
|
onChange = _ref6.onChange,
|
|
3510
3516
|
onInput = _ref6.onInput,
|
|
3511
|
-
onBlur = _ref6.onBlur
|
|
3512
|
-
|
|
3513
|
-
_ref6$refKey = _ref6.refKey,
|
|
3517
|
+
onBlur = _ref6.onBlur;
|
|
3518
|
+
_ref6.onChangeText;
|
|
3519
|
+
var _ref6$refKey = _ref6.refKey,
|
|
3514
3520
|
refKey = _ref6$refKey === void 0 ? 'ref' : _ref6$refKey,
|
|
3515
3521
|
ref = _ref6.ref,
|
|
3516
3522
|
rest = _objectWithoutPropertiesLoose(_ref6, ["onKeyDown", "onChange", "onInput", "onBlur", "onChangeText", "refKey", "ref"]);
|
|
@@ -3533,7 +3539,7 @@ function useCombobox(userProps) {
|
|
|
3533
3539
|
var inputHandleChange = function inputHandleChange(event) {
|
|
3534
3540
|
dispatch({
|
|
3535
3541
|
type: InputChange,
|
|
3536
|
-
inputValue:
|
|
3542
|
+
inputValue: event.target.value
|
|
3537
3543
|
});
|
|
3538
3544
|
};
|
|
3539
3545
|
|
|
@@ -3549,7 +3555,7 @@ function useCombobox(userProps) {
|
|
|
3549
3555
|
/* istanbul ignore next (preact) */
|
|
3550
3556
|
|
|
3551
3557
|
|
|
3552
|
-
var onChangeKey =
|
|
3558
|
+
var onChangeKey = 'onInput' ;
|
|
3553
3559
|
var eventHandlers = {};
|
|
3554
3560
|
|
|
3555
3561
|
if (!rest.disabled) {
|
|
@@ -3591,34 +3597,34 @@ function useCombobox(userProps) {
|
|
|
3591
3597
|
|
|
3592
3598
|
var toggleMenu = useCallback(function () {
|
|
3593
3599
|
dispatch({
|
|
3594
|
-
type: FunctionToggleMenu
|
|
3600
|
+
type: FunctionToggleMenu
|
|
3595
3601
|
});
|
|
3596
3602
|
}, [dispatch]);
|
|
3597
3603
|
var closeMenu = useCallback(function () {
|
|
3598
3604
|
dispatch({
|
|
3599
|
-
type: FunctionCloseMenu
|
|
3605
|
+
type: FunctionCloseMenu
|
|
3600
3606
|
});
|
|
3601
3607
|
}, [dispatch]);
|
|
3602
3608
|
var openMenu = useCallback(function () {
|
|
3603
3609
|
dispatch({
|
|
3604
|
-
type: FunctionOpenMenu
|
|
3610
|
+
type: FunctionOpenMenu
|
|
3605
3611
|
});
|
|
3606
3612
|
}, [dispatch]);
|
|
3607
3613
|
var setHighlightedIndex = useCallback(function (newHighlightedIndex) {
|
|
3608
3614
|
dispatch({
|
|
3609
|
-
type: FunctionSetHighlightedIndex
|
|
3615
|
+
type: FunctionSetHighlightedIndex,
|
|
3610
3616
|
highlightedIndex: newHighlightedIndex
|
|
3611
3617
|
});
|
|
3612
3618
|
}, [dispatch]);
|
|
3613
3619
|
var selectItem = useCallback(function (newSelectedItem) {
|
|
3614
3620
|
dispatch({
|
|
3615
|
-
type: FunctionSelectItem
|
|
3621
|
+
type: FunctionSelectItem,
|
|
3616
3622
|
selectedItem: newSelectedItem
|
|
3617
3623
|
});
|
|
3618
3624
|
}, [dispatch]);
|
|
3619
3625
|
var setInputValue = useCallback(function (newInputValue) {
|
|
3620
3626
|
dispatch({
|
|
3621
|
-
type: FunctionSetInputValue
|
|
3627
|
+
type: FunctionSetInputValue,
|
|
3622
3628
|
inputValue: newInputValue
|
|
3623
3629
|
});
|
|
3624
3630
|
}, [dispatch]);
|
|
@@ -3665,8 +3671,8 @@ var defaultStateValues = {
|
|
|
3665
3671
|
* @returns {any} The initial value for that prop.
|
|
3666
3672
|
*/
|
|
3667
3673
|
|
|
3668
|
-
function getInitialValue
|
|
3669
|
-
return getInitialValue(props, propKey, defaultStateValues);
|
|
3674
|
+
function getInitialValue(props, propKey) {
|
|
3675
|
+
return getInitialValue$1(props, propKey, defaultStateValues);
|
|
3670
3676
|
}
|
|
3671
3677
|
/**
|
|
3672
3678
|
* Returns the default value for a state key in the following order:
|
|
@@ -3678,8 +3684,8 @@ function getInitialValue$1(props, propKey) {
|
|
|
3678
3684
|
*/
|
|
3679
3685
|
|
|
3680
3686
|
|
|
3681
|
-
function getDefaultValue
|
|
3682
|
-
return getDefaultValue(props, propKey, defaultStateValues);
|
|
3687
|
+
function getDefaultValue(props, propKey) {
|
|
3688
|
+
return getDefaultValue$1(props, propKey, defaultStateValues);
|
|
3683
3689
|
}
|
|
3684
3690
|
/**
|
|
3685
3691
|
* Gets the initial state based on the provided props. It uses initial, default
|
|
@@ -3690,9 +3696,9 @@ function getDefaultValue$1(props, propKey) {
|
|
|
3690
3696
|
*/
|
|
3691
3697
|
|
|
3692
3698
|
|
|
3693
|
-
function getInitialState
|
|
3694
|
-
var activeIndex = getInitialValue
|
|
3695
|
-
var selectedItems = getInitialValue
|
|
3699
|
+
function getInitialState(props) {
|
|
3700
|
+
var activeIndex = getInitialValue(props, 'activeIndex');
|
|
3701
|
+
var selectedItems = getInitialValue(props, 'selectedItems');
|
|
3696
3702
|
return {
|
|
3697
3703
|
activeIndex: activeIndex,
|
|
3698
3704
|
selectedItems: selectedItems
|
|
@@ -3739,7 +3745,7 @@ function getA11yRemovalMessage(selectionParameters) {
|
|
|
3739
3745
|
return itemToStringLocal(removedSelectedItem) + " has been removed.";
|
|
3740
3746
|
}
|
|
3741
3747
|
|
|
3742
|
-
var propTypes
|
|
3748
|
+
var propTypes = {
|
|
3743
3749
|
selectedItems: PropTypes.array,
|
|
3744
3750
|
initialSelectedItems: PropTypes.array,
|
|
3745
3751
|
defaultSelectedItems: PropTypes.array,
|
|
@@ -3763,21 +3769,21 @@ var propTypes$2 = {
|
|
|
3763
3769
|
})
|
|
3764
3770
|
})
|
|
3765
3771
|
};
|
|
3766
|
-
var defaultProps
|
|
3767
|
-
itemToString: defaultProps.itemToString,
|
|
3768
|
-
stateReducer: defaultProps.stateReducer,
|
|
3769
|
-
environment: defaultProps.environment,
|
|
3772
|
+
var defaultProps = {
|
|
3773
|
+
itemToString: defaultProps$3.itemToString,
|
|
3774
|
+
stateReducer: defaultProps$3.stateReducer,
|
|
3775
|
+
environment: defaultProps$3.environment,
|
|
3770
3776
|
getA11yRemovalMessage: getA11yRemovalMessage,
|
|
3771
3777
|
keyNavigationNext: 'ArrowRight',
|
|
3772
3778
|
keyNavigationPrevious: 'ArrowLeft'
|
|
3773
3779
|
}; // eslint-disable-next-line import/no-mutable-exports
|
|
3774
3780
|
|
|
3775
|
-
var validatePropTypes
|
|
3781
|
+
var validatePropTypes = noop;
|
|
3776
3782
|
/* istanbul ignore next */
|
|
3777
3783
|
|
|
3778
3784
|
if (process.env.NODE_ENV !== 'production') {
|
|
3779
|
-
validatePropTypes
|
|
3780
|
-
PropTypes.checkPropTypes(propTypes
|
|
3785
|
+
validatePropTypes = function validatePropTypes(options, caller) {
|
|
3786
|
+
PropTypes.checkPropTypes(propTypes, options, 'prop', caller.name);
|
|
3781
3787
|
};
|
|
3782
3788
|
}
|
|
3783
3789
|
|
|
@@ -3793,9 +3799,9 @@ var FunctionAddSelectedItem = process.env.NODE_ENV !== "production" ? '__functio
|
|
|
3793
3799
|
var FunctionRemoveSelectedItem = process.env.NODE_ENV !== "production" ? '__function_remove_selected_item__' : 9;
|
|
3794
3800
|
var FunctionSetSelectedItems = process.env.NODE_ENV !== "production" ? '__function_set_selected_items__' : 10;
|
|
3795
3801
|
var FunctionSetActiveIndex = process.env.NODE_ENV !== "production" ? '__function_set_active_index__' : 11;
|
|
3796
|
-
var FunctionReset
|
|
3802
|
+
var FunctionReset = process.env.NODE_ENV !== "production" ? '__function_reset__' : 12;
|
|
3797
3803
|
|
|
3798
|
-
var stateChangeTypes
|
|
3804
|
+
var stateChangeTypes = /*#__PURE__*/Object.freeze({
|
|
3799
3805
|
__proto__: null,
|
|
3800
3806
|
SelectedItemClick: SelectedItemClick,
|
|
3801
3807
|
SelectedItemKeyDownDelete: SelectedItemKeyDownDelete,
|
|
@@ -3809,7 +3815,7 @@ var stateChangeTypes$3 = /*#__PURE__*/Object.freeze({
|
|
|
3809
3815
|
FunctionRemoveSelectedItem: FunctionRemoveSelectedItem,
|
|
3810
3816
|
FunctionSetSelectedItems: FunctionSetSelectedItems,
|
|
3811
3817
|
FunctionSetActiveIndex: FunctionSetActiveIndex,
|
|
3812
|
-
FunctionReset: FunctionReset
|
|
3818
|
+
FunctionReset: FunctionReset
|
|
3813
3819
|
});
|
|
3814
3820
|
|
|
3815
3821
|
/* eslint-disable complexity */
|
|
@@ -3922,10 +3928,10 @@ function downshiftMultipleSelectionReducer(state, action) {
|
|
|
3922
3928
|
break;
|
|
3923
3929
|
}
|
|
3924
3930
|
|
|
3925
|
-
case FunctionReset
|
|
3931
|
+
case FunctionReset:
|
|
3926
3932
|
changes = {
|
|
3927
|
-
activeIndex: getDefaultValue
|
|
3928
|
-
selectedItems: getDefaultValue
|
|
3933
|
+
activeIndex: getDefaultValue(props, 'activeIndex'),
|
|
3934
|
+
selectedItems: getDefaultValue(props, 'selectedItems')
|
|
3929
3935
|
};
|
|
3930
3936
|
break;
|
|
3931
3937
|
|
|
@@ -3936,16 +3942,16 @@ function downshiftMultipleSelectionReducer(state, action) {
|
|
|
3936
3942
|
return _extends({}, state, changes);
|
|
3937
3943
|
}
|
|
3938
3944
|
|
|
3939
|
-
useMultipleSelection.stateChangeTypes = stateChangeTypes
|
|
3945
|
+
useMultipleSelection.stateChangeTypes = stateChangeTypes;
|
|
3940
3946
|
|
|
3941
3947
|
function useMultipleSelection(userProps) {
|
|
3942
3948
|
if (userProps === void 0) {
|
|
3943
3949
|
userProps = {};
|
|
3944
3950
|
}
|
|
3945
3951
|
|
|
3946
|
-
validatePropTypes
|
|
3952
|
+
validatePropTypes(userProps, useMultipleSelection); // Props defaults and destructuring.
|
|
3947
3953
|
|
|
3948
|
-
var props = _extends({}, defaultProps
|
|
3954
|
+
var props = _extends({}, defaultProps, userProps);
|
|
3949
3955
|
|
|
3950
3956
|
var getA11yRemovalMessage = props.getA11yRemovalMessage,
|
|
3951
3957
|
itemToString = props.itemToString,
|
|
@@ -3953,7 +3959,7 @@ function useMultipleSelection(userProps) {
|
|
|
3953
3959
|
keyNavigationNext = props.keyNavigationNext,
|
|
3954
3960
|
keyNavigationPrevious = props.keyNavigationPrevious; // Reducer init.
|
|
3955
3961
|
|
|
3956
|
-
var _useControlledReducer = useControlledReducer(downshiftMultipleSelectionReducer, getInitialState
|
|
3962
|
+
var _useControlledReducer = useControlledReducer$1(downshiftMultipleSelectionReducer, getInitialState(props), props),
|
|
3957
3963
|
state = _useControlledReducer[0],
|
|
3958
3964
|
dispatch = _useControlledReducer[1];
|
|
3959
3965
|
|
|
@@ -4164,7 +4170,7 @@ function useMultipleSelection(userProps) {
|
|
|
4164
4170
|
}, [dispatch]);
|
|
4165
4171
|
var reset = useCallback(function () {
|
|
4166
4172
|
dispatch({
|
|
4167
|
-
type: FunctionReset
|
|
4173
|
+
type: FunctionReset
|
|
4168
4174
|
});
|
|
4169
4175
|
}, [dispatch]);
|
|
4170
4176
|
return {
|