downshift 6.1.3 → 6.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -2
- package/dist/downshift.cjs.js +130 -111
- package/dist/downshift.esm.js +131 -113
- package/dist/downshift.native.cjs.js +130 -111
- package/dist/downshift.umd.js +801 -928
- package/dist/downshift.umd.js.map +1 -1
- package/dist/downshift.umd.min.js +16 -28
- package/dist/downshift.umd.min.js.map +1 -1
- package/dist/src/hooks/reducer.d.ts +1 -0
- package/dist/src/hooks/useSelect/__tests__/utils.test.d.ts +1 -0
- package/dist/src/hooks/useSelect/reducer.d.ts +1 -0
- package/dist/src/hooks/useSelect/stateChangeTypes.d.ts +23 -0
- package/dist/src/hooks/useSelect/types.d.ts +7 -0
- package/dist/src/hooks/useSelect/utils.d.ts +23 -0
- package/dist/src/hooks/utils.d.ts +112 -0
- package/dist/src/is.macro.d.ts +2 -0
- package/dist/src/productionEnum.macro.d.ts +2 -0
- package/dist/src/set-a11y-status.d.ts +6 -0
- package/dist/src/types.d.ts +10 -0
- package/dist/src/utils.d.ts +156 -0
- package/dist/{basic.test.d.ts → test/basic.test.d.ts} +0 -0
- package/dist/{custom.test.d.ts → test/custom.test.d.ts} +0 -0
- package/dist/test/setup.d.ts +1 -0
- package/package.json +43 -42
- package/preact/dist/downshift.cjs.js +131 -111
- package/preact/dist/downshift.esm.js +132 -113
- package/preact/dist/downshift.umd.js +352 -429
- package/preact/dist/downshift.umd.js.map +1 -1
- package/preact/dist/downshift.umd.min.js +16 -11
- package/preact/dist/downshift.umd.min.js.map +1 -1
- package/typings/index.d.ts +4 -13
package/dist/downshift.esm.js
CHANGED
|
@@ -3,9 +3,10 @@ import _extends from '@babel/runtime/helpers/esm/extends';
|
|
|
3
3
|
import _assertThisInitialized from '@babel/runtime/helpers/esm/assertThisInitialized';
|
|
4
4
|
import _inheritsLoose from '@babel/runtime/helpers/esm/inheritsLoose';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
|
-
import { cloneElement, Component, useRef, useEffect,
|
|
6
|
+
import { cloneElement, Component, useRef, useEffect, useCallback, useLayoutEffect, useReducer, useMemo } from 'react';
|
|
7
7
|
import { isForwardRef } from 'react-is';
|
|
8
8
|
import computeScrollIntoView from 'compute-scroll-into-view';
|
|
9
|
+
import { __assign } from 'tslib';
|
|
9
10
|
|
|
10
11
|
var idCounter = 0;
|
|
11
12
|
/**
|
|
@@ -156,7 +157,7 @@ function resetIdCounter() {
|
|
|
156
157
|
}
|
|
157
158
|
/**
|
|
158
159
|
* Default implementation for status message. Only added when menu is open.
|
|
159
|
-
* Will
|
|
160
|
+
* Will specify if there are results in the list, and if so, how many,
|
|
160
161
|
* and what keys are relevant.
|
|
161
162
|
*
|
|
162
163
|
* @param {Object} param the downshift state and other relevant properties
|
|
@@ -535,6 +536,12 @@ var stateChangeTypes$3 = /*#__PURE__*/Object.freeze({
|
|
|
535
536
|
touchEnd: touchEnd
|
|
536
537
|
});
|
|
537
538
|
|
|
539
|
+
var _excluded$4 = ["refKey", "ref"],
|
|
540
|
+
_excluded2$3 = ["onClick", "onPress", "onKeyDown", "onKeyUp", "onBlur"],
|
|
541
|
+
_excluded3$2 = ["onKeyDown", "onBlur", "onChange", "onInput", "onChangeText"],
|
|
542
|
+
_excluded4$1 = ["refKey", "ref"],
|
|
543
|
+
_excluded5$1 = ["onMouseMove", "onMouseDown", "onClick", "onPress", "index", "item"];
|
|
544
|
+
|
|
538
545
|
var Downshift = /*#__PURE__*/function () {
|
|
539
546
|
var Downshift = /*#__PURE__*/function (_Component) {
|
|
540
547
|
_inheritsLoose(Downshift, _Component);
|
|
@@ -654,6 +661,8 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
654
661
|
isItemSelected = newStateToSet.hasOwnProperty('selectedItem'); // this keeps track of the object we want to call with setState
|
|
655
662
|
|
|
656
663
|
var nextState = {}; // this is just used to tell whether the state changed
|
|
664
|
+
|
|
665
|
+
var nextFullState = {}; // we need to call on change if the outside world is controlling any of our state
|
|
657
666
|
// and we're trying to update that state. OR if the selection has changed and we're
|
|
658
667
|
// trying to update the selection
|
|
659
668
|
|
|
@@ -679,7 +688,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
679
688
|
return;
|
|
680
689
|
}
|
|
681
690
|
|
|
682
|
-
newStateToSet[key]; // if it's coming from props, then we don't care to set it internally
|
|
691
|
+
nextFullState[key] = newStateToSet[key]; // if it's coming from props, then we don't care to set it internally
|
|
683
692
|
|
|
684
693
|
if (!isControlledProp(_this.props, key)) {
|
|
685
694
|
nextState[key] = newStateToSet[key];
|
|
@@ -728,7 +737,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
728
737
|
_ref$refKey = _ref.refKey,
|
|
729
738
|
refKey = _ref$refKey === void 0 ? 'ref' : _ref$refKey,
|
|
730
739
|
ref = _ref.ref,
|
|
731
|
-
rest = _objectWithoutPropertiesLoose(_ref,
|
|
740
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$4);
|
|
732
741
|
|
|
733
742
|
var _ref2 = _temp2 === void 0 ? {} : _temp2,
|
|
734
743
|
_ref2$suppressRefErro = _ref2.suppressRefError,
|
|
@@ -912,7 +921,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
912
921
|
var onKeyDown = _ref3.onKeyDown,
|
|
913
922
|
onKeyUp = _ref3.onKeyUp,
|
|
914
923
|
onBlur = _ref3.onBlur,
|
|
915
|
-
rest = _objectWithoutPropertiesLoose(_ref3,
|
|
924
|
+
rest = _objectWithoutPropertiesLoose(_ref3, _excluded2$3);
|
|
916
925
|
|
|
917
926
|
var _this$getState5 = _this.getState(),
|
|
918
927
|
isOpen = _this$getState5.isOpen;
|
|
@@ -980,10 +989,10 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
980
989
|
_this.internalSetTimeout(function () {
|
|
981
990
|
if (!_this.isMouseDown && (_this.props.environment.document.activeElement == null || _this.props.environment.document.activeElement.id !== _this.inputId) && _this.props.environment.document.activeElement !== blurTarget // Do nothing if we refocus the same element again (to solve issue in Safari on iOS)
|
|
982
991
|
) {
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
992
|
+
_this.reset({
|
|
993
|
+
type: blurButton
|
|
994
|
+
});
|
|
995
|
+
}
|
|
987
996
|
});
|
|
988
997
|
};
|
|
989
998
|
|
|
@@ -1001,7 +1010,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1001
1010
|
onChange = _ref4.onChange,
|
|
1002
1011
|
onInput = _ref4.onInput;
|
|
1003
1012
|
_ref4.onChangeText;
|
|
1004
|
-
var rest = _objectWithoutPropertiesLoose(_ref4,
|
|
1013
|
+
var rest = _objectWithoutPropertiesLoose(_ref4, _excluded3$2);
|
|
1005
1014
|
|
|
1006
1015
|
var onChangeKey;
|
|
1007
1016
|
var eventHandlers = {};
|
|
@@ -1076,7 +1085,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1076
1085
|
_ref5$refKey = _ref5.refKey,
|
|
1077
1086
|
refKey = _ref5$refKey === void 0 ? 'ref' : _ref5$refKey,
|
|
1078
1087
|
ref = _ref5.ref,
|
|
1079
|
-
props = _objectWithoutPropertiesLoose(_ref5,
|
|
1088
|
+
props = _objectWithoutPropertiesLoose(_ref5, _excluded4$1);
|
|
1080
1089
|
|
|
1081
1090
|
var _ref6 = _temp6 === void 0 ? {} : _temp6,
|
|
1082
1091
|
_ref6$suppressRefErro = _ref6.suppressRefError,
|
|
@@ -1101,7 +1110,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1101
1110
|
item = _ref7$item === void 0 ? process.env.NODE_ENV === 'production' ?
|
|
1102
1111
|
/* istanbul ignore next */
|
|
1103
1112
|
undefined : requiredProp('getItemProps', 'item') : _ref7$item,
|
|
1104
|
-
rest = _objectWithoutPropertiesLoose(_ref7,
|
|
1113
|
+
rest = _objectWithoutPropertiesLoose(_ref7, _excluded5$1);
|
|
1105
1114
|
|
|
1106
1115
|
if (index === undefined) {
|
|
1107
1116
|
_this.items.push(item);
|
|
@@ -1609,9 +1618,9 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1609
1618
|
selectedItemChanged: function selectedItemChanged(prevItem, item) {
|
|
1610
1619
|
return prevItem !== item;
|
|
1611
1620
|
},
|
|
1612
|
-
environment:
|
|
1621
|
+
environment:
|
|
1613
1622
|
/* istanbul ignore next (ssr) */
|
|
1614
|
-
? {} : window,
|
|
1623
|
+
typeof window === 'undefined' ? {} : window,
|
|
1615
1624
|
stateReducer: function stateReducer(state, stateToSet) {
|
|
1616
1625
|
return stateToSet;
|
|
1617
1626
|
},
|
|
@@ -1668,6 +1677,7 @@ process.env.NODE_ENV !== "production" ? Downshift.propTypes = {
|
|
|
1668
1677
|
/* eslint-enable react/no-unused-prop-types */
|
|
1669
1678
|
|
|
1670
1679
|
} : void 0;
|
|
1680
|
+
var Downshift$1 = Downshift;
|
|
1671
1681
|
|
|
1672
1682
|
function validateGetMenuPropsCalledCorrectly(node, _ref12) {
|
|
1673
1683
|
var refKey = _ref12.refKey;
|
|
@@ -1697,6 +1707,7 @@ function validateGetRootPropsCalledCorrectly(element, _ref13) {
|
|
|
1697
1707
|
}
|
|
1698
1708
|
}
|
|
1699
1709
|
|
|
1710
|
+
var _excluded$3 = ["isInitialMount", "highlightedIndex", "items", "environment"];
|
|
1700
1711
|
var dropdownDefaultStateValues = {
|
|
1701
1712
|
highlightedIndex: -1,
|
|
1702
1713
|
isOpen: false,
|
|
@@ -1894,9 +1905,9 @@ var defaultProps$3 = {
|
|
|
1894
1905
|
getA11ySelectionMessage: getA11ySelectionMessage,
|
|
1895
1906
|
scrollIntoView: scrollIntoView,
|
|
1896
1907
|
circularNavigation: false,
|
|
1897
|
-
environment:
|
|
1908
|
+
environment:
|
|
1898
1909
|
/* istanbul ignore next (ssr) */
|
|
1899
|
-
? {} : window
|
|
1910
|
+
typeof window === 'undefined' ? {} : window
|
|
1900
1911
|
};
|
|
1901
1912
|
|
|
1902
1913
|
function getDefaultValue$1(props, propKey, defaultStateValues) {
|
|
@@ -2110,11 +2121,11 @@ function useA11yMessageSetter(getA11yMessage, dependencyArray, _ref2) {
|
|
|
2110
2121
|
highlightedIndex = _ref2.highlightedIndex,
|
|
2111
2122
|
items = _ref2.items,
|
|
2112
2123
|
environment = _ref2.environment,
|
|
2113
|
-
rest = _objectWithoutPropertiesLoose(_ref2,
|
|
2124
|
+
rest = _objectWithoutPropertiesLoose(_ref2, _excluded$3);
|
|
2114
2125
|
|
|
2115
2126
|
// Sets a11y status message on changes in state.
|
|
2116
2127
|
useEffect(function () {
|
|
2117
|
-
if (isInitialMount) {
|
|
2128
|
+
if (isInitialMount || false) {
|
|
2118
2129
|
return;
|
|
2119
2130
|
}
|
|
2120
2131
|
|
|
@@ -2245,58 +2256,58 @@ function downshiftCommonReducer(state, action, stateChangeTypes) {
|
|
|
2245
2256
|
}
|
|
2246
2257
|
/* eslint-enable complexity */
|
|
2247
2258
|
|
|
2248
|
-
function getItemIndexByCharacterKey(
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2259
|
+
function getItemIndexByCharacterKey(_a) {
|
|
2260
|
+
var keysSoFar = _a.keysSoFar, highlightedIndex = _a.highlightedIndex, items = _a.items, itemToString = _a.itemToString, getItemNodeFromIndex = _a.getItemNodeFromIndex;
|
|
2261
|
+
var lowerCasedKeysSoFar = keysSoFar.toLowerCase();
|
|
2262
|
+
for (var index = 0; index < items.length; index++) {
|
|
2263
|
+
var offsetIndex = (index + highlightedIndex + 1) % items.length;
|
|
2264
|
+
var item = items[offsetIndex];
|
|
2265
|
+
if (item !== undefined &&
|
|
2266
|
+
itemToString(item)
|
|
2267
|
+
.toLowerCase()
|
|
2268
|
+
.startsWith(lowerCasedKeysSoFar)) {
|
|
2269
|
+
var element = getItemNodeFromIndex(offsetIndex);
|
|
2270
|
+
if (!(element === null || element === void 0 ? void 0 : element.hasAttribute('disabled'))) {
|
|
2271
|
+
return offsetIndex;
|
|
2272
|
+
}
|
|
2273
|
+
}
|
|
2260
2274
|
}
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
return highlightedIndex;
|
|
2275
|
+
return highlightedIndex;
|
|
2264
2276
|
}
|
|
2265
|
-
|
|
2266
2277
|
var propTypes$2 = {
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2278
|
+
items: PropTypes.array.isRequired,
|
|
2279
|
+
itemToString: PropTypes.func,
|
|
2280
|
+
getA11yStatusMessage: PropTypes.func,
|
|
2281
|
+
getA11ySelectionMessage: PropTypes.func,
|
|
2282
|
+
circularNavigation: PropTypes.bool,
|
|
2283
|
+
highlightedIndex: PropTypes.number,
|
|
2284
|
+
defaultHighlightedIndex: PropTypes.number,
|
|
2285
|
+
initialHighlightedIndex: PropTypes.number,
|
|
2286
|
+
isOpen: PropTypes.bool,
|
|
2287
|
+
defaultIsOpen: PropTypes.bool,
|
|
2288
|
+
initialIsOpen: PropTypes.bool,
|
|
2289
|
+
selectedItem: PropTypes.any,
|
|
2290
|
+
initialSelectedItem: PropTypes.any,
|
|
2291
|
+
defaultSelectedItem: PropTypes.any,
|
|
2292
|
+
id: PropTypes.string,
|
|
2293
|
+
labelId: PropTypes.string,
|
|
2294
|
+
menuId: PropTypes.string,
|
|
2295
|
+
getItemId: PropTypes.func,
|
|
2296
|
+
toggleButtonId: PropTypes.string,
|
|
2297
|
+
stateReducer: PropTypes.func,
|
|
2298
|
+
onSelectedItemChange: PropTypes.func,
|
|
2299
|
+
onHighlightedIndexChange: PropTypes.func,
|
|
2300
|
+
onStateChange: PropTypes.func,
|
|
2301
|
+
onIsOpenChange: PropTypes.func,
|
|
2302
|
+
environment: PropTypes.shape({
|
|
2303
|
+
addEventListener: PropTypes.func,
|
|
2304
|
+
removeEventListener: PropTypes.func,
|
|
2305
|
+
document: PropTypes.shape({
|
|
2306
|
+
getElementById: PropTypes.func,
|
|
2307
|
+
activeElement: PropTypes.any,
|
|
2308
|
+
body: PropTypes.any
|
|
2309
|
+
})
|
|
2298
2310
|
})
|
|
2299
|
-
})
|
|
2300
2311
|
};
|
|
2301
2312
|
/**
|
|
2302
2313
|
* Default implementation for status message. Only added when menu is open.
|
|
@@ -2306,39 +2317,27 @@ var propTypes$2 = {
|
|
|
2306
2317
|
* @param {Object} param the downshift state and other relevant properties
|
|
2307
2318
|
* @return {String} the a11y status message
|
|
2308
2319
|
*/
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2320
|
+
function getA11yStatusMessage(_a) {
|
|
2321
|
+
var isOpen = _a.isOpen, resultCount = _a.resultCount, previousResultCount = _a.previousResultCount;
|
|
2322
|
+
if (!isOpen) {
|
|
2323
|
+
return '';
|
|
2324
|
+
}
|
|
2325
|
+
if (!resultCount) {
|
|
2326
|
+
return 'No results are available.';
|
|
2327
|
+
}
|
|
2328
|
+
if (resultCount !== previousResultCount) {
|
|
2329
|
+
return resultCount + " result" + (resultCount === 1 ? ' is' : 's are') + " available, use up and down arrow keys to navigate. Press Enter or Space Bar keys to select.";
|
|
2330
|
+
}
|
|
2316
2331
|
return '';
|
|
2317
|
-
}
|
|
2318
|
-
|
|
2319
|
-
if (!resultCount) {
|
|
2320
|
-
return 'No results are available.';
|
|
2321
|
-
}
|
|
2322
|
-
|
|
2323
|
-
if (resultCount !== previousResultCount) {
|
|
2324
|
-
return resultCount + " result" + (resultCount === 1 ? ' is' : 's are') + " available, use up and down arrow keys to navigate. Press Enter or Space Bar keys to select.";
|
|
2325
|
-
}
|
|
2326
|
-
|
|
2327
|
-
return '';
|
|
2328
2332
|
}
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
getA11yStatusMessage: getA11yStatusMessage
|
|
2332
|
-
}); // eslint-disable-next-line import/no-mutable-exports
|
|
2333
|
-
|
|
2334
|
-
|
|
2333
|
+
var defaultProps$2 = __assign(__assign({}, defaultProps$3), { getA11yStatusMessage: getA11yStatusMessage });
|
|
2334
|
+
// eslint-disable-next-line import/no-mutable-exports
|
|
2335
2335
|
var validatePropTypes$2 = noop;
|
|
2336
2336
|
/* istanbul ignore next */
|
|
2337
|
-
|
|
2338
2337
|
if (process.env.NODE_ENV !== 'production') {
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2338
|
+
validatePropTypes$2 = function (options, caller) {
|
|
2339
|
+
PropTypes.checkPropTypes(propTypes$2, options, 'prop', caller.name);
|
|
2340
|
+
};
|
|
2342
2341
|
}
|
|
2343
2342
|
|
|
2344
2343
|
var MenuKeyDownArrowDown = process.env.NODE_ENV !== "production" ? '__menu_keydown_arrow_down__' : 0;
|
|
@@ -2413,7 +2412,13 @@ function downshiftSelectReducer(state, action) {
|
|
|
2413
2412
|
{
|
|
2414
2413
|
var lowercasedKey = action.key;
|
|
2415
2414
|
var inputValue = "" + state.inputValue + lowercasedKey;
|
|
2416
|
-
var itemIndex = getItemIndexByCharacterKey(
|
|
2415
|
+
var itemIndex = getItemIndexByCharacterKey({
|
|
2416
|
+
keysSoFar: inputValue,
|
|
2417
|
+
highlightedIndex: state.selectedItem ? props.items.indexOf(state.selectedItem) : -1,
|
|
2418
|
+
items: props.items,
|
|
2419
|
+
itemToString: props.itemToString,
|
|
2420
|
+
getItemNodeFromIndex: action.getItemNodeFromIndex
|
|
2421
|
+
});
|
|
2417
2422
|
changes = _extends({
|
|
2418
2423
|
inputValue: inputValue
|
|
2419
2424
|
}, itemIndex >= 0 && {
|
|
@@ -2478,7 +2483,13 @@ function downshiftSelectReducer(state, action) {
|
|
|
2478
2483
|
|
|
2479
2484
|
var _inputValue = "" + state.inputValue + _lowercasedKey;
|
|
2480
2485
|
|
|
2481
|
-
var highlightedIndex = getItemIndexByCharacterKey(
|
|
2486
|
+
var highlightedIndex = getItemIndexByCharacterKey({
|
|
2487
|
+
keysSoFar: _inputValue,
|
|
2488
|
+
highlightedIndex: state.highlightedIndex,
|
|
2489
|
+
items: props.items,
|
|
2490
|
+
itemToString: props.itemToString,
|
|
2491
|
+
getItemNodeFromIndex: action.getItemNodeFromIndex
|
|
2492
|
+
});
|
|
2482
2493
|
changes = _extends({
|
|
2483
2494
|
inputValue: _inputValue
|
|
2484
2495
|
}, highlightedIndex >= 0 && {
|
|
@@ -2513,6 +2524,9 @@ function downshiftSelectReducer(state, action) {
|
|
|
2513
2524
|
}
|
|
2514
2525
|
/* eslint-enable complexity */
|
|
2515
2526
|
|
|
2527
|
+
var _excluded$2 = ["onMouseLeave", "refKey", "onKeyDown", "onBlur", "ref"],
|
|
2528
|
+
_excluded2$2 = ["onClick", "onKeyDown", "refKey", "ref"],
|
|
2529
|
+
_excluded3$1 = ["item", "index", "onMouseMove", "onClick", "refKey", "ref"];
|
|
2516
2530
|
useSelect.stateChangeTypes = stateChangeTypes$2;
|
|
2517
2531
|
|
|
2518
2532
|
function useSelect(userProps) {
|
|
@@ -2803,7 +2817,7 @@ function useSelect(userProps) {
|
|
|
2803
2817
|
onKeyDown = _ref.onKeyDown,
|
|
2804
2818
|
onBlur = _ref.onBlur,
|
|
2805
2819
|
ref = _ref.ref,
|
|
2806
|
-
rest = _objectWithoutPropertiesLoose(_ref,
|
|
2820
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$2);
|
|
2807
2821
|
|
|
2808
2822
|
var _ref2 = _temp2 === void 0 ? {} : _temp2,
|
|
2809
2823
|
_ref2$suppressRefErro = _ref2.suppressRefError,
|
|
@@ -2868,7 +2882,7 @@ function useSelect(userProps) {
|
|
|
2868
2882
|
_ref3$refKey = _ref3.refKey,
|
|
2869
2883
|
refKey = _ref3$refKey === void 0 ? 'ref' : _ref3$refKey,
|
|
2870
2884
|
ref = _ref3.ref,
|
|
2871
|
-
rest = _objectWithoutPropertiesLoose(_ref3,
|
|
2885
|
+
rest = _objectWithoutPropertiesLoose(_ref3, _excluded2$2);
|
|
2872
2886
|
|
|
2873
2887
|
var _ref4 = _temp4 === void 0 ? {} : _temp4,
|
|
2874
2888
|
_ref4$suppressRefErro = _ref4.suppressRefError,
|
|
@@ -2917,7 +2931,7 @@ function useSelect(userProps) {
|
|
|
2917
2931
|
_ref5$refKey = _ref5.refKey,
|
|
2918
2932
|
refKey = _ref5$refKey === void 0 ? 'ref' : _ref5$refKey,
|
|
2919
2933
|
ref = _ref5.ref,
|
|
2920
|
-
rest = _objectWithoutPropertiesLoose(_ref5,
|
|
2934
|
+
rest = _objectWithoutPropertiesLoose(_ref5, _excluded3$1);
|
|
2921
2935
|
|
|
2922
2936
|
var _latest$current = latest.current,
|
|
2923
2937
|
latestState = _latest$current.state,
|
|
@@ -3253,6 +3267,11 @@ function downshiftUseComboboxReducer(state, action) {
|
|
|
3253
3267
|
}
|
|
3254
3268
|
/* eslint-enable complexity */
|
|
3255
3269
|
|
|
3270
|
+
var _excluded$1 = ["onMouseLeave", "refKey", "ref"],
|
|
3271
|
+
_excluded2$1 = ["item", "index", "refKey", "ref", "onMouseMove", "onClick", "onPress"],
|
|
3272
|
+
_excluded3 = ["onClick", "onPress", "refKey", "ref"],
|
|
3273
|
+
_excluded4 = ["onKeyDown", "onChange", "onInput", "onBlur", "onChangeText", "refKey", "ref"],
|
|
3274
|
+
_excluded5 = ["refKey", "ref"];
|
|
3256
3275
|
useCombobox.stateChangeTypes = stateChangeTypes$1;
|
|
3257
3276
|
|
|
3258
3277
|
function useCombobox(userProps) {
|
|
@@ -3423,8 +3442,8 @@ function useCombobox(userProps) {
|
|
|
3423
3442
|
|
|
3424
3443
|
if (!latestState.isOpen || latestState.highlightedIndex < 0 || event.which === 229 // if IME composing, wait for next Enter keydown event.
|
|
3425
3444
|
) {
|
|
3426
|
-
|
|
3427
|
-
|
|
3445
|
+
return;
|
|
3446
|
+
}
|
|
3428
3447
|
|
|
3429
3448
|
event.preventDefault();
|
|
3430
3449
|
dispatch({
|
|
@@ -3449,7 +3468,7 @@ function useCombobox(userProps) {
|
|
|
3449
3468
|
_ref$refKey = _ref.refKey,
|
|
3450
3469
|
refKey = _ref$refKey === void 0 ? 'ref' : _ref$refKey,
|
|
3451
3470
|
ref = _ref.ref,
|
|
3452
|
-
rest = _objectWithoutPropertiesLoose(_ref,
|
|
3471
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$1);
|
|
3453
3472
|
|
|
3454
3473
|
var _ref2 = _temp2 === void 0 ? {} : _temp2,
|
|
3455
3474
|
_ref2$suppressRefErro = _ref2.suppressRefError,
|
|
@@ -3476,7 +3495,7 @@ function useCombobox(userProps) {
|
|
|
3476
3495
|
onMouseMove = _ref3.onMouseMove,
|
|
3477
3496
|
onClick = _ref3.onClick;
|
|
3478
3497
|
_ref3.onPress;
|
|
3479
|
-
var rest = _objectWithoutPropertiesLoose(_ref3,
|
|
3498
|
+
var rest = _objectWithoutPropertiesLoose(_ref3, _excluded2$1);
|
|
3480
3499
|
|
|
3481
3500
|
var _latest$current = latest.current,
|
|
3482
3501
|
latestProps = _latest$current.props,
|
|
@@ -3530,7 +3549,7 @@ function useCombobox(userProps) {
|
|
|
3530
3549
|
var _ref5$refKey = _ref5.refKey,
|
|
3531
3550
|
refKey = _ref5$refKey === void 0 ? 'ref' : _ref5$refKey,
|
|
3532
3551
|
ref = _ref5.ref,
|
|
3533
|
-
rest = _objectWithoutPropertiesLoose(_ref5,
|
|
3552
|
+
rest = _objectWithoutPropertiesLoose(_ref5, _excluded3);
|
|
3534
3553
|
|
|
3535
3554
|
var toggleButtonHandleClick = function toggleButtonHandleClick() {
|
|
3536
3555
|
dispatch({
|
|
@@ -3560,7 +3579,7 @@ function useCombobox(userProps) {
|
|
|
3560
3579
|
var _ref6$refKey = _ref6.refKey,
|
|
3561
3580
|
refKey = _ref6$refKey === void 0 ? 'ref' : _ref6$refKey,
|
|
3562
3581
|
ref = _ref6.ref,
|
|
3563
|
-
rest = _objectWithoutPropertiesLoose(_ref6,
|
|
3582
|
+
rest = _objectWithoutPropertiesLoose(_ref6, _excluded4);
|
|
3564
3583
|
|
|
3565
3584
|
var _ref7 = _temp6 === void 0 ? {} : _temp6,
|
|
3566
3585
|
_ref7$suppressRefErro = _ref7.suppressRefError,
|
|
@@ -3624,7 +3643,7 @@ function useCombobox(userProps) {
|
|
|
3624
3643
|
_ref8$refKey = _ref8.refKey,
|
|
3625
3644
|
refKey = _ref8$refKey === void 0 ? 'ref' : _ref8$refKey,
|
|
3626
3645
|
ref = _ref8.ref,
|
|
3627
|
-
rest = _objectWithoutPropertiesLoose(_ref8,
|
|
3646
|
+
rest = _objectWithoutPropertiesLoose(_ref8, _excluded5);
|
|
3628
3647
|
|
|
3629
3648
|
var _ref9 = _temp8 === void 0 ? {} : _temp8,
|
|
3630
3649
|
_ref9$suppressRefErro = _ref9.suppressRefError,
|
|
@@ -3764,9 +3783,7 @@ function isKeyDownOperationPermitted(event) {
|
|
|
3764
3783
|
var element = event.target;
|
|
3765
3784
|
|
|
3766
3785
|
if (element instanceof HTMLInputElement && // if element is a text input
|
|
3767
|
-
element.value !== '' && (
|
|
3768
|
-
// and cursor is either not at the start or is currently highlighting text.
|
|
3769
|
-
element.selectionStart !== 0 || element.selectionEnd !== 0)) {
|
|
3786
|
+
element.value !== '' && (element.selectionStart !== 0 || element.selectionEnd !== 0)) {
|
|
3770
3787
|
return false;
|
|
3771
3788
|
}
|
|
3772
3789
|
|
|
@@ -3983,6 +4000,8 @@ function downshiftMultipleSelectionReducer(state, action) {
|
|
|
3983
4000
|
return _extends({}, state, changes);
|
|
3984
4001
|
}
|
|
3985
4002
|
|
|
4003
|
+
var _excluded = ["refKey", "ref", "onClick", "onKeyDown", "selectedItem", "index"],
|
|
4004
|
+
_excluded2 = ["refKey", "ref", "onKeyDown", "onClick", "preventKeyAction"];
|
|
3986
4005
|
useMultipleSelection.stateChangeTypes = stateChangeTypes;
|
|
3987
4006
|
|
|
3988
4007
|
function useMultipleSelection(userProps) {
|
|
@@ -4112,7 +4131,7 @@ function useMultipleSelection(userProps) {
|
|
|
4112
4131
|
onKeyDown = _ref3.onKeyDown,
|
|
4113
4132
|
selectedItem = _ref3.selectedItem,
|
|
4114
4133
|
index = _ref3.index,
|
|
4115
|
-
rest = _objectWithoutPropertiesLoose(_ref3,
|
|
4134
|
+
rest = _objectWithoutPropertiesLoose(_ref3, _excluded);
|
|
4116
4135
|
|
|
4117
4136
|
var latestState = latest.current.state;
|
|
4118
4137
|
var itemIndex = getItemIndex(index, selectedItem, latestState.selectedItems);
|
|
@@ -4153,7 +4172,7 @@ function useMultipleSelection(userProps) {
|
|
|
4153
4172
|
onClick = _ref4.onClick,
|
|
4154
4173
|
_ref4$preventKeyActio = _ref4.preventKeyAction,
|
|
4155
4174
|
preventKeyAction = _ref4$preventKeyActio === void 0 ? false : _ref4$preventKeyActio,
|
|
4156
|
-
rest = _objectWithoutPropertiesLoose(_ref4,
|
|
4175
|
+
rest = _objectWithoutPropertiesLoose(_ref4, _excluded2);
|
|
4157
4176
|
|
|
4158
4177
|
var _ref5 = _temp3 === void 0 ? {} : _temp3,
|
|
4159
4178
|
_ref5$suppressRefErro = _ref5.suppressRefError,
|
|
@@ -4227,5 +4246,4 @@ function useMultipleSelection(userProps) {
|
|
|
4227
4246
|
};
|
|
4228
4247
|
}
|
|
4229
4248
|
|
|
4230
|
-
export default
|
|
4231
|
-
export { resetIdCounter, useCombobox, useMultipleSelection, useSelect };
|
|
4249
|
+
export { Downshift$1 as default, resetIdCounter, useCombobox, useMultipleSelection, useSelect };
|