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
|
@@ -2,9 +2,10 @@ import _objectWithoutPropertiesLoose from '@babel/runtime/helpers/esm/objectWith
|
|
|
2
2
|
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
|
-
import { cloneElement, Component, useRef, useEffect,
|
|
5
|
+
import { cloneElement, Component, useRef, useEffect, useCallback, useLayoutEffect, useReducer, useMemo } from 'preact';
|
|
6
6
|
import { isForwardRef } from 'react-is';
|
|
7
7
|
import computeScrollIntoView from 'compute-scroll-into-view';
|
|
8
|
+
import { __assign } from 'tslib';
|
|
8
9
|
import PropTypes from 'prop-types';
|
|
9
10
|
|
|
10
11
|
var idCounter = 0;
|
|
@@ -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
|
|
@@ -541,6 +542,12 @@ var stateChangeTypes$3 = /*#__PURE__*/Object.freeze({
|
|
|
541
542
|
touchEnd: touchEnd
|
|
542
543
|
});
|
|
543
544
|
|
|
545
|
+
var _excluded$4 = ["refKey", "ref"],
|
|
546
|
+
_excluded2$3 = ["onClick", "onPress", "onKeyDown", "onKeyUp", "onBlur"],
|
|
547
|
+
_excluded3$2 = ["onKeyDown", "onBlur", "onChange", "onInput", "onChangeText"],
|
|
548
|
+
_excluded4$1 = ["refKey", "ref"],
|
|
549
|
+
_excluded5$1 = ["onMouseMove", "onMouseDown", "onClick", "onPress", "index", "item"];
|
|
550
|
+
|
|
544
551
|
var Downshift = /*#__PURE__*/function () {
|
|
545
552
|
var Downshift = /*#__PURE__*/function (_Component) {
|
|
546
553
|
_inheritsLoose(Downshift, _Component);
|
|
@@ -660,6 +667,8 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
660
667
|
isItemSelected = newStateToSet.hasOwnProperty('selectedItem'); // this keeps track of the object we want to call with setState
|
|
661
668
|
|
|
662
669
|
var nextState = {}; // this is just used to tell whether the state changed
|
|
670
|
+
|
|
671
|
+
var nextFullState = {}; // we need to call on change if the outside world is controlling any of our state
|
|
663
672
|
// and we're trying to update that state. OR if the selection has changed and we're
|
|
664
673
|
// trying to update the selection
|
|
665
674
|
|
|
@@ -685,7 +694,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
685
694
|
return;
|
|
686
695
|
}
|
|
687
696
|
|
|
688
|
-
newStateToSet[key]; // if it's coming from props, then we don't care to set it internally
|
|
697
|
+
nextFullState[key] = newStateToSet[key]; // if it's coming from props, then we don't care to set it internally
|
|
689
698
|
|
|
690
699
|
if (!isControlledProp(_this.props, key)) {
|
|
691
700
|
nextState[key] = newStateToSet[key];
|
|
@@ -734,7 +743,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
734
743
|
_ref$refKey = _ref.refKey,
|
|
735
744
|
refKey = _ref$refKey === void 0 ? 'ref' : _ref$refKey,
|
|
736
745
|
ref = _ref.ref,
|
|
737
|
-
rest = _objectWithoutPropertiesLoose(_ref,
|
|
746
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$4);
|
|
738
747
|
|
|
739
748
|
var _ref2 = _temp2 === void 0 ? {} : _temp2,
|
|
740
749
|
_ref2$suppressRefErro = _ref2.suppressRefError,
|
|
@@ -918,7 +927,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
918
927
|
var onKeyDown = _ref3.onKeyDown,
|
|
919
928
|
onKeyUp = _ref3.onKeyUp,
|
|
920
929
|
onBlur = _ref3.onBlur,
|
|
921
|
-
rest = _objectWithoutPropertiesLoose(_ref3,
|
|
930
|
+
rest = _objectWithoutPropertiesLoose(_ref3, _excluded2$3);
|
|
922
931
|
|
|
923
932
|
var _this$getState5 = _this.getState(),
|
|
924
933
|
isOpen = _this$getState5.isOpen;
|
|
@@ -986,10 +995,10 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
986
995
|
_this.internalSetTimeout(function () {
|
|
987
996
|
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)
|
|
988
997
|
) {
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
998
|
+
_this.reset({
|
|
999
|
+
type: blurButton
|
|
1000
|
+
});
|
|
1001
|
+
}
|
|
993
1002
|
});
|
|
994
1003
|
};
|
|
995
1004
|
|
|
@@ -1007,7 +1016,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1007
1016
|
onChange = _ref4.onChange,
|
|
1008
1017
|
onInput = _ref4.onInput;
|
|
1009
1018
|
_ref4.onChangeText;
|
|
1010
|
-
var rest = _objectWithoutPropertiesLoose(_ref4,
|
|
1019
|
+
var rest = _objectWithoutPropertiesLoose(_ref4, _excluded3$2);
|
|
1011
1020
|
|
|
1012
1021
|
var onChangeKey;
|
|
1013
1022
|
var eventHandlers = {};
|
|
@@ -1082,7 +1091,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1082
1091
|
_ref5$refKey = _ref5.refKey,
|
|
1083
1092
|
refKey = _ref5$refKey === void 0 ? 'ref' : _ref5$refKey,
|
|
1084
1093
|
ref = _ref5.ref,
|
|
1085
|
-
props = _objectWithoutPropertiesLoose(_ref5,
|
|
1094
|
+
props = _objectWithoutPropertiesLoose(_ref5, _excluded4$1);
|
|
1086
1095
|
|
|
1087
1096
|
var _ref6 = _temp6 === void 0 ? {} : _temp6,
|
|
1088
1097
|
_ref6$suppressRefErro = _ref6.suppressRefError,
|
|
@@ -1107,7 +1116,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1107
1116
|
item = _ref7$item === void 0 ? process.env.NODE_ENV === 'production' ?
|
|
1108
1117
|
/* istanbul ignore next */
|
|
1109
1118
|
undefined : requiredProp('getItemProps', 'item') : _ref7$item,
|
|
1110
|
-
rest = _objectWithoutPropertiesLoose(_ref7,
|
|
1119
|
+
rest = _objectWithoutPropertiesLoose(_ref7, _excluded5$1);
|
|
1111
1120
|
|
|
1112
1121
|
if (index === undefined) {
|
|
1113
1122
|
_this.items.push(item);
|
|
@@ -1615,9 +1624,9 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1615
1624
|
selectedItemChanged: function selectedItemChanged(prevItem, item) {
|
|
1616
1625
|
return prevItem !== item;
|
|
1617
1626
|
},
|
|
1618
|
-
environment:
|
|
1627
|
+
environment:
|
|
1619
1628
|
/* istanbul ignore next (ssr) */
|
|
1620
|
-
? {} : window,
|
|
1629
|
+
typeof window === 'undefined' ? {} : window,
|
|
1621
1630
|
stateReducer: function stateReducer(state, stateToSet) {
|
|
1622
1631
|
return stateToSet;
|
|
1623
1632
|
},
|
|
@@ -1628,6 +1637,8 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1628
1637
|
return Downshift;
|
|
1629
1638
|
}();
|
|
1630
1639
|
|
|
1640
|
+
var Downshift$1 = Downshift;
|
|
1641
|
+
|
|
1631
1642
|
function validateGetMenuPropsCalledCorrectly(node, _ref12) {
|
|
1632
1643
|
var refKey = _ref12.refKey;
|
|
1633
1644
|
|
|
@@ -1656,6 +1667,7 @@ function validateGetRootPropsCalledCorrectly(element, _ref13) {
|
|
|
1656
1667
|
}
|
|
1657
1668
|
}
|
|
1658
1669
|
|
|
1670
|
+
var _excluded$3 = ["isInitialMount", "highlightedIndex", "items", "environment"];
|
|
1659
1671
|
var dropdownDefaultStateValues = {
|
|
1660
1672
|
highlightedIndex: -1,
|
|
1661
1673
|
isOpen: false,
|
|
@@ -1853,9 +1865,9 @@ var defaultProps$3 = {
|
|
|
1853
1865
|
getA11ySelectionMessage: getA11ySelectionMessage,
|
|
1854
1866
|
scrollIntoView: scrollIntoView,
|
|
1855
1867
|
circularNavigation: false,
|
|
1856
|
-
environment:
|
|
1868
|
+
environment:
|
|
1857
1869
|
/* istanbul ignore next (ssr) */
|
|
1858
|
-
? {} : window
|
|
1870
|
+
typeof window === 'undefined' ? {} : window
|
|
1859
1871
|
};
|
|
1860
1872
|
|
|
1861
1873
|
function getDefaultValue$1(props, propKey, defaultStateValues) {
|
|
@@ -2069,11 +2081,11 @@ function useA11yMessageSetter(getA11yMessage, dependencyArray, _ref2) {
|
|
|
2069
2081
|
highlightedIndex = _ref2.highlightedIndex,
|
|
2070
2082
|
items = _ref2.items,
|
|
2071
2083
|
environment = _ref2.environment,
|
|
2072
|
-
rest = _objectWithoutPropertiesLoose(_ref2,
|
|
2084
|
+
rest = _objectWithoutPropertiesLoose(_ref2, _excluded$3);
|
|
2073
2085
|
|
|
2074
2086
|
// Sets a11y status message on changes in state.
|
|
2075
2087
|
useEffect(function () {
|
|
2076
|
-
if (isInitialMount) {
|
|
2088
|
+
if (isInitialMount || false) {
|
|
2077
2089
|
return;
|
|
2078
2090
|
}
|
|
2079
2091
|
|
|
@@ -2204,58 +2216,58 @@ function downshiftCommonReducer(state, action, stateChangeTypes) {
|
|
|
2204
2216
|
}
|
|
2205
2217
|
/* eslint-enable complexity */
|
|
2206
2218
|
|
|
2207
|
-
function getItemIndexByCharacterKey(
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
+
function getItemIndexByCharacterKey(_a) {
|
|
2220
|
+
var keysSoFar = _a.keysSoFar, highlightedIndex = _a.highlightedIndex, items = _a.items, itemToString = _a.itemToString, getItemNodeFromIndex = _a.getItemNodeFromIndex;
|
|
2221
|
+
var lowerCasedKeysSoFar = keysSoFar.toLowerCase();
|
|
2222
|
+
for (var index = 0; index < items.length; index++) {
|
|
2223
|
+
var offsetIndex = (index + highlightedIndex + 1) % items.length;
|
|
2224
|
+
var item = items[offsetIndex];
|
|
2225
|
+
if (item !== undefined &&
|
|
2226
|
+
itemToString(item)
|
|
2227
|
+
.toLowerCase()
|
|
2228
|
+
.startsWith(lowerCasedKeysSoFar)) {
|
|
2229
|
+
var element = getItemNodeFromIndex(offsetIndex);
|
|
2230
|
+
if (!(element === null || element === void 0 ? void 0 : element.hasAttribute('disabled'))) {
|
|
2231
|
+
return offsetIndex;
|
|
2232
|
+
}
|
|
2233
|
+
}
|
|
2219
2234
|
}
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
return highlightedIndex;
|
|
2235
|
+
return highlightedIndex;
|
|
2223
2236
|
}
|
|
2224
|
-
|
|
2225
2237
|
var propTypes$2 = {
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2238
|
+
items: PropTypes.array.isRequired,
|
|
2239
|
+
itemToString: PropTypes.func,
|
|
2240
|
+
getA11yStatusMessage: PropTypes.func,
|
|
2241
|
+
getA11ySelectionMessage: PropTypes.func,
|
|
2242
|
+
circularNavigation: PropTypes.bool,
|
|
2243
|
+
highlightedIndex: PropTypes.number,
|
|
2244
|
+
defaultHighlightedIndex: PropTypes.number,
|
|
2245
|
+
initialHighlightedIndex: PropTypes.number,
|
|
2246
|
+
isOpen: PropTypes.bool,
|
|
2247
|
+
defaultIsOpen: PropTypes.bool,
|
|
2248
|
+
initialIsOpen: PropTypes.bool,
|
|
2249
|
+
selectedItem: PropTypes.any,
|
|
2250
|
+
initialSelectedItem: PropTypes.any,
|
|
2251
|
+
defaultSelectedItem: PropTypes.any,
|
|
2252
|
+
id: PropTypes.string,
|
|
2253
|
+
labelId: PropTypes.string,
|
|
2254
|
+
menuId: PropTypes.string,
|
|
2255
|
+
getItemId: PropTypes.func,
|
|
2256
|
+
toggleButtonId: PropTypes.string,
|
|
2257
|
+
stateReducer: PropTypes.func,
|
|
2258
|
+
onSelectedItemChange: PropTypes.func,
|
|
2259
|
+
onHighlightedIndexChange: PropTypes.func,
|
|
2260
|
+
onStateChange: PropTypes.func,
|
|
2261
|
+
onIsOpenChange: PropTypes.func,
|
|
2262
|
+
environment: PropTypes.shape({
|
|
2263
|
+
addEventListener: PropTypes.func,
|
|
2264
|
+
removeEventListener: PropTypes.func,
|
|
2265
|
+
document: PropTypes.shape({
|
|
2266
|
+
getElementById: PropTypes.func,
|
|
2267
|
+
activeElement: PropTypes.any,
|
|
2268
|
+
body: PropTypes.any
|
|
2269
|
+
})
|
|
2257
2270
|
})
|
|
2258
|
-
})
|
|
2259
2271
|
};
|
|
2260
2272
|
/**
|
|
2261
2273
|
* Default implementation for status message. Only added when menu is open.
|
|
@@ -2265,39 +2277,27 @@ var propTypes$2 = {
|
|
|
2265
2277
|
* @param {Object} param the downshift state and other relevant properties
|
|
2266
2278
|
* @return {String} the a11y status message
|
|
2267
2279
|
*/
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2280
|
+
function getA11yStatusMessage(_a) {
|
|
2281
|
+
var isOpen = _a.isOpen, resultCount = _a.resultCount, previousResultCount = _a.previousResultCount;
|
|
2282
|
+
if (!isOpen) {
|
|
2283
|
+
return '';
|
|
2284
|
+
}
|
|
2285
|
+
if (!resultCount) {
|
|
2286
|
+
return 'No results are available.';
|
|
2287
|
+
}
|
|
2288
|
+
if (resultCount !== previousResultCount) {
|
|
2289
|
+
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.";
|
|
2290
|
+
}
|
|
2275
2291
|
return '';
|
|
2276
|
-
}
|
|
2277
|
-
|
|
2278
|
-
if (!resultCount) {
|
|
2279
|
-
return 'No results are available.';
|
|
2280
|
-
}
|
|
2281
|
-
|
|
2282
|
-
if (resultCount !== previousResultCount) {
|
|
2283
|
-
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.";
|
|
2284
|
-
}
|
|
2285
|
-
|
|
2286
|
-
return '';
|
|
2287
2292
|
}
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
getA11yStatusMessage: getA11yStatusMessage
|
|
2291
|
-
}); // eslint-disable-next-line import/no-mutable-exports
|
|
2292
|
-
|
|
2293
|
-
|
|
2293
|
+
var defaultProps$2 = __assign(__assign({}, defaultProps$3), { getA11yStatusMessage: getA11yStatusMessage });
|
|
2294
|
+
// eslint-disable-next-line import/no-mutable-exports
|
|
2294
2295
|
var validatePropTypes$2 = noop;
|
|
2295
2296
|
/* istanbul ignore next */
|
|
2296
|
-
|
|
2297
2297
|
if (process.env.NODE_ENV !== 'production') {
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2298
|
+
validatePropTypes$2 = function (options, caller) {
|
|
2299
|
+
PropTypes.checkPropTypes(propTypes$2, options, 'prop', caller.name);
|
|
2300
|
+
};
|
|
2301
2301
|
}
|
|
2302
2302
|
|
|
2303
2303
|
var MenuKeyDownArrowDown = process.env.NODE_ENV !== "production" ? '__menu_keydown_arrow_down__' : 0;
|
|
@@ -2372,7 +2372,13 @@ function downshiftSelectReducer(state, action) {
|
|
|
2372
2372
|
{
|
|
2373
2373
|
var lowercasedKey = action.key;
|
|
2374
2374
|
var inputValue = "" + state.inputValue + lowercasedKey;
|
|
2375
|
-
var itemIndex = getItemIndexByCharacterKey(
|
|
2375
|
+
var itemIndex = getItemIndexByCharacterKey({
|
|
2376
|
+
keysSoFar: inputValue,
|
|
2377
|
+
highlightedIndex: state.selectedItem ? props.items.indexOf(state.selectedItem) : -1,
|
|
2378
|
+
items: props.items,
|
|
2379
|
+
itemToString: props.itemToString,
|
|
2380
|
+
getItemNodeFromIndex: action.getItemNodeFromIndex
|
|
2381
|
+
});
|
|
2376
2382
|
changes = _extends({
|
|
2377
2383
|
inputValue: inputValue
|
|
2378
2384
|
}, itemIndex >= 0 && {
|
|
@@ -2437,7 +2443,13 @@ function downshiftSelectReducer(state, action) {
|
|
|
2437
2443
|
|
|
2438
2444
|
var _inputValue = "" + state.inputValue + _lowercasedKey;
|
|
2439
2445
|
|
|
2440
|
-
var highlightedIndex = getItemIndexByCharacterKey(
|
|
2446
|
+
var highlightedIndex = getItemIndexByCharacterKey({
|
|
2447
|
+
keysSoFar: _inputValue,
|
|
2448
|
+
highlightedIndex: state.highlightedIndex,
|
|
2449
|
+
items: props.items,
|
|
2450
|
+
itemToString: props.itemToString,
|
|
2451
|
+
getItemNodeFromIndex: action.getItemNodeFromIndex
|
|
2452
|
+
});
|
|
2441
2453
|
changes = _extends({
|
|
2442
2454
|
inputValue: _inputValue
|
|
2443
2455
|
}, highlightedIndex >= 0 && {
|
|
@@ -2472,6 +2484,9 @@ function downshiftSelectReducer(state, action) {
|
|
|
2472
2484
|
}
|
|
2473
2485
|
/* eslint-enable complexity */
|
|
2474
2486
|
|
|
2487
|
+
var _excluded$2 = ["onMouseLeave", "refKey", "onKeyDown", "onBlur", "ref"],
|
|
2488
|
+
_excluded2$2 = ["onClick", "onKeyDown", "refKey", "ref"],
|
|
2489
|
+
_excluded3$1 = ["item", "index", "onMouseMove", "onClick", "refKey", "ref"];
|
|
2475
2490
|
useSelect.stateChangeTypes = stateChangeTypes$2;
|
|
2476
2491
|
|
|
2477
2492
|
function useSelect(userProps) {
|
|
@@ -2762,7 +2777,7 @@ function useSelect(userProps) {
|
|
|
2762
2777
|
onKeyDown = _ref.onKeyDown,
|
|
2763
2778
|
onBlur = _ref.onBlur,
|
|
2764
2779
|
ref = _ref.ref,
|
|
2765
|
-
rest = _objectWithoutPropertiesLoose(_ref,
|
|
2780
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$2);
|
|
2766
2781
|
|
|
2767
2782
|
var _ref2 = _temp2 === void 0 ? {} : _temp2,
|
|
2768
2783
|
_ref2$suppressRefErro = _ref2.suppressRefError,
|
|
@@ -2827,7 +2842,7 @@ function useSelect(userProps) {
|
|
|
2827
2842
|
_ref3$refKey = _ref3.refKey,
|
|
2828
2843
|
refKey = _ref3$refKey === void 0 ? 'ref' : _ref3$refKey,
|
|
2829
2844
|
ref = _ref3.ref,
|
|
2830
|
-
rest = _objectWithoutPropertiesLoose(_ref3,
|
|
2845
|
+
rest = _objectWithoutPropertiesLoose(_ref3, _excluded2$2);
|
|
2831
2846
|
|
|
2832
2847
|
var _ref4 = _temp4 === void 0 ? {} : _temp4,
|
|
2833
2848
|
_ref4$suppressRefErro = _ref4.suppressRefError,
|
|
@@ -2876,7 +2891,7 @@ function useSelect(userProps) {
|
|
|
2876
2891
|
_ref5$refKey = _ref5.refKey,
|
|
2877
2892
|
refKey = _ref5$refKey === void 0 ? 'ref' : _ref5$refKey,
|
|
2878
2893
|
ref = _ref5.ref,
|
|
2879
|
-
rest = _objectWithoutPropertiesLoose(_ref5,
|
|
2894
|
+
rest = _objectWithoutPropertiesLoose(_ref5, _excluded3$1);
|
|
2880
2895
|
|
|
2881
2896
|
var _latest$current = latest.current,
|
|
2882
2897
|
latestState = _latest$current.state,
|
|
@@ -3212,6 +3227,11 @@ function downshiftUseComboboxReducer(state, action) {
|
|
|
3212
3227
|
}
|
|
3213
3228
|
/* eslint-enable complexity */
|
|
3214
3229
|
|
|
3230
|
+
var _excluded$1 = ["onMouseLeave", "refKey", "ref"],
|
|
3231
|
+
_excluded2$1 = ["item", "index", "refKey", "ref", "onMouseMove", "onClick", "onPress"],
|
|
3232
|
+
_excluded3 = ["onClick", "onPress", "refKey", "ref"],
|
|
3233
|
+
_excluded4 = ["onKeyDown", "onChange", "onInput", "onBlur", "onChangeText", "refKey", "ref"],
|
|
3234
|
+
_excluded5 = ["refKey", "ref"];
|
|
3215
3235
|
useCombobox.stateChangeTypes = stateChangeTypes$1;
|
|
3216
3236
|
|
|
3217
3237
|
function useCombobox(userProps) {
|
|
@@ -3382,8 +3402,8 @@ function useCombobox(userProps) {
|
|
|
3382
3402
|
|
|
3383
3403
|
if (!latestState.isOpen || latestState.highlightedIndex < 0 || event.which === 229 // if IME composing, wait for next Enter keydown event.
|
|
3384
3404
|
) {
|
|
3385
|
-
|
|
3386
|
-
|
|
3405
|
+
return;
|
|
3406
|
+
}
|
|
3387
3407
|
|
|
3388
3408
|
event.preventDefault();
|
|
3389
3409
|
dispatch({
|
|
@@ -3408,7 +3428,7 @@ function useCombobox(userProps) {
|
|
|
3408
3428
|
_ref$refKey = _ref.refKey,
|
|
3409
3429
|
refKey = _ref$refKey === void 0 ? 'ref' : _ref$refKey,
|
|
3410
3430
|
ref = _ref.ref,
|
|
3411
|
-
rest = _objectWithoutPropertiesLoose(_ref,
|
|
3431
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$1);
|
|
3412
3432
|
|
|
3413
3433
|
var _ref2 = _temp2 === void 0 ? {} : _temp2,
|
|
3414
3434
|
_ref2$suppressRefErro = _ref2.suppressRefError,
|
|
@@ -3435,7 +3455,7 @@ function useCombobox(userProps) {
|
|
|
3435
3455
|
onMouseMove = _ref3.onMouseMove,
|
|
3436
3456
|
onClick = _ref3.onClick;
|
|
3437
3457
|
_ref3.onPress;
|
|
3438
|
-
var rest = _objectWithoutPropertiesLoose(_ref3,
|
|
3458
|
+
var rest = _objectWithoutPropertiesLoose(_ref3, _excluded2$1);
|
|
3439
3459
|
|
|
3440
3460
|
var _latest$current = latest.current,
|
|
3441
3461
|
latestProps = _latest$current.props,
|
|
@@ -3489,7 +3509,7 @@ function useCombobox(userProps) {
|
|
|
3489
3509
|
var _ref5$refKey = _ref5.refKey,
|
|
3490
3510
|
refKey = _ref5$refKey === void 0 ? 'ref' : _ref5$refKey,
|
|
3491
3511
|
ref = _ref5.ref,
|
|
3492
|
-
rest = _objectWithoutPropertiesLoose(_ref5,
|
|
3512
|
+
rest = _objectWithoutPropertiesLoose(_ref5, _excluded3);
|
|
3493
3513
|
|
|
3494
3514
|
var toggleButtonHandleClick = function toggleButtonHandleClick() {
|
|
3495
3515
|
dispatch({
|
|
@@ -3519,7 +3539,7 @@ function useCombobox(userProps) {
|
|
|
3519
3539
|
var _ref6$refKey = _ref6.refKey,
|
|
3520
3540
|
refKey = _ref6$refKey === void 0 ? 'ref' : _ref6$refKey,
|
|
3521
3541
|
ref = _ref6.ref,
|
|
3522
|
-
rest = _objectWithoutPropertiesLoose(_ref6,
|
|
3542
|
+
rest = _objectWithoutPropertiesLoose(_ref6, _excluded4);
|
|
3523
3543
|
|
|
3524
3544
|
var _ref7 = _temp6 === void 0 ? {} : _temp6,
|
|
3525
3545
|
_ref7$suppressRefErro = _ref7.suppressRefError,
|
|
@@ -3583,7 +3603,7 @@ function useCombobox(userProps) {
|
|
|
3583
3603
|
_ref8$refKey = _ref8.refKey,
|
|
3584
3604
|
refKey = _ref8$refKey === void 0 ? 'ref' : _ref8$refKey,
|
|
3585
3605
|
ref = _ref8.ref,
|
|
3586
|
-
rest = _objectWithoutPropertiesLoose(_ref8,
|
|
3606
|
+
rest = _objectWithoutPropertiesLoose(_ref8, _excluded5);
|
|
3587
3607
|
|
|
3588
3608
|
var _ref9 = _temp8 === void 0 ? {} : _temp8,
|
|
3589
3609
|
_ref9$suppressRefErro = _ref9.suppressRefError,
|
|
@@ -3723,9 +3743,7 @@ function isKeyDownOperationPermitted(event) {
|
|
|
3723
3743
|
var element = event.target;
|
|
3724
3744
|
|
|
3725
3745
|
if (element instanceof HTMLInputElement && // if element is a text input
|
|
3726
|
-
element.value !== '' && (
|
|
3727
|
-
// and cursor is either not at the start or is currently highlighting text.
|
|
3728
|
-
element.selectionStart !== 0 || element.selectionEnd !== 0)) {
|
|
3746
|
+
element.value !== '' && (element.selectionStart !== 0 || element.selectionEnd !== 0)) {
|
|
3729
3747
|
return false;
|
|
3730
3748
|
}
|
|
3731
3749
|
|
|
@@ -3942,6 +3960,8 @@ function downshiftMultipleSelectionReducer(state, action) {
|
|
|
3942
3960
|
return _extends({}, state, changes);
|
|
3943
3961
|
}
|
|
3944
3962
|
|
|
3963
|
+
var _excluded = ["refKey", "ref", "onClick", "onKeyDown", "selectedItem", "index"],
|
|
3964
|
+
_excluded2 = ["refKey", "ref", "onKeyDown", "onClick", "preventKeyAction"];
|
|
3945
3965
|
useMultipleSelection.stateChangeTypes = stateChangeTypes;
|
|
3946
3966
|
|
|
3947
3967
|
function useMultipleSelection(userProps) {
|
|
@@ -4071,7 +4091,7 @@ function useMultipleSelection(userProps) {
|
|
|
4071
4091
|
onKeyDown = _ref3.onKeyDown,
|
|
4072
4092
|
selectedItem = _ref3.selectedItem,
|
|
4073
4093
|
index = _ref3.index,
|
|
4074
|
-
rest = _objectWithoutPropertiesLoose(_ref3,
|
|
4094
|
+
rest = _objectWithoutPropertiesLoose(_ref3, _excluded);
|
|
4075
4095
|
|
|
4076
4096
|
var latestState = latest.current.state;
|
|
4077
4097
|
var itemIndex = getItemIndex(index, selectedItem, latestState.selectedItems);
|
|
@@ -4112,7 +4132,7 @@ function useMultipleSelection(userProps) {
|
|
|
4112
4132
|
onClick = _ref4.onClick,
|
|
4113
4133
|
_ref4$preventKeyActio = _ref4.preventKeyAction,
|
|
4114
4134
|
preventKeyAction = _ref4$preventKeyActio === void 0 ? false : _ref4$preventKeyActio,
|
|
4115
|
-
rest = _objectWithoutPropertiesLoose(_ref4,
|
|
4135
|
+
rest = _objectWithoutPropertiesLoose(_ref4, _excluded2);
|
|
4116
4136
|
|
|
4117
4137
|
var _ref5 = _temp3 === void 0 ? {} : _temp3,
|
|
4118
4138
|
_ref5$suppressRefErro = _ref5.suppressRefError,
|
|
@@ -4186,5 +4206,4 @@ function useMultipleSelection(userProps) {
|
|
|
4186
4206
|
};
|
|
4187
4207
|
}
|
|
4188
4208
|
|
|
4189
|
-
export default
|
|
4190
|
-
export { resetIdCounter, useCombobox, useMultipleSelection, useSelect };
|
|
4209
|
+
export { Downshift$1 as default, resetIdCounter, useCombobox, useMultipleSelection, useSelect };
|