downshift 6.1.0 → 6.1.1
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 +173 -173
- package/dist/downshift.esm.js +173 -173
- package/dist/downshift.native.cjs.js +169 -177
- package/dist/downshift.umd.js +412 -403
- 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 +2 -2
- package/preact/dist/downshift.cjs.js +173 -173
- package/preact/dist/downshift.esm.js +173 -173
- package/preact/dist/downshift.umd.js +255 -246
- package/preact/dist/downshift.umd.js.map +1 -1
- package/preact/dist/downshift.umd.min.js +11 -2
- package/preact/dist/downshift.umd.min.js.map +1 -1
|
@@ -49,10 +49,19 @@
|
|
|
49
49
|
return self;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
+
function _setPrototypeOf(o, p) {
|
|
53
|
+
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
|
54
|
+
o.__proto__ = p;
|
|
55
|
+
return o;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
return _setPrototypeOf(o, p);
|
|
59
|
+
}
|
|
60
|
+
|
|
52
61
|
function _inheritsLoose(subClass, superClass) {
|
|
53
62
|
subClass.prototype = Object.create(superClass.prototype);
|
|
54
63
|
subClass.prototype.constructor = subClass;
|
|
55
|
-
subClass
|
|
64
|
+
_setPrototypeOf(subClass, superClass);
|
|
56
65
|
}
|
|
57
66
|
|
|
58
67
|
function createCommonjsModule(fn) {
|
|
@@ -330,7 +339,7 @@
|
|
|
330
339
|
});
|
|
331
340
|
|
|
332
341
|
function t(t) {
|
|
333
|
-
return
|
|
342
|
+
return "object" == typeof t && null != t && 1 === t.nodeType;
|
|
334
343
|
}
|
|
335
344
|
|
|
336
345
|
function e(t, e) {
|
|
@@ -375,15 +384,15 @@
|
|
|
375
384
|
if (!t(e)) throw new TypeError("Invalid target");
|
|
376
385
|
|
|
377
386
|
for (var f = document.scrollingElement || document.documentElement, s = [], p = e; t(p) && c(p);) {
|
|
378
|
-
if ((p = p.
|
|
387
|
+
if ((p = p.parentElement) === f) {
|
|
379
388
|
s.push(p);
|
|
380
389
|
break;
|
|
381
390
|
}
|
|
382
391
|
|
|
383
|
-
p === document.body && n(p) && !n(document.documentElement) || n(p, a) && s.push(p);
|
|
392
|
+
null != p && p === document.body && n(p) && !n(document.documentElement) || null != p && n(p, a) && s.push(p);
|
|
384
393
|
}
|
|
385
394
|
|
|
386
|
-
for (var
|
|
395
|
+
for (var m = o.visualViewport ? o.visualViewport.width : innerWidth, g = o.visualViewport ? o.visualViewport.height : innerHeight, w = window.scrollX || pageXOffset, v = window.scrollY || pageYOffset, W = e.getBoundingClientRect(), b = W.height, H = W.width, y = W.top, E = W.right, M = W.bottom, V = W.left, x = "start" === d || "nearest" === d ? y : "end" === d ? M : y + b / 2, I = "center" === u ? V + H / 2 : "end" === u ? E : V, C = [], T = 0; T < s.length; T++) {
|
|
387
396
|
var k = s[T],
|
|
388
397
|
B = k.getBoundingClientRect(),
|
|
389
398
|
D = B.height,
|
|
@@ -392,26 +401,26 @@
|
|
|
392
401
|
X = B.right,
|
|
393
402
|
Y = B.bottom,
|
|
394
403
|
L = B.left;
|
|
395
|
-
if ("if-needed" === l && y >= 0 && V >= 0 &&
|
|
404
|
+
if ("if-needed" === l && y >= 0 && V >= 0 && M <= g && E <= m && y >= R && M <= Y && V >= L && E <= X) return C;
|
|
396
405
|
var S = getComputedStyle(k),
|
|
397
406
|
j = parseInt(S.borderLeftWidth, 10),
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
A = 0,
|
|
407
|
+
q = parseInt(S.borderTopWidth, 10),
|
|
408
|
+
z = parseInt(S.borderRightWidth, 10),
|
|
409
|
+
A = parseInt(S.borderBottomWidth, 10),
|
|
402
410
|
F = 0,
|
|
403
|
-
G =
|
|
404
|
-
J = "
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
411
|
+
G = 0,
|
|
412
|
+
J = "offsetWidth" in k ? k.offsetWidth - k.clientWidth - j - z : 0,
|
|
413
|
+
K = "offsetHeight" in k ? k.offsetHeight - k.clientHeight - q - A : 0;
|
|
414
|
+
if (f === k) F = "start" === d ? x : "end" === d ? x - g : "nearest" === d ? r(v, v + g, g, q, A, v + x, v + x + b, b) : x - g / 2, G = "start" === u ? I : "center" === u ? I - m / 2 : "end" === u ? I - m : r(w, w + m, m, j, z, w + I, w + I + H, H), F = Math.max(0, F + v), G = Math.max(0, G + w);else {
|
|
415
|
+
F = "start" === d ? x - R - q : "end" === d ? x - Y + A + K : "nearest" === d ? r(R, Y, D, q, A + K, x, x + b, b) : x - (R + D / 2) + K / 2, G = "start" === u ? I - L - j : "center" === u ? I - (L + O / 2) + J / 2 : "end" === u ? I - X + z + J : r(L, X, O, j, z + J, I, I + H, H);
|
|
416
|
+
var N = k.scrollLeft,
|
|
408
417
|
P = k.scrollTop;
|
|
409
|
-
x += P - (
|
|
418
|
+
x += P - (F = Math.max(0, Math.min(P + F, k.scrollHeight - D + K))), I += N - (G = Math.max(0, Math.min(N + G, k.scrollWidth - O + J)));
|
|
410
419
|
}
|
|
411
420
|
C.push({
|
|
412
421
|
el: k,
|
|
413
|
-
top:
|
|
414
|
-
left:
|
|
422
|
+
top: F,
|
|
423
|
+
left: G
|
|
415
424
|
});
|
|
416
425
|
}
|
|
417
426
|
|
|
@@ -573,7 +582,7 @@
|
|
|
573
582
|
*/
|
|
574
583
|
|
|
575
584
|
|
|
576
|
-
function getA11yStatusMessage(_ref2) {
|
|
585
|
+
function getA11yStatusMessage$1(_ref2) {
|
|
577
586
|
var isOpen = _ref2.isOpen,
|
|
578
587
|
resultCount = _ref2.resultCount,
|
|
579
588
|
previousResultCount = _ref2.previousResultCount;
|
|
@@ -911,25 +920,25 @@
|
|
|
911
920
|
return statusDiv;
|
|
912
921
|
}
|
|
913
922
|
|
|
914
|
-
var unknown =
|
|
915
|
-
var mouseUp =
|
|
916
|
-
var itemMouseEnter =
|
|
917
|
-
var keyDownArrowUp =
|
|
918
|
-
var keyDownArrowDown =
|
|
919
|
-
var keyDownEscape =
|
|
920
|
-
var keyDownEnter =
|
|
921
|
-
var keyDownHome =
|
|
922
|
-
var keyDownEnd =
|
|
923
|
-
var clickItem =
|
|
924
|
-
var blurInput =
|
|
925
|
-
var changeInput =
|
|
926
|
-
var keyDownSpaceButton =
|
|
927
|
-
var clickButton =
|
|
928
|
-
var blurButton =
|
|
929
|
-
var controlledPropUpdatedSelectedItem =
|
|
930
|
-
var touchEnd =
|
|
923
|
+
var unknown = '__autocomplete_unknown__' ;
|
|
924
|
+
var mouseUp = '__autocomplete_mouseup__' ;
|
|
925
|
+
var itemMouseEnter = '__autocomplete_item_mouseenter__' ;
|
|
926
|
+
var keyDownArrowUp = '__autocomplete_keydown_arrow_up__' ;
|
|
927
|
+
var keyDownArrowDown = '__autocomplete_keydown_arrow_down__' ;
|
|
928
|
+
var keyDownEscape = '__autocomplete_keydown_escape__' ;
|
|
929
|
+
var keyDownEnter = '__autocomplete_keydown_enter__' ;
|
|
930
|
+
var keyDownHome = '__autocomplete_keydown_home__' ;
|
|
931
|
+
var keyDownEnd = '__autocomplete_keydown_end__' ;
|
|
932
|
+
var clickItem = '__autocomplete_click_item__' ;
|
|
933
|
+
var blurInput = '__autocomplete_blur_input__' ;
|
|
934
|
+
var changeInput = '__autocomplete_change_input__' ;
|
|
935
|
+
var keyDownSpaceButton = '__autocomplete_keydown_space_button__' ;
|
|
936
|
+
var clickButton = '__autocomplete_click_button__' ;
|
|
937
|
+
var blurButton = '__autocomplete_blur_button__' ;
|
|
938
|
+
var controlledPropUpdatedSelectedItem = '__autocomplete_controlled_prop_updated_selected_item__' ;
|
|
939
|
+
var touchEnd = '__autocomplete_touchend__' ;
|
|
931
940
|
|
|
932
|
-
var stateChangeTypes = /*#__PURE__*/Object.freeze({
|
|
941
|
+
var stateChangeTypes$3 = /*#__PURE__*/Object.freeze({
|
|
933
942
|
__proto__: null,
|
|
934
943
|
unknown: unknown,
|
|
935
944
|
mouseUp: mouseUp,
|
|
@@ -1322,9 +1331,9 @@
|
|
|
1322
1331
|
|
|
1323
1332
|
_this.getToggleButtonProps = function (_temp3) {
|
|
1324
1333
|
var _ref3 = _temp3 === void 0 ? {} : _temp3,
|
|
1325
|
-
onClick = _ref3.onClick
|
|
1326
|
-
|
|
1327
|
-
onKeyDown = _ref3.onKeyDown,
|
|
1334
|
+
onClick = _ref3.onClick;
|
|
1335
|
+
_ref3.onPress;
|
|
1336
|
+
var onKeyDown = _ref3.onKeyDown,
|
|
1328
1337
|
onKeyUp = _ref3.onKeyUp,
|
|
1329
1338
|
onBlur = _ref3.onBlur,
|
|
1330
1339
|
rest = _objectWithoutPropertiesLoose(_ref3, ["onClick", "onPress", "onKeyDown", "onKeyUp", "onBlur"]);
|
|
@@ -1332,7 +1341,7 @@
|
|
|
1332
1341
|
var _this$getState5 = _this.getState(),
|
|
1333
1342
|
isOpen = _this$getState5.isOpen;
|
|
1334
1343
|
|
|
1335
|
-
var enabledEventHandlers =
|
|
1344
|
+
var enabledEventHandlers = {
|
|
1336
1345
|
onClick: callAllEventHandlers(onClick, _this.buttonHandleClick),
|
|
1337
1346
|
onKeyDown: callAllEventHandlers(onKeyDown, _this.buttonHandleKeyDown),
|
|
1338
1347
|
onKeyUp: callAllEventHandlers(onKeyUp, _this.buttonHandleKeyUp),
|
|
@@ -1367,7 +1376,7 @@
|
|
|
1367
1376
|
|
|
1368
1377
|
/* istanbul ignore if (can't reasonably test this) */
|
|
1369
1378
|
|
|
1370
|
-
if (
|
|
1379
|
+
if (_this.props.environment.document.activeElement === _this.props.environment.document.body) {
|
|
1371
1380
|
event.target.focus();
|
|
1372
1381
|
} // to simplify testing components that use downshift, we'll not wrap this in a setTimeout
|
|
1373
1382
|
// if the NODE_ENV is test. With the proper build system, this should be dead code eliminated
|
|
@@ -1410,9 +1419,9 @@
|
|
|
1410
1419
|
onKeyDown = _ref4.onKeyDown,
|
|
1411
1420
|
onBlur = _ref4.onBlur,
|
|
1412
1421
|
onChange = _ref4.onChange,
|
|
1413
|
-
onInput = _ref4.onInput
|
|
1414
|
-
|
|
1415
|
-
rest = _objectWithoutPropertiesLoose(_ref4, ["onKeyDown", "onBlur", "onChange", "onInput", "onChangeText"]);
|
|
1422
|
+
onInput = _ref4.onInput;
|
|
1423
|
+
_ref4.onChangeText;
|
|
1424
|
+
var rest = _objectWithoutPropertiesLoose(_ref4, ["onKeyDown", "onBlur", "onChange", "onInput", "onChangeText"]);
|
|
1416
1425
|
|
|
1417
1426
|
var onChangeKey;
|
|
1418
1427
|
var eventHandlers = {};
|
|
@@ -1458,7 +1467,7 @@
|
|
|
1458
1467
|
_this.internalSetState({
|
|
1459
1468
|
type: changeInput,
|
|
1460
1469
|
isOpen: true,
|
|
1461
|
-
inputValue:
|
|
1470
|
+
inputValue: event.target.value,
|
|
1462
1471
|
highlightedIndex: _this.props.defaultHighlightedIndex
|
|
1463
1472
|
});
|
|
1464
1473
|
};
|
|
@@ -1505,11 +1514,11 @@
|
|
|
1505
1514
|
var _ref7 = _temp7 === void 0 ? {} : _temp7,
|
|
1506
1515
|
onMouseMove = _ref7.onMouseMove,
|
|
1507
1516
|
onMouseDown = _ref7.onMouseDown,
|
|
1508
|
-
onClick = _ref7.onClick
|
|
1509
|
-
|
|
1510
|
-
index = _ref7.index,
|
|
1517
|
+
onClick = _ref7.onClick;
|
|
1518
|
+
_ref7.onPress;
|
|
1519
|
+
var index = _ref7.index,
|
|
1511
1520
|
_ref7$item = _ref7.item,
|
|
1512
|
-
item = _ref7$item === void 0 ?
|
|
1521
|
+
item = _ref7$item === void 0 ? requiredProp('getItemProps', 'item') : _ref7$item,
|
|
1513
1522
|
rest = _objectWithoutPropertiesLoose(_ref7, ["onMouseMove", "onMouseDown", "onClick", "onPress", "index", "item"]);
|
|
1514
1523
|
|
|
1515
1524
|
if (index === undefined) {
|
|
@@ -1520,8 +1529,8 @@
|
|
|
1520
1529
|
_this.items[index] = item;
|
|
1521
1530
|
}
|
|
1522
1531
|
|
|
1523
|
-
var onSelectKey =
|
|
1524
|
-
var customClickHandler =
|
|
1532
|
+
var onSelectKey = 'onClick';
|
|
1533
|
+
var customClickHandler = onClick;
|
|
1525
1534
|
var enabledEventHandlers = (_enabledEventHandlers = {
|
|
1526
1535
|
// onMouseMove is used over onMouseEnter here. onMouseMove
|
|
1527
1536
|
// is only triggered on actual mouse movement while onMouseEnter
|
|
@@ -1816,7 +1825,7 @@
|
|
|
1816
1825
|
var _this7 = this;
|
|
1817
1826
|
|
|
1818
1827
|
/* istanbul ignore if (react-native) */
|
|
1819
|
-
if (
|
|
1828
|
+
if (this.getMenuProps.called && !this.getMenuProps.suppressRefError) {
|
|
1820
1829
|
validateGetMenuPropsCalledCorrectly(this._menuNode, this.getMenuProps);
|
|
1821
1830
|
}
|
|
1822
1831
|
/* istanbul ignore if (react-native) */
|
|
@@ -1911,7 +1920,7 @@
|
|
|
1911
1920
|
validateControlledUnchanged(this.state, prevProps, this.props);
|
|
1912
1921
|
/* istanbul ignore if (react-native) */
|
|
1913
1922
|
|
|
1914
|
-
if (
|
|
1923
|
+
if (this.getMenuProps.called && !this.getMenuProps.suppressRefError) {
|
|
1915
1924
|
validateGetMenuPropsCalledCorrectly(this._menuNode, this.getMenuProps);
|
|
1916
1925
|
}
|
|
1917
1926
|
}
|
|
@@ -1966,7 +1975,7 @@
|
|
|
1966
1975
|
}
|
|
1967
1976
|
|
|
1968
1977
|
if (this.getRootProps.called || this.props.suppressRefError) {
|
|
1969
|
-
if (
|
|
1978
|
+
if (!this.getRootProps.suppressRefError && !this.props.suppressRefError) {
|
|
1970
1979
|
validateGetRootPropsCalledCorrectly(element, this.getRootProps);
|
|
1971
1980
|
}
|
|
1972
1981
|
|
|
@@ -1992,13 +2001,13 @@
|
|
|
1992
2001
|
Downshift.defaultProps = {
|
|
1993
2002
|
defaultHighlightedIndex: null,
|
|
1994
2003
|
defaultIsOpen: false,
|
|
1995
|
-
getA11yStatusMessage: getA11yStatusMessage,
|
|
2004
|
+
getA11yStatusMessage: getA11yStatusMessage$1,
|
|
1996
2005
|
itemToString: function itemToString(i) {
|
|
1997
2006
|
if (i == null) {
|
|
1998
2007
|
return '';
|
|
1999
2008
|
}
|
|
2000
2009
|
|
|
2001
|
-
if (
|
|
2010
|
+
if (isPlainObject(i) && !i.hasOwnProperty('toString')) {
|
|
2002
2011
|
// eslint-disable-next-line no-console
|
|
2003
2012
|
console.warn('downshift: An object was passed to the default implementation of `itemToString`. You should probably provide your own `itemToString` implementation. Please refer to the `itemToString` API documentation.', 'The object that was passed:', i);
|
|
2004
2013
|
}
|
|
@@ -2023,7 +2032,7 @@
|
|
|
2023
2032
|
suppressRefError: false,
|
|
2024
2033
|
scrollIntoView: scrollIntoView
|
|
2025
2034
|
};
|
|
2026
|
-
Downshift.stateChangeTypes = stateChangeTypes;
|
|
2035
|
+
Downshift.stateChangeTypes = stateChangeTypes$3;
|
|
2027
2036
|
return Downshift;
|
|
2028
2037
|
}();
|
|
2029
2038
|
|
|
@@ -2238,7 +2247,7 @@
|
|
|
2238
2247
|
*/
|
|
2239
2248
|
|
|
2240
2249
|
|
|
2241
|
-
function useControlledReducer(reducer, initialState, props) {
|
|
2250
|
+
function useControlledReducer$1(reducer, initialState, props) {
|
|
2242
2251
|
var _useEnhancedReducer = useEnhancedReducer(reducer, initialState, props),
|
|
2243
2252
|
state = _useEnhancedReducer[0],
|
|
2244
2253
|
dispatch = _useEnhancedReducer[1];
|
|
@@ -2246,7 +2255,7 @@
|
|
|
2246
2255
|
return [getState(state, props), dispatch];
|
|
2247
2256
|
}
|
|
2248
2257
|
|
|
2249
|
-
var defaultProps = {
|
|
2258
|
+
var defaultProps$3 = {
|
|
2250
2259
|
itemToString: itemToString,
|
|
2251
2260
|
stateReducer: stateReducer,
|
|
2252
2261
|
getA11ySelectionMessage: getA11ySelectionMessage,
|
|
@@ -2257,7 +2266,7 @@
|
|
|
2257
2266
|
? {} : window
|
|
2258
2267
|
};
|
|
2259
2268
|
|
|
2260
|
-
function getDefaultValue(props, propKey, defaultStateValues) {
|
|
2269
|
+
function getDefaultValue$1(props, propKey, defaultStateValues) {
|
|
2261
2270
|
if (defaultStateValues === void 0) {
|
|
2262
2271
|
defaultStateValues = dropdownDefaultStateValues;
|
|
2263
2272
|
}
|
|
@@ -2271,7 +2280,7 @@
|
|
|
2271
2280
|
return defaultStateValues[propKey];
|
|
2272
2281
|
}
|
|
2273
2282
|
|
|
2274
|
-
function getInitialValue(props, propKey, defaultStateValues) {
|
|
2283
|
+
function getInitialValue$1(props, propKey, defaultStateValues) {
|
|
2275
2284
|
if (defaultStateValues === void 0) {
|
|
2276
2285
|
defaultStateValues = dropdownDefaultStateValues;
|
|
2277
2286
|
}
|
|
@@ -2286,14 +2295,14 @@
|
|
|
2286
2295
|
return props[initialPropKey];
|
|
2287
2296
|
}
|
|
2288
2297
|
|
|
2289
|
-
return getDefaultValue(props, propKey, defaultStateValues);
|
|
2298
|
+
return getDefaultValue$1(props, propKey, defaultStateValues);
|
|
2290
2299
|
}
|
|
2291
2300
|
|
|
2292
|
-
function getInitialState(props) {
|
|
2293
|
-
var selectedItem = getInitialValue(props, 'selectedItem');
|
|
2294
|
-
var isOpen = getInitialValue(props, 'isOpen');
|
|
2295
|
-
var highlightedIndex = getInitialValue(props, 'highlightedIndex');
|
|
2296
|
-
var inputValue = getInitialValue(props, 'inputValue');
|
|
2301
|
+
function getInitialState$2(props) {
|
|
2302
|
+
var selectedItem = getInitialValue$1(props, 'selectedItem');
|
|
2303
|
+
var isOpen = getInitialValue$1(props, 'isOpen');
|
|
2304
|
+
var highlightedIndex = getInitialValue$1(props, 'highlightedIndex');
|
|
2305
|
+
var inputValue = getInitialValue$1(props, 'inputValue');
|
|
2297
2306
|
return {
|
|
2298
2307
|
highlightedIndex: highlightedIndex < 0 && selectedItem && isOpen ? props.items.indexOf(selectedItem) : highlightedIndex,
|
|
2299
2308
|
isOpen: isOpen,
|
|
@@ -2588,10 +2597,10 @@
|
|
|
2588
2597
|
|
|
2589
2598
|
case stateChangeTypes.FunctionReset:
|
|
2590
2599
|
changes = {
|
|
2591
|
-
highlightedIndex: getDefaultValue(props, 'highlightedIndex'),
|
|
2592
|
-
isOpen: getDefaultValue(props, 'isOpen'),
|
|
2593
|
-
selectedItem: getDefaultValue(props, 'selectedItem'),
|
|
2594
|
-
inputValue: getDefaultValue(props, 'inputValue')
|
|
2600
|
+
highlightedIndex: getDefaultValue$1(props, 'highlightedIndex'),
|
|
2601
|
+
isOpen: getDefaultValue$1(props, 'isOpen'),
|
|
2602
|
+
selectedItem: getDefaultValue$1(props, 'selectedItem'),
|
|
2603
|
+
inputValue: getDefaultValue$1(props, 'inputValue')
|
|
2595
2604
|
};
|
|
2596
2605
|
break;
|
|
2597
2606
|
|
|
@@ -2621,7 +2630,7 @@
|
|
|
2621
2630
|
return highlightedIndex;
|
|
2622
2631
|
}
|
|
2623
2632
|
|
|
2624
|
-
var propTypes = {
|
|
2633
|
+
var propTypes$2 = {
|
|
2625
2634
|
items: PropTypes__default['default'].array.isRequired,
|
|
2626
2635
|
itemToString: PropTypes__default['default'].func,
|
|
2627
2636
|
getA11yStatusMessage: PropTypes__default['default'].func,
|
|
@@ -2665,7 +2674,7 @@
|
|
|
2665
2674
|
* @return {String} the a11y status message
|
|
2666
2675
|
*/
|
|
2667
2676
|
|
|
2668
|
-
function getA11yStatusMessage
|
|
2677
|
+
function getA11yStatusMessage(_ref) {
|
|
2669
2678
|
var isOpen = _ref.isOpen,
|
|
2670
2679
|
resultCount = _ref.resultCount,
|
|
2671
2680
|
previousResultCount = _ref.previousResultCount;
|
|
@@ -2685,45 +2694,45 @@
|
|
|
2685
2694
|
return '';
|
|
2686
2695
|
}
|
|
2687
2696
|
|
|
2688
|
-
var defaultProps$
|
|
2689
|
-
getA11yStatusMessage: getA11yStatusMessage
|
|
2697
|
+
var defaultProps$2 = _extends({}, defaultProps$3, {
|
|
2698
|
+
getA11yStatusMessage: getA11yStatusMessage
|
|
2690
2699
|
}); // eslint-disable-next-line import/no-mutable-exports
|
|
2691
2700
|
|
|
2692
2701
|
|
|
2693
|
-
var validatePropTypes = noop;
|
|
2702
|
+
var validatePropTypes$2 = noop;
|
|
2694
2703
|
/* istanbul ignore next */
|
|
2695
2704
|
|
|
2696
2705
|
{
|
|
2697
|
-
validatePropTypes = function validatePropTypes(options, caller) {
|
|
2698
|
-
PropTypes__default['default'].checkPropTypes(propTypes, options, 'prop', caller.name);
|
|
2706
|
+
validatePropTypes$2 = function validatePropTypes(options, caller) {
|
|
2707
|
+
PropTypes__default['default'].checkPropTypes(propTypes$2, options, 'prop', caller.name);
|
|
2699
2708
|
};
|
|
2700
2709
|
}
|
|
2701
2710
|
|
|
2702
|
-
var MenuKeyDownArrowDown =
|
|
2703
|
-
var MenuKeyDownArrowUp =
|
|
2704
|
-
var MenuKeyDownEscape =
|
|
2705
|
-
var MenuKeyDownHome =
|
|
2706
|
-
var MenuKeyDownEnd =
|
|
2707
|
-
var MenuKeyDownEnter =
|
|
2708
|
-
var MenuKeyDownSpaceButton =
|
|
2709
|
-
var MenuKeyDownCharacter =
|
|
2710
|
-
var MenuBlur =
|
|
2711
|
-
var MenuMouseLeave =
|
|
2712
|
-
var ItemMouseMove =
|
|
2713
|
-
var ItemClick =
|
|
2714
|
-
var ToggleButtonClick =
|
|
2715
|
-
var ToggleButtonKeyDownArrowDown =
|
|
2716
|
-
var ToggleButtonKeyDownArrowUp =
|
|
2717
|
-
var ToggleButtonKeyDownCharacter =
|
|
2718
|
-
var FunctionToggleMenu =
|
|
2719
|
-
var FunctionOpenMenu =
|
|
2720
|
-
var FunctionCloseMenu =
|
|
2721
|
-
var FunctionSetHighlightedIndex =
|
|
2722
|
-
var FunctionSelectItem =
|
|
2723
|
-
var FunctionSetInputValue =
|
|
2724
|
-
var FunctionReset =
|
|
2711
|
+
var MenuKeyDownArrowDown = '__menu_keydown_arrow_down__' ;
|
|
2712
|
+
var MenuKeyDownArrowUp = '__menu_keydown_arrow_up__' ;
|
|
2713
|
+
var MenuKeyDownEscape = '__menu_keydown_escape__' ;
|
|
2714
|
+
var MenuKeyDownHome = '__menu_keydown_home__' ;
|
|
2715
|
+
var MenuKeyDownEnd = '__menu_keydown_end__' ;
|
|
2716
|
+
var MenuKeyDownEnter = '__menu_keydown_enter__' ;
|
|
2717
|
+
var MenuKeyDownSpaceButton = '__menu_keydown_space_button__' ;
|
|
2718
|
+
var MenuKeyDownCharacter = '__menu_keydown_character__' ;
|
|
2719
|
+
var MenuBlur = '__menu_blur__' ;
|
|
2720
|
+
var MenuMouseLeave$1 = '__menu_mouse_leave__' ;
|
|
2721
|
+
var ItemMouseMove$1 = '__item_mouse_move__' ;
|
|
2722
|
+
var ItemClick$1 = '__item_click__' ;
|
|
2723
|
+
var ToggleButtonClick$1 = '__togglebutton_click__' ;
|
|
2724
|
+
var ToggleButtonKeyDownArrowDown = '__togglebutton_keydown_arrow_down__' ;
|
|
2725
|
+
var ToggleButtonKeyDownArrowUp = '__togglebutton_keydown_arrow_up__' ;
|
|
2726
|
+
var ToggleButtonKeyDownCharacter = '__togglebutton_keydown_character__' ;
|
|
2727
|
+
var FunctionToggleMenu$1 = '__function_toggle_menu__' ;
|
|
2728
|
+
var FunctionOpenMenu$1 = '__function_open_menu__' ;
|
|
2729
|
+
var FunctionCloseMenu$1 = '__function_close_menu__' ;
|
|
2730
|
+
var FunctionSetHighlightedIndex$1 = '__function_set_highlighted_index__' ;
|
|
2731
|
+
var FunctionSelectItem$1 = '__function_select_item__' ;
|
|
2732
|
+
var FunctionSetInputValue$1 = '__function_set_input_value__' ;
|
|
2733
|
+
var FunctionReset$2 = '__function_reset__' ;
|
|
2725
2734
|
|
|
2726
|
-
var stateChangeTypes$
|
|
2735
|
+
var stateChangeTypes$2 = /*#__PURE__*/Object.freeze({
|
|
2727
2736
|
__proto__: null,
|
|
2728
2737
|
MenuKeyDownArrowDown: MenuKeyDownArrowDown,
|
|
2729
2738
|
MenuKeyDownArrowUp: MenuKeyDownArrowUp,
|
|
@@ -2734,20 +2743,20 @@
|
|
|
2734
2743
|
MenuKeyDownSpaceButton: MenuKeyDownSpaceButton,
|
|
2735
2744
|
MenuKeyDownCharacter: MenuKeyDownCharacter,
|
|
2736
2745
|
MenuBlur: MenuBlur,
|
|
2737
|
-
MenuMouseLeave: MenuMouseLeave,
|
|
2738
|
-
ItemMouseMove: ItemMouseMove,
|
|
2739
|
-
ItemClick: ItemClick,
|
|
2740
|
-
ToggleButtonClick: ToggleButtonClick,
|
|
2746
|
+
MenuMouseLeave: MenuMouseLeave$1,
|
|
2747
|
+
ItemMouseMove: ItemMouseMove$1,
|
|
2748
|
+
ItemClick: ItemClick$1,
|
|
2749
|
+
ToggleButtonClick: ToggleButtonClick$1,
|
|
2741
2750
|
ToggleButtonKeyDownArrowDown: ToggleButtonKeyDownArrowDown,
|
|
2742
2751
|
ToggleButtonKeyDownArrowUp: ToggleButtonKeyDownArrowUp,
|
|
2743
2752
|
ToggleButtonKeyDownCharacter: ToggleButtonKeyDownCharacter,
|
|
2744
|
-
FunctionToggleMenu: FunctionToggleMenu,
|
|
2745
|
-
FunctionOpenMenu: FunctionOpenMenu,
|
|
2746
|
-
FunctionCloseMenu: FunctionCloseMenu,
|
|
2747
|
-
FunctionSetHighlightedIndex: FunctionSetHighlightedIndex,
|
|
2748
|
-
FunctionSelectItem: FunctionSelectItem,
|
|
2749
|
-
FunctionSetInputValue: FunctionSetInputValue,
|
|
2750
|
-
FunctionReset: FunctionReset
|
|
2753
|
+
FunctionToggleMenu: FunctionToggleMenu$1,
|
|
2754
|
+
FunctionOpenMenu: FunctionOpenMenu$1,
|
|
2755
|
+
FunctionCloseMenu: FunctionCloseMenu$1,
|
|
2756
|
+
FunctionSetHighlightedIndex: FunctionSetHighlightedIndex$1,
|
|
2757
|
+
FunctionSelectItem: FunctionSelectItem$1,
|
|
2758
|
+
FunctionSetInputValue: FunctionSetInputValue$1,
|
|
2759
|
+
FunctionReset: FunctionReset$2
|
|
2751
2760
|
});
|
|
2752
2761
|
|
|
2753
2762
|
/* eslint-disable complexity */
|
|
@@ -2759,10 +2768,10 @@
|
|
|
2759
2768
|
var changes;
|
|
2760
2769
|
|
|
2761
2770
|
switch (type) {
|
|
2762
|
-
case ItemClick:
|
|
2771
|
+
case ItemClick$1:
|
|
2763
2772
|
changes = {
|
|
2764
|
-
isOpen: getDefaultValue(props, 'isOpen'),
|
|
2765
|
-
highlightedIndex: getDefaultValue(props, 'highlightedIndex'),
|
|
2773
|
+
isOpen: getDefaultValue$1(props, 'isOpen'),
|
|
2774
|
+
highlightedIndex: getDefaultValue$1(props, 'highlightedIndex'),
|
|
2766
2775
|
selectedItem: props.items[action.index]
|
|
2767
2776
|
};
|
|
2768
2777
|
break;
|
|
@@ -2797,8 +2806,8 @@
|
|
|
2797
2806
|
case MenuKeyDownEnter:
|
|
2798
2807
|
case MenuKeyDownSpaceButton:
|
|
2799
2808
|
changes = _extends({
|
|
2800
|
-
isOpen: getDefaultValue(props, 'isOpen'),
|
|
2801
|
-
highlightedIndex: getDefaultValue(props, 'highlightedIndex')
|
|
2809
|
+
isOpen: getDefaultValue$1(props, 'isOpen'),
|
|
2810
|
+
highlightedIndex: getDefaultValue$1(props, 'highlightedIndex')
|
|
2802
2811
|
}, state.highlightedIndex >= 0 && {
|
|
2803
2812
|
selectedItem: props.items[state.highlightedIndex]
|
|
2804
2813
|
});
|
|
@@ -2857,30 +2866,30 @@
|
|
|
2857
2866
|
};
|
|
2858
2867
|
break;
|
|
2859
2868
|
|
|
2860
|
-
case FunctionSelectItem:
|
|
2869
|
+
case FunctionSelectItem$1:
|
|
2861
2870
|
changes = {
|
|
2862
2871
|
selectedItem: action.selectedItem
|
|
2863
2872
|
};
|
|
2864
2873
|
break;
|
|
2865
2874
|
|
|
2866
2875
|
default:
|
|
2867
|
-
return downshiftCommonReducer(state, action, stateChangeTypes$
|
|
2876
|
+
return downshiftCommonReducer(state, action, stateChangeTypes$2);
|
|
2868
2877
|
}
|
|
2869
2878
|
|
|
2870
2879
|
return _extends({}, state, changes);
|
|
2871
2880
|
}
|
|
2872
2881
|
/* eslint-enable complexity */
|
|
2873
2882
|
|
|
2874
|
-
useSelect.stateChangeTypes = stateChangeTypes$
|
|
2883
|
+
useSelect.stateChangeTypes = stateChangeTypes$2;
|
|
2875
2884
|
|
|
2876
2885
|
function useSelect(userProps) {
|
|
2877
2886
|
if (userProps === void 0) {
|
|
2878
2887
|
userProps = {};
|
|
2879
2888
|
}
|
|
2880
2889
|
|
|
2881
|
-
validatePropTypes(userProps, useSelect); // Props defaults and destructuring.
|
|
2890
|
+
validatePropTypes$2(userProps, useSelect); // Props defaults and destructuring.
|
|
2882
2891
|
|
|
2883
|
-
var props = _extends({}, defaultProps$
|
|
2892
|
+
var props = _extends({}, defaultProps$2, userProps);
|
|
2884
2893
|
|
|
2885
2894
|
var items = props.items,
|
|
2886
2895
|
scrollIntoView = props.scrollIntoView,
|
|
@@ -2891,9 +2900,9 @@
|
|
|
2891
2900
|
getA11ySelectionMessage = props.getA11ySelectionMessage,
|
|
2892
2901
|
getA11yStatusMessage = props.getA11yStatusMessage; // Initial state depending on controlled props.
|
|
2893
2902
|
|
|
2894
|
-
var initialState = getInitialState(props);
|
|
2903
|
+
var initialState = getInitialState$2(props);
|
|
2895
2904
|
|
|
2896
|
-
var _useControlledReducer = useControlledReducer(downshiftSelectReducer, initialState, props),
|
|
2905
|
+
var _useControlledReducer = useControlledReducer$1(downshiftSelectReducer, initialState, props),
|
|
2897
2906
|
state = _useControlledReducer[0],
|
|
2898
2907
|
dispatch = _useControlledReducer[1];
|
|
2899
2908
|
|
|
@@ -2955,7 +2964,7 @@
|
|
|
2955
2964
|
if (isInitialMountRef.current) {
|
|
2956
2965
|
clearTimeoutRef.current = debounce(function (outerDispatch) {
|
|
2957
2966
|
outerDispatch({
|
|
2958
|
-
type: FunctionSetInputValue,
|
|
2967
|
+
type: FunctionSetInputValue$1,
|
|
2959
2968
|
inputValue: ''
|
|
2960
2969
|
});
|
|
2961
2970
|
}, 500);
|
|
@@ -3104,39 +3113,39 @@
|
|
|
3104
3113
|
|
|
3105
3114
|
var toggleMenu = preact.useCallback(function () {
|
|
3106
3115
|
dispatch({
|
|
3107
|
-
type: FunctionToggleMenu
|
|
3116
|
+
type: FunctionToggleMenu$1
|
|
3108
3117
|
});
|
|
3109
3118
|
}, [dispatch]);
|
|
3110
3119
|
var closeMenu = preact.useCallback(function () {
|
|
3111
3120
|
dispatch({
|
|
3112
|
-
type: FunctionCloseMenu
|
|
3121
|
+
type: FunctionCloseMenu$1
|
|
3113
3122
|
});
|
|
3114
3123
|
}, [dispatch]);
|
|
3115
3124
|
var openMenu = preact.useCallback(function () {
|
|
3116
3125
|
dispatch({
|
|
3117
|
-
type: FunctionOpenMenu
|
|
3126
|
+
type: FunctionOpenMenu$1
|
|
3118
3127
|
});
|
|
3119
3128
|
}, [dispatch]);
|
|
3120
3129
|
var setHighlightedIndex = preact.useCallback(function (newHighlightedIndex) {
|
|
3121
3130
|
dispatch({
|
|
3122
|
-
type: FunctionSetHighlightedIndex,
|
|
3131
|
+
type: FunctionSetHighlightedIndex$1,
|
|
3123
3132
|
highlightedIndex: newHighlightedIndex
|
|
3124
3133
|
});
|
|
3125
3134
|
}, [dispatch]);
|
|
3126
3135
|
var selectItem = preact.useCallback(function (newSelectedItem) {
|
|
3127
3136
|
dispatch({
|
|
3128
|
-
type: FunctionSelectItem,
|
|
3137
|
+
type: FunctionSelectItem$1,
|
|
3129
3138
|
selectedItem: newSelectedItem
|
|
3130
3139
|
});
|
|
3131
3140
|
}, [dispatch]);
|
|
3132
3141
|
var reset = preact.useCallback(function () {
|
|
3133
3142
|
dispatch({
|
|
3134
|
-
type: FunctionReset
|
|
3143
|
+
type: FunctionReset$2
|
|
3135
3144
|
});
|
|
3136
3145
|
}, [dispatch]);
|
|
3137
3146
|
var setInputValue = preact.useCallback(function (newInputValue) {
|
|
3138
3147
|
dispatch({
|
|
3139
|
-
type: FunctionSetInputValue,
|
|
3148
|
+
type: FunctionSetInputValue$1,
|
|
3140
3149
|
inputValue: newInputValue
|
|
3141
3150
|
});
|
|
3142
3151
|
}, [dispatch]); // Getter functions.
|
|
@@ -3198,7 +3207,7 @@
|
|
|
3198
3207
|
|
|
3199
3208
|
var menuHandleMouseLeave = function menuHandleMouseLeave() {
|
|
3200
3209
|
dispatch({
|
|
3201
|
-
type: MenuMouseLeave
|
|
3210
|
+
type: MenuMouseLeave$1
|
|
3202
3211
|
});
|
|
3203
3212
|
};
|
|
3204
3213
|
|
|
@@ -3230,7 +3239,7 @@
|
|
|
3230
3239
|
|
|
3231
3240
|
var toggleButtonHandleClick = function toggleButtonHandleClick() {
|
|
3232
3241
|
dispatch({
|
|
3233
|
-
type: ToggleButtonClick
|
|
3242
|
+
type: ToggleButtonClick$1
|
|
3234
3243
|
});
|
|
3235
3244
|
};
|
|
3236
3245
|
|
|
@@ -3284,14 +3293,14 @@
|
|
|
3284
3293
|
|
|
3285
3294
|
shouldScrollRef.current = false;
|
|
3286
3295
|
dispatch({
|
|
3287
|
-
type: ItemMouseMove,
|
|
3296
|
+
type: ItemMouseMove$1,
|
|
3288
3297
|
index: index
|
|
3289
3298
|
});
|
|
3290
3299
|
};
|
|
3291
3300
|
|
|
3292
3301
|
var itemHandleClick = function itemHandleClick() {
|
|
3293
3302
|
dispatch({
|
|
3294
|
-
type: ItemClick,
|
|
3303
|
+
type: ItemClick$1,
|
|
3295
3304
|
index: index
|
|
3296
3305
|
});
|
|
3297
3306
|
};
|
|
@@ -3341,28 +3350,28 @@
|
|
|
3341
3350
|
};
|
|
3342
3351
|
}
|
|
3343
3352
|
|
|
3344
|
-
var InputKeyDownArrowDown =
|
|
3345
|
-
var InputKeyDownArrowUp =
|
|
3346
|
-
var InputKeyDownEscape =
|
|
3347
|
-
var InputKeyDownHome =
|
|
3348
|
-
var InputKeyDownEnd =
|
|
3349
|
-
var InputKeyDownEnter =
|
|
3350
|
-
var InputChange =
|
|
3351
|
-
var InputBlur =
|
|
3352
|
-
var MenuMouseLeave
|
|
3353
|
-
var ItemMouseMove
|
|
3354
|
-
var ItemClick
|
|
3355
|
-
var ToggleButtonClick
|
|
3356
|
-
var FunctionToggleMenu
|
|
3357
|
-
var FunctionOpenMenu
|
|
3358
|
-
var FunctionCloseMenu
|
|
3359
|
-
var FunctionSetHighlightedIndex
|
|
3360
|
-
var FunctionSelectItem
|
|
3361
|
-
var FunctionSetInputValue
|
|
3362
|
-
var FunctionReset$1 =
|
|
3363
|
-
var ControlledPropUpdatedSelectedItem =
|
|
3353
|
+
var InputKeyDownArrowDown = '__input_keydown_arrow_down__' ;
|
|
3354
|
+
var InputKeyDownArrowUp = '__input_keydown_arrow_up__' ;
|
|
3355
|
+
var InputKeyDownEscape = '__input_keydown_escape__' ;
|
|
3356
|
+
var InputKeyDownHome = '__input_keydown_home__' ;
|
|
3357
|
+
var InputKeyDownEnd = '__input_keydown_end__' ;
|
|
3358
|
+
var InputKeyDownEnter = '__input_keydown_enter__' ;
|
|
3359
|
+
var InputChange = '__input_change__' ;
|
|
3360
|
+
var InputBlur = '__input_blur__' ;
|
|
3361
|
+
var MenuMouseLeave = '__menu_mouse_leave__' ;
|
|
3362
|
+
var ItemMouseMove = '__item_mouse_move__' ;
|
|
3363
|
+
var ItemClick = '__item_click__' ;
|
|
3364
|
+
var ToggleButtonClick = '__togglebutton_click__' ;
|
|
3365
|
+
var FunctionToggleMenu = '__function_toggle_menu__' ;
|
|
3366
|
+
var FunctionOpenMenu = '__function_open_menu__' ;
|
|
3367
|
+
var FunctionCloseMenu = '__function_close_menu__' ;
|
|
3368
|
+
var FunctionSetHighlightedIndex = '__function_set_highlighted_index__' ;
|
|
3369
|
+
var FunctionSelectItem = '__function_select_item__' ;
|
|
3370
|
+
var FunctionSetInputValue = '__function_set_input_value__' ;
|
|
3371
|
+
var FunctionReset$1 = '__function_reset__' ;
|
|
3372
|
+
var ControlledPropUpdatedSelectedItem = '__controlled_prop_updated_selected_item__' ;
|
|
3364
3373
|
|
|
3365
|
-
var stateChangeTypes$
|
|
3374
|
+
var stateChangeTypes$1 = /*#__PURE__*/Object.freeze({
|
|
3366
3375
|
__proto__: null,
|
|
3367
3376
|
InputKeyDownArrowDown: InputKeyDownArrowDown,
|
|
3368
3377
|
InputKeyDownArrowUp: InputKeyDownArrowUp,
|
|
@@ -3372,22 +3381,22 @@
|
|
|
3372
3381
|
InputKeyDownEnter: InputKeyDownEnter,
|
|
3373
3382
|
InputChange: InputChange,
|
|
3374
3383
|
InputBlur: InputBlur,
|
|
3375
|
-
MenuMouseLeave: MenuMouseLeave
|
|
3376
|
-
ItemMouseMove: ItemMouseMove
|
|
3377
|
-
ItemClick: ItemClick
|
|
3378
|
-
ToggleButtonClick: ToggleButtonClick
|
|
3379
|
-
FunctionToggleMenu: FunctionToggleMenu
|
|
3380
|
-
FunctionOpenMenu: FunctionOpenMenu
|
|
3381
|
-
FunctionCloseMenu: FunctionCloseMenu
|
|
3382
|
-
FunctionSetHighlightedIndex: FunctionSetHighlightedIndex
|
|
3383
|
-
FunctionSelectItem: FunctionSelectItem
|
|
3384
|
-
FunctionSetInputValue: FunctionSetInputValue
|
|
3384
|
+
MenuMouseLeave: MenuMouseLeave,
|
|
3385
|
+
ItemMouseMove: ItemMouseMove,
|
|
3386
|
+
ItemClick: ItemClick,
|
|
3387
|
+
ToggleButtonClick: ToggleButtonClick,
|
|
3388
|
+
FunctionToggleMenu: FunctionToggleMenu,
|
|
3389
|
+
FunctionOpenMenu: FunctionOpenMenu,
|
|
3390
|
+
FunctionCloseMenu: FunctionCloseMenu,
|
|
3391
|
+
FunctionSetHighlightedIndex: FunctionSetHighlightedIndex,
|
|
3392
|
+
FunctionSelectItem: FunctionSelectItem,
|
|
3393
|
+
FunctionSetInputValue: FunctionSetInputValue,
|
|
3385
3394
|
FunctionReset: FunctionReset$1,
|
|
3386
3395
|
ControlledPropUpdatedSelectedItem: ControlledPropUpdatedSelectedItem
|
|
3387
3396
|
});
|
|
3388
3397
|
|
|
3389
3398
|
function getInitialState$1(props) {
|
|
3390
|
-
var initialState = getInitialState(props);
|
|
3399
|
+
var initialState = getInitialState$2(props);
|
|
3391
3400
|
var selectedItem = initialState.selectedItem;
|
|
3392
3401
|
var inputValue = initialState.inputValue;
|
|
3393
3402
|
|
|
@@ -3453,7 +3462,7 @@
|
|
|
3453
3462
|
* @returns {Array} An array with the state and an action dispatcher.
|
|
3454
3463
|
*/
|
|
3455
3464
|
|
|
3456
|
-
function useControlledReducer
|
|
3465
|
+
function useControlledReducer(reducer, initialState, props) {
|
|
3457
3466
|
var previousSelectedItemRef = preact.useRef();
|
|
3458
3467
|
|
|
3459
3468
|
var _useEnhancedReducer = useEnhancedReducer(reducer, initialState, props),
|
|
@@ -3486,8 +3495,8 @@
|
|
|
3486
3495
|
};
|
|
3487
3496
|
}
|
|
3488
3497
|
|
|
3489
|
-
var defaultProps$
|
|
3490
|
-
getA11yStatusMessage: getA11yStatusMessage,
|
|
3498
|
+
var defaultProps$1 = _extends({}, defaultProps$3, {
|
|
3499
|
+
getA11yStatusMessage: getA11yStatusMessage$1,
|
|
3491
3500
|
circularNavigation: true
|
|
3492
3501
|
});
|
|
3493
3502
|
|
|
@@ -3500,10 +3509,10 @@
|
|
|
3500
3509
|
var changes;
|
|
3501
3510
|
|
|
3502
3511
|
switch (type) {
|
|
3503
|
-
case ItemClick
|
|
3512
|
+
case ItemClick:
|
|
3504
3513
|
changes = {
|
|
3505
|
-
isOpen: getDefaultValue(props, 'isOpen'),
|
|
3506
|
-
highlightedIndex: getDefaultValue(props, 'highlightedIndex'),
|
|
3514
|
+
isOpen: getDefaultValue$1(props, 'isOpen'),
|
|
3515
|
+
highlightedIndex: getDefaultValue$1(props, 'highlightedIndex'),
|
|
3507
3516
|
selectedItem: props.items[action.index],
|
|
3508
3517
|
inputValue: props.itemToString(props.items[action.index])
|
|
3509
3518
|
};
|
|
@@ -3540,8 +3549,8 @@
|
|
|
3540
3549
|
case InputKeyDownEnter:
|
|
3541
3550
|
changes = _extends({}, state.isOpen && state.highlightedIndex >= 0 && {
|
|
3542
3551
|
selectedItem: props.items[state.highlightedIndex],
|
|
3543
|
-
isOpen: getDefaultValue(props, 'isOpen'),
|
|
3544
|
-
highlightedIndex: getDefaultValue(props, 'highlightedIndex'),
|
|
3552
|
+
isOpen: getDefaultValue$1(props, 'isOpen'),
|
|
3553
|
+
highlightedIndex: getDefaultValue$1(props, 'highlightedIndex'),
|
|
3545
3554
|
inputValue: props.itemToString(props.items[state.highlightedIndex])
|
|
3546
3555
|
});
|
|
3547
3556
|
break;
|
|
@@ -3581,12 +3590,12 @@
|
|
|
3581
3590
|
case InputChange:
|
|
3582
3591
|
changes = {
|
|
3583
3592
|
isOpen: true,
|
|
3584
|
-
highlightedIndex: getDefaultValue(props, 'highlightedIndex'),
|
|
3593
|
+
highlightedIndex: getDefaultValue$1(props, 'highlightedIndex'),
|
|
3585
3594
|
inputValue: action.inputValue
|
|
3586
3595
|
};
|
|
3587
3596
|
break;
|
|
3588
3597
|
|
|
3589
|
-
case FunctionSelectItem
|
|
3598
|
+
case FunctionSelectItem:
|
|
3590
3599
|
changes = {
|
|
3591
3600
|
selectedItem: action.selectedItem,
|
|
3592
3601
|
inputValue: props.itemToString(action.selectedItem)
|
|
@@ -3600,14 +3609,14 @@
|
|
|
3600
3609
|
break;
|
|
3601
3610
|
|
|
3602
3611
|
default:
|
|
3603
|
-
return downshiftCommonReducer(state, action, stateChangeTypes$
|
|
3612
|
+
return downshiftCommonReducer(state, action, stateChangeTypes$1);
|
|
3604
3613
|
}
|
|
3605
3614
|
|
|
3606
3615
|
return _extends({}, state, changes);
|
|
3607
3616
|
}
|
|
3608
3617
|
/* eslint-enable complexity */
|
|
3609
3618
|
|
|
3610
|
-
useCombobox.stateChangeTypes = stateChangeTypes$
|
|
3619
|
+
useCombobox.stateChangeTypes = stateChangeTypes$1;
|
|
3611
3620
|
|
|
3612
3621
|
function useCombobox(userProps) {
|
|
3613
3622
|
if (userProps === void 0) {
|
|
@@ -3616,7 +3625,7 @@
|
|
|
3616
3625
|
|
|
3617
3626
|
validatePropTypes$1(userProps, useCombobox); // Props defaults and destructuring.
|
|
3618
3627
|
|
|
3619
|
-
var props = _extends({}, defaultProps$
|
|
3628
|
+
var props = _extends({}, defaultProps$1, userProps);
|
|
3620
3629
|
|
|
3621
3630
|
var initialIsOpen = props.initialIsOpen,
|
|
3622
3631
|
defaultIsOpen = props.defaultIsOpen,
|
|
@@ -3629,7 +3638,7 @@
|
|
|
3629
3638
|
|
|
3630
3639
|
var initialState = getInitialState$1(props);
|
|
3631
3640
|
|
|
3632
|
-
var _useControlledReducer = useControlledReducer
|
|
3641
|
+
var _useControlledReducer = useControlledReducer(downshiftUseComboboxReducer, initialState, props),
|
|
3633
3642
|
state = _useControlledReducer[0],
|
|
3634
3643
|
dispatch = _useControlledReducer[1];
|
|
3635
3644
|
|
|
@@ -3814,7 +3823,7 @@
|
|
|
3814
3823
|
menuRef.current = menuNode;
|
|
3815
3824
|
}), _extends2.id = elementIds.menuId, _extends2.role = 'listbox', _extends2['aria-labelledby'] = elementIds.labelId, _extends2.onMouseLeave = callAllEventHandlers(onMouseLeave, function () {
|
|
3816
3825
|
dispatch({
|
|
3817
|
-
type: MenuMouseLeave
|
|
3826
|
+
type: MenuMouseLeave
|
|
3818
3827
|
});
|
|
3819
3828
|
}), _extends2), rest);
|
|
3820
3829
|
}, [dispatch, setGetterPropCallInfo, elementIds]);
|
|
@@ -3828,9 +3837,9 @@
|
|
|
3828
3837
|
refKey = _ref3$refKey === void 0 ? 'ref' : _ref3$refKey,
|
|
3829
3838
|
ref = _ref3.ref,
|
|
3830
3839
|
onMouseMove = _ref3.onMouseMove,
|
|
3831
|
-
onClick = _ref3.onClick
|
|
3832
|
-
|
|
3833
|
-
rest = _objectWithoutPropertiesLoose(_ref3, ["item", "index", "refKey", "ref", "onMouseMove", "onClick", "onPress"]);
|
|
3840
|
+
onClick = _ref3.onClick;
|
|
3841
|
+
_ref3.onPress;
|
|
3842
|
+
var rest = _objectWithoutPropertiesLoose(_ref3, ["item", "index", "refKey", "ref", "onMouseMove", "onClick", "onPress"]);
|
|
3834
3843
|
|
|
3835
3844
|
var _latest$current = latest.current,
|
|
3836
3845
|
latestProps = _latest$current.props,
|
|
@@ -3841,8 +3850,8 @@
|
|
|
3841
3850
|
throw new Error('Pass either item or item index in getItemProps!');
|
|
3842
3851
|
}
|
|
3843
3852
|
|
|
3844
|
-
var onSelectKey =
|
|
3845
|
-
var customClickHandler =
|
|
3853
|
+
var onSelectKey = 'onClick';
|
|
3854
|
+
var customClickHandler = onClick;
|
|
3846
3855
|
|
|
3847
3856
|
var itemHandleMouseMove = function itemHandleMouseMove() {
|
|
3848
3857
|
if (index === latestState.highlightedIndex) {
|
|
@@ -3851,14 +3860,14 @@
|
|
|
3851
3860
|
|
|
3852
3861
|
shouldScrollRef.current = false;
|
|
3853
3862
|
dispatch({
|
|
3854
|
-
type: ItemMouseMove
|
|
3863
|
+
type: ItemMouseMove,
|
|
3855
3864
|
index: index
|
|
3856
3865
|
});
|
|
3857
3866
|
};
|
|
3858
3867
|
|
|
3859
3868
|
var itemHandleClick = function itemHandleClick() {
|
|
3860
3869
|
dispatch({
|
|
3861
|
-
type: ItemClick
|
|
3870
|
+
type: ItemClick,
|
|
3862
3871
|
index: index
|
|
3863
3872
|
});
|
|
3864
3873
|
|
|
@@ -3879,16 +3888,16 @@
|
|
|
3879
3888
|
var _extends4;
|
|
3880
3889
|
|
|
3881
3890
|
var _ref5 = _temp4 === void 0 ? {} : _temp4,
|
|
3882
|
-
onClick = _ref5.onClick
|
|
3883
|
-
|
|
3884
|
-
_ref5$refKey = _ref5.refKey,
|
|
3891
|
+
onClick = _ref5.onClick;
|
|
3892
|
+
_ref5.onPress;
|
|
3893
|
+
var _ref5$refKey = _ref5.refKey,
|
|
3885
3894
|
refKey = _ref5$refKey === void 0 ? 'ref' : _ref5$refKey,
|
|
3886
3895
|
ref = _ref5.ref,
|
|
3887
3896
|
rest = _objectWithoutPropertiesLoose(_ref5, ["onClick", "onPress", "refKey", "ref"]);
|
|
3888
3897
|
|
|
3889
3898
|
var toggleButtonHandleClick = function toggleButtonHandleClick() {
|
|
3890
3899
|
dispatch({
|
|
3891
|
-
type: ToggleButtonClick
|
|
3900
|
+
type: ToggleButtonClick
|
|
3892
3901
|
});
|
|
3893
3902
|
|
|
3894
3903
|
if (!latest.current.state.isOpen && inputRef.current) {
|
|
@@ -3898,7 +3907,7 @@
|
|
|
3898
3907
|
|
|
3899
3908
|
return _extends((_extends4 = {}, _extends4[refKey] = handleRefs(ref, function (toggleButtonNode) {
|
|
3900
3909
|
toggleButtonRef.current = toggleButtonNode;
|
|
3901
|
-
}), _extends4.id = elementIds.toggleButtonId, _extends4.tabIndex = -1, _extends4), !rest.disabled && _extends({},
|
|
3910
|
+
}), _extends4.id = elementIds.toggleButtonId, _extends4.tabIndex = -1, _extends4), !rest.disabled && _extends({}, {
|
|
3902
3911
|
onClick: callAllEventHandlers(onClick, toggleButtonHandleClick)
|
|
3903
3912
|
}), rest);
|
|
3904
3913
|
}, [dispatch, latest, elementIds]);
|
|
@@ -3909,9 +3918,9 @@
|
|
|
3909
3918
|
onKeyDown = _ref6.onKeyDown,
|
|
3910
3919
|
onChange = _ref6.onChange,
|
|
3911
3920
|
onInput = _ref6.onInput,
|
|
3912
|
-
onBlur = _ref6.onBlur
|
|
3913
|
-
|
|
3914
|
-
_ref6$refKey = _ref6.refKey,
|
|
3921
|
+
onBlur = _ref6.onBlur;
|
|
3922
|
+
_ref6.onChangeText;
|
|
3923
|
+
var _ref6$refKey = _ref6.refKey,
|
|
3915
3924
|
refKey = _ref6$refKey === void 0 ? 'ref' : _ref6$refKey,
|
|
3916
3925
|
ref = _ref6.ref,
|
|
3917
3926
|
rest = _objectWithoutPropertiesLoose(_ref6, ["onKeyDown", "onChange", "onInput", "onBlur", "onChangeText", "refKey", "ref"]);
|
|
@@ -3934,7 +3943,7 @@
|
|
|
3934
3943
|
var inputHandleChange = function inputHandleChange(event) {
|
|
3935
3944
|
dispatch({
|
|
3936
3945
|
type: InputChange,
|
|
3937
|
-
inputValue:
|
|
3946
|
+
inputValue: event.target.value
|
|
3938
3947
|
});
|
|
3939
3948
|
};
|
|
3940
3949
|
|
|
@@ -3950,7 +3959,7 @@
|
|
|
3950
3959
|
/* istanbul ignore next (preact) */
|
|
3951
3960
|
|
|
3952
3961
|
|
|
3953
|
-
var onChangeKey =
|
|
3962
|
+
var onChangeKey = 'onInput' ;
|
|
3954
3963
|
var eventHandlers = {};
|
|
3955
3964
|
|
|
3956
3965
|
if (!rest.disabled) {
|
|
@@ -3992,34 +4001,34 @@
|
|
|
3992
4001
|
|
|
3993
4002
|
var toggleMenu = preact.useCallback(function () {
|
|
3994
4003
|
dispatch({
|
|
3995
|
-
type: FunctionToggleMenu
|
|
4004
|
+
type: FunctionToggleMenu
|
|
3996
4005
|
});
|
|
3997
4006
|
}, [dispatch]);
|
|
3998
4007
|
var closeMenu = preact.useCallback(function () {
|
|
3999
4008
|
dispatch({
|
|
4000
|
-
type: FunctionCloseMenu
|
|
4009
|
+
type: FunctionCloseMenu
|
|
4001
4010
|
});
|
|
4002
4011
|
}, [dispatch]);
|
|
4003
4012
|
var openMenu = preact.useCallback(function () {
|
|
4004
4013
|
dispatch({
|
|
4005
|
-
type: FunctionOpenMenu
|
|
4014
|
+
type: FunctionOpenMenu
|
|
4006
4015
|
});
|
|
4007
4016
|
}, [dispatch]);
|
|
4008
4017
|
var setHighlightedIndex = preact.useCallback(function (newHighlightedIndex) {
|
|
4009
4018
|
dispatch({
|
|
4010
|
-
type: FunctionSetHighlightedIndex
|
|
4019
|
+
type: FunctionSetHighlightedIndex,
|
|
4011
4020
|
highlightedIndex: newHighlightedIndex
|
|
4012
4021
|
});
|
|
4013
4022
|
}, [dispatch]);
|
|
4014
4023
|
var selectItem = preact.useCallback(function (newSelectedItem) {
|
|
4015
4024
|
dispatch({
|
|
4016
|
-
type: FunctionSelectItem
|
|
4025
|
+
type: FunctionSelectItem,
|
|
4017
4026
|
selectedItem: newSelectedItem
|
|
4018
4027
|
});
|
|
4019
4028
|
}, [dispatch]);
|
|
4020
4029
|
var setInputValue = preact.useCallback(function (newInputValue) {
|
|
4021
4030
|
dispatch({
|
|
4022
|
-
type: FunctionSetInputValue
|
|
4031
|
+
type: FunctionSetInputValue,
|
|
4023
4032
|
inputValue: newInputValue
|
|
4024
4033
|
});
|
|
4025
4034
|
}, [dispatch]);
|
|
@@ -4066,8 +4075,8 @@
|
|
|
4066
4075
|
* @returns {any} The initial value for that prop.
|
|
4067
4076
|
*/
|
|
4068
4077
|
|
|
4069
|
-
function getInitialValue
|
|
4070
|
-
return getInitialValue(props, propKey, defaultStateValues);
|
|
4078
|
+
function getInitialValue(props, propKey) {
|
|
4079
|
+
return getInitialValue$1(props, propKey, defaultStateValues);
|
|
4071
4080
|
}
|
|
4072
4081
|
/**
|
|
4073
4082
|
* Returns the default value for a state key in the following order:
|
|
@@ -4079,8 +4088,8 @@
|
|
|
4079
4088
|
*/
|
|
4080
4089
|
|
|
4081
4090
|
|
|
4082
|
-
function getDefaultValue
|
|
4083
|
-
return getDefaultValue(props, propKey, defaultStateValues);
|
|
4091
|
+
function getDefaultValue(props, propKey) {
|
|
4092
|
+
return getDefaultValue$1(props, propKey, defaultStateValues);
|
|
4084
4093
|
}
|
|
4085
4094
|
/**
|
|
4086
4095
|
* Gets the initial state based on the provided props. It uses initial, default
|
|
@@ -4091,9 +4100,9 @@
|
|
|
4091
4100
|
*/
|
|
4092
4101
|
|
|
4093
4102
|
|
|
4094
|
-
function getInitialState
|
|
4095
|
-
var activeIndex = getInitialValue
|
|
4096
|
-
var selectedItems = getInitialValue
|
|
4103
|
+
function getInitialState(props) {
|
|
4104
|
+
var activeIndex = getInitialValue(props, 'activeIndex');
|
|
4105
|
+
var selectedItems = getInitialValue(props, 'selectedItems');
|
|
4097
4106
|
return {
|
|
4098
4107
|
activeIndex: activeIndex,
|
|
4099
4108
|
selectedItems: selectedItems
|
|
@@ -4140,7 +4149,7 @@
|
|
|
4140
4149
|
return itemToStringLocal(removedSelectedItem) + " has been removed.";
|
|
4141
4150
|
}
|
|
4142
4151
|
|
|
4143
|
-
var propTypes
|
|
4152
|
+
var propTypes = {
|
|
4144
4153
|
selectedItems: PropTypes__default['default'].array,
|
|
4145
4154
|
initialSelectedItems: PropTypes__default['default'].array,
|
|
4146
4155
|
defaultSelectedItems: PropTypes__default['default'].array,
|
|
@@ -4164,39 +4173,39 @@
|
|
|
4164
4173
|
})
|
|
4165
4174
|
})
|
|
4166
4175
|
};
|
|
4167
|
-
var defaultProps
|
|
4168
|
-
itemToString: defaultProps.itemToString,
|
|
4169
|
-
stateReducer: defaultProps.stateReducer,
|
|
4170
|
-
environment: defaultProps.environment,
|
|
4176
|
+
var defaultProps = {
|
|
4177
|
+
itemToString: defaultProps$3.itemToString,
|
|
4178
|
+
stateReducer: defaultProps$3.stateReducer,
|
|
4179
|
+
environment: defaultProps$3.environment,
|
|
4171
4180
|
getA11yRemovalMessage: getA11yRemovalMessage,
|
|
4172
4181
|
keyNavigationNext: 'ArrowRight',
|
|
4173
4182
|
keyNavigationPrevious: 'ArrowLeft'
|
|
4174
4183
|
}; // eslint-disable-next-line import/no-mutable-exports
|
|
4175
4184
|
|
|
4176
|
-
var validatePropTypes
|
|
4185
|
+
var validatePropTypes = noop;
|
|
4177
4186
|
/* istanbul ignore next */
|
|
4178
4187
|
|
|
4179
4188
|
{
|
|
4180
|
-
validatePropTypes
|
|
4181
|
-
PropTypes__default['default'].checkPropTypes(propTypes
|
|
4189
|
+
validatePropTypes = function validatePropTypes(options, caller) {
|
|
4190
|
+
PropTypes__default['default'].checkPropTypes(propTypes, options, 'prop', caller.name);
|
|
4182
4191
|
};
|
|
4183
4192
|
}
|
|
4184
4193
|
|
|
4185
|
-
var SelectedItemClick =
|
|
4186
|
-
var SelectedItemKeyDownDelete =
|
|
4187
|
-
var SelectedItemKeyDownBackspace =
|
|
4188
|
-
var SelectedItemKeyDownNavigationNext =
|
|
4189
|
-
var SelectedItemKeyDownNavigationPrevious =
|
|
4190
|
-
var DropdownKeyDownNavigationPrevious =
|
|
4191
|
-
var DropdownKeyDownBackspace =
|
|
4192
|
-
var DropdownClick =
|
|
4193
|
-
var FunctionAddSelectedItem =
|
|
4194
|
-
var FunctionRemoveSelectedItem =
|
|
4195
|
-
var FunctionSetSelectedItems =
|
|
4196
|
-
var FunctionSetActiveIndex =
|
|
4197
|
-
var FunctionReset
|
|
4194
|
+
var SelectedItemClick = '__selected_item_click__' ;
|
|
4195
|
+
var SelectedItemKeyDownDelete = '__selected_item_keydown_delete__' ;
|
|
4196
|
+
var SelectedItemKeyDownBackspace = '__selected_item_keydown_backspace__' ;
|
|
4197
|
+
var SelectedItemKeyDownNavigationNext = '__selected_item_keydown_navigation_next__' ;
|
|
4198
|
+
var SelectedItemKeyDownNavigationPrevious = '__selected_item_keydown_navigation_previous__' ;
|
|
4199
|
+
var DropdownKeyDownNavigationPrevious = '__dropdown_keydown_navigation_previous__' ;
|
|
4200
|
+
var DropdownKeyDownBackspace = '__dropdown_keydown_backspace__' ;
|
|
4201
|
+
var DropdownClick = '__dropdown_click__' ;
|
|
4202
|
+
var FunctionAddSelectedItem = '__function_add_selected_item__' ;
|
|
4203
|
+
var FunctionRemoveSelectedItem = '__function_remove_selected_item__' ;
|
|
4204
|
+
var FunctionSetSelectedItems = '__function_set_selected_items__' ;
|
|
4205
|
+
var FunctionSetActiveIndex = '__function_set_active_index__' ;
|
|
4206
|
+
var FunctionReset = '__function_reset__' ;
|
|
4198
4207
|
|
|
4199
|
-
var stateChangeTypes
|
|
4208
|
+
var stateChangeTypes = /*#__PURE__*/Object.freeze({
|
|
4200
4209
|
__proto__: null,
|
|
4201
4210
|
SelectedItemClick: SelectedItemClick,
|
|
4202
4211
|
SelectedItemKeyDownDelete: SelectedItemKeyDownDelete,
|
|
@@ -4210,7 +4219,7 @@
|
|
|
4210
4219
|
FunctionRemoveSelectedItem: FunctionRemoveSelectedItem,
|
|
4211
4220
|
FunctionSetSelectedItems: FunctionSetSelectedItems,
|
|
4212
4221
|
FunctionSetActiveIndex: FunctionSetActiveIndex,
|
|
4213
|
-
FunctionReset: FunctionReset
|
|
4222
|
+
FunctionReset: FunctionReset
|
|
4214
4223
|
});
|
|
4215
4224
|
|
|
4216
4225
|
/* eslint-disable complexity */
|
|
@@ -4323,10 +4332,10 @@
|
|
|
4323
4332
|
break;
|
|
4324
4333
|
}
|
|
4325
4334
|
|
|
4326
|
-
case FunctionReset
|
|
4335
|
+
case FunctionReset:
|
|
4327
4336
|
changes = {
|
|
4328
|
-
activeIndex: getDefaultValue
|
|
4329
|
-
selectedItems: getDefaultValue
|
|
4337
|
+
activeIndex: getDefaultValue(props, 'activeIndex'),
|
|
4338
|
+
selectedItems: getDefaultValue(props, 'selectedItems')
|
|
4330
4339
|
};
|
|
4331
4340
|
break;
|
|
4332
4341
|
|
|
@@ -4337,16 +4346,16 @@
|
|
|
4337
4346
|
return _extends({}, state, changes);
|
|
4338
4347
|
}
|
|
4339
4348
|
|
|
4340
|
-
useMultipleSelection.stateChangeTypes = stateChangeTypes
|
|
4349
|
+
useMultipleSelection.stateChangeTypes = stateChangeTypes;
|
|
4341
4350
|
|
|
4342
4351
|
function useMultipleSelection(userProps) {
|
|
4343
4352
|
if (userProps === void 0) {
|
|
4344
4353
|
userProps = {};
|
|
4345
4354
|
}
|
|
4346
4355
|
|
|
4347
|
-
validatePropTypes
|
|
4356
|
+
validatePropTypes(userProps, useMultipleSelection); // Props defaults and destructuring.
|
|
4348
4357
|
|
|
4349
|
-
var props = _extends({}, defaultProps
|
|
4358
|
+
var props = _extends({}, defaultProps, userProps);
|
|
4350
4359
|
|
|
4351
4360
|
var getA11yRemovalMessage = props.getA11yRemovalMessage,
|
|
4352
4361
|
itemToString = props.itemToString,
|
|
@@ -4354,7 +4363,7 @@
|
|
|
4354
4363
|
keyNavigationNext = props.keyNavigationNext,
|
|
4355
4364
|
keyNavigationPrevious = props.keyNavigationPrevious; // Reducer init.
|
|
4356
4365
|
|
|
4357
|
-
var _useControlledReducer = useControlledReducer(downshiftMultipleSelectionReducer, getInitialState
|
|
4366
|
+
var _useControlledReducer = useControlledReducer$1(downshiftMultipleSelectionReducer, getInitialState(props), props),
|
|
4358
4367
|
state = _useControlledReducer[0],
|
|
4359
4368
|
dispatch = _useControlledReducer[1];
|
|
4360
4369
|
|
|
@@ -4565,7 +4574,7 @@
|
|
|
4565
4574
|
}, [dispatch]);
|
|
4566
4575
|
var reset = preact.useCallback(function () {
|
|
4567
4576
|
dispatch({
|
|
4568
|
-
type: FunctionReset
|
|
4577
|
+
type: FunctionReset
|
|
4569
4578
|
});
|
|
4570
4579
|
}, [dispatch]);
|
|
4571
4580
|
return {
|