downshift 6.0.16 → 6.1.2
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 +1 -1
- package/dist/downshift.cjs.js +234 -216
- package/dist/downshift.esm.js +234 -216
- package/dist/downshift.native.cjs.js +230 -220
- package/dist/downshift.umd.js +475 -448
- 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 +24 -24
- package/preact/dist/downshift.cjs.js +234 -216
- package/preact/dist/downshift.esm.js +234 -216
- package/preact/dist/downshift.umd.js +318 -291
- package/preact/dist/downshift.umd.js.map +1 -1
- package/preact/dist/downshift.umd.min.js +12 -3
- package/preact/dist/downshift.umd.min.js.map +1 -1
package/dist/downshift.umd.js
CHANGED
|
@@ -45,10 +45,19 @@
|
|
|
45
45
|
return self;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
+
function _setPrototypeOf(o, p) {
|
|
49
|
+
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
|
50
|
+
o.__proto__ = p;
|
|
51
|
+
return o;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
return _setPrototypeOf(o, p);
|
|
55
|
+
}
|
|
56
|
+
|
|
48
57
|
function _inheritsLoose(subClass, superClass) {
|
|
49
58
|
subClass.prototype = Object.create(superClass.prototype);
|
|
50
59
|
subClass.prototype.constructor = subClass;
|
|
51
|
-
subClass
|
|
60
|
+
_setPrototypeOf(subClass, superClass);
|
|
52
61
|
}
|
|
53
62
|
|
|
54
63
|
function createCommonjsModule(fn) {
|
|
@@ -64,7 +73,7 @@
|
|
|
64
73
|
* This source code is licensed under the MIT license found in the
|
|
65
74
|
* LICENSE file in the root directory of this source tree.
|
|
66
75
|
*/
|
|
67
|
-
var reactIs_development = createCommonjsModule(function (module, exports) {
|
|
76
|
+
var reactIs_development$1 = createCommonjsModule(function (module, exports) {
|
|
68
77
|
|
|
69
78
|
{
|
|
70
79
|
(function () {
|
|
@@ -246,10 +255,10 @@
|
|
|
246
255
|
}
|
|
247
256
|
});
|
|
248
257
|
|
|
249
|
-
var reactIs = createCommonjsModule(function (module) {
|
|
258
|
+
var reactIs$1 = createCommonjsModule(function (module) {
|
|
250
259
|
|
|
251
260
|
{
|
|
252
|
-
module.exports = reactIs_development;
|
|
261
|
+
module.exports = reactIs_development$1;
|
|
253
262
|
}
|
|
254
263
|
});
|
|
255
264
|
|
|
@@ -355,8 +364,8 @@
|
|
|
355
364
|
* LICENSE file in the root directory of this source tree.
|
|
356
365
|
*/
|
|
357
366
|
|
|
358
|
-
var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
|
|
359
|
-
var ReactPropTypesSecret_1 = ReactPropTypesSecret;
|
|
367
|
+
var ReactPropTypesSecret$1 = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
|
|
368
|
+
var ReactPropTypesSecret_1 = ReactPropTypesSecret$1;
|
|
360
369
|
|
|
361
370
|
/**
|
|
362
371
|
* Copyright (c) 2013-present, Facebook, Inc.
|
|
@@ -365,14 +374,14 @@
|
|
|
365
374
|
* LICENSE file in the root directory of this source tree.
|
|
366
375
|
*/
|
|
367
376
|
|
|
368
|
-
var printWarning = function () {};
|
|
377
|
+
var printWarning$1 = function () {};
|
|
369
378
|
|
|
370
379
|
{
|
|
371
|
-
var ReactPropTypesSecret
|
|
380
|
+
var ReactPropTypesSecret = ReactPropTypesSecret_1;
|
|
372
381
|
var loggedTypeFailures = {};
|
|
373
|
-
var has = Function.call.bind(Object.prototype.hasOwnProperty);
|
|
382
|
+
var has$1 = Function.call.bind(Object.prototype.hasOwnProperty);
|
|
374
383
|
|
|
375
|
-
printWarning = function (text) {
|
|
384
|
+
printWarning$1 = function (text) {
|
|
376
385
|
var message = 'Warning: ' + text;
|
|
377
386
|
|
|
378
387
|
if (typeof console !== 'undefined') {
|
|
@@ -403,7 +412,7 @@
|
|
|
403
412
|
function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
|
|
404
413
|
{
|
|
405
414
|
for (var typeSpecName in typeSpecs) {
|
|
406
|
-
if (has(typeSpecs, typeSpecName)) {
|
|
415
|
+
if (has$1(typeSpecs, typeSpecName)) {
|
|
407
416
|
var error; // Prop type validation may throw. In case they do, we don't want to
|
|
408
417
|
// fail the render phase where it didn't fail before. So we log it.
|
|
409
418
|
// After these have been cleaned up, we'll let them throw.
|
|
@@ -417,13 +426,13 @@
|
|
|
417
426
|
throw err;
|
|
418
427
|
}
|
|
419
428
|
|
|
420
|
-
error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret
|
|
429
|
+
error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret);
|
|
421
430
|
} catch (ex) {
|
|
422
431
|
error = ex;
|
|
423
432
|
}
|
|
424
433
|
|
|
425
434
|
if (error && !(error instanceof Error)) {
|
|
426
|
-
printWarning((componentName || 'React class') + ': type specification of ' + location + ' `' + typeSpecName + '` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a ' + typeof error + '. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).');
|
|
435
|
+
printWarning$1((componentName || 'React class') + ': type specification of ' + location + ' `' + typeSpecName + '` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a ' + typeof error + '. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).');
|
|
427
436
|
}
|
|
428
437
|
|
|
429
438
|
if (error instanceof Error && !(error.message in loggedTypeFailures)) {
|
|
@@ -431,7 +440,7 @@
|
|
|
431
440
|
// same error.
|
|
432
441
|
loggedTypeFailures[error.message] = true;
|
|
433
442
|
var stack = getStack ? getStack() : '';
|
|
434
|
-
printWarning('Failed ' + location + ' type: ' + error.message + (stack != null ? stack : ''));
|
|
443
|
+
printWarning$1('Failed ' + location + ' type: ' + error.message + (stack != null ? stack : ''));
|
|
435
444
|
}
|
|
436
445
|
}
|
|
437
446
|
}
|
|
@@ -459,12 +468,12 @@
|
|
|
459
468
|
* LICENSE file in the root directory of this source tree.
|
|
460
469
|
*/
|
|
461
470
|
|
|
462
|
-
var has
|
|
471
|
+
var has = Function.call.bind(Object.prototype.hasOwnProperty);
|
|
463
472
|
|
|
464
|
-
var printWarning
|
|
473
|
+
var printWarning = function () {};
|
|
465
474
|
|
|
466
475
|
{
|
|
467
|
-
printWarning
|
|
476
|
+
printWarning = function (text) {
|
|
468
477
|
var message = 'Warning: ' + text;
|
|
469
478
|
|
|
470
479
|
if (typeof console !== 'undefined') {
|
|
@@ -635,13 +644,13 @@
|
|
|
635
644
|
var err = new Error('Calling PropTypes validators directly is not supported by the `prop-types` package. ' + 'Use `PropTypes.checkPropTypes()` to call them. ' + 'Read more at http://fb.me/use-check-prop-types');
|
|
636
645
|
err.name = 'Invariant Violation';
|
|
637
646
|
throw err;
|
|
638
|
-
} else if (
|
|
647
|
+
} else if (typeof console !== 'undefined') {
|
|
639
648
|
// Old behavior for people using React.PropTypes
|
|
640
649
|
var cacheKey = componentName + ':' + propName;
|
|
641
650
|
|
|
642
651
|
if (!manualPropTypeCallCache[cacheKey] && // Avoid spamming the console because they are often not actionable except for lib authors
|
|
643
652
|
manualPropTypeWarningCount < 3) {
|
|
644
|
-
printWarning
|
|
653
|
+
printWarning('You are manually calling a React.PropTypes validation ' + 'function for the `' + propFullName + '` prop on `' + componentName + '`. This is deprecated ' + 'and will throw in the standalone `prop-types` package. ' + 'You may be seeing this warning due to a third-party PropTypes ' + 'library. See https://fb.me/react-warning-dont-call-proptypes ' + 'for details.');
|
|
645
654
|
manualPropTypeCallCache[cacheKey] = true;
|
|
646
655
|
manualPropTypeWarningCount++;
|
|
647
656
|
}
|
|
@@ -737,7 +746,7 @@
|
|
|
737
746
|
function validate(props, propName, componentName, location, propFullName) {
|
|
738
747
|
var propValue = props[propName];
|
|
739
748
|
|
|
740
|
-
if (!reactIs.isValidElementType(propValue)) {
|
|
749
|
+
if (!reactIs$1.isValidElementType(propValue)) {
|
|
741
750
|
var propType = getPropType(propValue);
|
|
742
751
|
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement type.'));
|
|
743
752
|
}
|
|
@@ -766,9 +775,9 @@
|
|
|
766
775
|
if (!Array.isArray(expectedValues)) {
|
|
767
776
|
{
|
|
768
777
|
if (arguments.length > 1) {
|
|
769
|
-
printWarning
|
|
778
|
+
printWarning('Invalid arguments supplied to oneOf, expected an array, got ' + arguments.length + ' arguments. ' + 'A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z]).');
|
|
770
779
|
} else {
|
|
771
|
-
printWarning
|
|
780
|
+
printWarning('Invalid argument supplied to oneOf, expected an array.');
|
|
772
781
|
}
|
|
773
782
|
}
|
|
774
783
|
|
|
@@ -813,7 +822,7 @@
|
|
|
813
822
|
}
|
|
814
823
|
|
|
815
824
|
for (var key in propValue) {
|
|
816
|
-
if (has
|
|
825
|
+
if (has(propValue, key)) {
|
|
817
826
|
var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1);
|
|
818
827
|
|
|
819
828
|
if (error instanceof Error) {
|
|
@@ -830,7 +839,7 @@
|
|
|
830
839
|
|
|
831
840
|
function createUnionTypeChecker(arrayOfTypeCheckers) {
|
|
832
841
|
if (!Array.isArray(arrayOfTypeCheckers)) {
|
|
833
|
-
|
|
842
|
+
printWarning('Invalid argument supplied to oneOfType, expected an instance of array.') ;
|
|
834
843
|
return emptyFunctionThatReturnsNull;
|
|
835
844
|
}
|
|
836
845
|
|
|
@@ -838,7 +847,7 @@
|
|
|
838
847
|
var checker = arrayOfTypeCheckers[i];
|
|
839
848
|
|
|
840
849
|
if (typeof checker !== 'function') {
|
|
841
|
-
printWarning
|
|
850
|
+
printWarning('Invalid argument supplied to oneOfType. Expected an array of check functions, but ' + 'received ' + getPostfixForTypeWarning(checker) + ' at index ' + i + '.');
|
|
842
851
|
return emptyFunctionThatReturnsNull;
|
|
843
852
|
}
|
|
844
853
|
}
|
|
@@ -1093,9 +1102,9 @@
|
|
|
1093
1102
|
* This source code is licensed under the MIT license found in the
|
|
1094
1103
|
* LICENSE file in the root directory of this source tree.
|
|
1095
1104
|
*/
|
|
1096
|
-
var propTypes = createCommonjsModule(function (module) {
|
|
1105
|
+
var propTypes$3 = createCommonjsModule(function (module) {
|
|
1097
1106
|
{
|
|
1098
|
-
var ReactIs = reactIs; // By explicitly using `prop-types` you are opting into new development behavior.
|
|
1107
|
+
var ReactIs = reactIs$1; // By explicitly using `prop-types` you are opting into new development behavior.
|
|
1099
1108
|
// http://fb.me/prop-types-in-prod
|
|
1100
1109
|
|
|
1101
1110
|
var throwOnDirectAccess = true;
|
|
@@ -1103,7 +1112,7 @@
|
|
|
1103
1112
|
}
|
|
1104
1113
|
});
|
|
1105
1114
|
|
|
1106
|
-
/** @license React v17.0.
|
|
1115
|
+
/** @license React v17.0.2
|
|
1107
1116
|
* react-is.production.min.js
|
|
1108
1117
|
*
|
|
1109
1118
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
@@ -1133,7 +1142,7 @@
|
|
|
1133
1142
|
x("react.legacy_hidden");
|
|
1134
1143
|
}
|
|
1135
1144
|
|
|
1136
|
-
/** @license React v17.0.
|
|
1145
|
+
/** @license React v17.0.2
|
|
1137
1146
|
* react-is.development.js
|
|
1138
1147
|
*
|
|
1139
1148
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
@@ -1141,7 +1150,7 @@
|
|
|
1141
1150
|
* This source code is licensed under the MIT license found in the
|
|
1142
1151
|
* LICENSE file in the root directory of this source tree.
|
|
1143
1152
|
*/
|
|
1144
|
-
var reactIs_development
|
|
1153
|
+
var reactIs_development = createCommonjsModule(function (module, exports) {
|
|
1145
1154
|
|
|
1146
1155
|
{
|
|
1147
1156
|
(function () {
|
|
@@ -1365,15 +1374,15 @@
|
|
|
1365
1374
|
}
|
|
1366
1375
|
});
|
|
1367
1376
|
|
|
1368
|
-
var reactIs
|
|
1377
|
+
var reactIs = createCommonjsModule(function (module) {
|
|
1369
1378
|
|
|
1370
1379
|
{
|
|
1371
|
-
module.exports = reactIs_development
|
|
1380
|
+
module.exports = reactIs_development;
|
|
1372
1381
|
}
|
|
1373
1382
|
});
|
|
1374
1383
|
|
|
1375
1384
|
function t(t) {
|
|
1376
|
-
return
|
|
1385
|
+
return "object" == typeof t && null != t && 1 === t.nodeType;
|
|
1377
1386
|
}
|
|
1378
1387
|
|
|
1379
1388
|
function e(t, e) {
|
|
@@ -1418,15 +1427,15 @@
|
|
|
1418
1427
|
if (!t(e)) throw new TypeError("Invalid target");
|
|
1419
1428
|
|
|
1420
1429
|
for (var f = document.scrollingElement || document.documentElement, s = [], p = e; t(p) && c(p);) {
|
|
1421
|
-
if ((p = p.
|
|
1430
|
+
if ((p = p.parentElement) === f) {
|
|
1422
1431
|
s.push(p);
|
|
1423
1432
|
break;
|
|
1424
1433
|
}
|
|
1425
1434
|
|
|
1426
|
-
p === document.body && n(p) && !n(document.documentElement) || n(p, a) && s.push(p);
|
|
1435
|
+
null != p && p === document.body && n(p) && !n(document.documentElement) || null != p && n(p, a) && s.push(p);
|
|
1427
1436
|
}
|
|
1428
1437
|
|
|
1429
|
-
for (var
|
|
1438
|
+
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++) {
|
|
1430
1439
|
var k = s[T],
|
|
1431
1440
|
B = k.getBoundingClientRect(),
|
|
1432
1441
|
D = B.height,
|
|
@@ -1435,26 +1444,26 @@
|
|
|
1435
1444
|
X = B.right,
|
|
1436
1445
|
Y = B.bottom,
|
|
1437
1446
|
L = B.left;
|
|
1438
|
-
if ("if-needed" === l && y >= 0 && V >= 0 &&
|
|
1447
|
+
if ("if-needed" === l && y >= 0 && V >= 0 && M <= g && E <= m && y >= R && M <= Y && V >= L && E <= X) return C;
|
|
1439
1448
|
var S = getComputedStyle(k),
|
|
1440
1449
|
j = parseInt(S.borderLeftWidth, 10),
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
A = 0,
|
|
1450
|
+
q = parseInt(S.borderTopWidth, 10),
|
|
1451
|
+
z = parseInt(S.borderRightWidth, 10),
|
|
1452
|
+
A = parseInt(S.borderBottomWidth, 10),
|
|
1445
1453
|
F = 0,
|
|
1446
|
-
G =
|
|
1447
|
-
J = "
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1454
|
+
G = 0,
|
|
1455
|
+
J = "offsetWidth" in k ? k.offsetWidth - k.clientWidth - j - z : 0,
|
|
1456
|
+
K = "offsetHeight" in k ? k.offsetHeight - k.clientHeight - q - A : 0;
|
|
1457
|
+
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 {
|
|
1458
|
+
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);
|
|
1459
|
+
var N = k.scrollLeft,
|
|
1451
1460
|
P = k.scrollTop;
|
|
1452
|
-
x += P - (
|
|
1461
|
+
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)));
|
|
1453
1462
|
}
|
|
1454
1463
|
C.push({
|
|
1455
1464
|
el: k,
|
|
1456
|
-
top:
|
|
1457
|
-
left:
|
|
1465
|
+
top: F,
|
|
1466
|
+
left: G
|
|
1458
1467
|
});
|
|
1459
1468
|
}
|
|
1460
1469
|
|
|
@@ -1616,7 +1625,7 @@
|
|
|
1616
1625
|
*/
|
|
1617
1626
|
|
|
1618
1627
|
|
|
1619
|
-
function getA11yStatusMessage(_ref2) {
|
|
1628
|
+
function getA11yStatusMessage$1(_ref2) {
|
|
1620
1629
|
var isOpen = _ref2.isOpen,
|
|
1621
1630
|
resultCount = _ref2.resultCount,
|
|
1622
1631
|
previousResultCount = _ref2.previousResultCount;
|
|
@@ -1948,25 +1957,25 @@
|
|
|
1948
1957
|
return statusDiv;
|
|
1949
1958
|
}
|
|
1950
1959
|
|
|
1951
|
-
var unknown =
|
|
1952
|
-
var mouseUp =
|
|
1953
|
-
var itemMouseEnter =
|
|
1954
|
-
var keyDownArrowUp =
|
|
1955
|
-
var keyDownArrowDown =
|
|
1956
|
-
var keyDownEscape =
|
|
1957
|
-
var keyDownEnter =
|
|
1958
|
-
var keyDownHome =
|
|
1959
|
-
var keyDownEnd =
|
|
1960
|
-
var clickItem =
|
|
1961
|
-
var blurInput =
|
|
1962
|
-
var changeInput =
|
|
1963
|
-
var keyDownSpaceButton =
|
|
1964
|
-
var clickButton =
|
|
1965
|
-
var blurButton =
|
|
1966
|
-
var controlledPropUpdatedSelectedItem =
|
|
1967
|
-
var touchEnd =
|
|
1960
|
+
var unknown = '__autocomplete_unknown__' ;
|
|
1961
|
+
var mouseUp = '__autocomplete_mouseup__' ;
|
|
1962
|
+
var itemMouseEnter = '__autocomplete_item_mouseenter__' ;
|
|
1963
|
+
var keyDownArrowUp = '__autocomplete_keydown_arrow_up__' ;
|
|
1964
|
+
var keyDownArrowDown = '__autocomplete_keydown_arrow_down__' ;
|
|
1965
|
+
var keyDownEscape = '__autocomplete_keydown_escape__' ;
|
|
1966
|
+
var keyDownEnter = '__autocomplete_keydown_enter__' ;
|
|
1967
|
+
var keyDownHome = '__autocomplete_keydown_home__' ;
|
|
1968
|
+
var keyDownEnd = '__autocomplete_keydown_end__' ;
|
|
1969
|
+
var clickItem = '__autocomplete_click_item__' ;
|
|
1970
|
+
var blurInput = '__autocomplete_blur_input__' ;
|
|
1971
|
+
var changeInput = '__autocomplete_change_input__' ;
|
|
1972
|
+
var keyDownSpaceButton = '__autocomplete_keydown_space_button__' ;
|
|
1973
|
+
var clickButton = '__autocomplete_click_button__' ;
|
|
1974
|
+
var blurButton = '__autocomplete_blur_button__' ;
|
|
1975
|
+
var controlledPropUpdatedSelectedItem = '__autocomplete_controlled_prop_updated_selected_item__' ;
|
|
1976
|
+
var touchEnd = '__autocomplete_touchend__' ;
|
|
1968
1977
|
|
|
1969
|
-
var stateChangeTypes = /*#__PURE__*/Object.freeze({
|
|
1978
|
+
var stateChangeTypes$3 = /*#__PURE__*/Object.freeze({
|
|
1970
1979
|
__proto__: null,
|
|
1971
1980
|
unknown: unknown,
|
|
1972
1981
|
mouseUp: mouseUp,
|
|
@@ -2308,12 +2317,16 @@
|
|
|
2308
2317
|
Home: function Home(event) {
|
|
2309
2318
|
var _this4 = this;
|
|
2310
2319
|
|
|
2311
|
-
event.preventDefault();
|
|
2312
|
-
var itemCount = this.getItemCount();
|
|
2313
|
-
|
|
2314
2320
|
var _this$getState3 = this.getState(),
|
|
2315
2321
|
isOpen = _this$getState3.isOpen;
|
|
2316
2322
|
|
|
2323
|
+
if (!isOpen) {
|
|
2324
|
+
return;
|
|
2325
|
+
}
|
|
2326
|
+
|
|
2327
|
+
event.preventDefault();
|
|
2328
|
+
var itemCount = this.getItemCount();
|
|
2329
|
+
|
|
2317
2330
|
if (itemCount <= 0 || !isOpen) {
|
|
2318
2331
|
return;
|
|
2319
2332
|
} // get next non-disabled starting downwards from 0 if that's disabled.
|
|
@@ -2329,12 +2342,16 @@
|
|
|
2329
2342
|
End: function End(event) {
|
|
2330
2343
|
var _this5 = this;
|
|
2331
2344
|
|
|
2332
|
-
event.preventDefault();
|
|
2333
|
-
var itemCount = this.getItemCount();
|
|
2334
|
-
|
|
2335
2345
|
var _this$getState4 = this.getState(),
|
|
2336
2346
|
isOpen = _this$getState4.isOpen;
|
|
2337
2347
|
|
|
2348
|
+
if (!isOpen) {
|
|
2349
|
+
return;
|
|
2350
|
+
}
|
|
2351
|
+
|
|
2352
|
+
event.preventDefault();
|
|
2353
|
+
var itemCount = this.getItemCount();
|
|
2354
|
+
|
|
2338
2355
|
if (itemCount <= 0 || !isOpen) {
|
|
2339
2356
|
return;
|
|
2340
2357
|
} // get next non-disabled starting upwards from last index if that's disabled.
|
|
@@ -2351,9 +2368,9 @@
|
|
|
2351
2368
|
|
|
2352
2369
|
_this.getToggleButtonProps = function (_temp3) {
|
|
2353
2370
|
var _ref3 = _temp3 === void 0 ? {} : _temp3,
|
|
2354
|
-
onClick = _ref3.onClick
|
|
2355
|
-
|
|
2356
|
-
onKeyDown = _ref3.onKeyDown,
|
|
2371
|
+
onClick = _ref3.onClick;
|
|
2372
|
+
_ref3.onPress;
|
|
2373
|
+
var onKeyDown = _ref3.onKeyDown,
|
|
2357
2374
|
onKeyUp = _ref3.onKeyUp,
|
|
2358
2375
|
onBlur = _ref3.onBlur,
|
|
2359
2376
|
rest = _objectWithoutPropertiesLoose(_ref3, ["onClick", "onPress", "onKeyDown", "onKeyUp", "onBlur"]);
|
|
@@ -2361,7 +2378,7 @@
|
|
|
2361
2378
|
var _this$getState5 = _this.getState(),
|
|
2362
2379
|
isOpen = _this$getState5.isOpen;
|
|
2363
2380
|
|
|
2364
|
-
var enabledEventHandlers =
|
|
2381
|
+
var enabledEventHandlers = {
|
|
2365
2382
|
onClick: callAllEventHandlers(onClick, _this.buttonHandleClick),
|
|
2366
2383
|
onKeyDown: callAllEventHandlers(onKeyDown, _this.buttonHandleKeyDown),
|
|
2367
2384
|
onKeyUp: callAllEventHandlers(onKeyUp, _this.buttonHandleKeyUp),
|
|
@@ -2396,7 +2413,7 @@
|
|
|
2396
2413
|
|
|
2397
2414
|
/* istanbul ignore if (can't reasonably test this) */
|
|
2398
2415
|
|
|
2399
|
-
if (
|
|
2416
|
+
if (_this.props.environment.document.activeElement === _this.props.environment.document.body) {
|
|
2400
2417
|
event.target.focus();
|
|
2401
2418
|
} // to simplify testing components that use downshift, we'll not wrap this in a setTimeout
|
|
2402
2419
|
// if the NODE_ENV is test. With the proper build system, this should be dead code eliminated
|
|
@@ -2439,9 +2456,9 @@
|
|
|
2439
2456
|
onKeyDown = _ref4.onKeyDown,
|
|
2440
2457
|
onBlur = _ref4.onBlur,
|
|
2441
2458
|
onChange = _ref4.onChange,
|
|
2442
|
-
onInput = _ref4.onInput
|
|
2443
|
-
|
|
2444
|
-
rest = _objectWithoutPropertiesLoose(_ref4, ["onKeyDown", "onBlur", "onChange", "onInput", "onChangeText"]);
|
|
2459
|
+
onInput = _ref4.onInput;
|
|
2460
|
+
_ref4.onChangeText;
|
|
2461
|
+
var rest = _objectWithoutPropertiesLoose(_ref4, ["onKeyDown", "onBlur", "onChange", "onInput", "onChangeText"]);
|
|
2445
2462
|
|
|
2446
2463
|
var onChangeKey;
|
|
2447
2464
|
var eventHandlers = {};
|
|
@@ -2487,7 +2504,7 @@
|
|
|
2487
2504
|
_this.internalSetState({
|
|
2488
2505
|
type: changeInput,
|
|
2489
2506
|
isOpen: true,
|
|
2490
|
-
inputValue:
|
|
2507
|
+
inputValue: event.target.value,
|
|
2491
2508
|
highlightedIndex: _this.props.defaultHighlightedIndex
|
|
2492
2509
|
});
|
|
2493
2510
|
};
|
|
@@ -2534,11 +2551,11 @@
|
|
|
2534
2551
|
var _ref7 = _temp7 === void 0 ? {} : _temp7,
|
|
2535
2552
|
onMouseMove = _ref7.onMouseMove,
|
|
2536
2553
|
onMouseDown = _ref7.onMouseDown,
|
|
2537
|
-
onClick = _ref7.onClick
|
|
2538
|
-
|
|
2539
|
-
index = _ref7.index,
|
|
2554
|
+
onClick = _ref7.onClick;
|
|
2555
|
+
_ref7.onPress;
|
|
2556
|
+
var index = _ref7.index,
|
|
2540
2557
|
_ref7$item = _ref7.item,
|
|
2541
|
-
item = _ref7$item === void 0 ?
|
|
2558
|
+
item = _ref7$item === void 0 ? requiredProp('getItemProps', 'item') : _ref7$item,
|
|
2542
2559
|
rest = _objectWithoutPropertiesLoose(_ref7, ["onMouseMove", "onMouseDown", "onClick", "onPress", "index", "item"]);
|
|
2543
2560
|
|
|
2544
2561
|
if (index === undefined) {
|
|
@@ -2549,8 +2566,8 @@
|
|
|
2549
2566
|
_this.items[index] = item;
|
|
2550
2567
|
}
|
|
2551
2568
|
|
|
2552
|
-
var onSelectKey =
|
|
2553
|
-
var customClickHandler =
|
|
2569
|
+
var onSelectKey = 'onClick';
|
|
2570
|
+
var customClickHandler = onClick;
|
|
2554
2571
|
var enabledEventHandlers = (_enabledEventHandlers = {
|
|
2555
2572
|
// onMouseMove is used over onMouseEnter here. onMouseMove
|
|
2556
2573
|
// is only triggered on actual mouse movement while onMouseEnter
|
|
@@ -2845,7 +2862,7 @@
|
|
|
2845
2862
|
var _this7 = this;
|
|
2846
2863
|
|
|
2847
2864
|
/* istanbul ignore if (react-native) */
|
|
2848
|
-
if (
|
|
2865
|
+
if (this.getMenuProps.called && !this.getMenuProps.suppressRefError) {
|
|
2849
2866
|
validateGetMenuPropsCalledCorrectly(this._menuNode, this.getMenuProps);
|
|
2850
2867
|
}
|
|
2851
2868
|
/* istanbul ignore if (react-native) */
|
|
@@ -2940,7 +2957,7 @@
|
|
|
2940
2957
|
validateControlledUnchanged(this.state, prevProps, this.props);
|
|
2941
2958
|
/* istanbul ignore if (react-native) */
|
|
2942
2959
|
|
|
2943
|
-
if (
|
|
2960
|
+
if (this.getMenuProps.called && !this.getMenuProps.suppressRefError) {
|
|
2944
2961
|
validateGetMenuPropsCalledCorrectly(this._menuNode, this.getMenuProps);
|
|
2945
2962
|
}
|
|
2946
2963
|
}
|
|
@@ -2995,7 +3012,7 @@
|
|
|
2995
3012
|
}
|
|
2996
3013
|
|
|
2997
3014
|
if (this.getRootProps.called || this.props.suppressRefError) {
|
|
2998
|
-
if (
|
|
3015
|
+
if (!this.getRootProps.suppressRefError && !this.props.suppressRefError) {
|
|
2999
3016
|
validateGetRootPropsCalledCorrectly(element, this.getRootProps);
|
|
3000
3017
|
}
|
|
3001
3018
|
|
|
@@ -3021,13 +3038,13 @@
|
|
|
3021
3038
|
Downshift.defaultProps = {
|
|
3022
3039
|
defaultHighlightedIndex: null,
|
|
3023
3040
|
defaultIsOpen: false,
|
|
3024
|
-
getA11yStatusMessage: getA11yStatusMessage,
|
|
3041
|
+
getA11yStatusMessage: getA11yStatusMessage$1,
|
|
3025
3042
|
itemToString: function itemToString(i) {
|
|
3026
3043
|
if (i == null) {
|
|
3027
3044
|
return '';
|
|
3028
3045
|
}
|
|
3029
3046
|
|
|
3030
|
-
if (
|
|
3047
|
+
if (isPlainObject(i) && !i.hasOwnProperty('toString')) {
|
|
3031
3048
|
// eslint-disable-next-line no-console
|
|
3032
3049
|
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);
|
|
3033
3050
|
}
|
|
@@ -3052,53 +3069,53 @@
|
|
|
3052
3069
|
suppressRefError: false,
|
|
3053
3070
|
scrollIntoView: scrollIntoView
|
|
3054
3071
|
};
|
|
3055
|
-
Downshift.stateChangeTypes = stateChangeTypes;
|
|
3072
|
+
Downshift.stateChangeTypes = stateChangeTypes$3;
|
|
3056
3073
|
return Downshift;
|
|
3057
3074
|
}();
|
|
3058
3075
|
|
|
3059
|
-
|
|
3060
|
-
children: propTypes.func,
|
|
3061
|
-
defaultHighlightedIndex: propTypes.number,
|
|
3062
|
-
defaultIsOpen: propTypes.bool,
|
|
3063
|
-
initialHighlightedIndex: propTypes.number,
|
|
3064
|
-
initialSelectedItem: propTypes.any,
|
|
3065
|
-
initialInputValue: propTypes.string,
|
|
3066
|
-
initialIsOpen: propTypes.bool,
|
|
3067
|
-
getA11yStatusMessage: propTypes.func,
|
|
3068
|
-
itemToString: propTypes.func,
|
|
3069
|
-
onChange: propTypes.func,
|
|
3070
|
-
onSelect: propTypes.func,
|
|
3071
|
-
onStateChange: propTypes.func,
|
|
3072
|
-
onInputValueChange: propTypes.func,
|
|
3073
|
-
onUserAction: propTypes.func,
|
|
3074
|
-
onOuterClick: propTypes.func,
|
|
3075
|
-
selectedItemChanged: propTypes.func,
|
|
3076
|
-
stateReducer: propTypes.func,
|
|
3077
|
-
itemCount: propTypes.number,
|
|
3078
|
-
id: propTypes.string,
|
|
3079
|
-
environment: propTypes.shape({
|
|
3080
|
-
addEventListener: propTypes.func,
|
|
3081
|
-
removeEventListener: propTypes.func,
|
|
3082
|
-
document: propTypes.shape({
|
|
3083
|
-
getElementById: propTypes.func,
|
|
3084
|
-
activeElement: propTypes.any,
|
|
3085
|
-
body: propTypes.any
|
|
3076
|
+
Downshift.propTypes = {
|
|
3077
|
+
children: propTypes$3.func,
|
|
3078
|
+
defaultHighlightedIndex: propTypes$3.number,
|
|
3079
|
+
defaultIsOpen: propTypes$3.bool,
|
|
3080
|
+
initialHighlightedIndex: propTypes$3.number,
|
|
3081
|
+
initialSelectedItem: propTypes$3.any,
|
|
3082
|
+
initialInputValue: propTypes$3.string,
|
|
3083
|
+
initialIsOpen: propTypes$3.bool,
|
|
3084
|
+
getA11yStatusMessage: propTypes$3.func,
|
|
3085
|
+
itemToString: propTypes$3.func,
|
|
3086
|
+
onChange: propTypes$3.func,
|
|
3087
|
+
onSelect: propTypes$3.func,
|
|
3088
|
+
onStateChange: propTypes$3.func,
|
|
3089
|
+
onInputValueChange: propTypes$3.func,
|
|
3090
|
+
onUserAction: propTypes$3.func,
|
|
3091
|
+
onOuterClick: propTypes$3.func,
|
|
3092
|
+
selectedItemChanged: propTypes$3.func,
|
|
3093
|
+
stateReducer: propTypes$3.func,
|
|
3094
|
+
itemCount: propTypes$3.number,
|
|
3095
|
+
id: propTypes$3.string,
|
|
3096
|
+
environment: propTypes$3.shape({
|
|
3097
|
+
addEventListener: propTypes$3.func,
|
|
3098
|
+
removeEventListener: propTypes$3.func,
|
|
3099
|
+
document: propTypes$3.shape({
|
|
3100
|
+
getElementById: propTypes$3.func,
|
|
3101
|
+
activeElement: propTypes$3.any,
|
|
3102
|
+
body: propTypes$3.any
|
|
3086
3103
|
})
|
|
3087
3104
|
}),
|
|
3088
|
-
suppressRefError: propTypes.bool,
|
|
3089
|
-
scrollIntoView: propTypes.func,
|
|
3105
|
+
suppressRefError: propTypes$3.bool,
|
|
3106
|
+
scrollIntoView: propTypes$3.func,
|
|
3090
3107
|
// things we keep in state for uncontrolled components
|
|
3091
3108
|
// but can accept as props for controlled components
|
|
3092
3109
|
|
|
3093
3110
|
/* eslint-disable react/no-unused-prop-types */
|
|
3094
|
-
selectedItem: propTypes.any,
|
|
3095
|
-
isOpen: propTypes.bool,
|
|
3096
|
-
inputValue: propTypes.string,
|
|
3097
|
-
highlightedIndex: propTypes.number,
|
|
3098
|
-
labelId: propTypes.string,
|
|
3099
|
-
inputId: propTypes.string,
|
|
3100
|
-
menuId: propTypes.string,
|
|
3101
|
-
getItemId: propTypes.func
|
|
3111
|
+
selectedItem: propTypes$3.any,
|
|
3112
|
+
isOpen: propTypes$3.bool,
|
|
3113
|
+
inputValue: propTypes$3.string,
|
|
3114
|
+
highlightedIndex: propTypes$3.number,
|
|
3115
|
+
labelId: propTypes$3.string,
|
|
3116
|
+
inputId: propTypes$3.string,
|
|
3117
|
+
menuId: propTypes$3.string,
|
|
3118
|
+
getItemId: propTypes$3.func
|
|
3102
3119
|
/* eslint-enable react/no-unused-prop-types */
|
|
3103
3120
|
|
|
3104
3121
|
} ;
|
|
@@ -3117,7 +3134,7 @@
|
|
|
3117
3134
|
var refKeySpecified = refKey !== 'ref';
|
|
3118
3135
|
var isComposite = !isDOMElement(element);
|
|
3119
3136
|
|
|
3120
|
-
if (isComposite && !refKeySpecified && !reactIs
|
|
3137
|
+
if (isComposite && !refKeySpecified && !reactIs.isForwardRef(element)) {
|
|
3121
3138
|
// eslint-disable-next-line no-console
|
|
3122
3139
|
console.error('downshift: You returned a non-DOM element. You must specify a refKey in getRootProps');
|
|
3123
3140
|
} else if (!isComposite && refKeySpecified) {
|
|
@@ -3125,7 +3142,7 @@
|
|
|
3125
3142
|
console.error("downshift: You returned a DOM element. You should not specify a refKey in getRootProps. You specified \"" + refKey + "\"");
|
|
3126
3143
|
}
|
|
3127
3144
|
|
|
3128
|
-
if (!reactIs
|
|
3145
|
+
if (!reactIs.isForwardRef(element) && !getElementProps(element)[refKey]) {
|
|
3129
3146
|
// eslint-disable-next-line no-console
|
|
3130
3147
|
console.error("downshift: You must apply the ref prop \"" + refKey + "\" from getRootProps onto your root element.");
|
|
3131
3148
|
}
|
|
@@ -3314,7 +3331,7 @@
|
|
|
3314
3331
|
*/
|
|
3315
3332
|
|
|
3316
3333
|
|
|
3317
|
-
function useControlledReducer(reducer, initialState, props) {
|
|
3334
|
+
function useControlledReducer$1(reducer, initialState, props) {
|
|
3318
3335
|
var _useEnhancedReducer = useEnhancedReducer(reducer, initialState, props),
|
|
3319
3336
|
state = _useEnhancedReducer[0],
|
|
3320
3337
|
dispatch = _useEnhancedReducer[1];
|
|
@@ -3322,7 +3339,7 @@
|
|
|
3322
3339
|
return [getState(state, props), dispatch];
|
|
3323
3340
|
}
|
|
3324
3341
|
|
|
3325
|
-
var defaultProps = {
|
|
3342
|
+
var defaultProps$3 = {
|
|
3326
3343
|
itemToString: itemToString,
|
|
3327
3344
|
stateReducer: stateReducer,
|
|
3328
3345
|
getA11ySelectionMessage: getA11ySelectionMessage,
|
|
@@ -3333,7 +3350,7 @@
|
|
|
3333
3350
|
? {} : window
|
|
3334
3351
|
};
|
|
3335
3352
|
|
|
3336
|
-
function getDefaultValue(props, propKey, defaultStateValues) {
|
|
3353
|
+
function getDefaultValue$1(props, propKey, defaultStateValues) {
|
|
3337
3354
|
if (defaultStateValues === void 0) {
|
|
3338
3355
|
defaultStateValues = dropdownDefaultStateValues;
|
|
3339
3356
|
}
|
|
@@ -3347,7 +3364,7 @@
|
|
|
3347
3364
|
return defaultStateValues[propKey];
|
|
3348
3365
|
}
|
|
3349
3366
|
|
|
3350
|
-
function getInitialValue(props, propKey, defaultStateValues) {
|
|
3367
|
+
function getInitialValue$1(props, propKey, defaultStateValues) {
|
|
3351
3368
|
if (defaultStateValues === void 0) {
|
|
3352
3369
|
defaultStateValues = dropdownDefaultStateValues;
|
|
3353
3370
|
}
|
|
@@ -3362,14 +3379,14 @@
|
|
|
3362
3379
|
return props[initialPropKey];
|
|
3363
3380
|
}
|
|
3364
3381
|
|
|
3365
|
-
return getDefaultValue(props, propKey, defaultStateValues);
|
|
3382
|
+
return getDefaultValue$1(props, propKey, defaultStateValues);
|
|
3366
3383
|
}
|
|
3367
3384
|
|
|
3368
|
-
function getInitialState(props) {
|
|
3369
|
-
var selectedItem = getInitialValue(props, 'selectedItem');
|
|
3370
|
-
var isOpen = getInitialValue(props, 'isOpen');
|
|
3371
|
-
var highlightedIndex = getInitialValue(props, 'highlightedIndex');
|
|
3372
|
-
var inputValue = getInitialValue(props, 'inputValue');
|
|
3385
|
+
function getInitialState$2(props) {
|
|
3386
|
+
var selectedItem = getInitialValue$1(props, 'selectedItem');
|
|
3387
|
+
var isOpen = getInitialValue$1(props, 'isOpen');
|
|
3388
|
+
var highlightedIndex = getInitialValue$1(props, 'highlightedIndex');
|
|
3389
|
+
var inputValue = getInitialValue$1(props, 'inputValue');
|
|
3373
3390
|
return {
|
|
3374
3391
|
highlightedIndex: highlightedIndex < 0 && selectedItem && isOpen ? props.items.indexOf(selectedItem) : highlightedIndex,
|
|
3375
3392
|
isOpen: isOpen,
|
|
@@ -3664,10 +3681,10 @@
|
|
|
3664
3681
|
|
|
3665
3682
|
case stateChangeTypes.FunctionReset:
|
|
3666
3683
|
changes = {
|
|
3667
|
-
highlightedIndex: getDefaultValue(props, 'highlightedIndex'),
|
|
3668
|
-
isOpen: getDefaultValue(props, 'isOpen'),
|
|
3669
|
-
selectedItem: getDefaultValue(props, 'selectedItem'),
|
|
3670
|
-
inputValue: getDefaultValue(props, 'inputValue')
|
|
3684
|
+
highlightedIndex: getDefaultValue$1(props, 'highlightedIndex'),
|
|
3685
|
+
isOpen: getDefaultValue$1(props, 'isOpen'),
|
|
3686
|
+
selectedItem: getDefaultValue$1(props, 'selectedItem'),
|
|
3687
|
+
inputValue: getDefaultValue$1(props, 'inputValue')
|
|
3671
3688
|
};
|
|
3672
3689
|
break;
|
|
3673
3690
|
|
|
@@ -3697,38 +3714,38 @@
|
|
|
3697
3714
|
return highlightedIndex;
|
|
3698
3715
|
}
|
|
3699
3716
|
|
|
3700
|
-
var propTypes$
|
|
3701
|
-
items: propTypes.array.isRequired,
|
|
3702
|
-
itemToString: propTypes.func,
|
|
3703
|
-
getA11yStatusMessage: propTypes.func,
|
|
3704
|
-
getA11ySelectionMessage: propTypes.func,
|
|
3705
|
-
circularNavigation: propTypes.bool,
|
|
3706
|
-
highlightedIndex: propTypes.number,
|
|
3707
|
-
defaultHighlightedIndex: propTypes.number,
|
|
3708
|
-
initialHighlightedIndex: propTypes.number,
|
|
3709
|
-
isOpen: propTypes.bool,
|
|
3710
|
-
defaultIsOpen: propTypes.bool,
|
|
3711
|
-
initialIsOpen: propTypes.bool,
|
|
3712
|
-
selectedItem: propTypes.any,
|
|
3713
|
-
initialSelectedItem: propTypes.any,
|
|
3714
|
-
defaultSelectedItem: propTypes.any,
|
|
3715
|
-
id: propTypes.string,
|
|
3716
|
-
labelId: propTypes.string,
|
|
3717
|
-
menuId: propTypes.string,
|
|
3718
|
-
getItemId: propTypes.func,
|
|
3719
|
-
toggleButtonId: propTypes.string,
|
|
3720
|
-
stateReducer: propTypes.func,
|
|
3721
|
-
onSelectedItemChange: propTypes.func,
|
|
3722
|
-
onHighlightedIndexChange: propTypes.func,
|
|
3723
|
-
onStateChange: propTypes.func,
|
|
3724
|
-
onIsOpenChange: propTypes.func,
|
|
3725
|
-
environment: propTypes.shape({
|
|
3726
|
-
addEventListener: propTypes.func,
|
|
3727
|
-
removeEventListener: propTypes.func,
|
|
3728
|
-
document: propTypes.shape({
|
|
3729
|
-
getElementById: propTypes.func,
|
|
3730
|
-
activeElement: propTypes.any,
|
|
3731
|
-
body: propTypes.any
|
|
3717
|
+
var propTypes$2 = {
|
|
3718
|
+
items: propTypes$3.array.isRequired,
|
|
3719
|
+
itemToString: propTypes$3.func,
|
|
3720
|
+
getA11yStatusMessage: propTypes$3.func,
|
|
3721
|
+
getA11ySelectionMessage: propTypes$3.func,
|
|
3722
|
+
circularNavigation: propTypes$3.bool,
|
|
3723
|
+
highlightedIndex: propTypes$3.number,
|
|
3724
|
+
defaultHighlightedIndex: propTypes$3.number,
|
|
3725
|
+
initialHighlightedIndex: propTypes$3.number,
|
|
3726
|
+
isOpen: propTypes$3.bool,
|
|
3727
|
+
defaultIsOpen: propTypes$3.bool,
|
|
3728
|
+
initialIsOpen: propTypes$3.bool,
|
|
3729
|
+
selectedItem: propTypes$3.any,
|
|
3730
|
+
initialSelectedItem: propTypes$3.any,
|
|
3731
|
+
defaultSelectedItem: propTypes$3.any,
|
|
3732
|
+
id: propTypes$3.string,
|
|
3733
|
+
labelId: propTypes$3.string,
|
|
3734
|
+
menuId: propTypes$3.string,
|
|
3735
|
+
getItemId: propTypes$3.func,
|
|
3736
|
+
toggleButtonId: propTypes$3.string,
|
|
3737
|
+
stateReducer: propTypes$3.func,
|
|
3738
|
+
onSelectedItemChange: propTypes$3.func,
|
|
3739
|
+
onHighlightedIndexChange: propTypes$3.func,
|
|
3740
|
+
onStateChange: propTypes$3.func,
|
|
3741
|
+
onIsOpenChange: propTypes$3.func,
|
|
3742
|
+
environment: propTypes$3.shape({
|
|
3743
|
+
addEventListener: propTypes$3.func,
|
|
3744
|
+
removeEventListener: propTypes$3.func,
|
|
3745
|
+
document: propTypes$3.shape({
|
|
3746
|
+
getElementById: propTypes$3.func,
|
|
3747
|
+
activeElement: propTypes$3.any,
|
|
3748
|
+
body: propTypes$3.any
|
|
3732
3749
|
})
|
|
3733
3750
|
})
|
|
3734
3751
|
};
|
|
@@ -3741,7 +3758,7 @@
|
|
|
3741
3758
|
* @return {String} the a11y status message
|
|
3742
3759
|
*/
|
|
3743
3760
|
|
|
3744
|
-
function getA11yStatusMessage
|
|
3761
|
+
function getA11yStatusMessage(_ref) {
|
|
3745
3762
|
var isOpen = _ref.isOpen,
|
|
3746
3763
|
resultCount = _ref.resultCount,
|
|
3747
3764
|
previousResultCount = _ref.previousResultCount;
|
|
@@ -3761,45 +3778,45 @@
|
|
|
3761
3778
|
return '';
|
|
3762
3779
|
}
|
|
3763
3780
|
|
|
3764
|
-
var defaultProps$
|
|
3765
|
-
getA11yStatusMessage: getA11yStatusMessage
|
|
3781
|
+
var defaultProps$2 = _extends({}, defaultProps$3, {
|
|
3782
|
+
getA11yStatusMessage: getA11yStatusMessage
|
|
3766
3783
|
}); // eslint-disable-next-line import/no-mutable-exports
|
|
3767
3784
|
|
|
3768
3785
|
|
|
3769
|
-
var validatePropTypes = noop;
|
|
3786
|
+
var validatePropTypes$2 = noop;
|
|
3770
3787
|
/* istanbul ignore next */
|
|
3771
3788
|
|
|
3772
3789
|
{
|
|
3773
|
-
validatePropTypes = function validatePropTypes(options, caller) {
|
|
3774
|
-
propTypes.checkPropTypes(propTypes$
|
|
3790
|
+
validatePropTypes$2 = function validatePropTypes(options, caller) {
|
|
3791
|
+
propTypes$3.checkPropTypes(propTypes$2, options, 'prop', caller.name);
|
|
3775
3792
|
};
|
|
3776
3793
|
}
|
|
3777
3794
|
|
|
3778
|
-
var MenuKeyDownArrowDown =
|
|
3779
|
-
var MenuKeyDownArrowUp =
|
|
3780
|
-
var MenuKeyDownEscape =
|
|
3781
|
-
var MenuKeyDownHome =
|
|
3782
|
-
var MenuKeyDownEnd =
|
|
3783
|
-
var MenuKeyDownEnter =
|
|
3784
|
-
var MenuKeyDownSpaceButton =
|
|
3785
|
-
var MenuKeyDownCharacter =
|
|
3786
|
-
var MenuBlur =
|
|
3787
|
-
var MenuMouseLeave =
|
|
3788
|
-
var ItemMouseMove =
|
|
3789
|
-
var ItemClick =
|
|
3790
|
-
var ToggleButtonClick =
|
|
3791
|
-
var ToggleButtonKeyDownArrowDown =
|
|
3792
|
-
var ToggleButtonKeyDownArrowUp =
|
|
3793
|
-
var ToggleButtonKeyDownCharacter =
|
|
3794
|
-
var FunctionToggleMenu =
|
|
3795
|
-
var FunctionOpenMenu =
|
|
3796
|
-
var FunctionCloseMenu =
|
|
3797
|
-
var FunctionSetHighlightedIndex =
|
|
3798
|
-
var FunctionSelectItem =
|
|
3799
|
-
var FunctionSetInputValue =
|
|
3800
|
-
var FunctionReset =
|
|
3795
|
+
var MenuKeyDownArrowDown = '__menu_keydown_arrow_down__' ;
|
|
3796
|
+
var MenuKeyDownArrowUp = '__menu_keydown_arrow_up__' ;
|
|
3797
|
+
var MenuKeyDownEscape = '__menu_keydown_escape__' ;
|
|
3798
|
+
var MenuKeyDownHome = '__menu_keydown_home__' ;
|
|
3799
|
+
var MenuKeyDownEnd = '__menu_keydown_end__' ;
|
|
3800
|
+
var MenuKeyDownEnter = '__menu_keydown_enter__' ;
|
|
3801
|
+
var MenuKeyDownSpaceButton = '__menu_keydown_space_button__' ;
|
|
3802
|
+
var MenuKeyDownCharacter = '__menu_keydown_character__' ;
|
|
3803
|
+
var MenuBlur = '__menu_blur__' ;
|
|
3804
|
+
var MenuMouseLeave$1 = '__menu_mouse_leave__' ;
|
|
3805
|
+
var ItemMouseMove$1 = '__item_mouse_move__' ;
|
|
3806
|
+
var ItemClick$1 = '__item_click__' ;
|
|
3807
|
+
var ToggleButtonClick$1 = '__togglebutton_click__' ;
|
|
3808
|
+
var ToggleButtonKeyDownArrowDown = '__togglebutton_keydown_arrow_down__' ;
|
|
3809
|
+
var ToggleButtonKeyDownArrowUp = '__togglebutton_keydown_arrow_up__' ;
|
|
3810
|
+
var ToggleButtonKeyDownCharacter = '__togglebutton_keydown_character__' ;
|
|
3811
|
+
var FunctionToggleMenu$1 = '__function_toggle_menu__' ;
|
|
3812
|
+
var FunctionOpenMenu$1 = '__function_open_menu__' ;
|
|
3813
|
+
var FunctionCloseMenu$1 = '__function_close_menu__' ;
|
|
3814
|
+
var FunctionSetHighlightedIndex$1 = '__function_set_highlighted_index__' ;
|
|
3815
|
+
var FunctionSelectItem$1 = '__function_select_item__' ;
|
|
3816
|
+
var FunctionSetInputValue$1 = '__function_set_input_value__' ;
|
|
3817
|
+
var FunctionReset$2 = '__function_reset__' ;
|
|
3801
3818
|
|
|
3802
|
-
var stateChangeTypes$
|
|
3819
|
+
var stateChangeTypes$2 = /*#__PURE__*/Object.freeze({
|
|
3803
3820
|
__proto__: null,
|
|
3804
3821
|
MenuKeyDownArrowDown: MenuKeyDownArrowDown,
|
|
3805
3822
|
MenuKeyDownArrowUp: MenuKeyDownArrowUp,
|
|
@@ -3810,20 +3827,20 @@
|
|
|
3810
3827
|
MenuKeyDownSpaceButton: MenuKeyDownSpaceButton,
|
|
3811
3828
|
MenuKeyDownCharacter: MenuKeyDownCharacter,
|
|
3812
3829
|
MenuBlur: MenuBlur,
|
|
3813
|
-
MenuMouseLeave: MenuMouseLeave,
|
|
3814
|
-
ItemMouseMove: ItemMouseMove,
|
|
3815
|
-
ItemClick: ItemClick,
|
|
3816
|
-
ToggleButtonClick: ToggleButtonClick,
|
|
3830
|
+
MenuMouseLeave: MenuMouseLeave$1,
|
|
3831
|
+
ItemMouseMove: ItemMouseMove$1,
|
|
3832
|
+
ItemClick: ItemClick$1,
|
|
3833
|
+
ToggleButtonClick: ToggleButtonClick$1,
|
|
3817
3834
|
ToggleButtonKeyDownArrowDown: ToggleButtonKeyDownArrowDown,
|
|
3818
3835
|
ToggleButtonKeyDownArrowUp: ToggleButtonKeyDownArrowUp,
|
|
3819
3836
|
ToggleButtonKeyDownCharacter: ToggleButtonKeyDownCharacter,
|
|
3820
|
-
FunctionToggleMenu: FunctionToggleMenu,
|
|
3821
|
-
FunctionOpenMenu: FunctionOpenMenu,
|
|
3822
|
-
FunctionCloseMenu: FunctionCloseMenu,
|
|
3823
|
-
FunctionSetHighlightedIndex: FunctionSetHighlightedIndex,
|
|
3824
|
-
FunctionSelectItem: FunctionSelectItem,
|
|
3825
|
-
FunctionSetInputValue: FunctionSetInputValue,
|
|
3826
|
-
FunctionReset: FunctionReset
|
|
3837
|
+
FunctionToggleMenu: FunctionToggleMenu$1,
|
|
3838
|
+
FunctionOpenMenu: FunctionOpenMenu$1,
|
|
3839
|
+
FunctionCloseMenu: FunctionCloseMenu$1,
|
|
3840
|
+
FunctionSetHighlightedIndex: FunctionSetHighlightedIndex$1,
|
|
3841
|
+
FunctionSelectItem: FunctionSelectItem$1,
|
|
3842
|
+
FunctionSetInputValue: FunctionSetInputValue$1,
|
|
3843
|
+
FunctionReset: FunctionReset$2
|
|
3827
3844
|
});
|
|
3828
3845
|
|
|
3829
3846
|
/* eslint-disable complexity */
|
|
@@ -3835,10 +3852,10 @@
|
|
|
3835
3852
|
var changes;
|
|
3836
3853
|
|
|
3837
3854
|
switch (type) {
|
|
3838
|
-
case ItemClick:
|
|
3855
|
+
case ItemClick$1:
|
|
3839
3856
|
changes = {
|
|
3840
|
-
isOpen: getDefaultValue(props, 'isOpen'),
|
|
3841
|
-
highlightedIndex: getDefaultValue(props, 'highlightedIndex'),
|
|
3857
|
+
isOpen: getDefaultValue$1(props, 'isOpen'),
|
|
3858
|
+
highlightedIndex: getDefaultValue$1(props, 'highlightedIndex'),
|
|
3842
3859
|
selectedItem: props.items[action.index]
|
|
3843
3860
|
};
|
|
3844
3861
|
break;
|
|
@@ -3873,8 +3890,8 @@
|
|
|
3873
3890
|
case MenuKeyDownEnter:
|
|
3874
3891
|
case MenuKeyDownSpaceButton:
|
|
3875
3892
|
changes = _extends({
|
|
3876
|
-
isOpen: getDefaultValue(props, 'isOpen'),
|
|
3877
|
-
highlightedIndex: getDefaultValue(props, 'highlightedIndex')
|
|
3893
|
+
isOpen: getDefaultValue$1(props, 'isOpen'),
|
|
3894
|
+
highlightedIndex: getDefaultValue$1(props, 'highlightedIndex')
|
|
3878
3895
|
}, state.highlightedIndex >= 0 && {
|
|
3879
3896
|
selectedItem: props.items[state.highlightedIndex]
|
|
3880
3897
|
});
|
|
@@ -3933,30 +3950,30 @@
|
|
|
3933
3950
|
};
|
|
3934
3951
|
break;
|
|
3935
3952
|
|
|
3936
|
-
case FunctionSelectItem:
|
|
3953
|
+
case FunctionSelectItem$1:
|
|
3937
3954
|
changes = {
|
|
3938
3955
|
selectedItem: action.selectedItem
|
|
3939
3956
|
};
|
|
3940
3957
|
break;
|
|
3941
3958
|
|
|
3942
3959
|
default:
|
|
3943
|
-
return downshiftCommonReducer(state, action, stateChangeTypes$
|
|
3960
|
+
return downshiftCommonReducer(state, action, stateChangeTypes$2);
|
|
3944
3961
|
}
|
|
3945
3962
|
|
|
3946
3963
|
return _extends({}, state, changes);
|
|
3947
3964
|
}
|
|
3948
3965
|
/* eslint-enable complexity */
|
|
3949
3966
|
|
|
3950
|
-
useSelect.stateChangeTypes = stateChangeTypes$
|
|
3967
|
+
useSelect.stateChangeTypes = stateChangeTypes$2;
|
|
3951
3968
|
|
|
3952
3969
|
function useSelect(userProps) {
|
|
3953
3970
|
if (userProps === void 0) {
|
|
3954
3971
|
userProps = {};
|
|
3955
3972
|
}
|
|
3956
3973
|
|
|
3957
|
-
validatePropTypes(userProps, useSelect); // Props defaults and destructuring.
|
|
3974
|
+
validatePropTypes$2(userProps, useSelect); // Props defaults and destructuring.
|
|
3958
3975
|
|
|
3959
|
-
var props = _extends({}, defaultProps$
|
|
3976
|
+
var props = _extends({}, defaultProps$2, userProps);
|
|
3960
3977
|
|
|
3961
3978
|
var items = props.items,
|
|
3962
3979
|
scrollIntoView = props.scrollIntoView,
|
|
@@ -3967,9 +3984,9 @@
|
|
|
3967
3984
|
getA11ySelectionMessage = props.getA11ySelectionMessage,
|
|
3968
3985
|
getA11yStatusMessage = props.getA11yStatusMessage; // Initial state depending on controlled props.
|
|
3969
3986
|
|
|
3970
|
-
var initialState = getInitialState(props);
|
|
3987
|
+
var initialState = getInitialState$2(props);
|
|
3971
3988
|
|
|
3972
|
-
var _useControlledReducer = useControlledReducer(downshiftSelectReducer, initialState, props),
|
|
3989
|
+
var _useControlledReducer = useControlledReducer$1(downshiftSelectReducer, initialState, props),
|
|
3973
3990
|
state = _useControlledReducer[0],
|
|
3974
3991
|
dispatch = _useControlledReducer[1];
|
|
3975
3992
|
|
|
@@ -4024,19 +4041,23 @@
|
|
|
4024
4041
|
itemRefs: itemRefs,
|
|
4025
4042
|
scrollIntoView: scrollIntoView,
|
|
4026
4043
|
getItemNodeFromIndex: getItemNodeFromIndex
|
|
4027
|
-
}); // Sets cleanup for the keysSoFar after 500ms.
|
|
4044
|
+
}); // Sets cleanup for the keysSoFar callback, debounded after 500ms.
|
|
4028
4045
|
|
|
4029
4046
|
react.useEffect(function () {
|
|
4030
4047
|
// init the clean function here as we need access to dispatch.
|
|
4031
|
-
|
|
4032
|
-
|
|
4033
|
-
|
|
4034
|
-
|
|
4035
|
-
|
|
4036
|
-
|
|
4037
|
-
|
|
4038
|
-
|
|
4048
|
+
clearTimeoutRef.current = debounce(function (outerDispatch) {
|
|
4049
|
+
outerDispatch({
|
|
4050
|
+
type: FunctionSetInputValue$1,
|
|
4051
|
+
inputValue: ''
|
|
4052
|
+
});
|
|
4053
|
+
}, 500); // Cancel any pending debounced calls on mount
|
|
4054
|
+
|
|
4055
|
+
return function () {
|
|
4056
|
+
clearTimeoutRef.current.cancel();
|
|
4057
|
+
};
|
|
4058
|
+
}, []); // Invokes the keysSoFar callback set up above.
|
|
4039
4059
|
|
|
4060
|
+
react.useEffect(function () {
|
|
4040
4061
|
if (!inputValue) {
|
|
4041
4062
|
return;
|
|
4042
4063
|
}
|
|
@@ -4180,39 +4201,39 @@
|
|
|
4180
4201
|
|
|
4181
4202
|
var toggleMenu = react.useCallback(function () {
|
|
4182
4203
|
dispatch({
|
|
4183
|
-
type: FunctionToggleMenu
|
|
4204
|
+
type: FunctionToggleMenu$1
|
|
4184
4205
|
});
|
|
4185
4206
|
}, [dispatch]);
|
|
4186
4207
|
var closeMenu = react.useCallback(function () {
|
|
4187
4208
|
dispatch({
|
|
4188
|
-
type: FunctionCloseMenu
|
|
4209
|
+
type: FunctionCloseMenu$1
|
|
4189
4210
|
});
|
|
4190
4211
|
}, [dispatch]);
|
|
4191
4212
|
var openMenu = react.useCallback(function () {
|
|
4192
4213
|
dispatch({
|
|
4193
|
-
type: FunctionOpenMenu
|
|
4214
|
+
type: FunctionOpenMenu$1
|
|
4194
4215
|
});
|
|
4195
4216
|
}, [dispatch]);
|
|
4196
4217
|
var setHighlightedIndex = react.useCallback(function (newHighlightedIndex) {
|
|
4197
4218
|
dispatch({
|
|
4198
|
-
type: FunctionSetHighlightedIndex,
|
|
4219
|
+
type: FunctionSetHighlightedIndex$1,
|
|
4199
4220
|
highlightedIndex: newHighlightedIndex
|
|
4200
4221
|
});
|
|
4201
4222
|
}, [dispatch]);
|
|
4202
4223
|
var selectItem = react.useCallback(function (newSelectedItem) {
|
|
4203
4224
|
dispatch({
|
|
4204
|
-
type: FunctionSelectItem,
|
|
4225
|
+
type: FunctionSelectItem$1,
|
|
4205
4226
|
selectedItem: newSelectedItem
|
|
4206
4227
|
});
|
|
4207
4228
|
}, [dispatch]);
|
|
4208
4229
|
var reset = react.useCallback(function () {
|
|
4209
4230
|
dispatch({
|
|
4210
|
-
type: FunctionReset
|
|
4231
|
+
type: FunctionReset$2
|
|
4211
4232
|
});
|
|
4212
4233
|
}, [dispatch]);
|
|
4213
4234
|
var setInputValue = react.useCallback(function (newInputValue) {
|
|
4214
4235
|
dispatch({
|
|
4215
|
-
type: FunctionSetInputValue,
|
|
4236
|
+
type: FunctionSetInputValue$1,
|
|
4216
4237
|
inputValue: newInputValue
|
|
4217
4238
|
});
|
|
4218
4239
|
}, [dispatch]); // Getter functions.
|
|
@@ -4274,7 +4295,7 @@
|
|
|
4274
4295
|
|
|
4275
4296
|
var menuHandleMouseLeave = function menuHandleMouseLeave() {
|
|
4276
4297
|
dispatch({
|
|
4277
|
-
type: MenuMouseLeave
|
|
4298
|
+
type: MenuMouseLeave$1
|
|
4278
4299
|
});
|
|
4279
4300
|
};
|
|
4280
4301
|
|
|
@@ -4306,7 +4327,7 @@
|
|
|
4306
4327
|
|
|
4307
4328
|
var toggleButtonHandleClick = function toggleButtonHandleClick() {
|
|
4308
4329
|
dispatch({
|
|
4309
|
-
type: ToggleButtonClick
|
|
4330
|
+
type: ToggleButtonClick$1
|
|
4310
4331
|
});
|
|
4311
4332
|
};
|
|
4312
4333
|
|
|
@@ -4360,14 +4381,14 @@
|
|
|
4360
4381
|
|
|
4361
4382
|
shouldScrollRef.current = false;
|
|
4362
4383
|
dispatch({
|
|
4363
|
-
type: ItemMouseMove,
|
|
4384
|
+
type: ItemMouseMove$1,
|
|
4364
4385
|
index: index
|
|
4365
4386
|
});
|
|
4366
4387
|
};
|
|
4367
4388
|
|
|
4368
4389
|
var itemHandleClick = function itemHandleClick() {
|
|
4369
4390
|
dispatch({
|
|
4370
|
-
type: ItemClick,
|
|
4391
|
+
type: ItemClick$1,
|
|
4371
4392
|
index: index
|
|
4372
4393
|
});
|
|
4373
4394
|
};
|
|
@@ -4417,28 +4438,28 @@
|
|
|
4417
4438
|
};
|
|
4418
4439
|
}
|
|
4419
4440
|
|
|
4420
|
-
var InputKeyDownArrowDown =
|
|
4421
|
-
var InputKeyDownArrowUp =
|
|
4422
|
-
var InputKeyDownEscape =
|
|
4423
|
-
var InputKeyDownHome =
|
|
4424
|
-
var InputKeyDownEnd =
|
|
4425
|
-
var InputKeyDownEnter =
|
|
4426
|
-
var InputChange =
|
|
4427
|
-
var InputBlur =
|
|
4428
|
-
var MenuMouseLeave
|
|
4429
|
-
var ItemMouseMove
|
|
4430
|
-
var ItemClick
|
|
4431
|
-
var ToggleButtonClick
|
|
4432
|
-
var FunctionToggleMenu
|
|
4433
|
-
var FunctionOpenMenu
|
|
4434
|
-
var FunctionCloseMenu
|
|
4435
|
-
var FunctionSetHighlightedIndex
|
|
4436
|
-
var FunctionSelectItem
|
|
4437
|
-
var FunctionSetInputValue
|
|
4438
|
-
var FunctionReset$1 =
|
|
4439
|
-
var ControlledPropUpdatedSelectedItem =
|
|
4441
|
+
var InputKeyDownArrowDown = '__input_keydown_arrow_down__' ;
|
|
4442
|
+
var InputKeyDownArrowUp = '__input_keydown_arrow_up__' ;
|
|
4443
|
+
var InputKeyDownEscape = '__input_keydown_escape__' ;
|
|
4444
|
+
var InputKeyDownHome = '__input_keydown_home__' ;
|
|
4445
|
+
var InputKeyDownEnd = '__input_keydown_end__' ;
|
|
4446
|
+
var InputKeyDownEnter = '__input_keydown_enter__' ;
|
|
4447
|
+
var InputChange = '__input_change__' ;
|
|
4448
|
+
var InputBlur = '__input_blur__' ;
|
|
4449
|
+
var MenuMouseLeave = '__menu_mouse_leave__' ;
|
|
4450
|
+
var ItemMouseMove = '__item_mouse_move__' ;
|
|
4451
|
+
var ItemClick = '__item_click__' ;
|
|
4452
|
+
var ToggleButtonClick = '__togglebutton_click__' ;
|
|
4453
|
+
var FunctionToggleMenu = '__function_toggle_menu__' ;
|
|
4454
|
+
var FunctionOpenMenu = '__function_open_menu__' ;
|
|
4455
|
+
var FunctionCloseMenu = '__function_close_menu__' ;
|
|
4456
|
+
var FunctionSetHighlightedIndex = '__function_set_highlighted_index__' ;
|
|
4457
|
+
var FunctionSelectItem = '__function_select_item__' ;
|
|
4458
|
+
var FunctionSetInputValue = '__function_set_input_value__' ;
|
|
4459
|
+
var FunctionReset$1 = '__function_reset__' ;
|
|
4460
|
+
var ControlledPropUpdatedSelectedItem = '__controlled_prop_updated_selected_item__' ;
|
|
4440
4461
|
|
|
4441
|
-
var stateChangeTypes$
|
|
4462
|
+
var stateChangeTypes$1 = /*#__PURE__*/Object.freeze({
|
|
4442
4463
|
__proto__: null,
|
|
4443
4464
|
InputKeyDownArrowDown: InputKeyDownArrowDown,
|
|
4444
4465
|
InputKeyDownArrowUp: InputKeyDownArrowUp,
|
|
@@ -4448,22 +4469,22 @@
|
|
|
4448
4469
|
InputKeyDownEnter: InputKeyDownEnter,
|
|
4449
4470
|
InputChange: InputChange,
|
|
4450
4471
|
InputBlur: InputBlur,
|
|
4451
|
-
MenuMouseLeave: MenuMouseLeave
|
|
4452
|
-
ItemMouseMove: ItemMouseMove
|
|
4453
|
-
ItemClick: ItemClick
|
|
4454
|
-
ToggleButtonClick: ToggleButtonClick
|
|
4455
|
-
FunctionToggleMenu: FunctionToggleMenu
|
|
4456
|
-
FunctionOpenMenu: FunctionOpenMenu
|
|
4457
|
-
FunctionCloseMenu: FunctionCloseMenu
|
|
4458
|
-
FunctionSetHighlightedIndex: FunctionSetHighlightedIndex
|
|
4459
|
-
FunctionSelectItem: FunctionSelectItem
|
|
4460
|
-
FunctionSetInputValue: FunctionSetInputValue
|
|
4472
|
+
MenuMouseLeave: MenuMouseLeave,
|
|
4473
|
+
ItemMouseMove: ItemMouseMove,
|
|
4474
|
+
ItemClick: ItemClick,
|
|
4475
|
+
ToggleButtonClick: ToggleButtonClick,
|
|
4476
|
+
FunctionToggleMenu: FunctionToggleMenu,
|
|
4477
|
+
FunctionOpenMenu: FunctionOpenMenu,
|
|
4478
|
+
FunctionCloseMenu: FunctionCloseMenu,
|
|
4479
|
+
FunctionSetHighlightedIndex: FunctionSetHighlightedIndex,
|
|
4480
|
+
FunctionSelectItem: FunctionSelectItem,
|
|
4481
|
+
FunctionSetInputValue: FunctionSetInputValue,
|
|
4461
4482
|
FunctionReset: FunctionReset$1,
|
|
4462
4483
|
ControlledPropUpdatedSelectedItem: ControlledPropUpdatedSelectedItem
|
|
4463
4484
|
});
|
|
4464
4485
|
|
|
4465
4486
|
function getInitialState$1(props) {
|
|
4466
|
-
var initialState = getInitialState(props);
|
|
4487
|
+
var initialState = getInitialState$2(props);
|
|
4467
4488
|
var selectedItem = initialState.selectedItem;
|
|
4468
4489
|
var inputValue = initialState.inputValue;
|
|
4469
4490
|
|
|
@@ -4476,43 +4497,43 @@
|
|
|
4476
4497
|
});
|
|
4477
4498
|
}
|
|
4478
4499
|
|
|
4479
|
-
var propTypes$
|
|
4480
|
-
items: propTypes.array.isRequired,
|
|
4481
|
-
itemToString: propTypes.func,
|
|
4482
|
-
getA11yStatusMessage: propTypes.func,
|
|
4483
|
-
getA11ySelectionMessage: propTypes.func,
|
|
4484
|
-
circularNavigation: propTypes.bool,
|
|
4485
|
-
highlightedIndex: propTypes.number,
|
|
4486
|
-
defaultHighlightedIndex: propTypes.number,
|
|
4487
|
-
initialHighlightedIndex: propTypes.number,
|
|
4488
|
-
isOpen: propTypes.bool,
|
|
4489
|
-
defaultIsOpen: propTypes.bool,
|
|
4490
|
-
initialIsOpen: propTypes.bool,
|
|
4491
|
-
selectedItem: propTypes.any,
|
|
4492
|
-
initialSelectedItem: propTypes.any,
|
|
4493
|
-
defaultSelectedItem: propTypes.any,
|
|
4494
|
-
inputValue: propTypes.string,
|
|
4495
|
-
defaultInputValue: propTypes.string,
|
|
4496
|
-
initialInputValue: propTypes.string,
|
|
4497
|
-
id: propTypes.string,
|
|
4498
|
-
labelId: propTypes.string,
|
|
4499
|
-
menuId: propTypes.string,
|
|
4500
|
-
getItemId: propTypes.func,
|
|
4501
|
-
inputId: propTypes.string,
|
|
4502
|
-
toggleButtonId: propTypes.string,
|
|
4503
|
-
stateReducer: propTypes.func,
|
|
4504
|
-
onSelectedItemChange: propTypes.func,
|
|
4505
|
-
onHighlightedIndexChange: propTypes.func,
|
|
4506
|
-
onStateChange: propTypes.func,
|
|
4507
|
-
onIsOpenChange: propTypes.func,
|
|
4508
|
-
onInputValueChange: propTypes.func,
|
|
4509
|
-
environment: propTypes.shape({
|
|
4510
|
-
addEventListener: propTypes.func,
|
|
4511
|
-
removeEventListener: propTypes.func,
|
|
4512
|
-
document: propTypes.shape({
|
|
4513
|
-
getElementById: propTypes.func,
|
|
4514
|
-
activeElement: propTypes.any,
|
|
4515
|
-
body: propTypes.any
|
|
4500
|
+
var propTypes$1 = {
|
|
4501
|
+
items: propTypes$3.array.isRequired,
|
|
4502
|
+
itemToString: propTypes$3.func,
|
|
4503
|
+
getA11yStatusMessage: propTypes$3.func,
|
|
4504
|
+
getA11ySelectionMessage: propTypes$3.func,
|
|
4505
|
+
circularNavigation: propTypes$3.bool,
|
|
4506
|
+
highlightedIndex: propTypes$3.number,
|
|
4507
|
+
defaultHighlightedIndex: propTypes$3.number,
|
|
4508
|
+
initialHighlightedIndex: propTypes$3.number,
|
|
4509
|
+
isOpen: propTypes$3.bool,
|
|
4510
|
+
defaultIsOpen: propTypes$3.bool,
|
|
4511
|
+
initialIsOpen: propTypes$3.bool,
|
|
4512
|
+
selectedItem: propTypes$3.any,
|
|
4513
|
+
initialSelectedItem: propTypes$3.any,
|
|
4514
|
+
defaultSelectedItem: propTypes$3.any,
|
|
4515
|
+
inputValue: propTypes$3.string,
|
|
4516
|
+
defaultInputValue: propTypes$3.string,
|
|
4517
|
+
initialInputValue: propTypes$3.string,
|
|
4518
|
+
id: propTypes$3.string,
|
|
4519
|
+
labelId: propTypes$3.string,
|
|
4520
|
+
menuId: propTypes$3.string,
|
|
4521
|
+
getItemId: propTypes$3.func,
|
|
4522
|
+
inputId: propTypes$3.string,
|
|
4523
|
+
toggleButtonId: propTypes$3.string,
|
|
4524
|
+
stateReducer: propTypes$3.func,
|
|
4525
|
+
onSelectedItemChange: propTypes$3.func,
|
|
4526
|
+
onHighlightedIndexChange: propTypes$3.func,
|
|
4527
|
+
onStateChange: propTypes$3.func,
|
|
4528
|
+
onIsOpenChange: propTypes$3.func,
|
|
4529
|
+
onInputValueChange: propTypes$3.func,
|
|
4530
|
+
environment: propTypes$3.shape({
|
|
4531
|
+
addEventListener: propTypes$3.func,
|
|
4532
|
+
removeEventListener: propTypes$3.func,
|
|
4533
|
+
document: propTypes$3.shape({
|
|
4534
|
+
getElementById: propTypes$3.func,
|
|
4535
|
+
activeElement: propTypes$3.any,
|
|
4536
|
+
body: propTypes$3.any
|
|
4516
4537
|
})
|
|
4517
4538
|
})
|
|
4518
4539
|
};
|
|
@@ -4529,7 +4550,7 @@
|
|
|
4529
4550
|
* @returns {Array} An array with the state and an action dispatcher.
|
|
4530
4551
|
*/
|
|
4531
4552
|
|
|
4532
|
-
function useControlledReducer
|
|
4553
|
+
function useControlledReducer(reducer, initialState, props) {
|
|
4533
4554
|
var previousSelectedItemRef = react.useRef();
|
|
4534
4555
|
|
|
4535
4556
|
var _useEnhancedReducer = useEnhancedReducer(reducer, initialState, props),
|
|
@@ -4558,12 +4579,12 @@
|
|
|
4558
4579
|
|
|
4559
4580
|
{
|
|
4560
4581
|
validatePropTypes$1 = function validatePropTypes(options, caller) {
|
|
4561
|
-
propTypes.checkPropTypes(propTypes$
|
|
4582
|
+
propTypes$3.checkPropTypes(propTypes$1, options, 'prop', caller.name);
|
|
4562
4583
|
};
|
|
4563
4584
|
}
|
|
4564
4585
|
|
|
4565
|
-
var defaultProps$
|
|
4566
|
-
getA11yStatusMessage: getA11yStatusMessage,
|
|
4586
|
+
var defaultProps$1 = _extends({}, defaultProps$3, {
|
|
4587
|
+
getA11yStatusMessage: getA11yStatusMessage$1,
|
|
4567
4588
|
circularNavigation: true
|
|
4568
4589
|
});
|
|
4569
4590
|
|
|
@@ -4576,10 +4597,10 @@
|
|
|
4576
4597
|
var changes;
|
|
4577
4598
|
|
|
4578
4599
|
switch (type) {
|
|
4579
|
-
case ItemClick
|
|
4600
|
+
case ItemClick:
|
|
4580
4601
|
changes = {
|
|
4581
|
-
isOpen: getDefaultValue(props, 'isOpen'),
|
|
4582
|
-
highlightedIndex: getDefaultValue(props, 'highlightedIndex'),
|
|
4602
|
+
isOpen: getDefaultValue$1(props, 'isOpen'),
|
|
4603
|
+
highlightedIndex: getDefaultValue$1(props, 'highlightedIndex'),
|
|
4583
4604
|
selectedItem: props.items[action.index],
|
|
4584
4605
|
inputValue: props.itemToString(props.items[action.index])
|
|
4585
4606
|
};
|
|
@@ -4593,7 +4614,7 @@
|
|
|
4593
4614
|
} else {
|
|
4594
4615
|
changes = {
|
|
4595
4616
|
highlightedIndex: getHighlightedIndexOnOpen(props, state, 1, action.getItemNodeFromIndex),
|
|
4596
|
-
isOpen:
|
|
4617
|
+
isOpen: props.items.length >= 0
|
|
4597
4618
|
};
|
|
4598
4619
|
}
|
|
4599
4620
|
|
|
@@ -4607,7 +4628,7 @@
|
|
|
4607
4628
|
} else {
|
|
4608
4629
|
changes = {
|
|
4609
4630
|
highlightedIndex: getHighlightedIndexOnOpen(props, state, -1, action.getItemNodeFromIndex),
|
|
4610
|
-
isOpen:
|
|
4631
|
+
isOpen: props.items.length >= 0
|
|
4611
4632
|
};
|
|
4612
4633
|
}
|
|
4613
4634
|
|
|
@@ -4616,8 +4637,8 @@
|
|
|
4616
4637
|
case InputKeyDownEnter:
|
|
4617
4638
|
changes = _extends({}, state.isOpen && state.highlightedIndex >= 0 && {
|
|
4618
4639
|
selectedItem: props.items[state.highlightedIndex],
|
|
4619
|
-
isOpen: getDefaultValue(props, 'isOpen'),
|
|
4620
|
-
highlightedIndex: getDefaultValue(props, 'highlightedIndex'),
|
|
4640
|
+
isOpen: getDefaultValue$1(props, 'isOpen'),
|
|
4641
|
+
highlightedIndex: getDefaultValue$1(props, 'highlightedIndex'),
|
|
4621
4642
|
inputValue: props.itemToString(props.items[state.highlightedIndex])
|
|
4622
4643
|
});
|
|
4623
4644
|
break;
|
|
@@ -4633,39 +4654,36 @@
|
|
|
4633
4654
|
break;
|
|
4634
4655
|
|
|
4635
4656
|
case InputKeyDownHome:
|
|
4636
|
-
changes =
|
|
4657
|
+
changes = {
|
|
4637
4658
|
highlightedIndex: getNextNonDisabledIndex(1, 0, props.items.length, action.getItemNodeFromIndex, false)
|
|
4638
|
-
}
|
|
4659
|
+
};
|
|
4639
4660
|
break;
|
|
4640
4661
|
|
|
4641
4662
|
case InputKeyDownEnd:
|
|
4642
|
-
changes =
|
|
4663
|
+
changes = {
|
|
4643
4664
|
highlightedIndex: getNextNonDisabledIndex(-1, props.items.length - 1, props.items.length, action.getItemNodeFromIndex, false)
|
|
4644
|
-
}
|
|
4665
|
+
};
|
|
4645
4666
|
break;
|
|
4646
4667
|
|
|
4647
4668
|
case InputBlur:
|
|
4648
|
-
|
|
4649
|
-
|
|
4650
|
-
|
|
4651
|
-
|
|
4652
|
-
|
|
4653
|
-
|
|
4654
|
-
|
|
4655
|
-
});
|
|
4656
|
-
}
|
|
4657
|
-
|
|
4669
|
+
changes = _extends({
|
|
4670
|
+
isOpen: false,
|
|
4671
|
+
highlightedIndex: -1
|
|
4672
|
+
}, state.highlightedIndex >= 0 && action.selectItem && {
|
|
4673
|
+
selectedItem: props.items[state.highlightedIndex],
|
|
4674
|
+
inputValue: props.itemToString(props.items[state.highlightedIndex])
|
|
4675
|
+
});
|
|
4658
4676
|
break;
|
|
4659
4677
|
|
|
4660
4678
|
case InputChange:
|
|
4661
4679
|
changes = {
|
|
4662
4680
|
isOpen: true,
|
|
4663
|
-
highlightedIndex: getDefaultValue(props, 'highlightedIndex'),
|
|
4681
|
+
highlightedIndex: getDefaultValue$1(props, 'highlightedIndex'),
|
|
4664
4682
|
inputValue: action.inputValue
|
|
4665
4683
|
};
|
|
4666
4684
|
break;
|
|
4667
4685
|
|
|
4668
|
-
case FunctionSelectItem
|
|
4686
|
+
case FunctionSelectItem:
|
|
4669
4687
|
changes = {
|
|
4670
4688
|
selectedItem: action.selectedItem,
|
|
4671
4689
|
inputValue: props.itemToString(action.selectedItem)
|
|
@@ -4679,14 +4697,14 @@
|
|
|
4679
4697
|
break;
|
|
4680
4698
|
|
|
4681
4699
|
default:
|
|
4682
|
-
return downshiftCommonReducer(state, action, stateChangeTypes$
|
|
4700
|
+
return downshiftCommonReducer(state, action, stateChangeTypes$1);
|
|
4683
4701
|
}
|
|
4684
4702
|
|
|
4685
4703
|
return _extends({}, state, changes);
|
|
4686
4704
|
}
|
|
4687
4705
|
/* eslint-enable complexity */
|
|
4688
4706
|
|
|
4689
|
-
useCombobox.stateChangeTypes = stateChangeTypes$
|
|
4707
|
+
useCombobox.stateChangeTypes = stateChangeTypes$1;
|
|
4690
4708
|
|
|
4691
4709
|
function useCombobox(userProps) {
|
|
4692
4710
|
if (userProps === void 0) {
|
|
@@ -4695,7 +4713,7 @@
|
|
|
4695
4713
|
|
|
4696
4714
|
validatePropTypes$1(userProps, useCombobox); // Props defaults and destructuring.
|
|
4697
4715
|
|
|
4698
|
-
var props = _extends({}, defaultProps$
|
|
4716
|
+
var props = _extends({}, defaultProps$1, userProps);
|
|
4699
4717
|
|
|
4700
4718
|
var initialIsOpen = props.initialIsOpen,
|
|
4701
4719
|
defaultIsOpen = props.defaultIsOpen,
|
|
@@ -4708,7 +4726,7 @@
|
|
|
4708
4726
|
|
|
4709
4727
|
var initialState = getInitialState$1(props);
|
|
4710
4728
|
|
|
4711
|
-
var _useControlledReducer = useControlledReducer
|
|
4729
|
+
var _useControlledReducer = useControlledReducer(downshiftUseComboboxReducer, initialState, props),
|
|
4712
4730
|
state = _useControlledReducer[0],
|
|
4713
4731
|
dispatch = _useControlledReducer[1];
|
|
4714
4732
|
|
|
@@ -4821,6 +4839,10 @@
|
|
|
4821
4839
|
});
|
|
4822
4840
|
},
|
|
4823
4841
|
Home: function Home(event) {
|
|
4842
|
+
if (!latest.current.state.isOpen) {
|
|
4843
|
+
return;
|
|
4844
|
+
}
|
|
4845
|
+
|
|
4824
4846
|
event.preventDefault();
|
|
4825
4847
|
dispatch({
|
|
4826
4848
|
type: InputKeyDownHome,
|
|
@@ -4828,6 +4850,10 @@
|
|
|
4828
4850
|
});
|
|
4829
4851
|
},
|
|
4830
4852
|
End: function End(event) {
|
|
4853
|
+
if (!latest.current.state.isOpen) {
|
|
4854
|
+
return;
|
|
4855
|
+
}
|
|
4856
|
+
|
|
4831
4857
|
event.preventDefault();
|
|
4832
4858
|
dispatch({
|
|
4833
4859
|
type: InputKeyDownEnd,
|
|
@@ -4835,22 +4861,23 @@
|
|
|
4835
4861
|
});
|
|
4836
4862
|
},
|
|
4837
4863
|
Escape: function Escape() {
|
|
4838
|
-
dispatch({
|
|
4839
|
-
type: InputKeyDownEscape
|
|
4840
|
-
});
|
|
4841
|
-
},
|
|
4842
|
-
Enter: function Enter(event) {
|
|
4843
|
-
// if IME composing, wait for next Enter keydown event.
|
|
4844
|
-
if (event.which === 229) {
|
|
4845
|
-
return;
|
|
4846
|
-
}
|
|
4847
|
-
|
|
4848
4864
|
var latestState = latest.current.state;
|
|
4849
4865
|
|
|
4850
|
-
if (latestState.isOpen) {
|
|
4851
|
-
|
|
4866
|
+
if (latestState.isOpen || latestState.inputValue || latestState.selectedItem || latestState.highlightedIndex > -1) {
|
|
4867
|
+
dispatch({
|
|
4868
|
+
type: InputKeyDownEscape
|
|
4869
|
+
});
|
|
4852
4870
|
}
|
|
4871
|
+
},
|
|
4872
|
+
Enter: function Enter(event) {
|
|
4873
|
+
var latestState = latest.current.state; // if closed or no highlighted index, do nothing.
|
|
4874
|
+
|
|
4875
|
+
if (!latestState.isOpen || latestState.highlightedIndex < 0 || event.which === 229 // if IME composing, wait for next Enter keydown event.
|
|
4876
|
+
) {
|
|
4877
|
+
return;
|
|
4878
|
+
}
|
|
4853
4879
|
|
|
4880
|
+
event.preventDefault();
|
|
4854
4881
|
dispatch({
|
|
4855
4882
|
type: InputKeyDownEnter,
|
|
4856
4883
|
getItemNodeFromIndex: getItemNodeFromIndex
|
|
@@ -4884,7 +4911,7 @@
|
|
|
4884
4911
|
menuRef.current = menuNode;
|
|
4885
4912
|
}), _extends2.id = elementIds.menuId, _extends2.role = 'listbox', _extends2['aria-labelledby'] = elementIds.labelId, _extends2.onMouseLeave = callAllEventHandlers(onMouseLeave, function () {
|
|
4886
4913
|
dispatch({
|
|
4887
|
-
type: MenuMouseLeave
|
|
4914
|
+
type: MenuMouseLeave
|
|
4888
4915
|
});
|
|
4889
4916
|
}), _extends2), rest);
|
|
4890
4917
|
}, [dispatch, setGetterPropCallInfo, elementIds]);
|
|
@@ -4898,9 +4925,9 @@
|
|
|
4898
4925
|
refKey = _ref3$refKey === void 0 ? 'ref' : _ref3$refKey,
|
|
4899
4926
|
ref = _ref3.ref,
|
|
4900
4927
|
onMouseMove = _ref3.onMouseMove,
|
|
4901
|
-
onClick = _ref3.onClick
|
|
4902
|
-
|
|
4903
|
-
rest = _objectWithoutPropertiesLoose(_ref3, ["item", "index", "refKey", "ref", "onMouseMove", "onClick", "onPress"]);
|
|
4928
|
+
onClick = _ref3.onClick;
|
|
4929
|
+
_ref3.onPress;
|
|
4930
|
+
var rest = _objectWithoutPropertiesLoose(_ref3, ["item", "index", "refKey", "ref", "onMouseMove", "onClick", "onPress"]);
|
|
4904
4931
|
|
|
4905
4932
|
var _latest$current = latest.current,
|
|
4906
4933
|
latestProps = _latest$current.props,
|
|
@@ -4911,8 +4938,8 @@
|
|
|
4911
4938
|
throw new Error('Pass either item or item index in getItemProps!');
|
|
4912
4939
|
}
|
|
4913
4940
|
|
|
4914
|
-
var onSelectKey =
|
|
4915
|
-
var customClickHandler =
|
|
4941
|
+
var onSelectKey = 'onClick';
|
|
4942
|
+
var customClickHandler = onClick;
|
|
4916
4943
|
|
|
4917
4944
|
var itemHandleMouseMove = function itemHandleMouseMove() {
|
|
4918
4945
|
if (index === latestState.highlightedIndex) {
|
|
@@ -4921,14 +4948,14 @@
|
|
|
4921
4948
|
|
|
4922
4949
|
shouldScrollRef.current = false;
|
|
4923
4950
|
dispatch({
|
|
4924
|
-
type: ItemMouseMove
|
|
4951
|
+
type: ItemMouseMove,
|
|
4925
4952
|
index: index
|
|
4926
4953
|
});
|
|
4927
4954
|
};
|
|
4928
4955
|
|
|
4929
4956
|
var itemHandleClick = function itemHandleClick() {
|
|
4930
4957
|
dispatch({
|
|
4931
|
-
type: ItemClick
|
|
4958
|
+
type: ItemClick,
|
|
4932
4959
|
index: index
|
|
4933
4960
|
});
|
|
4934
4961
|
|
|
@@ -4949,16 +4976,16 @@
|
|
|
4949
4976
|
var _extends4;
|
|
4950
4977
|
|
|
4951
4978
|
var _ref5 = _temp4 === void 0 ? {} : _temp4,
|
|
4952
|
-
onClick = _ref5.onClick
|
|
4953
|
-
|
|
4954
|
-
_ref5$refKey = _ref5.refKey,
|
|
4979
|
+
onClick = _ref5.onClick;
|
|
4980
|
+
_ref5.onPress;
|
|
4981
|
+
var _ref5$refKey = _ref5.refKey,
|
|
4955
4982
|
refKey = _ref5$refKey === void 0 ? 'ref' : _ref5$refKey,
|
|
4956
4983
|
ref = _ref5.ref,
|
|
4957
4984
|
rest = _objectWithoutPropertiesLoose(_ref5, ["onClick", "onPress", "refKey", "ref"]);
|
|
4958
4985
|
|
|
4959
4986
|
var toggleButtonHandleClick = function toggleButtonHandleClick() {
|
|
4960
4987
|
dispatch({
|
|
4961
|
-
type: ToggleButtonClick
|
|
4988
|
+
type: ToggleButtonClick
|
|
4962
4989
|
});
|
|
4963
4990
|
|
|
4964
4991
|
if (!latest.current.state.isOpen && inputRef.current) {
|
|
@@ -4968,7 +4995,7 @@
|
|
|
4968
4995
|
|
|
4969
4996
|
return _extends((_extends4 = {}, _extends4[refKey] = handleRefs(ref, function (toggleButtonNode) {
|
|
4970
4997
|
toggleButtonRef.current = toggleButtonNode;
|
|
4971
|
-
}), _extends4.id = elementIds.toggleButtonId, _extends4.tabIndex = -1, _extends4), !rest.disabled && _extends({},
|
|
4998
|
+
}), _extends4.id = elementIds.toggleButtonId, _extends4.tabIndex = -1, _extends4), !rest.disabled && _extends({}, {
|
|
4972
4999
|
onClick: callAllEventHandlers(onClick, toggleButtonHandleClick)
|
|
4973
5000
|
}), rest);
|
|
4974
5001
|
}, [dispatch, latest, elementIds]);
|
|
@@ -4979,9 +5006,9 @@
|
|
|
4979
5006
|
onKeyDown = _ref6.onKeyDown,
|
|
4980
5007
|
onChange = _ref6.onChange,
|
|
4981
5008
|
onInput = _ref6.onInput,
|
|
4982
|
-
onBlur = _ref6.onBlur
|
|
4983
|
-
|
|
4984
|
-
_ref6$refKey = _ref6.refKey,
|
|
5009
|
+
onBlur = _ref6.onBlur;
|
|
5010
|
+
_ref6.onChangeText;
|
|
5011
|
+
var _ref6$refKey = _ref6.refKey,
|
|
4985
5012
|
refKey = _ref6$refKey === void 0 ? 'ref' : _ref6$refKey,
|
|
4986
5013
|
ref = _ref6.ref,
|
|
4987
5014
|
rest = _objectWithoutPropertiesLoose(_ref6, ["onKeyDown", "onChange", "onInput", "onBlur", "onChangeText", "refKey", "ref"]);
|
|
@@ -5004,13 +5031,13 @@
|
|
|
5004
5031
|
var inputHandleChange = function inputHandleChange(event) {
|
|
5005
5032
|
dispatch({
|
|
5006
5033
|
type: InputChange,
|
|
5007
|
-
inputValue:
|
|
5034
|
+
inputValue: event.target.value
|
|
5008
5035
|
});
|
|
5009
5036
|
};
|
|
5010
5037
|
|
|
5011
5038
|
var inputHandleBlur = function inputHandleBlur() {
|
|
5012
5039
|
/* istanbul ignore else */
|
|
5013
|
-
if (!mouseAndTouchTrackersRef.current.isMouseDown) {
|
|
5040
|
+
if (latestState.isOpen && !mouseAndTouchTrackersRef.current.isMouseDown) {
|
|
5014
5041
|
dispatch({
|
|
5015
5042
|
type: InputBlur,
|
|
5016
5043
|
selectItem: true
|
|
@@ -5020,7 +5047,7 @@
|
|
|
5020
5047
|
/* istanbul ignore next (preact) */
|
|
5021
5048
|
|
|
5022
5049
|
|
|
5023
|
-
var onChangeKey =
|
|
5050
|
+
var onChangeKey = 'onChange';
|
|
5024
5051
|
var eventHandlers = {};
|
|
5025
5052
|
|
|
5026
5053
|
if (!rest.disabled) {
|
|
@@ -5062,34 +5089,34 @@
|
|
|
5062
5089
|
|
|
5063
5090
|
var toggleMenu = react.useCallback(function () {
|
|
5064
5091
|
dispatch({
|
|
5065
|
-
type: FunctionToggleMenu
|
|
5092
|
+
type: FunctionToggleMenu
|
|
5066
5093
|
});
|
|
5067
5094
|
}, [dispatch]);
|
|
5068
5095
|
var closeMenu = react.useCallback(function () {
|
|
5069
5096
|
dispatch({
|
|
5070
|
-
type: FunctionCloseMenu
|
|
5097
|
+
type: FunctionCloseMenu
|
|
5071
5098
|
});
|
|
5072
5099
|
}, [dispatch]);
|
|
5073
5100
|
var openMenu = react.useCallback(function () {
|
|
5074
5101
|
dispatch({
|
|
5075
|
-
type: FunctionOpenMenu
|
|
5102
|
+
type: FunctionOpenMenu
|
|
5076
5103
|
});
|
|
5077
5104
|
}, [dispatch]);
|
|
5078
5105
|
var setHighlightedIndex = react.useCallback(function (newHighlightedIndex) {
|
|
5079
5106
|
dispatch({
|
|
5080
|
-
type: FunctionSetHighlightedIndex
|
|
5107
|
+
type: FunctionSetHighlightedIndex,
|
|
5081
5108
|
highlightedIndex: newHighlightedIndex
|
|
5082
5109
|
});
|
|
5083
5110
|
}, [dispatch]);
|
|
5084
5111
|
var selectItem = react.useCallback(function (newSelectedItem) {
|
|
5085
5112
|
dispatch({
|
|
5086
|
-
type: FunctionSelectItem
|
|
5113
|
+
type: FunctionSelectItem,
|
|
5087
5114
|
selectedItem: newSelectedItem
|
|
5088
5115
|
});
|
|
5089
5116
|
}, [dispatch]);
|
|
5090
5117
|
var setInputValue = react.useCallback(function (newInputValue) {
|
|
5091
5118
|
dispatch({
|
|
5092
|
-
type: FunctionSetInputValue
|
|
5119
|
+
type: FunctionSetInputValue,
|
|
5093
5120
|
inputValue: newInputValue
|
|
5094
5121
|
});
|
|
5095
5122
|
}, [dispatch]);
|
|
@@ -5136,8 +5163,8 @@
|
|
|
5136
5163
|
* @returns {any} The initial value for that prop.
|
|
5137
5164
|
*/
|
|
5138
5165
|
|
|
5139
|
-
function getInitialValue
|
|
5140
|
-
return getInitialValue(props, propKey, defaultStateValues);
|
|
5166
|
+
function getInitialValue(props, propKey) {
|
|
5167
|
+
return getInitialValue$1(props, propKey, defaultStateValues);
|
|
5141
5168
|
}
|
|
5142
5169
|
/**
|
|
5143
5170
|
* Returns the default value for a state key in the following order:
|
|
@@ -5149,8 +5176,8 @@
|
|
|
5149
5176
|
*/
|
|
5150
5177
|
|
|
5151
5178
|
|
|
5152
|
-
function getDefaultValue
|
|
5153
|
-
return getDefaultValue(props, propKey, defaultStateValues);
|
|
5179
|
+
function getDefaultValue(props, propKey) {
|
|
5180
|
+
return getDefaultValue$1(props, propKey, defaultStateValues);
|
|
5154
5181
|
}
|
|
5155
5182
|
/**
|
|
5156
5183
|
* Gets the initial state based on the provided props. It uses initial, default
|
|
@@ -5161,9 +5188,9 @@
|
|
|
5161
5188
|
*/
|
|
5162
5189
|
|
|
5163
5190
|
|
|
5164
|
-
function getInitialState
|
|
5165
|
-
var activeIndex = getInitialValue
|
|
5166
|
-
var selectedItems = getInitialValue
|
|
5191
|
+
function getInitialState(props) {
|
|
5192
|
+
var activeIndex = getInitialValue(props, 'activeIndex');
|
|
5193
|
+
var selectedItems = getInitialValue(props, 'selectedItems');
|
|
5167
5194
|
return {
|
|
5168
5195
|
activeIndex: activeIndex,
|
|
5169
5196
|
selectedItems: selectedItems
|
|
@@ -5210,63 +5237,63 @@
|
|
|
5210
5237
|
return itemToStringLocal(removedSelectedItem) + " has been removed.";
|
|
5211
5238
|
}
|
|
5212
5239
|
|
|
5213
|
-
var propTypes
|
|
5214
|
-
selectedItems: propTypes.array,
|
|
5215
|
-
initialSelectedItems: propTypes.array,
|
|
5216
|
-
defaultSelectedItems: propTypes.array,
|
|
5217
|
-
itemToString: propTypes.func,
|
|
5218
|
-
getA11yRemovalMessage: propTypes.func,
|
|
5219
|
-
stateReducer: propTypes.func,
|
|
5220
|
-
activeIndex: propTypes.number,
|
|
5221
|
-
initialActiveIndex: propTypes.number,
|
|
5222
|
-
defaultActiveIndex: propTypes.number,
|
|
5223
|
-
onActiveIndexChange: propTypes.func,
|
|
5224
|
-
onSelectedItemsChange: propTypes.func,
|
|
5225
|
-
keyNavigationNext: propTypes.string,
|
|
5226
|
-
keyNavigationPrevious: propTypes.string,
|
|
5227
|
-
environment: propTypes.shape({
|
|
5228
|
-
addEventListener: propTypes.func,
|
|
5229
|
-
removeEventListener: propTypes.func,
|
|
5230
|
-
document: propTypes.shape({
|
|
5231
|
-
getElementById: propTypes.func,
|
|
5232
|
-
activeElement: propTypes.any,
|
|
5233
|
-
body: propTypes.any
|
|
5240
|
+
var propTypes = {
|
|
5241
|
+
selectedItems: propTypes$3.array,
|
|
5242
|
+
initialSelectedItems: propTypes$3.array,
|
|
5243
|
+
defaultSelectedItems: propTypes$3.array,
|
|
5244
|
+
itemToString: propTypes$3.func,
|
|
5245
|
+
getA11yRemovalMessage: propTypes$3.func,
|
|
5246
|
+
stateReducer: propTypes$3.func,
|
|
5247
|
+
activeIndex: propTypes$3.number,
|
|
5248
|
+
initialActiveIndex: propTypes$3.number,
|
|
5249
|
+
defaultActiveIndex: propTypes$3.number,
|
|
5250
|
+
onActiveIndexChange: propTypes$3.func,
|
|
5251
|
+
onSelectedItemsChange: propTypes$3.func,
|
|
5252
|
+
keyNavigationNext: propTypes$3.string,
|
|
5253
|
+
keyNavigationPrevious: propTypes$3.string,
|
|
5254
|
+
environment: propTypes$3.shape({
|
|
5255
|
+
addEventListener: propTypes$3.func,
|
|
5256
|
+
removeEventListener: propTypes$3.func,
|
|
5257
|
+
document: propTypes$3.shape({
|
|
5258
|
+
getElementById: propTypes$3.func,
|
|
5259
|
+
activeElement: propTypes$3.any,
|
|
5260
|
+
body: propTypes$3.any
|
|
5234
5261
|
})
|
|
5235
5262
|
})
|
|
5236
5263
|
};
|
|
5237
|
-
var defaultProps
|
|
5238
|
-
itemToString: defaultProps.itemToString,
|
|
5239
|
-
stateReducer: defaultProps.stateReducer,
|
|
5240
|
-
environment: defaultProps.environment,
|
|
5264
|
+
var defaultProps = {
|
|
5265
|
+
itemToString: defaultProps$3.itemToString,
|
|
5266
|
+
stateReducer: defaultProps$3.stateReducer,
|
|
5267
|
+
environment: defaultProps$3.environment,
|
|
5241
5268
|
getA11yRemovalMessage: getA11yRemovalMessage,
|
|
5242
5269
|
keyNavigationNext: 'ArrowRight',
|
|
5243
5270
|
keyNavigationPrevious: 'ArrowLeft'
|
|
5244
5271
|
}; // eslint-disable-next-line import/no-mutable-exports
|
|
5245
5272
|
|
|
5246
|
-
var validatePropTypes
|
|
5273
|
+
var validatePropTypes = noop;
|
|
5247
5274
|
/* istanbul ignore next */
|
|
5248
5275
|
|
|
5249
5276
|
{
|
|
5250
|
-
validatePropTypes
|
|
5251
|
-
propTypes.checkPropTypes(propTypes
|
|
5277
|
+
validatePropTypes = function validatePropTypes(options, caller) {
|
|
5278
|
+
propTypes$3.checkPropTypes(propTypes, options, 'prop', caller.name);
|
|
5252
5279
|
};
|
|
5253
5280
|
}
|
|
5254
5281
|
|
|
5255
|
-
var SelectedItemClick =
|
|
5256
|
-
var SelectedItemKeyDownDelete =
|
|
5257
|
-
var SelectedItemKeyDownBackspace =
|
|
5258
|
-
var SelectedItemKeyDownNavigationNext =
|
|
5259
|
-
var SelectedItemKeyDownNavigationPrevious =
|
|
5260
|
-
var DropdownKeyDownNavigationPrevious =
|
|
5261
|
-
var DropdownKeyDownBackspace =
|
|
5262
|
-
var DropdownClick =
|
|
5263
|
-
var FunctionAddSelectedItem =
|
|
5264
|
-
var FunctionRemoveSelectedItem =
|
|
5265
|
-
var FunctionSetSelectedItems =
|
|
5266
|
-
var FunctionSetActiveIndex =
|
|
5267
|
-
var FunctionReset
|
|
5282
|
+
var SelectedItemClick = '__selected_item_click__' ;
|
|
5283
|
+
var SelectedItemKeyDownDelete = '__selected_item_keydown_delete__' ;
|
|
5284
|
+
var SelectedItemKeyDownBackspace = '__selected_item_keydown_backspace__' ;
|
|
5285
|
+
var SelectedItemKeyDownNavigationNext = '__selected_item_keydown_navigation_next__' ;
|
|
5286
|
+
var SelectedItemKeyDownNavigationPrevious = '__selected_item_keydown_navigation_previous__' ;
|
|
5287
|
+
var DropdownKeyDownNavigationPrevious = '__dropdown_keydown_navigation_previous__' ;
|
|
5288
|
+
var DropdownKeyDownBackspace = '__dropdown_keydown_backspace__' ;
|
|
5289
|
+
var DropdownClick = '__dropdown_click__' ;
|
|
5290
|
+
var FunctionAddSelectedItem = '__function_add_selected_item__' ;
|
|
5291
|
+
var FunctionRemoveSelectedItem = '__function_remove_selected_item__' ;
|
|
5292
|
+
var FunctionSetSelectedItems = '__function_set_selected_items__' ;
|
|
5293
|
+
var FunctionSetActiveIndex = '__function_set_active_index__' ;
|
|
5294
|
+
var FunctionReset = '__function_reset__' ;
|
|
5268
5295
|
|
|
5269
|
-
var stateChangeTypes
|
|
5296
|
+
var stateChangeTypes = /*#__PURE__*/Object.freeze({
|
|
5270
5297
|
__proto__: null,
|
|
5271
5298
|
SelectedItemClick: SelectedItemClick,
|
|
5272
5299
|
SelectedItemKeyDownDelete: SelectedItemKeyDownDelete,
|
|
@@ -5280,7 +5307,7 @@
|
|
|
5280
5307
|
FunctionRemoveSelectedItem: FunctionRemoveSelectedItem,
|
|
5281
5308
|
FunctionSetSelectedItems: FunctionSetSelectedItems,
|
|
5282
5309
|
FunctionSetActiveIndex: FunctionSetActiveIndex,
|
|
5283
|
-
FunctionReset: FunctionReset
|
|
5310
|
+
FunctionReset: FunctionReset
|
|
5284
5311
|
});
|
|
5285
5312
|
|
|
5286
5313
|
/* eslint-disable complexity */
|
|
@@ -5393,10 +5420,10 @@
|
|
|
5393
5420
|
break;
|
|
5394
5421
|
}
|
|
5395
5422
|
|
|
5396
|
-
case FunctionReset
|
|
5423
|
+
case FunctionReset:
|
|
5397
5424
|
changes = {
|
|
5398
|
-
activeIndex: getDefaultValue
|
|
5399
|
-
selectedItems: getDefaultValue
|
|
5425
|
+
activeIndex: getDefaultValue(props, 'activeIndex'),
|
|
5426
|
+
selectedItems: getDefaultValue(props, 'selectedItems')
|
|
5400
5427
|
};
|
|
5401
5428
|
break;
|
|
5402
5429
|
|
|
@@ -5407,16 +5434,16 @@
|
|
|
5407
5434
|
return _extends({}, state, changes);
|
|
5408
5435
|
}
|
|
5409
5436
|
|
|
5410
|
-
useMultipleSelection.stateChangeTypes = stateChangeTypes
|
|
5437
|
+
useMultipleSelection.stateChangeTypes = stateChangeTypes;
|
|
5411
5438
|
|
|
5412
5439
|
function useMultipleSelection(userProps) {
|
|
5413
5440
|
if (userProps === void 0) {
|
|
5414
5441
|
userProps = {};
|
|
5415
5442
|
}
|
|
5416
5443
|
|
|
5417
|
-
validatePropTypes
|
|
5444
|
+
validatePropTypes(userProps, useMultipleSelection); // Props defaults and destructuring.
|
|
5418
5445
|
|
|
5419
|
-
var props = _extends({}, defaultProps
|
|
5446
|
+
var props = _extends({}, defaultProps, userProps);
|
|
5420
5447
|
|
|
5421
5448
|
var getA11yRemovalMessage = props.getA11yRemovalMessage,
|
|
5422
5449
|
itemToString = props.itemToString,
|
|
@@ -5424,7 +5451,7 @@
|
|
|
5424
5451
|
keyNavigationNext = props.keyNavigationNext,
|
|
5425
5452
|
keyNavigationPrevious = props.keyNavigationPrevious; // Reducer init.
|
|
5426
5453
|
|
|
5427
|
-
var _useControlledReducer = useControlledReducer(downshiftMultipleSelectionReducer, getInitialState
|
|
5454
|
+
var _useControlledReducer = useControlledReducer$1(downshiftMultipleSelectionReducer, getInitialState(props), props),
|
|
5428
5455
|
state = _useControlledReducer[0],
|
|
5429
5456
|
dispatch = _useControlledReducer[1];
|
|
5430
5457
|
|
|
@@ -5635,7 +5662,7 @@
|
|
|
5635
5662
|
}, [dispatch]);
|
|
5636
5663
|
var reset = react.useCallback(function () {
|
|
5637
5664
|
dispatch({
|
|
5638
|
-
type: FunctionReset
|
|
5665
|
+
type: FunctionReset
|
|
5639
5666
|
});
|
|
5640
5667
|
}, [dispatch]);
|
|
5641
5668
|
return {
|