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
|
@@ -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) {
|
|
@@ -60,7 +69,7 @@
|
|
|
60
69
|
return fn(module, module.exports), module.exports;
|
|
61
70
|
}
|
|
62
71
|
|
|
63
|
-
/** @license React v17.0.
|
|
72
|
+
/** @license React v17.0.2
|
|
64
73
|
* react-is.production.min.js
|
|
65
74
|
*
|
|
66
75
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
@@ -90,7 +99,7 @@
|
|
|
90
99
|
x("react.legacy_hidden");
|
|
91
100
|
}
|
|
92
101
|
|
|
93
|
-
/** @license React v17.0.
|
|
102
|
+
/** @license React v17.0.2
|
|
94
103
|
* react-is.development.js
|
|
95
104
|
*
|
|
96
105
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
@@ -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,
|
|
@@ -1271,12 +1280,16 @@
|
|
|
1271
1280
|
Home: function Home(event) {
|
|
1272
1281
|
var _this4 = this;
|
|
1273
1282
|
|
|
1274
|
-
event.preventDefault();
|
|
1275
|
-
var itemCount = this.getItemCount();
|
|
1276
|
-
|
|
1277
1283
|
var _this$getState3 = this.getState(),
|
|
1278
1284
|
isOpen = _this$getState3.isOpen;
|
|
1279
1285
|
|
|
1286
|
+
if (!isOpen) {
|
|
1287
|
+
return;
|
|
1288
|
+
}
|
|
1289
|
+
|
|
1290
|
+
event.preventDefault();
|
|
1291
|
+
var itemCount = this.getItemCount();
|
|
1292
|
+
|
|
1280
1293
|
if (itemCount <= 0 || !isOpen) {
|
|
1281
1294
|
return;
|
|
1282
1295
|
} // get next non-disabled starting downwards from 0 if that's disabled.
|
|
@@ -1292,12 +1305,16 @@
|
|
|
1292
1305
|
End: function End(event) {
|
|
1293
1306
|
var _this5 = this;
|
|
1294
1307
|
|
|
1295
|
-
event.preventDefault();
|
|
1296
|
-
var itemCount = this.getItemCount();
|
|
1297
|
-
|
|
1298
1308
|
var _this$getState4 = this.getState(),
|
|
1299
1309
|
isOpen = _this$getState4.isOpen;
|
|
1300
1310
|
|
|
1311
|
+
if (!isOpen) {
|
|
1312
|
+
return;
|
|
1313
|
+
}
|
|
1314
|
+
|
|
1315
|
+
event.preventDefault();
|
|
1316
|
+
var itemCount = this.getItemCount();
|
|
1317
|
+
|
|
1301
1318
|
if (itemCount <= 0 || !isOpen) {
|
|
1302
1319
|
return;
|
|
1303
1320
|
} // get next non-disabled starting upwards from last index if that's disabled.
|
|
@@ -1314,9 +1331,9 @@
|
|
|
1314
1331
|
|
|
1315
1332
|
_this.getToggleButtonProps = function (_temp3) {
|
|
1316
1333
|
var _ref3 = _temp3 === void 0 ? {} : _temp3,
|
|
1317
|
-
onClick = _ref3.onClick
|
|
1318
|
-
|
|
1319
|
-
onKeyDown = _ref3.onKeyDown,
|
|
1334
|
+
onClick = _ref3.onClick;
|
|
1335
|
+
_ref3.onPress;
|
|
1336
|
+
var onKeyDown = _ref3.onKeyDown,
|
|
1320
1337
|
onKeyUp = _ref3.onKeyUp,
|
|
1321
1338
|
onBlur = _ref3.onBlur,
|
|
1322
1339
|
rest = _objectWithoutPropertiesLoose(_ref3, ["onClick", "onPress", "onKeyDown", "onKeyUp", "onBlur"]);
|
|
@@ -1324,7 +1341,7 @@
|
|
|
1324
1341
|
var _this$getState5 = _this.getState(),
|
|
1325
1342
|
isOpen = _this$getState5.isOpen;
|
|
1326
1343
|
|
|
1327
|
-
var enabledEventHandlers =
|
|
1344
|
+
var enabledEventHandlers = {
|
|
1328
1345
|
onClick: callAllEventHandlers(onClick, _this.buttonHandleClick),
|
|
1329
1346
|
onKeyDown: callAllEventHandlers(onKeyDown, _this.buttonHandleKeyDown),
|
|
1330
1347
|
onKeyUp: callAllEventHandlers(onKeyUp, _this.buttonHandleKeyUp),
|
|
@@ -1359,7 +1376,7 @@
|
|
|
1359
1376
|
|
|
1360
1377
|
/* istanbul ignore if (can't reasonably test this) */
|
|
1361
1378
|
|
|
1362
|
-
if (
|
|
1379
|
+
if (_this.props.environment.document.activeElement === _this.props.environment.document.body) {
|
|
1363
1380
|
event.target.focus();
|
|
1364
1381
|
} // to simplify testing components that use downshift, we'll not wrap this in a setTimeout
|
|
1365
1382
|
// if the NODE_ENV is test. With the proper build system, this should be dead code eliminated
|
|
@@ -1402,9 +1419,9 @@
|
|
|
1402
1419
|
onKeyDown = _ref4.onKeyDown,
|
|
1403
1420
|
onBlur = _ref4.onBlur,
|
|
1404
1421
|
onChange = _ref4.onChange,
|
|
1405
|
-
onInput = _ref4.onInput
|
|
1406
|
-
|
|
1407
|
-
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"]);
|
|
1408
1425
|
|
|
1409
1426
|
var onChangeKey;
|
|
1410
1427
|
var eventHandlers = {};
|
|
@@ -1450,7 +1467,7 @@
|
|
|
1450
1467
|
_this.internalSetState({
|
|
1451
1468
|
type: changeInput,
|
|
1452
1469
|
isOpen: true,
|
|
1453
|
-
inputValue:
|
|
1470
|
+
inputValue: event.target.value,
|
|
1454
1471
|
highlightedIndex: _this.props.defaultHighlightedIndex
|
|
1455
1472
|
});
|
|
1456
1473
|
};
|
|
@@ -1497,11 +1514,11 @@
|
|
|
1497
1514
|
var _ref7 = _temp7 === void 0 ? {} : _temp7,
|
|
1498
1515
|
onMouseMove = _ref7.onMouseMove,
|
|
1499
1516
|
onMouseDown = _ref7.onMouseDown,
|
|
1500
|
-
onClick = _ref7.onClick
|
|
1501
|
-
|
|
1502
|
-
index = _ref7.index,
|
|
1517
|
+
onClick = _ref7.onClick;
|
|
1518
|
+
_ref7.onPress;
|
|
1519
|
+
var index = _ref7.index,
|
|
1503
1520
|
_ref7$item = _ref7.item,
|
|
1504
|
-
item = _ref7$item === void 0 ?
|
|
1521
|
+
item = _ref7$item === void 0 ? requiredProp('getItemProps', 'item') : _ref7$item,
|
|
1505
1522
|
rest = _objectWithoutPropertiesLoose(_ref7, ["onMouseMove", "onMouseDown", "onClick", "onPress", "index", "item"]);
|
|
1506
1523
|
|
|
1507
1524
|
if (index === undefined) {
|
|
@@ -1512,8 +1529,8 @@
|
|
|
1512
1529
|
_this.items[index] = item;
|
|
1513
1530
|
}
|
|
1514
1531
|
|
|
1515
|
-
var onSelectKey =
|
|
1516
|
-
var customClickHandler =
|
|
1532
|
+
var onSelectKey = 'onClick';
|
|
1533
|
+
var customClickHandler = onClick;
|
|
1517
1534
|
var enabledEventHandlers = (_enabledEventHandlers = {
|
|
1518
1535
|
// onMouseMove is used over onMouseEnter here. onMouseMove
|
|
1519
1536
|
// is only triggered on actual mouse movement while onMouseEnter
|
|
@@ -1808,7 +1825,7 @@
|
|
|
1808
1825
|
var _this7 = this;
|
|
1809
1826
|
|
|
1810
1827
|
/* istanbul ignore if (react-native) */
|
|
1811
|
-
if (
|
|
1828
|
+
if (this.getMenuProps.called && !this.getMenuProps.suppressRefError) {
|
|
1812
1829
|
validateGetMenuPropsCalledCorrectly(this._menuNode, this.getMenuProps);
|
|
1813
1830
|
}
|
|
1814
1831
|
/* istanbul ignore if (react-native) */
|
|
@@ -1903,7 +1920,7 @@
|
|
|
1903
1920
|
validateControlledUnchanged(this.state, prevProps, this.props);
|
|
1904
1921
|
/* istanbul ignore if (react-native) */
|
|
1905
1922
|
|
|
1906
|
-
if (
|
|
1923
|
+
if (this.getMenuProps.called && !this.getMenuProps.suppressRefError) {
|
|
1907
1924
|
validateGetMenuPropsCalledCorrectly(this._menuNode, this.getMenuProps);
|
|
1908
1925
|
}
|
|
1909
1926
|
}
|
|
@@ -1958,7 +1975,7 @@
|
|
|
1958
1975
|
}
|
|
1959
1976
|
|
|
1960
1977
|
if (this.getRootProps.called || this.props.suppressRefError) {
|
|
1961
|
-
if (
|
|
1978
|
+
if (!this.getRootProps.suppressRefError && !this.props.suppressRefError) {
|
|
1962
1979
|
validateGetRootPropsCalledCorrectly(element, this.getRootProps);
|
|
1963
1980
|
}
|
|
1964
1981
|
|
|
@@ -1984,13 +2001,13 @@
|
|
|
1984
2001
|
Downshift.defaultProps = {
|
|
1985
2002
|
defaultHighlightedIndex: null,
|
|
1986
2003
|
defaultIsOpen: false,
|
|
1987
|
-
getA11yStatusMessage: getA11yStatusMessage,
|
|
2004
|
+
getA11yStatusMessage: getA11yStatusMessage$1,
|
|
1988
2005
|
itemToString: function itemToString(i) {
|
|
1989
2006
|
if (i == null) {
|
|
1990
2007
|
return '';
|
|
1991
2008
|
}
|
|
1992
2009
|
|
|
1993
|
-
if (
|
|
2010
|
+
if (isPlainObject(i) && !i.hasOwnProperty('toString')) {
|
|
1994
2011
|
// eslint-disable-next-line no-console
|
|
1995
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);
|
|
1996
2013
|
}
|
|
@@ -2015,7 +2032,7 @@
|
|
|
2015
2032
|
suppressRefError: false,
|
|
2016
2033
|
scrollIntoView: scrollIntoView
|
|
2017
2034
|
};
|
|
2018
|
-
Downshift.stateChangeTypes = stateChangeTypes;
|
|
2035
|
+
Downshift.stateChangeTypes = stateChangeTypes$3;
|
|
2019
2036
|
return Downshift;
|
|
2020
2037
|
}();
|
|
2021
2038
|
|
|
@@ -2230,7 +2247,7 @@
|
|
|
2230
2247
|
*/
|
|
2231
2248
|
|
|
2232
2249
|
|
|
2233
|
-
function useControlledReducer(reducer, initialState, props) {
|
|
2250
|
+
function useControlledReducer$1(reducer, initialState, props) {
|
|
2234
2251
|
var _useEnhancedReducer = useEnhancedReducer(reducer, initialState, props),
|
|
2235
2252
|
state = _useEnhancedReducer[0],
|
|
2236
2253
|
dispatch = _useEnhancedReducer[1];
|
|
@@ -2238,7 +2255,7 @@
|
|
|
2238
2255
|
return [getState(state, props), dispatch];
|
|
2239
2256
|
}
|
|
2240
2257
|
|
|
2241
|
-
var defaultProps = {
|
|
2258
|
+
var defaultProps$3 = {
|
|
2242
2259
|
itemToString: itemToString,
|
|
2243
2260
|
stateReducer: stateReducer,
|
|
2244
2261
|
getA11ySelectionMessage: getA11ySelectionMessage,
|
|
@@ -2249,7 +2266,7 @@
|
|
|
2249
2266
|
? {} : window
|
|
2250
2267
|
};
|
|
2251
2268
|
|
|
2252
|
-
function getDefaultValue(props, propKey, defaultStateValues) {
|
|
2269
|
+
function getDefaultValue$1(props, propKey, defaultStateValues) {
|
|
2253
2270
|
if (defaultStateValues === void 0) {
|
|
2254
2271
|
defaultStateValues = dropdownDefaultStateValues;
|
|
2255
2272
|
}
|
|
@@ -2263,7 +2280,7 @@
|
|
|
2263
2280
|
return defaultStateValues[propKey];
|
|
2264
2281
|
}
|
|
2265
2282
|
|
|
2266
|
-
function getInitialValue(props, propKey, defaultStateValues) {
|
|
2283
|
+
function getInitialValue$1(props, propKey, defaultStateValues) {
|
|
2267
2284
|
if (defaultStateValues === void 0) {
|
|
2268
2285
|
defaultStateValues = dropdownDefaultStateValues;
|
|
2269
2286
|
}
|
|
@@ -2278,14 +2295,14 @@
|
|
|
2278
2295
|
return props[initialPropKey];
|
|
2279
2296
|
}
|
|
2280
2297
|
|
|
2281
|
-
return getDefaultValue(props, propKey, defaultStateValues);
|
|
2298
|
+
return getDefaultValue$1(props, propKey, defaultStateValues);
|
|
2282
2299
|
}
|
|
2283
2300
|
|
|
2284
|
-
function getInitialState(props) {
|
|
2285
|
-
var selectedItem = getInitialValue(props, 'selectedItem');
|
|
2286
|
-
var isOpen = getInitialValue(props, 'isOpen');
|
|
2287
|
-
var highlightedIndex = getInitialValue(props, 'highlightedIndex');
|
|
2288
|
-
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');
|
|
2289
2306
|
return {
|
|
2290
2307
|
highlightedIndex: highlightedIndex < 0 && selectedItem && isOpen ? props.items.indexOf(selectedItem) : highlightedIndex,
|
|
2291
2308
|
isOpen: isOpen,
|
|
@@ -2580,10 +2597,10 @@
|
|
|
2580
2597
|
|
|
2581
2598
|
case stateChangeTypes.FunctionReset:
|
|
2582
2599
|
changes = {
|
|
2583
|
-
highlightedIndex: getDefaultValue(props, 'highlightedIndex'),
|
|
2584
|
-
isOpen: getDefaultValue(props, 'isOpen'),
|
|
2585
|
-
selectedItem: getDefaultValue(props, 'selectedItem'),
|
|
2586
|
-
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')
|
|
2587
2604
|
};
|
|
2588
2605
|
break;
|
|
2589
2606
|
|
|
@@ -2613,7 +2630,7 @@
|
|
|
2613
2630
|
return highlightedIndex;
|
|
2614
2631
|
}
|
|
2615
2632
|
|
|
2616
|
-
var propTypes = {
|
|
2633
|
+
var propTypes$2 = {
|
|
2617
2634
|
items: PropTypes__default['default'].array.isRequired,
|
|
2618
2635
|
itemToString: PropTypes__default['default'].func,
|
|
2619
2636
|
getA11yStatusMessage: PropTypes__default['default'].func,
|
|
@@ -2657,7 +2674,7 @@
|
|
|
2657
2674
|
* @return {String} the a11y status message
|
|
2658
2675
|
*/
|
|
2659
2676
|
|
|
2660
|
-
function getA11yStatusMessage
|
|
2677
|
+
function getA11yStatusMessage(_ref) {
|
|
2661
2678
|
var isOpen = _ref.isOpen,
|
|
2662
2679
|
resultCount = _ref.resultCount,
|
|
2663
2680
|
previousResultCount = _ref.previousResultCount;
|
|
@@ -2677,45 +2694,45 @@
|
|
|
2677
2694
|
return '';
|
|
2678
2695
|
}
|
|
2679
2696
|
|
|
2680
|
-
var defaultProps$
|
|
2681
|
-
getA11yStatusMessage: getA11yStatusMessage
|
|
2697
|
+
var defaultProps$2 = _extends({}, defaultProps$3, {
|
|
2698
|
+
getA11yStatusMessage: getA11yStatusMessage
|
|
2682
2699
|
}); // eslint-disable-next-line import/no-mutable-exports
|
|
2683
2700
|
|
|
2684
2701
|
|
|
2685
|
-
var validatePropTypes = noop;
|
|
2702
|
+
var validatePropTypes$2 = noop;
|
|
2686
2703
|
/* istanbul ignore next */
|
|
2687
2704
|
|
|
2688
2705
|
{
|
|
2689
|
-
validatePropTypes = function validatePropTypes(options, caller) {
|
|
2690
|
-
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);
|
|
2691
2708
|
};
|
|
2692
2709
|
}
|
|
2693
2710
|
|
|
2694
|
-
var MenuKeyDownArrowDown =
|
|
2695
|
-
var MenuKeyDownArrowUp =
|
|
2696
|
-
var MenuKeyDownEscape =
|
|
2697
|
-
var MenuKeyDownHome =
|
|
2698
|
-
var MenuKeyDownEnd =
|
|
2699
|
-
var MenuKeyDownEnter =
|
|
2700
|
-
var MenuKeyDownSpaceButton =
|
|
2701
|
-
var MenuKeyDownCharacter =
|
|
2702
|
-
var MenuBlur =
|
|
2703
|
-
var MenuMouseLeave =
|
|
2704
|
-
var ItemMouseMove =
|
|
2705
|
-
var ItemClick =
|
|
2706
|
-
var ToggleButtonClick =
|
|
2707
|
-
var ToggleButtonKeyDownArrowDown =
|
|
2708
|
-
var ToggleButtonKeyDownArrowUp =
|
|
2709
|
-
var ToggleButtonKeyDownCharacter =
|
|
2710
|
-
var FunctionToggleMenu =
|
|
2711
|
-
var FunctionOpenMenu =
|
|
2712
|
-
var FunctionCloseMenu =
|
|
2713
|
-
var FunctionSetHighlightedIndex =
|
|
2714
|
-
var FunctionSelectItem =
|
|
2715
|
-
var FunctionSetInputValue =
|
|
2716
|
-
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__' ;
|
|
2717
2734
|
|
|
2718
|
-
var stateChangeTypes$
|
|
2735
|
+
var stateChangeTypes$2 = /*#__PURE__*/Object.freeze({
|
|
2719
2736
|
__proto__: null,
|
|
2720
2737
|
MenuKeyDownArrowDown: MenuKeyDownArrowDown,
|
|
2721
2738
|
MenuKeyDownArrowUp: MenuKeyDownArrowUp,
|
|
@@ -2726,20 +2743,20 @@
|
|
|
2726
2743
|
MenuKeyDownSpaceButton: MenuKeyDownSpaceButton,
|
|
2727
2744
|
MenuKeyDownCharacter: MenuKeyDownCharacter,
|
|
2728
2745
|
MenuBlur: MenuBlur,
|
|
2729
|
-
MenuMouseLeave: MenuMouseLeave,
|
|
2730
|
-
ItemMouseMove: ItemMouseMove,
|
|
2731
|
-
ItemClick: ItemClick,
|
|
2732
|
-
ToggleButtonClick: ToggleButtonClick,
|
|
2746
|
+
MenuMouseLeave: MenuMouseLeave$1,
|
|
2747
|
+
ItemMouseMove: ItemMouseMove$1,
|
|
2748
|
+
ItemClick: ItemClick$1,
|
|
2749
|
+
ToggleButtonClick: ToggleButtonClick$1,
|
|
2733
2750
|
ToggleButtonKeyDownArrowDown: ToggleButtonKeyDownArrowDown,
|
|
2734
2751
|
ToggleButtonKeyDownArrowUp: ToggleButtonKeyDownArrowUp,
|
|
2735
2752
|
ToggleButtonKeyDownCharacter: ToggleButtonKeyDownCharacter,
|
|
2736
|
-
FunctionToggleMenu: FunctionToggleMenu,
|
|
2737
|
-
FunctionOpenMenu: FunctionOpenMenu,
|
|
2738
|
-
FunctionCloseMenu: FunctionCloseMenu,
|
|
2739
|
-
FunctionSetHighlightedIndex: FunctionSetHighlightedIndex,
|
|
2740
|
-
FunctionSelectItem: FunctionSelectItem,
|
|
2741
|
-
FunctionSetInputValue: FunctionSetInputValue,
|
|
2742
|
-
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
|
|
2743
2760
|
});
|
|
2744
2761
|
|
|
2745
2762
|
/* eslint-disable complexity */
|
|
@@ -2751,10 +2768,10 @@
|
|
|
2751
2768
|
var changes;
|
|
2752
2769
|
|
|
2753
2770
|
switch (type) {
|
|
2754
|
-
case ItemClick:
|
|
2771
|
+
case ItemClick$1:
|
|
2755
2772
|
changes = {
|
|
2756
|
-
isOpen: getDefaultValue(props, 'isOpen'),
|
|
2757
|
-
highlightedIndex: getDefaultValue(props, 'highlightedIndex'),
|
|
2773
|
+
isOpen: getDefaultValue$1(props, 'isOpen'),
|
|
2774
|
+
highlightedIndex: getDefaultValue$1(props, 'highlightedIndex'),
|
|
2758
2775
|
selectedItem: props.items[action.index]
|
|
2759
2776
|
};
|
|
2760
2777
|
break;
|
|
@@ -2789,8 +2806,8 @@
|
|
|
2789
2806
|
case MenuKeyDownEnter:
|
|
2790
2807
|
case MenuKeyDownSpaceButton:
|
|
2791
2808
|
changes = _extends({
|
|
2792
|
-
isOpen: getDefaultValue(props, 'isOpen'),
|
|
2793
|
-
highlightedIndex: getDefaultValue(props, 'highlightedIndex')
|
|
2809
|
+
isOpen: getDefaultValue$1(props, 'isOpen'),
|
|
2810
|
+
highlightedIndex: getDefaultValue$1(props, 'highlightedIndex')
|
|
2794
2811
|
}, state.highlightedIndex >= 0 && {
|
|
2795
2812
|
selectedItem: props.items[state.highlightedIndex]
|
|
2796
2813
|
});
|
|
@@ -2849,30 +2866,30 @@
|
|
|
2849
2866
|
};
|
|
2850
2867
|
break;
|
|
2851
2868
|
|
|
2852
|
-
case FunctionSelectItem:
|
|
2869
|
+
case FunctionSelectItem$1:
|
|
2853
2870
|
changes = {
|
|
2854
2871
|
selectedItem: action.selectedItem
|
|
2855
2872
|
};
|
|
2856
2873
|
break;
|
|
2857
2874
|
|
|
2858
2875
|
default:
|
|
2859
|
-
return downshiftCommonReducer(state, action, stateChangeTypes$
|
|
2876
|
+
return downshiftCommonReducer(state, action, stateChangeTypes$2);
|
|
2860
2877
|
}
|
|
2861
2878
|
|
|
2862
2879
|
return _extends({}, state, changes);
|
|
2863
2880
|
}
|
|
2864
2881
|
/* eslint-enable complexity */
|
|
2865
2882
|
|
|
2866
|
-
useSelect.stateChangeTypes = stateChangeTypes$
|
|
2883
|
+
useSelect.stateChangeTypes = stateChangeTypes$2;
|
|
2867
2884
|
|
|
2868
2885
|
function useSelect(userProps) {
|
|
2869
2886
|
if (userProps === void 0) {
|
|
2870
2887
|
userProps = {};
|
|
2871
2888
|
}
|
|
2872
2889
|
|
|
2873
|
-
validatePropTypes(userProps, useSelect); // Props defaults and destructuring.
|
|
2890
|
+
validatePropTypes$2(userProps, useSelect); // Props defaults and destructuring.
|
|
2874
2891
|
|
|
2875
|
-
var props = _extends({}, defaultProps$
|
|
2892
|
+
var props = _extends({}, defaultProps$2, userProps);
|
|
2876
2893
|
|
|
2877
2894
|
var items = props.items,
|
|
2878
2895
|
scrollIntoView = props.scrollIntoView,
|
|
@@ -2883,9 +2900,9 @@
|
|
|
2883
2900
|
getA11ySelectionMessage = props.getA11ySelectionMessage,
|
|
2884
2901
|
getA11yStatusMessage = props.getA11yStatusMessage; // Initial state depending on controlled props.
|
|
2885
2902
|
|
|
2886
|
-
var initialState = getInitialState(props);
|
|
2903
|
+
var initialState = getInitialState$2(props);
|
|
2887
2904
|
|
|
2888
|
-
var _useControlledReducer = useControlledReducer(downshiftSelectReducer, initialState, props),
|
|
2905
|
+
var _useControlledReducer = useControlledReducer$1(downshiftSelectReducer, initialState, props),
|
|
2889
2906
|
state = _useControlledReducer[0],
|
|
2890
2907
|
dispatch = _useControlledReducer[1];
|
|
2891
2908
|
|
|
@@ -2940,19 +2957,23 @@
|
|
|
2940
2957
|
itemRefs: itemRefs,
|
|
2941
2958
|
scrollIntoView: scrollIntoView,
|
|
2942
2959
|
getItemNodeFromIndex: getItemNodeFromIndex
|
|
2943
|
-
}); // Sets cleanup for the keysSoFar after 500ms.
|
|
2960
|
+
}); // Sets cleanup for the keysSoFar callback, debounded after 500ms.
|
|
2944
2961
|
|
|
2945
2962
|
preact.useEffect(function () {
|
|
2946
2963
|
// init the clean function here as we need access to dispatch.
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
}, 500);
|
|
2954
|
-
}
|
|
2964
|
+
clearTimeoutRef.current = debounce(function (outerDispatch) {
|
|
2965
|
+
outerDispatch({
|
|
2966
|
+
type: FunctionSetInputValue$1,
|
|
2967
|
+
inputValue: ''
|
|
2968
|
+
});
|
|
2969
|
+
}, 500); // Cancel any pending debounced calls on mount
|
|
2955
2970
|
|
|
2971
|
+
return function () {
|
|
2972
|
+
clearTimeoutRef.current.cancel();
|
|
2973
|
+
};
|
|
2974
|
+
}, []); // Invokes the keysSoFar callback set up above.
|
|
2975
|
+
|
|
2976
|
+
preact.useEffect(function () {
|
|
2956
2977
|
if (!inputValue) {
|
|
2957
2978
|
return;
|
|
2958
2979
|
}
|
|
@@ -3096,39 +3117,39 @@
|
|
|
3096
3117
|
|
|
3097
3118
|
var toggleMenu = preact.useCallback(function () {
|
|
3098
3119
|
dispatch({
|
|
3099
|
-
type: FunctionToggleMenu
|
|
3120
|
+
type: FunctionToggleMenu$1
|
|
3100
3121
|
});
|
|
3101
3122
|
}, [dispatch]);
|
|
3102
3123
|
var closeMenu = preact.useCallback(function () {
|
|
3103
3124
|
dispatch({
|
|
3104
|
-
type: FunctionCloseMenu
|
|
3125
|
+
type: FunctionCloseMenu$1
|
|
3105
3126
|
});
|
|
3106
3127
|
}, [dispatch]);
|
|
3107
3128
|
var openMenu = preact.useCallback(function () {
|
|
3108
3129
|
dispatch({
|
|
3109
|
-
type: FunctionOpenMenu
|
|
3130
|
+
type: FunctionOpenMenu$1
|
|
3110
3131
|
});
|
|
3111
3132
|
}, [dispatch]);
|
|
3112
3133
|
var setHighlightedIndex = preact.useCallback(function (newHighlightedIndex) {
|
|
3113
3134
|
dispatch({
|
|
3114
|
-
type: FunctionSetHighlightedIndex,
|
|
3135
|
+
type: FunctionSetHighlightedIndex$1,
|
|
3115
3136
|
highlightedIndex: newHighlightedIndex
|
|
3116
3137
|
});
|
|
3117
3138
|
}, [dispatch]);
|
|
3118
3139
|
var selectItem = preact.useCallback(function (newSelectedItem) {
|
|
3119
3140
|
dispatch({
|
|
3120
|
-
type: FunctionSelectItem,
|
|
3141
|
+
type: FunctionSelectItem$1,
|
|
3121
3142
|
selectedItem: newSelectedItem
|
|
3122
3143
|
});
|
|
3123
3144
|
}, [dispatch]);
|
|
3124
3145
|
var reset = preact.useCallback(function () {
|
|
3125
3146
|
dispatch({
|
|
3126
|
-
type: FunctionReset
|
|
3147
|
+
type: FunctionReset$2
|
|
3127
3148
|
});
|
|
3128
3149
|
}, [dispatch]);
|
|
3129
3150
|
var setInputValue = preact.useCallback(function (newInputValue) {
|
|
3130
3151
|
dispatch({
|
|
3131
|
-
type: FunctionSetInputValue,
|
|
3152
|
+
type: FunctionSetInputValue$1,
|
|
3132
3153
|
inputValue: newInputValue
|
|
3133
3154
|
});
|
|
3134
3155
|
}, [dispatch]); // Getter functions.
|
|
@@ -3190,7 +3211,7 @@
|
|
|
3190
3211
|
|
|
3191
3212
|
var menuHandleMouseLeave = function menuHandleMouseLeave() {
|
|
3192
3213
|
dispatch({
|
|
3193
|
-
type: MenuMouseLeave
|
|
3214
|
+
type: MenuMouseLeave$1
|
|
3194
3215
|
});
|
|
3195
3216
|
};
|
|
3196
3217
|
|
|
@@ -3222,7 +3243,7 @@
|
|
|
3222
3243
|
|
|
3223
3244
|
var toggleButtonHandleClick = function toggleButtonHandleClick() {
|
|
3224
3245
|
dispatch({
|
|
3225
|
-
type: ToggleButtonClick
|
|
3246
|
+
type: ToggleButtonClick$1
|
|
3226
3247
|
});
|
|
3227
3248
|
};
|
|
3228
3249
|
|
|
@@ -3276,14 +3297,14 @@
|
|
|
3276
3297
|
|
|
3277
3298
|
shouldScrollRef.current = false;
|
|
3278
3299
|
dispatch({
|
|
3279
|
-
type: ItemMouseMove,
|
|
3300
|
+
type: ItemMouseMove$1,
|
|
3280
3301
|
index: index
|
|
3281
3302
|
});
|
|
3282
3303
|
};
|
|
3283
3304
|
|
|
3284
3305
|
var itemHandleClick = function itemHandleClick() {
|
|
3285
3306
|
dispatch({
|
|
3286
|
-
type: ItemClick,
|
|
3307
|
+
type: ItemClick$1,
|
|
3287
3308
|
index: index
|
|
3288
3309
|
});
|
|
3289
3310
|
};
|
|
@@ -3333,28 +3354,28 @@
|
|
|
3333
3354
|
};
|
|
3334
3355
|
}
|
|
3335
3356
|
|
|
3336
|
-
var InputKeyDownArrowDown =
|
|
3337
|
-
var InputKeyDownArrowUp =
|
|
3338
|
-
var InputKeyDownEscape =
|
|
3339
|
-
var InputKeyDownHome =
|
|
3340
|
-
var InputKeyDownEnd =
|
|
3341
|
-
var InputKeyDownEnter =
|
|
3342
|
-
var InputChange =
|
|
3343
|
-
var InputBlur =
|
|
3344
|
-
var MenuMouseLeave
|
|
3345
|
-
var ItemMouseMove
|
|
3346
|
-
var ItemClick
|
|
3347
|
-
var ToggleButtonClick
|
|
3348
|
-
var FunctionToggleMenu
|
|
3349
|
-
var FunctionOpenMenu
|
|
3350
|
-
var FunctionCloseMenu
|
|
3351
|
-
var FunctionSetHighlightedIndex
|
|
3352
|
-
var FunctionSelectItem
|
|
3353
|
-
var FunctionSetInputValue
|
|
3354
|
-
var FunctionReset$1 =
|
|
3355
|
-
var ControlledPropUpdatedSelectedItem =
|
|
3357
|
+
var InputKeyDownArrowDown = '__input_keydown_arrow_down__' ;
|
|
3358
|
+
var InputKeyDownArrowUp = '__input_keydown_arrow_up__' ;
|
|
3359
|
+
var InputKeyDownEscape = '__input_keydown_escape__' ;
|
|
3360
|
+
var InputKeyDownHome = '__input_keydown_home__' ;
|
|
3361
|
+
var InputKeyDownEnd = '__input_keydown_end__' ;
|
|
3362
|
+
var InputKeyDownEnter = '__input_keydown_enter__' ;
|
|
3363
|
+
var InputChange = '__input_change__' ;
|
|
3364
|
+
var InputBlur = '__input_blur__' ;
|
|
3365
|
+
var MenuMouseLeave = '__menu_mouse_leave__' ;
|
|
3366
|
+
var ItemMouseMove = '__item_mouse_move__' ;
|
|
3367
|
+
var ItemClick = '__item_click__' ;
|
|
3368
|
+
var ToggleButtonClick = '__togglebutton_click__' ;
|
|
3369
|
+
var FunctionToggleMenu = '__function_toggle_menu__' ;
|
|
3370
|
+
var FunctionOpenMenu = '__function_open_menu__' ;
|
|
3371
|
+
var FunctionCloseMenu = '__function_close_menu__' ;
|
|
3372
|
+
var FunctionSetHighlightedIndex = '__function_set_highlighted_index__' ;
|
|
3373
|
+
var FunctionSelectItem = '__function_select_item__' ;
|
|
3374
|
+
var FunctionSetInputValue = '__function_set_input_value__' ;
|
|
3375
|
+
var FunctionReset$1 = '__function_reset__' ;
|
|
3376
|
+
var ControlledPropUpdatedSelectedItem = '__controlled_prop_updated_selected_item__' ;
|
|
3356
3377
|
|
|
3357
|
-
var stateChangeTypes$
|
|
3378
|
+
var stateChangeTypes$1 = /*#__PURE__*/Object.freeze({
|
|
3358
3379
|
__proto__: null,
|
|
3359
3380
|
InputKeyDownArrowDown: InputKeyDownArrowDown,
|
|
3360
3381
|
InputKeyDownArrowUp: InputKeyDownArrowUp,
|
|
@@ -3364,22 +3385,22 @@
|
|
|
3364
3385
|
InputKeyDownEnter: InputKeyDownEnter,
|
|
3365
3386
|
InputChange: InputChange,
|
|
3366
3387
|
InputBlur: InputBlur,
|
|
3367
|
-
MenuMouseLeave: MenuMouseLeave
|
|
3368
|
-
ItemMouseMove: ItemMouseMove
|
|
3369
|
-
ItemClick: ItemClick
|
|
3370
|
-
ToggleButtonClick: ToggleButtonClick
|
|
3371
|
-
FunctionToggleMenu: FunctionToggleMenu
|
|
3372
|
-
FunctionOpenMenu: FunctionOpenMenu
|
|
3373
|
-
FunctionCloseMenu: FunctionCloseMenu
|
|
3374
|
-
FunctionSetHighlightedIndex: FunctionSetHighlightedIndex
|
|
3375
|
-
FunctionSelectItem: FunctionSelectItem
|
|
3376
|
-
FunctionSetInputValue: FunctionSetInputValue
|
|
3388
|
+
MenuMouseLeave: MenuMouseLeave,
|
|
3389
|
+
ItemMouseMove: ItemMouseMove,
|
|
3390
|
+
ItemClick: ItemClick,
|
|
3391
|
+
ToggleButtonClick: ToggleButtonClick,
|
|
3392
|
+
FunctionToggleMenu: FunctionToggleMenu,
|
|
3393
|
+
FunctionOpenMenu: FunctionOpenMenu,
|
|
3394
|
+
FunctionCloseMenu: FunctionCloseMenu,
|
|
3395
|
+
FunctionSetHighlightedIndex: FunctionSetHighlightedIndex,
|
|
3396
|
+
FunctionSelectItem: FunctionSelectItem,
|
|
3397
|
+
FunctionSetInputValue: FunctionSetInputValue,
|
|
3377
3398
|
FunctionReset: FunctionReset$1,
|
|
3378
3399
|
ControlledPropUpdatedSelectedItem: ControlledPropUpdatedSelectedItem
|
|
3379
3400
|
});
|
|
3380
3401
|
|
|
3381
3402
|
function getInitialState$1(props) {
|
|
3382
|
-
var initialState = getInitialState(props);
|
|
3403
|
+
var initialState = getInitialState$2(props);
|
|
3383
3404
|
var selectedItem = initialState.selectedItem;
|
|
3384
3405
|
var inputValue = initialState.inputValue;
|
|
3385
3406
|
|
|
@@ -3445,7 +3466,7 @@
|
|
|
3445
3466
|
* @returns {Array} An array with the state and an action dispatcher.
|
|
3446
3467
|
*/
|
|
3447
3468
|
|
|
3448
|
-
function useControlledReducer
|
|
3469
|
+
function useControlledReducer(reducer, initialState, props) {
|
|
3449
3470
|
var previousSelectedItemRef = preact.useRef();
|
|
3450
3471
|
|
|
3451
3472
|
var _useEnhancedReducer = useEnhancedReducer(reducer, initialState, props),
|
|
@@ -3478,8 +3499,8 @@
|
|
|
3478
3499
|
};
|
|
3479
3500
|
}
|
|
3480
3501
|
|
|
3481
|
-
var defaultProps$
|
|
3482
|
-
getA11yStatusMessage: getA11yStatusMessage,
|
|
3502
|
+
var defaultProps$1 = _extends({}, defaultProps$3, {
|
|
3503
|
+
getA11yStatusMessage: getA11yStatusMessage$1,
|
|
3483
3504
|
circularNavigation: true
|
|
3484
3505
|
});
|
|
3485
3506
|
|
|
@@ -3492,10 +3513,10 @@
|
|
|
3492
3513
|
var changes;
|
|
3493
3514
|
|
|
3494
3515
|
switch (type) {
|
|
3495
|
-
case ItemClick
|
|
3516
|
+
case ItemClick:
|
|
3496
3517
|
changes = {
|
|
3497
|
-
isOpen: getDefaultValue(props, 'isOpen'),
|
|
3498
|
-
highlightedIndex: getDefaultValue(props, 'highlightedIndex'),
|
|
3518
|
+
isOpen: getDefaultValue$1(props, 'isOpen'),
|
|
3519
|
+
highlightedIndex: getDefaultValue$1(props, 'highlightedIndex'),
|
|
3499
3520
|
selectedItem: props.items[action.index],
|
|
3500
3521
|
inputValue: props.itemToString(props.items[action.index])
|
|
3501
3522
|
};
|
|
@@ -3509,7 +3530,7 @@
|
|
|
3509
3530
|
} else {
|
|
3510
3531
|
changes = {
|
|
3511
3532
|
highlightedIndex: getHighlightedIndexOnOpen(props, state, 1, action.getItemNodeFromIndex),
|
|
3512
|
-
isOpen:
|
|
3533
|
+
isOpen: props.items.length >= 0
|
|
3513
3534
|
};
|
|
3514
3535
|
}
|
|
3515
3536
|
|
|
@@ -3523,7 +3544,7 @@
|
|
|
3523
3544
|
} else {
|
|
3524
3545
|
changes = {
|
|
3525
3546
|
highlightedIndex: getHighlightedIndexOnOpen(props, state, -1, action.getItemNodeFromIndex),
|
|
3526
|
-
isOpen:
|
|
3547
|
+
isOpen: props.items.length >= 0
|
|
3527
3548
|
};
|
|
3528
3549
|
}
|
|
3529
3550
|
|
|
@@ -3532,8 +3553,8 @@
|
|
|
3532
3553
|
case InputKeyDownEnter:
|
|
3533
3554
|
changes = _extends({}, state.isOpen && state.highlightedIndex >= 0 && {
|
|
3534
3555
|
selectedItem: props.items[state.highlightedIndex],
|
|
3535
|
-
isOpen: getDefaultValue(props, 'isOpen'),
|
|
3536
|
-
highlightedIndex: getDefaultValue(props, 'highlightedIndex'),
|
|
3556
|
+
isOpen: getDefaultValue$1(props, 'isOpen'),
|
|
3557
|
+
highlightedIndex: getDefaultValue$1(props, 'highlightedIndex'),
|
|
3537
3558
|
inputValue: props.itemToString(props.items[state.highlightedIndex])
|
|
3538
3559
|
});
|
|
3539
3560
|
break;
|
|
@@ -3549,39 +3570,36 @@
|
|
|
3549
3570
|
break;
|
|
3550
3571
|
|
|
3551
3572
|
case InputKeyDownHome:
|
|
3552
|
-
changes =
|
|
3573
|
+
changes = {
|
|
3553
3574
|
highlightedIndex: getNextNonDisabledIndex(1, 0, props.items.length, action.getItemNodeFromIndex, false)
|
|
3554
|
-
}
|
|
3575
|
+
};
|
|
3555
3576
|
break;
|
|
3556
3577
|
|
|
3557
3578
|
case InputKeyDownEnd:
|
|
3558
|
-
changes =
|
|
3579
|
+
changes = {
|
|
3559
3580
|
highlightedIndex: getNextNonDisabledIndex(-1, props.items.length - 1, props.items.length, action.getItemNodeFromIndex, false)
|
|
3560
|
-
}
|
|
3581
|
+
};
|
|
3561
3582
|
break;
|
|
3562
3583
|
|
|
3563
3584
|
case InputBlur:
|
|
3564
|
-
|
|
3565
|
-
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
|
|
3571
|
-
});
|
|
3572
|
-
}
|
|
3573
|
-
|
|
3585
|
+
changes = _extends({
|
|
3586
|
+
isOpen: false,
|
|
3587
|
+
highlightedIndex: -1
|
|
3588
|
+
}, state.highlightedIndex >= 0 && action.selectItem && {
|
|
3589
|
+
selectedItem: props.items[state.highlightedIndex],
|
|
3590
|
+
inputValue: props.itemToString(props.items[state.highlightedIndex])
|
|
3591
|
+
});
|
|
3574
3592
|
break;
|
|
3575
3593
|
|
|
3576
3594
|
case InputChange:
|
|
3577
3595
|
changes = {
|
|
3578
3596
|
isOpen: true,
|
|
3579
|
-
highlightedIndex: getDefaultValue(props, 'highlightedIndex'),
|
|
3597
|
+
highlightedIndex: getDefaultValue$1(props, 'highlightedIndex'),
|
|
3580
3598
|
inputValue: action.inputValue
|
|
3581
3599
|
};
|
|
3582
3600
|
break;
|
|
3583
3601
|
|
|
3584
|
-
case FunctionSelectItem
|
|
3602
|
+
case FunctionSelectItem:
|
|
3585
3603
|
changes = {
|
|
3586
3604
|
selectedItem: action.selectedItem,
|
|
3587
3605
|
inputValue: props.itemToString(action.selectedItem)
|
|
@@ -3595,14 +3613,14 @@
|
|
|
3595
3613
|
break;
|
|
3596
3614
|
|
|
3597
3615
|
default:
|
|
3598
|
-
return downshiftCommonReducer(state, action, stateChangeTypes$
|
|
3616
|
+
return downshiftCommonReducer(state, action, stateChangeTypes$1);
|
|
3599
3617
|
}
|
|
3600
3618
|
|
|
3601
3619
|
return _extends({}, state, changes);
|
|
3602
3620
|
}
|
|
3603
3621
|
/* eslint-enable complexity */
|
|
3604
3622
|
|
|
3605
|
-
useCombobox.stateChangeTypes = stateChangeTypes$
|
|
3623
|
+
useCombobox.stateChangeTypes = stateChangeTypes$1;
|
|
3606
3624
|
|
|
3607
3625
|
function useCombobox(userProps) {
|
|
3608
3626
|
if (userProps === void 0) {
|
|
@@ -3611,7 +3629,7 @@
|
|
|
3611
3629
|
|
|
3612
3630
|
validatePropTypes$1(userProps, useCombobox); // Props defaults and destructuring.
|
|
3613
3631
|
|
|
3614
|
-
var props = _extends({}, defaultProps$
|
|
3632
|
+
var props = _extends({}, defaultProps$1, userProps);
|
|
3615
3633
|
|
|
3616
3634
|
var initialIsOpen = props.initialIsOpen,
|
|
3617
3635
|
defaultIsOpen = props.defaultIsOpen,
|
|
@@ -3624,7 +3642,7 @@
|
|
|
3624
3642
|
|
|
3625
3643
|
var initialState = getInitialState$1(props);
|
|
3626
3644
|
|
|
3627
|
-
var _useControlledReducer = useControlledReducer
|
|
3645
|
+
var _useControlledReducer = useControlledReducer(downshiftUseComboboxReducer, initialState, props),
|
|
3628
3646
|
state = _useControlledReducer[0],
|
|
3629
3647
|
dispatch = _useControlledReducer[1];
|
|
3630
3648
|
|
|
@@ -3737,6 +3755,10 @@
|
|
|
3737
3755
|
});
|
|
3738
3756
|
},
|
|
3739
3757
|
Home: function Home(event) {
|
|
3758
|
+
if (!latest.current.state.isOpen) {
|
|
3759
|
+
return;
|
|
3760
|
+
}
|
|
3761
|
+
|
|
3740
3762
|
event.preventDefault();
|
|
3741
3763
|
dispatch({
|
|
3742
3764
|
type: InputKeyDownHome,
|
|
@@ -3744,6 +3766,10 @@
|
|
|
3744
3766
|
});
|
|
3745
3767
|
},
|
|
3746
3768
|
End: function End(event) {
|
|
3769
|
+
if (!latest.current.state.isOpen) {
|
|
3770
|
+
return;
|
|
3771
|
+
}
|
|
3772
|
+
|
|
3747
3773
|
event.preventDefault();
|
|
3748
3774
|
dispatch({
|
|
3749
3775
|
type: InputKeyDownEnd,
|
|
@@ -3751,22 +3777,23 @@
|
|
|
3751
3777
|
});
|
|
3752
3778
|
},
|
|
3753
3779
|
Escape: function Escape() {
|
|
3754
|
-
dispatch({
|
|
3755
|
-
type: InputKeyDownEscape
|
|
3756
|
-
});
|
|
3757
|
-
},
|
|
3758
|
-
Enter: function Enter(event) {
|
|
3759
|
-
// if IME composing, wait for next Enter keydown event.
|
|
3760
|
-
if (event.which === 229) {
|
|
3761
|
-
return;
|
|
3762
|
-
}
|
|
3763
|
-
|
|
3764
3780
|
var latestState = latest.current.state;
|
|
3765
3781
|
|
|
3766
|
-
if (latestState.isOpen) {
|
|
3767
|
-
|
|
3782
|
+
if (latestState.isOpen || latestState.inputValue || latestState.selectedItem || latestState.highlightedIndex > -1) {
|
|
3783
|
+
dispatch({
|
|
3784
|
+
type: InputKeyDownEscape
|
|
3785
|
+
});
|
|
3768
3786
|
}
|
|
3787
|
+
},
|
|
3788
|
+
Enter: function Enter(event) {
|
|
3789
|
+
var latestState = latest.current.state; // if closed or no highlighted index, do nothing.
|
|
3790
|
+
|
|
3791
|
+
if (!latestState.isOpen || latestState.highlightedIndex < 0 || event.which === 229 // if IME composing, wait for next Enter keydown event.
|
|
3792
|
+
) {
|
|
3793
|
+
return;
|
|
3794
|
+
}
|
|
3769
3795
|
|
|
3796
|
+
event.preventDefault();
|
|
3770
3797
|
dispatch({
|
|
3771
3798
|
type: InputKeyDownEnter,
|
|
3772
3799
|
getItemNodeFromIndex: getItemNodeFromIndex
|
|
@@ -3800,7 +3827,7 @@
|
|
|
3800
3827
|
menuRef.current = menuNode;
|
|
3801
3828
|
}), _extends2.id = elementIds.menuId, _extends2.role = 'listbox', _extends2['aria-labelledby'] = elementIds.labelId, _extends2.onMouseLeave = callAllEventHandlers(onMouseLeave, function () {
|
|
3802
3829
|
dispatch({
|
|
3803
|
-
type: MenuMouseLeave
|
|
3830
|
+
type: MenuMouseLeave
|
|
3804
3831
|
});
|
|
3805
3832
|
}), _extends2), rest);
|
|
3806
3833
|
}, [dispatch, setGetterPropCallInfo, elementIds]);
|
|
@@ -3814,9 +3841,9 @@
|
|
|
3814
3841
|
refKey = _ref3$refKey === void 0 ? 'ref' : _ref3$refKey,
|
|
3815
3842
|
ref = _ref3.ref,
|
|
3816
3843
|
onMouseMove = _ref3.onMouseMove,
|
|
3817
|
-
onClick = _ref3.onClick
|
|
3818
|
-
|
|
3819
|
-
rest = _objectWithoutPropertiesLoose(_ref3, ["item", "index", "refKey", "ref", "onMouseMove", "onClick", "onPress"]);
|
|
3844
|
+
onClick = _ref3.onClick;
|
|
3845
|
+
_ref3.onPress;
|
|
3846
|
+
var rest = _objectWithoutPropertiesLoose(_ref3, ["item", "index", "refKey", "ref", "onMouseMove", "onClick", "onPress"]);
|
|
3820
3847
|
|
|
3821
3848
|
var _latest$current = latest.current,
|
|
3822
3849
|
latestProps = _latest$current.props,
|
|
@@ -3827,8 +3854,8 @@
|
|
|
3827
3854
|
throw new Error('Pass either item or item index in getItemProps!');
|
|
3828
3855
|
}
|
|
3829
3856
|
|
|
3830
|
-
var onSelectKey =
|
|
3831
|
-
var customClickHandler =
|
|
3857
|
+
var onSelectKey = 'onClick';
|
|
3858
|
+
var customClickHandler = onClick;
|
|
3832
3859
|
|
|
3833
3860
|
var itemHandleMouseMove = function itemHandleMouseMove() {
|
|
3834
3861
|
if (index === latestState.highlightedIndex) {
|
|
@@ -3837,14 +3864,14 @@
|
|
|
3837
3864
|
|
|
3838
3865
|
shouldScrollRef.current = false;
|
|
3839
3866
|
dispatch({
|
|
3840
|
-
type: ItemMouseMove
|
|
3867
|
+
type: ItemMouseMove,
|
|
3841
3868
|
index: index
|
|
3842
3869
|
});
|
|
3843
3870
|
};
|
|
3844
3871
|
|
|
3845
3872
|
var itemHandleClick = function itemHandleClick() {
|
|
3846
3873
|
dispatch({
|
|
3847
|
-
type: ItemClick
|
|
3874
|
+
type: ItemClick,
|
|
3848
3875
|
index: index
|
|
3849
3876
|
});
|
|
3850
3877
|
|
|
@@ -3865,16 +3892,16 @@
|
|
|
3865
3892
|
var _extends4;
|
|
3866
3893
|
|
|
3867
3894
|
var _ref5 = _temp4 === void 0 ? {} : _temp4,
|
|
3868
|
-
onClick = _ref5.onClick
|
|
3869
|
-
|
|
3870
|
-
_ref5$refKey = _ref5.refKey,
|
|
3895
|
+
onClick = _ref5.onClick;
|
|
3896
|
+
_ref5.onPress;
|
|
3897
|
+
var _ref5$refKey = _ref5.refKey,
|
|
3871
3898
|
refKey = _ref5$refKey === void 0 ? 'ref' : _ref5$refKey,
|
|
3872
3899
|
ref = _ref5.ref,
|
|
3873
3900
|
rest = _objectWithoutPropertiesLoose(_ref5, ["onClick", "onPress", "refKey", "ref"]);
|
|
3874
3901
|
|
|
3875
3902
|
var toggleButtonHandleClick = function toggleButtonHandleClick() {
|
|
3876
3903
|
dispatch({
|
|
3877
|
-
type: ToggleButtonClick
|
|
3904
|
+
type: ToggleButtonClick
|
|
3878
3905
|
});
|
|
3879
3906
|
|
|
3880
3907
|
if (!latest.current.state.isOpen && inputRef.current) {
|
|
@@ -3884,7 +3911,7 @@
|
|
|
3884
3911
|
|
|
3885
3912
|
return _extends((_extends4 = {}, _extends4[refKey] = handleRefs(ref, function (toggleButtonNode) {
|
|
3886
3913
|
toggleButtonRef.current = toggleButtonNode;
|
|
3887
|
-
}), _extends4.id = elementIds.toggleButtonId, _extends4.tabIndex = -1, _extends4), !rest.disabled && _extends({},
|
|
3914
|
+
}), _extends4.id = elementIds.toggleButtonId, _extends4.tabIndex = -1, _extends4), !rest.disabled && _extends({}, {
|
|
3888
3915
|
onClick: callAllEventHandlers(onClick, toggleButtonHandleClick)
|
|
3889
3916
|
}), rest);
|
|
3890
3917
|
}, [dispatch, latest, elementIds]);
|
|
@@ -3895,9 +3922,9 @@
|
|
|
3895
3922
|
onKeyDown = _ref6.onKeyDown,
|
|
3896
3923
|
onChange = _ref6.onChange,
|
|
3897
3924
|
onInput = _ref6.onInput,
|
|
3898
|
-
onBlur = _ref6.onBlur
|
|
3899
|
-
|
|
3900
|
-
_ref6$refKey = _ref6.refKey,
|
|
3925
|
+
onBlur = _ref6.onBlur;
|
|
3926
|
+
_ref6.onChangeText;
|
|
3927
|
+
var _ref6$refKey = _ref6.refKey,
|
|
3901
3928
|
refKey = _ref6$refKey === void 0 ? 'ref' : _ref6$refKey,
|
|
3902
3929
|
ref = _ref6.ref,
|
|
3903
3930
|
rest = _objectWithoutPropertiesLoose(_ref6, ["onKeyDown", "onChange", "onInput", "onBlur", "onChangeText", "refKey", "ref"]);
|
|
@@ -3920,13 +3947,13 @@
|
|
|
3920
3947
|
var inputHandleChange = function inputHandleChange(event) {
|
|
3921
3948
|
dispatch({
|
|
3922
3949
|
type: InputChange,
|
|
3923
|
-
inputValue:
|
|
3950
|
+
inputValue: event.target.value
|
|
3924
3951
|
});
|
|
3925
3952
|
};
|
|
3926
3953
|
|
|
3927
3954
|
var inputHandleBlur = function inputHandleBlur() {
|
|
3928
3955
|
/* istanbul ignore else */
|
|
3929
|
-
if (!mouseAndTouchTrackersRef.current.isMouseDown) {
|
|
3956
|
+
if (latestState.isOpen && !mouseAndTouchTrackersRef.current.isMouseDown) {
|
|
3930
3957
|
dispatch({
|
|
3931
3958
|
type: InputBlur,
|
|
3932
3959
|
selectItem: true
|
|
@@ -3936,7 +3963,7 @@
|
|
|
3936
3963
|
/* istanbul ignore next (preact) */
|
|
3937
3964
|
|
|
3938
3965
|
|
|
3939
|
-
var onChangeKey =
|
|
3966
|
+
var onChangeKey = 'onInput' ;
|
|
3940
3967
|
var eventHandlers = {};
|
|
3941
3968
|
|
|
3942
3969
|
if (!rest.disabled) {
|
|
@@ -3978,34 +4005,34 @@
|
|
|
3978
4005
|
|
|
3979
4006
|
var toggleMenu = preact.useCallback(function () {
|
|
3980
4007
|
dispatch({
|
|
3981
|
-
type: FunctionToggleMenu
|
|
4008
|
+
type: FunctionToggleMenu
|
|
3982
4009
|
});
|
|
3983
4010
|
}, [dispatch]);
|
|
3984
4011
|
var closeMenu = preact.useCallback(function () {
|
|
3985
4012
|
dispatch({
|
|
3986
|
-
type: FunctionCloseMenu
|
|
4013
|
+
type: FunctionCloseMenu
|
|
3987
4014
|
});
|
|
3988
4015
|
}, [dispatch]);
|
|
3989
4016
|
var openMenu = preact.useCallback(function () {
|
|
3990
4017
|
dispatch({
|
|
3991
|
-
type: FunctionOpenMenu
|
|
4018
|
+
type: FunctionOpenMenu
|
|
3992
4019
|
});
|
|
3993
4020
|
}, [dispatch]);
|
|
3994
4021
|
var setHighlightedIndex = preact.useCallback(function (newHighlightedIndex) {
|
|
3995
4022
|
dispatch({
|
|
3996
|
-
type: FunctionSetHighlightedIndex
|
|
4023
|
+
type: FunctionSetHighlightedIndex,
|
|
3997
4024
|
highlightedIndex: newHighlightedIndex
|
|
3998
4025
|
});
|
|
3999
4026
|
}, [dispatch]);
|
|
4000
4027
|
var selectItem = preact.useCallback(function (newSelectedItem) {
|
|
4001
4028
|
dispatch({
|
|
4002
|
-
type: FunctionSelectItem
|
|
4029
|
+
type: FunctionSelectItem,
|
|
4003
4030
|
selectedItem: newSelectedItem
|
|
4004
4031
|
});
|
|
4005
4032
|
}, [dispatch]);
|
|
4006
4033
|
var setInputValue = preact.useCallback(function (newInputValue) {
|
|
4007
4034
|
dispatch({
|
|
4008
|
-
type: FunctionSetInputValue
|
|
4035
|
+
type: FunctionSetInputValue,
|
|
4009
4036
|
inputValue: newInputValue
|
|
4010
4037
|
});
|
|
4011
4038
|
}, [dispatch]);
|
|
@@ -4052,8 +4079,8 @@
|
|
|
4052
4079
|
* @returns {any} The initial value for that prop.
|
|
4053
4080
|
*/
|
|
4054
4081
|
|
|
4055
|
-
function getInitialValue
|
|
4056
|
-
return getInitialValue(props, propKey, defaultStateValues);
|
|
4082
|
+
function getInitialValue(props, propKey) {
|
|
4083
|
+
return getInitialValue$1(props, propKey, defaultStateValues);
|
|
4057
4084
|
}
|
|
4058
4085
|
/**
|
|
4059
4086
|
* Returns the default value for a state key in the following order:
|
|
@@ -4065,8 +4092,8 @@
|
|
|
4065
4092
|
*/
|
|
4066
4093
|
|
|
4067
4094
|
|
|
4068
|
-
function getDefaultValue
|
|
4069
|
-
return getDefaultValue(props, propKey, defaultStateValues);
|
|
4095
|
+
function getDefaultValue(props, propKey) {
|
|
4096
|
+
return getDefaultValue$1(props, propKey, defaultStateValues);
|
|
4070
4097
|
}
|
|
4071
4098
|
/**
|
|
4072
4099
|
* Gets the initial state based on the provided props. It uses initial, default
|
|
@@ -4077,9 +4104,9 @@
|
|
|
4077
4104
|
*/
|
|
4078
4105
|
|
|
4079
4106
|
|
|
4080
|
-
function getInitialState
|
|
4081
|
-
var activeIndex = getInitialValue
|
|
4082
|
-
var selectedItems = getInitialValue
|
|
4107
|
+
function getInitialState(props) {
|
|
4108
|
+
var activeIndex = getInitialValue(props, 'activeIndex');
|
|
4109
|
+
var selectedItems = getInitialValue(props, 'selectedItems');
|
|
4083
4110
|
return {
|
|
4084
4111
|
activeIndex: activeIndex,
|
|
4085
4112
|
selectedItems: selectedItems
|
|
@@ -4126,7 +4153,7 @@
|
|
|
4126
4153
|
return itemToStringLocal(removedSelectedItem) + " has been removed.";
|
|
4127
4154
|
}
|
|
4128
4155
|
|
|
4129
|
-
var propTypes
|
|
4156
|
+
var propTypes = {
|
|
4130
4157
|
selectedItems: PropTypes__default['default'].array,
|
|
4131
4158
|
initialSelectedItems: PropTypes__default['default'].array,
|
|
4132
4159
|
defaultSelectedItems: PropTypes__default['default'].array,
|
|
@@ -4150,39 +4177,39 @@
|
|
|
4150
4177
|
})
|
|
4151
4178
|
})
|
|
4152
4179
|
};
|
|
4153
|
-
var defaultProps
|
|
4154
|
-
itemToString: defaultProps.itemToString,
|
|
4155
|
-
stateReducer: defaultProps.stateReducer,
|
|
4156
|
-
environment: defaultProps.environment,
|
|
4180
|
+
var defaultProps = {
|
|
4181
|
+
itemToString: defaultProps$3.itemToString,
|
|
4182
|
+
stateReducer: defaultProps$3.stateReducer,
|
|
4183
|
+
environment: defaultProps$3.environment,
|
|
4157
4184
|
getA11yRemovalMessage: getA11yRemovalMessage,
|
|
4158
4185
|
keyNavigationNext: 'ArrowRight',
|
|
4159
4186
|
keyNavigationPrevious: 'ArrowLeft'
|
|
4160
4187
|
}; // eslint-disable-next-line import/no-mutable-exports
|
|
4161
4188
|
|
|
4162
|
-
var validatePropTypes
|
|
4189
|
+
var validatePropTypes = noop;
|
|
4163
4190
|
/* istanbul ignore next */
|
|
4164
4191
|
|
|
4165
4192
|
{
|
|
4166
|
-
validatePropTypes
|
|
4167
|
-
PropTypes__default['default'].checkPropTypes(propTypes
|
|
4193
|
+
validatePropTypes = function validatePropTypes(options, caller) {
|
|
4194
|
+
PropTypes__default['default'].checkPropTypes(propTypes, options, 'prop', caller.name);
|
|
4168
4195
|
};
|
|
4169
4196
|
}
|
|
4170
4197
|
|
|
4171
|
-
var SelectedItemClick =
|
|
4172
|
-
var SelectedItemKeyDownDelete =
|
|
4173
|
-
var SelectedItemKeyDownBackspace =
|
|
4174
|
-
var SelectedItemKeyDownNavigationNext =
|
|
4175
|
-
var SelectedItemKeyDownNavigationPrevious =
|
|
4176
|
-
var DropdownKeyDownNavigationPrevious =
|
|
4177
|
-
var DropdownKeyDownBackspace =
|
|
4178
|
-
var DropdownClick =
|
|
4179
|
-
var FunctionAddSelectedItem =
|
|
4180
|
-
var FunctionRemoveSelectedItem =
|
|
4181
|
-
var FunctionSetSelectedItems =
|
|
4182
|
-
var FunctionSetActiveIndex =
|
|
4183
|
-
var FunctionReset
|
|
4198
|
+
var SelectedItemClick = '__selected_item_click__' ;
|
|
4199
|
+
var SelectedItemKeyDownDelete = '__selected_item_keydown_delete__' ;
|
|
4200
|
+
var SelectedItemKeyDownBackspace = '__selected_item_keydown_backspace__' ;
|
|
4201
|
+
var SelectedItemKeyDownNavigationNext = '__selected_item_keydown_navigation_next__' ;
|
|
4202
|
+
var SelectedItemKeyDownNavigationPrevious = '__selected_item_keydown_navigation_previous__' ;
|
|
4203
|
+
var DropdownKeyDownNavigationPrevious = '__dropdown_keydown_navigation_previous__' ;
|
|
4204
|
+
var DropdownKeyDownBackspace = '__dropdown_keydown_backspace__' ;
|
|
4205
|
+
var DropdownClick = '__dropdown_click__' ;
|
|
4206
|
+
var FunctionAddSelectedItem = '__function_add_selected_item__' ;
|
|
4207
|
+
var FunctionRemoveSelectedItem = '__function_remove_selected_item__' ;
|
|
4208
|
+
var FunctionSetSelectedItems = '__function_set_selected_items__' ;
|
|
4209
|
+
var FunctionSetActiveIndex = '__function_set_active_index__' ;
|
|
4210
|
+
var FunctionReset = '__function_reset__' ;
|
|
4184
4211
|
|
|
4185
|
-
var stateChangeTypes
|
|
4212
|
+
var stateChangeTypes = /*#__PURE__*/Object.freeze({
|
|
4186
4213
|
__proto__: null,
|
|
4187
4214
|
SelectedItemClick: SelectedItemClick,
|
|
4188
4215
|
SelectedItemKeyDownDelete: SelectedItemKeyDownDelete,
|
|
@@ -4196,7 +4223,7 @@
|
|
|
4196
4223
|
FunctionRemoveSelectedItem: FunctionRemoveSelectedItem,
|
|
4197
4224
|
FunctionSetSelectedItems: FunctionSetSelectedItems,
|
|
4198
4225
|
FunctionSetActiveIndex: FunctionSetActiveIndex,
|
|
4199
|
-
FunctionReset: FunctionReset
|
|
4226
|
+
FunctionReset: FunctionReset
|
|
4200
4227
|
});
|
|
4201
4228
|
|
|
4202
4229
|
/* eslint-disable complexity */
|
|
@@ -4309,10 +4336,10 @@
|
|
|
4309
4336
|
break;
|
|
4310
4337
|
}
|
|
4311
4338
|
|
|
4312
|
-
case FunctionReset
|
|
4339
|
+
case FunctionReset:
|
|
4313
4340
|
changes = {
|
|
4314
|
-
activeIndex: getDefaultValue
|
|
4315
|
-
selectedItems: getDefaultValue
|
|
4341
|
+
activeIndex: getDefaultValue(props, 'activeIndex'),
|
|
4342
|
+
selectedItems: getDefaultValue(props, 'selectedItems')
|
|
4316
4343
|
};
|
|
4317
4344
|
break;
|
|
4318
4345
|
|
|
@@ -4323,16 +4350,16 @@
|
|
|
4323
4350
|
return _extends({}, state, changes);
|
|
4324
4351
|
}
|
|
4325
4352
|
|
|
4326
|
-
useMultipleSelection.stateChangeTypes = stateChangeTypes
|
|
4353
|
+
useMultipleSelection.stateChangeTypes = stateChangeTypes;
|
|
4327
4354
|
|
|
4328
4355
|
function useMultipleSelection(userProps) {
|
|
4329
4356
|
if (userProps === void 0) {
|
|
4330
4357
|
userProps = {};
|
|
4331
4358
|
}
|
|
4332
4359
|
|
|
4333
|
-
validatePropTypes
|
|
4360
|
+
validatePropTypes(userProps, useMultipleSelection); // Props defaults and destructuring.
|
|
4334
4361
|
|
|
4335
|
-
var props = _extends({}, defaultProps
|
|
4362
|
+
var props = _extends({}, defaultProps, userProps);
|
|
4336
4363
|
|
|
4337
4364
|
var getA11yRemovalMessage = props.getA11yRemovalMessage,
|
|
4338
4365
|
itemToString = props.itemToString,
|
|
@@ -4340,7 +4367,7 @@
|
|
|
4340
4367
|
keyNavigationNext = props.keyNavigationNext,
|
|
4341
4368
|
keyNavigationPrevious = props.keyNavigationPrevious; // Reducer init.
|
|
4342
4369
|
|
|
4343
|
-
var _useControlledReducer = useControlledReducer(downshiftMultipleSelectionReducer, getInitialState
|
|
4370
|
+
var _useControlledReducer = useControlledReducer$1(downshiftMultipleSelectionReducer, getInitialState(props), props),
|
|
4344
4371
|
state = _useControlledReducer[0],
|
|
4345
4372
|
dispatch = _useControlledReducer[1];
|
|
4346
4373
|
|
|
@@ -4551,7 +4578,7 @@
|
|
|
4551
4578
|
}, [dispatch]);
|
|
4552
4579
|
var reset = preact.useCallback(function () {
|
|
4553
4580
|
dispatch({
|
|
4554
|
-
type: FunctionReset
|
|
4581
|
+
type: FunctionReset
|
|
4555
4582
|
});
|
|
4556
4583
|
}, [dispatch]);
|
|
4557
4584
|
return {
|