downshift 9.0.4 → 9.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/downshift.cjs.js +254 -234
- package/dist/downshift.esm.js +92 -64
- package/dist/downshift.native.cjs.js +254 -234
- package/dist/downshift.nativeweb.cjs.js +254 -234
- package/dist/downshift.umd.js +133 -108
- package/dist/downshift.umd.js.map +1 -1
- package/dist/downshift.umd.min.js +1 -1
- package/dist/downshift.umd.min.js.map +1 -1
- package/dist/src/hooks/utils.d.ts +7 -0
- package/package.json +37 -37
- package/preact/dist/downshift.cjs.js +216 -196
- package/preact/dist/downshift.esm.js +92 -64
- package/preact/dist/downshift.umd.js +187 -163
- package/preact/dist/downshift.umd.js.map +1 -1
- package/preact/dist/downshift.umd.min.js +2 -2
- package/preact/dist/downshift.umd.min.js.map +1 -1
|
@@ -11,14 +11,6 @@ var reactIs = require('react-is');
|
|
|
11
11
|
var computeScrollIntoView = require('compute-scroll-into-view');
|
|
12
12
|
var tslib = require('tslib');
|
|
13
13
|
|
|
14
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
15
|
-
|
|
16
|
-
var _objectWithoutPropertiesLoose__default = /*#__PURE__*/_interopDefaultLegacy(_objectWithoutPropertiesLoose);
|
|
17
|
-
var _extends__default = /*#__PURE__*/_interopDefaultLegacy(_extends);
|
|
18
|
-
var _inheritsLoose__default = /*#__PURE__*/_interopDefaultLegacy(_inheritsLoose);
|
|
19
|
-
var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
20
|
-
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
21
|
-
|
|
22
14
|
var idCounter = 0;
|
|
23
15
|
|
|
24
16
|
/**
|
|
@@ -137,7 +129,7 @@ function generateId() {
|
|
|
137
129
|
*/
|
|
138
130
|
function resetIdCounter() {
|
|
139
131
|
// istanbul ignore next
|
|
140
|
-
if ('useId' in
|
|
132
|
+
if ('useId' in React) {
|
|
141
133
|
console.warn("It is not necessary to call resetIdCounter when using React 18+");
|
|
142
134
|
return;
|
|
143
135
|
}
|
|
@@ -452,23 +444,23 @@ var touchEnd = process.env.NODE_ENV !== "production" ? '__autocomplete_touchend_
|
|
|
452
444
|
|
|
453
445
|
var stateChangeTypes$3 = /*#__PURE__*/Object.freeze({
|
|
454
446
|
__proto__: null,
|
|
455
|
-
|
|
456
|
-
|
|
447
|
+
blurButton: blurButton,
|
|
448
|
+
blurInput: blurInput,
|
|
449
|
+
changeInput: changeInput,
|
|
450
|
+
clickButton: clickButton,
|
|
451
|
+
clickItem: clickItem,
|
|
452
|
+
controlledPropUpdatedSelectedItem: controlledPropUpdatedSelectedItem,
|
|
457
453
|
itemMouseEnter: itemMouseEnter,
|
|
458
|
-
keyDownArrowUp: keyDownArrowUp,
|
|
459
454
|
keyDownArrowDown: keyDownArrowDown,
|
|
460
|
-
|
|
455
|
+
keyDownArrowUp: keyDownArrowUp,
|
|
456
|
+
keyDownEnd: keyDownEnd,
|
|
461
457
|
keyDownEnter: keyDownEnter,
|
|
458
|
+
keyDownEscape: keyDownEscape,
|
|
462
459
|
keyDownHome: keyDownHome,
|
|
463
|
-
keyDownEnd: keyDownEnd,
|
|
464
|
-
clickItem: clickItem,
|
|
465
|
-
blurInput: blurInput,
|
|
466
|
-
changeInput: changeInput,
|
|
467
460
|
keyDownSpaceButton: keyDownSpaceButton,
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
touchEnd: touchEnd
|
|
461
|
+
mouseUp: mouseUp,
|
|
462
|
+
touchEnd: touchEnd,
|
|
463
|
+
unknown: unknown
|
|
472
464
|
});
|
|
473
465
|
|
|
474
466
|
var _excluded$3 = ["refKey", "ref"],
|
|
@@ -531,7 +523,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
531
523
|
otherStateToSet = {};
|
|
532
524
|
}
|
|
533
525
|
otherStateToSet = pickState(otherStateToSet);
|
|
534
|
-
_this.internalSetState(
|
|
526
|
+
_this.internalSetState(_extends({
|
|
535
527
|
highlightedIndex: highlightedIndex
|
|
536
528
|
}, otherStateToSet));
|
|
537
529
|
};
|
|
@@ -545,7 +537,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
545
537
|
};
|
|
546
538
|
_this.selectItem = function (item, otherStateToSet, cb) {
|
|
547
539
|
otherStateToSet = pickState(otherStateToSet);
|
|
548
|
-
_this.internalSetState(
|
|
540
|
+
_this.internalSetState(_extends({
|
|
549
541
|
isOpen: _this.props.defaultIsOpen,
|
|
550
542
|
highlightedIndex: _this.props.defaultHighlightedIndex,
|
|
551
543
|
selectedItem: item,
|
|
@@ -581,7 +573,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
581
573
|
// preserving the cursor position.
|
|
582
574
|
// See https://github.com/downshift-js/downshift/issues/217 for more info.
|
|
583
575
|
if (!isStateToSetFunction && stateToSet.hasOwnProperty('inputValue')) {
|
|
584
|
-
_this.props.onInputValueChange(stateToSet.inputValue,
|
|
576
|
+
_this.props.onInputValueChange(stateToSet.inputValue, _extends({}, _this.getStateAndHelpers(), stateToSet));
|
|
585
577
|
}
|
|
586
578
|
return _this.setState(function (state) {
|
|
587
579
|
var _newStateToSet;
|
|
@@ -629,7 +621,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
629
621
|
// if stateToSet is a function, then we weren't able to call onInputValueChange
|
|
630
622
|
// earlier, so we'll call it now that we know what the inputValue state will be.
|
|
631
623
|
if (isStateToSetFunction && newStateToSet.hasOwnProperty('inputValue')) {
|
|
632
|
-
_this.props.onInputValueChange(newStateToSet.inputValue,
|
|
624
|
+
_this.props.onInputValueChange(newStateToSet.inputValue, _extends({}, _this.getStateAndHelpers(), newStateToSet));
|
|
633
625
|
}
|
|
634
626
|
return nextState;
|
|
635
627
|
}, function () {
|
|
@@ -663,7 +655,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
663
655
|
_ref$refKey = _ref.refKey,
|
|
664
656
|
refKey = _ref$refKey === void 0 ? 'ref' : _ref$refKey,
|
|
665
657
|
ref = _ref.ref,
|
|
666
|
-
rest =
|
|
658
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$3);
|
|
667
659
|
var _ref2 = _temp2 === void 0 ? {} : _temp2,
|
|
668
660
|
_ref2$suppressRefErro = _ref2.suppressRefError,
|
|
669
661
|
suppressRefError = _ref2$suppressRefErro === void 0 ? false : _ref2$suppressRefErro;
|
|
@@ -674,7 +666,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
674
666
|
_this.getRootProps.suppressRefError = suppressRefError;
|
|
675
667
|
var _this$getState = _this.getState(),
|
|
676
668
|
isOpen = _this$getState.isOpen;
|
|
677
|
-
return
|
|
669
|
+
return _extends((_extends2 = {}, _extends2[refKey] = handleRefs(ref, _this.rootRef), _extends2.role = 'combobox', _extends2['aria-expanded'] = isOpen, _extends2['aria-haspopup'] = 'listbox', _extends2['aria-owns'] = isOpen ? _this.menuId : undefined, _extends2['aria-labelledby'] = _this.labelId, _extends2), rest);
|
|
678
670
|
};
|
|
679
671
|
//\\\\\\\\\\\\\\\\\\\\\\\\\\ ROOT
|
|
680
672
|
_this.keyDownHandlers = {
|
|
@@ -753,7 +745,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
753
745
|
},
|
|
754
746
|
Escape: function Escape(event) {
|
|
755
747
|
event.preventDefault();
|
|
756
|
-
this.reset(
|
|
748
|
+
this.reset(_extends({
|
|
757
749
|
type: keyDownEscape
|
|
758
750
|
}, !this.state.isOpen && {
|
|
759
751
|
selectedItem: null,
|
|
@@ -762,7 +754,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
762
754
|
}
|
|
763
755
|
};
|
|
764
756
|
//////////////////////////// BUTTON
|
|
765
|
-
_this.buttonKeyDownHandlers =
|
|
757
|
+
_this.buttonKeyDownHandlers = _extends({}, _this.keyDownHandlers, {
|
|
766
758
|
' ': function _(event) {
|
|
767
759
|
event.preventDefault();
|
|
768
760
|
this.toggleMenu({
|
|
@@ -770,7 +762,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
770
762
|
});
|
|
771
763
|
}
|
|
772
764
|
});
|
|
773
|
-
_this.inputKeyDownHandlers =
|
|
765
|
+
_this.inputKeyDownHandlers = _extends({}, _this.keyDownHandlers, {
|
|
774
766
|
Home: function Home(event) {
|
|
775
767
|
var _this$getState3 = this.getState(),
|
|
776
768
|
isOpen = _this$getState3.isOpen;
|
|
@@ -819,7 +811,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
819
811
|
_ref3.onKeyDown;
|
|
820
812
|
_ref3.onKeyUp;
|
|
821
813
|
_ref3.onBlur;
|
|
822
|
-
var rest =
|
|
814
|
+
var rest = _objectWithoutPropertiesLoose(_ref3, _excluded2$3);
|
|
823
815
|
var _this$getState5 = _this.getState(),
|
|
824
816
|
isOpen = _this$getState5.isOpen;
|
|
825
817
|
var enabledEventHandlers = /* istanbul ignore next (react-native) */
|
|
@@ -827,7 +819,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
827
819
|
onPress: callAllEventHandlers(onPress, _this.buttonHandleClick)
|
|
828
820
|
} ;
|
|
829
821
|
var eventHandlers = rest.disabled ? {} : enabledEventHandlers;
|
|
830
|
-
return
|
|
822
|
+
return _extends({
|
|
831
823
|
type: 'button',
|
|
832
824
|
role: 'button',
|
|
833
825
|
'aria-label': isOpen ? 'close menu' : 'open menu',
|
|
@@ -882,7 +874,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
882
874
|
//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ BUTTON
|
|
883
875
|
/////////////////////////////// LABEL
|
|
884
876
|
_this.getLabelProps = function (props) {
|
|
885
|
-
return
|
|
877
|
+
return _extends({
|
|
886
878
|
htmlFor: _this.inputId,
|
|
887
879
|
id: _this.labelId
|
|
888
880
|
}, props);
|
|
@@ -896,7 +888,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
896
888
|
onChange = _ref4.onChange,
|
|
897
889
|
onInput = _ref4.onInput,
|
|
898
890
|
onChangeText = _ref4.onChangeText,
|
|
899
|
-
rest =
|
|
891
|
+
rest = _objectWithoutPropertiesLoose(_ref4, _excluded3$2);
|
|
900
892
|
var onChangeKey;
|
|
901
893
|
var eventHandlers = {};
|
|
902
894
|
|
|
@@ -927,7 +919,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
927
919
|
onBlur: callAllEventHandlers(onBlur, _this.inputHandleBlur)
|
|
928
920
|
};
|
|
929
921
|
}
|
|
930
|
-
return
|
|
922
|
+
return _extends({
|
|
931
923
|
'aria-autocomplete': 'list',
|
|
932
924
|
'aria-activedescendant': isOpen && typeof highlightedIndex === 'number' && highlightedIndex >= 0 ? _this.getItemId(highlightedIndex) : undefined,
|
|
933
925
|
'aria-controls': isOpen ? _this.menuId : undefined,
|
|
@@ -980,14 +972,14 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
980
972
|
_ref5$refKey = _ref5.refKey,
|
|
981
973
|
refKey = _ref5$refKey === void 0 ? 'ref' : _ref5$refKey,
|
|
982
974
|
ref = _ref5.ref,
|
|
983
|
-
props =
|
|
975
|
+
props = _objectWithoutPropertiesLoose(_ref5, _excluded4$2);
|
|
984
976
|
var _ref6 = _temp6 === void 0 ? {} : _temp6,
|
|
985
977
|
_ref6$suppressRefErro = _ref6.suppressRefError,
|
|
986
978
|
suppressRefError = _ref6$suppressRefErro === void 0 ? false : _ref6$suppressRefErro;
|
|
987
979
|
_this.getMenuProps.called = true;
|
|
988
980
|
_this.getMenuProps.refKey = refKey;
|
|
989
981
|
_this.getMenuProps.suppressRefError = suppressRefError;
|
|
990
|
-
return
|
|
982
|
+
return _extends((_extends3 = {}, _extends3[refKey] = handleRefs(ref, _this.menuRef), _extends3.role = 'listbox', _extends3['aria-labelledby'] = props && props['aria-label'] ? undefined : _this.labelId, _extends3.id = _this.menuId, _extends3), props);
|
|
991
983
|
};
|
|
992
984
|
//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ MENU
|
|
993
985
|
/////////////////////////////// ITEM
|
|
@@ -1001,7 +993,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1001
993
|
index = _ref7.index,
|
|
1002
994
|
_ref7$item = _ref7.item,
|
|
1003
995
|
item = _ref7$item === void 0 ? process.env.NODE_ENV === 'production' ? /* istanbul ignore next */undefined : requiredProp('getItemProps', 'item') : _ref7$item,
|
|
1004
|
-
rest =
|
|
996
|
+
rest = _objectWithoutPropertiesLoose(_ref7, _excluded5);
|
|
1005
997
|
if (index === undefined) {
|
|
1006
998
|
_this.items.push(item);
|
|
1007
999
|
index = _this.items.indexOf(item);
|
|
@@ -1048,7 +1040,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1048
1040
|
var eventHandlers = rest.disabled ? {
|
|
1049
1041
|
onMouseDown: enabledEventHandlers.onMouseDown
|
|
1050
1042
|
} : enabledEventHandlers;
|
|
1051
|
-
return
|
|
1043
|
+
return _extends({
|
|
1052
1044
|
id: _this.getItemId(index),
|
|
1053
1045
|
role: 'option',
|
|
1054
1046
|
'aria-selected': _this.getState().highlightedIndex === index
|
|
@@ -1065,7 +1057,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1065
1057
|
otherStateToSet = pickState(otherStateToSet);
|
|
1066
1058
|
_this.internalSetState(function (_ref8) {
|
|
1067
1059
|
var selectedItem = _ref8.selectedItem;
|
|
1068
|
-
return
|
|
1060
|
+
return _extends({
|
|
1069
1061
|
isOpen: _this.props.defaultIsOpen,
|
|
1070
1062
|
highlightedIndex: _this.props.defaultHighlightedIndex,
|
|
1071
1063
|
inputValue: _this.props.itemToString(selectedItem)
|
|
@@ -1079,7 +1071,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1079
1071
|
otherStateToSet = pickState(otherStateToSet);
|
|
1080
1072
|
_this.internalSetState(function (_ref9) {
|
|
1081
1073
|
var isOpen = _ref9.isOpen;
|
|
1082
|
-
return
|
|
1074
|
+
return _extends({
|
|
1083
1075
|
isOpen: !isOpen
|
|
1084
1076
|
}, isOpen && {
|
|
1085
1077
|
highlightedIndex: _this.props.defaultHighlightedIndex
|
|
@@ -1114,7 +1106,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1114
1106
|
var state = _this.getState();
|
|
1115
1107
|
var item = _this.items[state.highlightedIndex];
|
|
1116
1108
|
var resultCount = _this.getItemCount();
|
|
1117
|
-
var status = _this.props.getA11yStatusMessage(
|
|
1109
|
+
var status = _this.props.getA11yStatusMessage(_extends({
|
|
1118
1110
|
itemToString: _this.props.itemToString,
|
|
1119
1111
|
previousResultCount: _this.previousResultCount,
|
|
1120
1112
|
resultCount: resultCount,
|
|
@@ -1146,7 +1138,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1146
1138
|
_this.state = _state;
|
|
1147
1139
|
return _this;
|
|
1148
1140
|
}
|
|
1149
|
-
|
|
1141
|
+
_inheritsLoose(Downshift, _Component);
|
|
1150
1142
|
var _proto = Downshift.prototype;
|
|
1151
1143
|
/**
|
|
1152
1144
|
* Clear all running timeouts
|
|
@@ -1386,49 +1378,49 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1386
1378
|
return Downshift;
|
|
1387
1379
|
}();
|
|
1388
1380
|
process.env.NODE_ENV !== "production" ? Downshift.propTypes = {
|
|
1389
|
-
children:
|
|
1390
|
-
defaultHighlightedIndex:
|
|
1391
|
-
defaultIsOpen:
|
|
1392
|
-
initialHighlightedIndex:
|
|
1393
|
-
initialSelectedItem:
|
|
1394
|
-
initialInputValue:
|
|
1395
|
-
initialIsOpen:
|
|
1396
|
-
getA11yStatusMessage:
|
|
1397
|
-
itemToString:
|
|
1398
|
-
onChange:
|
|
1399
|
-
onSelect:
|
|
1400
|
-
onStateChange:
|
|
1401
|
-
onInputValueChange:
|
|
1402
|
-
onUserAction:
|
|
1403
|
-
onOuterClick:
|
|
1404
|
-
selectedItemChanged:
|
|
1405
|
-
stateReducer:
|
|
1406
|
-
itemCount:
|
|
1407
|
-
id:
|
|
1408
|
-
environment:
|
|
1409
|
-
addEventListener:
|
|
1410
|
-
removeEventListener:
|
|
1411
|
-
document:
|
|
1412
|
-
createElement:
|
|
1413
|
-
getElementById:
|
|
1414
|
-
activeElement:
|
|
1415
|
-
body:
|
|
1381
|
+
children: PropTypes.func,
|
|
1382
|
+
defaultHighlightedIndex: PropTypes.number,
|
|
1383
|
+
defaultIsOpen: PropTypes.bool,
|
|
1384
|
+
initialHighlightedIndex: PropTypes.number,
|
|
1385
|
+
initialSelectedItem: PropTypes.any,
|
|
1386
|
+
initialInputValue: PropTypes.string,
|
|
1387
|
+
initialIsOpen: PropTypes.bool,
|
|
1388
|
+
getA11yStatusMessage: PropTypes.func,
|
|
1389
|
+
itemToString: PropTypes.func,
|
|
1390
|
+
onChange: PropTypes.func,
|
|
1391
|
+
onSelect: PropTypes.func,
|
|
1392
|
+
onStateChange: PropTypes.func,
|
|
1393
|
+
onInputValueChange: PropTypes.func,
|
|
1394
|
+
onUserAction: PropTypes.func,
|
|
1395
|
+
onOuterClick: PropTypes.func,
|
|
1396
|
+
selectedItemChanged: PropTypes.func,
|
|
1397
|
+
stateReducer: PropTypes.func,
|
|
1398
|
+
itemCount: PropTypes.number,
|
|
1399
|
+
id: PropTypes.string,
|
|
1400
|
+
environment: PropTypes.shape({
|
|
1401
|
+
addEventListener: PropTypes.func.isRequired,
|
|
1402
|
+
removeEventListener: PropTypes.func.isRequired,
|
|
1403
|
+
document: PropTypes.shape({
|
|
1404
|
+
createElement: PropTypes.func.isRequired,
|
|
1405
|
+
getElementById: PropTypes.func.isRequired,
|
|
1406
|
+
activeElement: PropTypes.any.isRequired,
|
|
1407
|
+
body: PropTypes.any.isRequired
|
|
1416
1408
|
}).isRequired,
|
|
1417
|
-
Node:
|
|
1409
|
+
Node: PropTypes.func.isRequired
|
|
1418
1410
|
}),
|
|
1419
|
-
suppressRefError:
|
|
1420
|
-
scrollIntoView:
|
|
1411
|
+
suppressRefError: PropTypes.bool,
|
|
1412
|
+
scrollIntoView: PropTypes.func,
|
|
1421
1413
|
// things we keep in state for uncontrolled components
|
|
1422
1414
|
// but can accept as props for controlled components
|
|
1423
1415
|
/* eslint-disable react/no-unused-prop-types */
|
|
1424
|
-
selectedItem:
|
|
1425
|
-
isOpen:
|
|
1426
|
-
inputValue:
|
|
1427
|
-
highlightedIndex:
|
|
1428
|
-
labelId:
|
|
1429
|
-
inputId:
|
|
1430
|
-
menuId:
|
|
1431
|
-
getItemId:
|
|
1416
|
+
selectedItem: PropTypes.any,
|
|
1417
|
+
isOpen: PropTypes.bool,
|
|
1418
|
+
inputValue: PropTypes.string,
|
|
1419
|
+
highlightedIndex: PropTypes.number,
|
|
1420
|
+
labelId: PropTypes.string,
|
|
1421
|
+
inputId: PropTypes.string,
|
|
1422
|
+
menuId: PropTypes.string,
|
|
1423
|
+
getItemId: PropTypes.func
|
|
1432
1424
|
/* eslint-enable react/no-unused-prop-types */
|
|
1433
1425
|
} : void 0;
|
|
1434
1426
|
var Downshift$1 = Downshift;
|
|
@@ -1473,7 +1465,7 @@ function callOnChangeProps(action, state, newState) {
|
|
|
1473
1465
|
}
|
|
1474
1466
|
});
|
|
1475
1467
|
if (props.onStateChange && Object.keys(changes).length) {
|
|
1476
|
-
props.onStateChange(
|
|
1468
|
+
props.onStateChange(_extends({
|
|
1477
1469
|
type: type
|
|
1478
1470
|
}, changes));
|
|
1479
1471
|
}
|
|
@@ -1483,7 +1475,7 @@ function invokeOnChangeHandler(key, action, state, newState) {
|
|
|
1483
1475
|
type = action.type;
|
|
1484
1476
|
var handler = "on" + capitalizeString(key) + "Change";
|
|
1485
1477
|
if (props[handler] && newState[key] !== undefined && newState[key] !== state[key]) {
|
|
1486
|
-
props[handler](
|
|
1478
|
+
props[handler](_extends({
|
|
1487
1479
|
type: type
|
|
1488
1480
|
}, newState));
|
|
1489
1481
|
}
|
|
@@ -1511,7 +1503,7 @@ var updateA11yStatus = debounce(function (status, document) {
|
|
|
1511
1503
|
var useIsomorphicLayoutEffect = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined' ? React.useLayoutEffect : React.useEffect;
|
|
1512
1504
|
|
|
1513
1505
|
// istanbul ignore next
|
|
1514
|
-
var useElementIds = 'useId' in
|
|
1506
|
+
var useElementIds = 'useId' in React // Avoid conditional useId call
|
|
1515
1507
|
? function useElementIds(_ref) {
|
|
1516
1508
|
var id = _ref.id,
|
|
1517
1509
|
labelId = _ref.labelId,
|
|
@@ -1520,7 +1512,7 @@ var useElementIds = 'useId' in React__default["default"] // Avoid conditional us
|
|
|
1520
1512
|
toggleButtonId = _ref.toggleButtonId,
|
|
1521
1513
|
inputId = _ref.inputId;
|
|
1522
1514
|
// Avoid conditional useId call
|
|
1523
|
-
var reactId = "downshift-" +
|
|
1515
|
+
var reactId = "downshift-" + React.useId();
|
|
1524
1516
|
if (!id) {
|
|
1525
1517
|
id = reactId;
|
|
1526
1518
|
}
|
|
@@ -1599,7 +1591,7 @@ function useEnhancedReducer(reducer, props, createInitialState, isStateEqual) {
|
|
|
1599
1591
|
actionRef.current = action;
|
|
1600
1592
|
state = getState(state, action.props);
|
|
1601
1593
|
var changes = reducer(state, action);
|
|
1602
|
-
var newState = action.props.stateReducer(state,
|
|
1594
|
+
var newState = action.props.stateReducer(state, _extends({}, action, {
|
|
1603
1595
|
changes: changes
|
|
1604
1596
|
}));
|
|
1605
1597
|
return newState;
|
|
@@ -1609,7 +1601,7 @@ function useEnhancedReducer(reducer, props, createInitialState, isStateEqual) {
|
|
|
1609
1601
|
dispatch = _useReducer[1];
|
|
1610
1602
|
var propsRef = useLatestRef(props);
|
|
1611
1603
|
var dispatchWithProps = React.useCallback(function (action) {
|
|
1612
|
-
return dispatch(
|
|
1604
|
+
return dispatch(_extends({
|
|
1613
1605
|
props: propsRef.current
|
|
1614
1606
|
}, action));
|
|
1615
1607
|
}, [propsRef]);
|
|
@@ -1680,7 +1672,7 @@ function getInitialValue$1(props, propKey, defaultStateValues) {
|
|
|
1680
1672
|
function getInitialState$2(props) {
|
|
1681
1673
|
var selectedItem = getInitialValue$1(props, 'selectedItem');
|
|
1682
1674
|
var isOpen = getInitialValue$1(props, 'isOpen');
|
|
1683
|
-
var highlightedIndex =
|
|
1675
|
+
var highlightedIndex = getInitialHighlightedIndex(props);
|
|
1684
1676
|
var inputValue = getInitialValue$1(props, 'inputValue');
|
|
1685
1677
|
return {
|
|
1686
1678
|
highlightedIndex: highlightedIndex < 0 && selectedItem && isOpen ? props.items.findIndex(function (item) {
|
|
@@ -1704,10 +1696,10 @@ function getHighlightedIndexOnOpen(props, state, offset) {
|
|
|
1704
1696
|
}
|
|
1705
1697
|
|
|
1706
1698
|
// initialHighlightedIndex will give value to highlightedIndex on initial state only.
|
|
1707
|
-
if (initialHighlightedIndex !== undefined && highlightedIndex === initialHighlightedIndex && !isItemDisabled(items[initialHighlightedIndex])) {
|
|
1699
|
+
if (initialHighlightedIndex !== undefined && highlightedIndex === initialHighlightedIndex && !isItemDisabled(items[initialHighlightedIndex], initialHighlightedIndex)) {
|
|
1708
1700
|
return initialHighlightedIndex;
|
|
1709
1701
|
}
|
|
1710
|
-
if (defaultHighlightedIndex !== undefined && !isItemDisabled(items[defaultHighlightedIndex])) {
|
|
1702
|
+
if (defaultHighlightedIndex !== undefined && !isItemDisabled(items[defaultHighlightedIndex], defaultHighlightedIndex)) {
|
|
1711
1703
|
return defaultHighlightedIndex;
|
|
1712
1704
|
}
|
|
1713
1705
|
if (selectedItem) {
|
|
@@ -1715,10 +1707,10 @@ function getHighlightedIndexOnOpen(props, state, offset) {
|
|
|
1715
1707
|
return itemToKey(selectedItem) === itemToKey(item);
|
|
1716
1708
|
});
|
|
1717
1709
|
}
|
|
1718
|
-
if (offset < 0 && !isItemDisabled(items[items.length - 1])) {
|
|
1710
|
+
if (offset < 0 && !isItemDisabled(items[items.length - 1], items.length - 1)) {
|
|
1719
1711
|
return items.length - 1;
|
|
1720
1712
|
}
|
|
1721
|
-
if (offset > 0 && !isItemDisabled(items[0])) {
|
|
1713
|
+
if (offset > 0 && !isItemDisabled(items[0], 0)) {
|
|
1722
1714
|
return 0;
|
|
1723
1715
|
}
|
|
1724
1716
|
return -1;
|
|
@@ -1890,10 +1882,10 @@ function getChangesOnSelection(props, highlightedIndex, inputValue) {
|
|
|
1890
1882
|
inputValue = true;
|
|
1891
1883
|
}
|
|
1892
1884
|
var shouldSelect = ((_props$items = props.items) == null ? void 0 : _props$items.length) && highlightedIndex >= 0;
|
|
1893
|
-
return
|
|
1885
|
+
return _extends({
|
|
1894
1886
|
isOpen: false,
|
|
1895
1887
|
highlightedIndex: -1
|
|
1896
|
-
}, shouldSelect &&
|
|
1888
|
+
}, shouldSelect && _extends({
|
|
1897
1889
|
selectedItem: props.items[highlightedIndex],
|
|
1898
1890
|
isOpen: getDefaultValue$1(props, 'isOpen'),
|
|
1899
1891
|
highlightedIndex: getDefaultValue$1(props, 'highlightedIndex')
|
|
@@ -1918,8 +1910,8 @@ function isDropdownsStateEqual(prevState, newState) {
|
|
|
1918
1910
|
* Tracks if it's the first render.
|
|
1919
1911
|
*/
|
|
1920
1912
|
function useIsInitialMount() {
|
|
1921
|
-
var isInitialMountRef =
|
|
1922
|
-
|
|
1913
|
+
var isInitialMountRef = React.useRef(true);
|
|
1914
|
+
React.useEffect(function () {
|
|
1923
1915
|
isInitialMountRef.current = false;
|
|
1924
1916
|
return function () {
|
|
1925
1917
|
isInitialMountRef.current = true;
|
|
@@ -1928,46 +1920,74 @@ function useIsInitialMount() {
|
|
|
1928
1920
|
return isInitialMountRef.current;
|
|
1929
1921
|
}
|
|
1930
1922
|
|
|
1923
|
+
/**
|
|
1924
|
+
* Returns the new highlightedIndex based on the defaultHighlightedIndex prop, if it's not disabled.
|
|
1925
|
+
*
|
|
1926
|
+
* @param {Object} props Props from useCombobox or useSelect.
|
|
1927
|
+
* @returns {number} The highlighted index.
|
|
1928
|
+
*/
|
|
1929
|
+
function getDefaultHighlightedIndex(props) {
|
|
1930
|
+
var highlightedIndex = getDefaultValue$1(props, 'highlightedIndex');
|
|
1931
|
+
if (highlightedIndex > -1 && props.isItemDisabled(props.items[highlightedIndex], highlightedIndex)) {
|
|
1932
|
+
return -1;
|
|
1933
|
+
}
|
|
1934
|
+
return highlightedIndex;
|
|
1935
|
+
}
|
|
1936
|
+
|
|
1937
|
+
/**
|
|
1938
|
+
* Returns the new highlightedIndex based on the initialHighlightedIndex prop, if not disabled.
|
|
1939
|
+
*
|
|
1940
|
+
* @param {Object} props Props from useCombobox or useSelect.
|
|
1941
|
+
* @returns {number} The highlighted index.
|
|
1942
|
+
*/
|
|
1943
|
+
function getInitialHighlightedIndex(props) {
|
|
1944
|
+
var highlightedIndex = getInitialValue$1(props, 'highlightedIndex');
|
|
1945
|
+
if (highlightedIndex > -1 && props.isItemDisabled(props.items[highlightedIndex], highlightedIndex)) {
|
|
1946
|
+
return -1;
|
|
1947
|
+
}
|
|
1948
|
+
return highlightedIndex;
|
|
1949
|
+
}
|
|
1950
|
+
|
|
1931
1951
|
// Shared between all exports.
|
|
1932
1952
|
var commonPropTypes = {
|
|
1933
|
-
environment:
|
|
1934
|
-
addEventListener:
|
|
1935
|
-
removeEventListener:
|
|
1936
|
-
document:
|
|
1937
|
-
createElement:
|
|
1938
|
-
getElementById:
|
|
1939
|
-
activeElement:
|
|
1940
|
-
body:
|
|
1953
|
+
environment: PropTypes.shape({
|
|
1954
|
+
addEventListener: PropTypes.func.isRequired,
|
|
1955
|
+
removeEventListener: PropTypes.func.isRequired,
|
|
1956
|
+
document: PropTypes.shape({
|
|
1957
|
+
createElement: PropTypes.func.isRequired,
|
|
1958
|
+
getElementById: PropTypes.func.isRequired,
|
|
1959
|
+
activeElement: PropTypes.any.isRequired,
|
|
1960
|
+
body: PropTypes.any.isRequired
|
|
1941
1961
|
}).isRequired,
|
|
1942
|
-
Node:
|
|
1962
|
+
Node: PropTypes.func.isRequired
|
|
1943
1963
|
}),
|
|
1944
|
-
itemToString:
|
|
1945
|
-
itemToKey:
|
|
1946
|
-
stateReducer:
|
|
1964
|
+
itemToString: PropTypes.func,
|
|
1965
|
+
itemToKey: PropTypes.func,
|
|
1966
|
+
stateReducer: PropTypes.func
|
|
1947
1967
|
};
|
|
1948
1968
|
|
|
1949
1969
|
// Shared between useSelect, useCombobox, Downshift.
|
|
1950
|
-
var commonDropdownPropTypes =
|
|
1951
|
-
getA11yStatusMessage:
|
|
1952
|
-
highlightedIndex:
|
|
1953
|
-
defaultHighlightedIndex:
|
|
1954
|
-
initialHighlightedIndex:
|
|
1955
|
-
isOpen:
|
|
1956
|
-
defaultIsOpen:
|
|
1957
|
-
initialIsOpen:
|
|
1958
|
-
selectedItem:
|
|
1959
|
-
initialSelectedItem:
|
|
1960
|
-
defaultSelectedItem:
|
|
1961
|
-
id:
|
|
1962
|
-
labelId:
|
|
1963
|
-
menuId:
|
|
1964
|
-
getItemId:
|
|
1965
|
-
toggleButtonId:
|
|
1966
|
-
onSelectedItemChange:
|
|
1967
|
-
onHighlightedIndexChange:
|
|
1968
|
-
onStateChange:
|
|
1969
|
-
onIsOpenChange:
|
|
1970
|
-
scrollIntoView:
|
|
1970
|
+
var commonDropdownPropTypes = _extends({}, commonPropTypes, {
|
|
1971
|
+
getA11yStatusMessage: PropTypes.func,
|
|
1972
|
+
highlightedIndex: PropTypes.number,
|
|
1973
|
+
defaultHighlightedIndex: PropTypes.number,
|
|
1974
|
+
initialHighlightedIndex: PropTypes.number,
|
|
1975
|
+
isOpen: PropTypes.bool,
|
|
1976
|
+
defaultIsOpen: PropTypes.bool,
|
|
1977
|
+
initialIsOpen: PropTypes.bool,
|
|
1978
|
+
selectedItem: PropTypes.any,
|
|
1979
|
+
initialSelectedItem: PropTypes.any,
|
|
1980
|
+
defaultSelectedItem: PropTypes.any,
|
|
1981
|
+
id: PropTypes.string,
|
|
1982
|
+
labelId: PropTypes.string,
|
|
1983
|
+
menuId: PropTypes.string,
|
|
1984
|
+
getItemId: PropTypes.func,
|
|
1985
|
+
toggleButtonId: PropTypes.string,
|
|
1986
|
+
onSelectedItemChange: PropTypes.func,
|
|
1987
|
+
onHighlightedIndexChange: PropTypes.func,
|
|
1988
|
+
onStateChange: PropTypes.func,
|
|
1989
|
+
onIsOpenChange: PropTypes.func,
|
|
1990
|
+
scrollIntoView: PropTypes.func
|
|
1971
1991
|
});
|
|
1972
1992
|
|
|
1973
1993
|
function downshiftCommonReducer(state, action, stateChangeTypes) {
|
|
@@ -2005,7 +2025,7 @@ function downshiftCommonReducer(state, action, stateChangeTypes) {
|
|
|
2005
2025
|
break;
|
|
2006
2026
|
case stateChangeTypes.FunctionSetHighlightedIndex:
|
|
2007
2027
|
changes = {
|
|
2008
|
-
highlightedIndex: action.highlightedIndex
|
|
2028
|
+
highlightedIndex: props.isItemDisabled(props.items[action.highlightedIndex], action.highlightedIndex) ? -1 : action.highlightedIndex
|
|
2009
2029
|
};
|
|
2010
2030
|
break;
|
|
2011
2031
|
case stateChangeTypes.FunctionSetInputValue:
|
|
@@ -2015,7 +2035,7 @@ function downshiftCommonReducer(state, action, stateChangeTypes) {
|
|
|
2015
2035
|
break;
|
|
2016
2036
|
case stateChangeTypes.FunctionReset:
|
|
2017
2037
|
changes = {
|
|
2018
|
-
highlightedIndex:
|
|
2038
|
+
highlightedIndex: getDefaultHighlightedIndex(props),
|
|
2019
2039
|
isOpen: getDefaultValue$1(props, 'isOpen'),
|
|
2020
2040
|
selectedItem: getDefaultValue$1(props, 'selectedItem'),
|
|
2021
2041
|
inputValue: getDefaultValue$1(props, 'inputValue')
|
|
@@ -2024,7 +2044,7 @@ function downshiftCommonReducer(state, action, stateChangeTypes) {
|
|
|
2024
2044
|
default:
|
|
2025
2045
|
throw new Error('Reducer called without proper action type.');
|
|
2026
2046
|
}
|
|
2027
|
-
return
|
|
2047
|
+
return _extends({}, state, changes);
|
|
2028
2048
|
}
|
|
2029
2049
|
/* eslint-enable complexity */
|
|
2030
2050
|
|
|
@@ -2043,7 +2063,7 @@ function getItemIndexByCharacterKey(_a) {
|
|
|
2043
2063
|
}
|
|
2044
2064
|
return highlightedIndex;
|
|
2045
2065
|
}
|
|
2046
|
-
var propTypes$2 = tslib.__assign(tslib.__assign({}, commonDropdownPropTypes), { items:
|
|
2066
|
+
var propTypes$2 = tslib.__assign(tslib.__assign({}, commonDropdownPropTypes), { items: PropTypes.array.isRequired, isItemDisabled: PropTypes.func });
|
|
2047
2067
|
var defaultProps$2 = tslib.__assign(tslib.__assign({}, defaultProps$3), { isItemDisabled: function () {
|
|
2048
2068
|
return false;
|
|
2049
2069
|
} });
|
|
@@ -2052,7 +2072,7 @@ var validatePropTypes$2 = noop;
|
|
|
2052
2072
|
/* istanbul ignore next */
|
|
2053
2073
|
if (process.env.NODE_ENV !== 'production') {
|
|
2054
2074
|
validatePropTypes$2 = function (options, caller) {
|
|
2055
|
-
|
|
2075
|
+
PropTypes.checkPropTypes(propTypes$2, options, 'prop', caller.name);
|
|
2056
2076
|
};
|
|
2057
2077
|
}
|
|
2058
2078
|
|
|
@@ -2081,28 +2101,28 @@ var FunctionReset$2 = process.env.NODE_ENV !== "production" ? '__function_reset_
|
|
|
2081
2101
|
|
|
2082
2102
|
var stateChangeTypes$2 = /*#__PURE__*/Object.freeze({
|
|
2083
2103
|
__proto__: null,
|
|
2104
|
+
FunctionCloseMenu: FunctionCloseMenu$1,
|
|
2105
|
+
FunctionOpenMenu: FunctionOpenMenu$1,
|
|
2106
|
+
FunctionReset: FunctionReset$2,
|
|
2107
|
+
FunctionSelectItem: FunctionSelectItem$1,
|
|
2108
|
+
FunctionSetHighlightedIndex: FunctionSetHighlightedIndex$1,
|
|
2109
|
+
FunctionSetInputValue: FunctionSetInputValue$1,
|
|
2110
|
+
FunctionToggleMenu: FunctionToggleMenu$1,
|
|
2111
|
+
ItemClick: ItemClick$1,
|
|
2112
|
+
ItemMouseMove: ItemMouseMove$1,
|
|
2113
|
+
MenuMouseLeave: MenuMouseLeave$1,
|
|
2114
|
+
ToggleButtonBlur: ToggleButtonBlur,
|
|
2084
2115
|
ToggleButtonClick: ToggleButtonClick$1,
|
|
2085
2116
|
ToggleButtonKeyDownArrowDown: ToggleButtonKeyDownArrowDown,
|
|
2086
2117
|
ToggleButtonKeyDownArrowUp: ToggleButtonKeyDownArrowUp,
|
|
2087
2118
|
ToggleButtonKeyDownCharacter: ToggleButtonKeyDownCharacter,
|
|
2088
|
-
ToggleButtonKeyDownEscape: ToggleButtonKeyDownEscape,
|
|
2089
|
-
ToggleButtonKeyDownHome: ToggleButtonKeyDownHome,
|
|
2090
2119
|
ToggleButtonKeyDownEnd: ToggleButtonKeyDownEnd,
|
|
2091
2120
|
ToggleButtonKeyDownEnter: ToggleButtonKeyDownEnter,
|
|
2092
|
-
|
|
2093
|
-
|
|
2121
|
+
ToggleButtonKeyDownEscape: ToggleButtonKeyDownEscape,
|
|
2122
|
+
ToggleButtonKeyDownHome: ToggleButtonKeyDownHome,
|
|
2094
2123
|
ToggleButtonKeyDownPageDown: ToggleButtonKeyDownPageDown,
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
ItemMouseMove: ItemMouseMove$1,
|
|
2098
|
-
ItemClick: ItemClick$1,
|
|
2099
|
-
FunctionToggleMenu: FunctionToggleMenu$1,
|
|
2100
|
-
FunctionOpenMenu: FunctionOpenMenu$1,
|
|
2101
|
-
FunctionCloseMenu: FunctionCloseMenu$1,
|
|
2102
|
-
FunctionSetHighlightedIndex: FunctionSetHighlightedIndex$1,
|
|
2103
|
-
FunctionSelectItem: FunctionSelectItem$1,
|
|
2104
|
-
FunctionSetInputValue: FunctionSetInputValue$1,
|
|
2105
|
-
FunctionReset: FunctionReset$2
|
|
2124
|
+
ToggleButtonKeyDownPageUp: ToggleButtonKeyDownPageUp,
|
|
2125
|
+
ToggleButtonKeyDownSpaceButton: ToggleButtonKeyDownSpaceButton
|
|
2106
2126
|
});
|
|
2107
2127
|
|
|
2108
2128
|
/* eslint-disable complexity */
|
|
@@ -2116,7 +2136,7 @@ function downshiftSelectReducer(state, action) {
|
|
|
2116
2136
|
case ItemClick$1:
|
|
2117
2137
|
changes = {
|
|
2118
2138
|
isOpen: getDefaultValue$1(props, 'isOpen'),
|
|
2119
|
-
highlightedIndex:
|
|
2139
|
+
highlightedIndex: getDefaultHighlightedIndex(props),
|
|
2120
2140
|
selectedItem: props.items[action.index]
|
|
2121
2141
|
};
|
|
2122
2142
|
break;
|
|
@@ -2195,7 +2215,7 @@ function downshiftSelectReducer(state, action) {
|
|
|
2195
2215
|
};
|
|
2196
2216
|
break;
|
|
2197
2217
|
case ToggleButtonBlur:
|
|
2198
|
-
changes =
|
|
2218
|
+
changes = _extends({
|
|
2199
2219
|
isOpen: false,
|
|
2200
2220
|
highlightedIndex: -1
|
|
2201
2221
|
}, state.highlightedIndex >= 0 && ((_props$items = props.items) == null ? void 0 : _props$items.length) && {
|
|
@@ -2210,7 +2230,7 @@ function downshiftSelectReducer(state, action) {
|
|
|
2210
2230
|
default:
|
|
2211
2231
|
return downshiftCommonReducer(state, action, stateChangeTypes$2);
|
|
2212
2232
|
}
|
|
2213
|
-
return
|
|
2233
|
+
return _extends({}, state, changes);
|
|
2214
2234
|
}
|
|
2215
2235
|
/* eslint-enable complexity */
|
|
2216
2236
|
|
|
@@ -2225,7 +2245,7 @@ function useSelect(userProps) {
|
|
|
2225
2245
|
}
|
|
2226
2246
|
validatePropTypes$2(userProps, useSelect);
|
|
2227
2247
|
// Props defaults and destructuring.
|
|
2228
|
-
var props =
|
|
2248
|
+
var props = _extends({}, defaultProps$2, userProps);
|
|
2229
2249
|
var scrollIntoView = props.scrollIntoView,
|
|
2230
2250
|
environment = props.environment,
|
|
2231
2251
|
getA11yStatusMessage = props.getA11yStatusMessage;
|
|
@@ -2441,12 +2461,12 @@ function useSelect(userProps) {
|
|
|
2441
2461
|
var getLabelProps = React.useCallback(function (_temp) {
|
|
2442
2462
|
var _ref = _temp === void 0 ? {} : _temp,
|
|
2443
2463
|
onClick = _ref.onClick,
|
|
2444
|
-
labelProps =
|
|
2464
|
+
labelProps = _objectWithoutPropertiesLoose(_ref, _excluded$2);
|
|
2445
2465
|
var labelHandleClick = function labelHandleClick() {
|
|
2446
2466
|
var _toggleButtonRef$curr;
|
|
2447
2467
|
(_toggleButtonRef$curr = toggleButtonRef.current) == null || _toggleButtonRef$curr.focus();
|
|
2448
2468
|
};
|
|
2449
|
-
return
|
|
2469
|
+
return _extends({
|
|
2450
2470
|
id: elementIds.labelId,
|
|
2451
2471
|
htmlFor: elementIds.toggleButtonId,
|
|
2452
2472
|
onClick: callAllEventHandlers(onClick, labelHandleClick)
|
|
@@ -2459,7 +2479,7 @@ function useSelect(userProps) {
|
|
|
2459
2479
|
_ref2$refKey = _ref2.refKey,
|
|
2460
2480
|
refKey = _ref2$refKey === void 0 ? 'ref' : _ref2$refKey,
|
|
2461
2481
|
ref = _ref2.ref,
|
|
2462
|
-
rest =
|
|
2482
|
+
rest = _objectWithoutPropertiesLoose(_ref2, _excluded2$2);
|
|
2463
2483
|
var _ref3 = _temp3 === void 0 ? {} : _temp3,
|
|
2464
2484
|
_ref3$suppressRefErro = _ref3.suppressRefError,
|
|
2465
2485
|
suppressRefError = _ref3$suppressRefErro === void 0 ? false : _ref3$suppressRefErro;
|
|
@@ -2469,7 +2489,7 @@ function useSelect(userProps) {
|
|
|
2469
2489
|
});
|
|
2470
2490
|
};
|
|
2471
2491
|
setGetterPropCallInfo('getMenuProps', suppressRefError, refKey, menuRef);
|
|
2472
|
-
return
|
|
2492
|
+
return _extends((_extends2 = {}, _extends2[refKey] = handleRefs(ref, function (menuNode) {
|
|
2473
2493
|
menuRef.current = menuNode;
|
|
2474
2494
|
}), _extends2.id = elementIds.menuId, _extends2.role = 'listbox', _extends2['aria-labelledby'] = rest && rest['aria-label'] ? undefined : "" + elementIds.labelId, _extends2.onMouseLeave = callAllEventHandlers(onMouseLeave, menuHandleMouseLeave), _extends2), rest);
|
|
2475
2495
|
}, [dispatch, setGetterPropCallInfo, elementIds]);
|
|
@@ -2483,7 +2503,7 @@ function useSelect(userProps) {
|
|
|
2483
2503
|
var _ref4$refKey = _ref4.refKey,
|
|
2484
2504
|
refKey = _ref4$refKey === void 0 ? 'ref' : _ref4$refKey,
|
|
2485
2505
|
ref = _ref4.ref,
|
|
2486
|
-
rest =
|
|
2506
|
+
rest = _objectWithoutPropertiesLoose(_ref4, _excluded3$1);
|
|
2487
2507
|
var _ref5 = _temp5 === void 0 ? {} : _temp5,
|
|
2488
2508
|
_ref5$suppressRefErro = _ref5.suppressRefError,
|
|
2489
2509
|
suppressRefError = _ref5$suppressRefErro === void 0 ? false : _ref5$suppressRefErro;
|
|
@@ -2500,7 +2520,7 @@ function useSelect(userProps) {
|
|
|
2500
2520
|
});
|
|
2501
2521
|
}
|
|
2502
2522
|
};
|
|
2503
|
-
var toggleProps =
|
|
2523
|
+
var toggleProps = _extends((_extends3 = {}, _extends3[refKey] = handleRefs(ref, function (toggleButtonNode) {
|
|
2504
2524
|
toggleButtonRef.current = toggleButtonNode;
|
|
2505
2525
|
}), _extends3['aria-activedescendant'] = latestState.isOpen && latestState.highlightedIndex > -1 ? elementIds.getItemId(latestState.highlightedIndex) : '', _extends3['aria-controls'] = elementIds.menuId, _extends3['aria-expanded'] = latest.current.state.isOpen, _extends3['aria-haspopup'] = 'listbox', _extends3['aria-labelledby'] = rest && rest['aria-label'] ? undefined : "" + elementIds.labelId, _extends3.id = elementIds.toggleButtonId, _extends3.role = 'combobox', _extends3.tabIndex = 0, _extends3.onBlur = callAllEventHandlers(onBlur, toggleButtonHandleBlur), _extends3), rest);
|
|
2506
2526
|
if (!rest.disabled) {
|
|
@@ -2525,7 +2545,7 @@ function useSelect(userProps) {
|
|
|
2525
2545
|
refKey = _ref6$refKey === void 0 ? 'ref' : _ref6$refKey,
|
|
2526
2546
|
disabledProp = _ref6.disabled,
|
|
2527
2547
|
ref = _ref6.ref,
|
|
2528
|
-
rest =
|
|
2548
|
+
rest = _objectWithoutPropertiesLoose(_ref6, _excluded4$1);
|
|
2529
2549
|
if (disabledProp !== undefined) {
|
|
2530
2550
|
console.warn('Passing "disabled" as an argument to getItemProps is not supported anymore. Please use the isItemDisabled prop from useSelect.');
|
|
2531
2551
|
}
|
|
@@ -2557,7 +2577,7 @@ function useSelect(userProps) {
|
|
|
2557
2577
|
return e.preventDefault();
|
|
2558
2578
|
}; // keep focus on the toggle after item click select.
|
|
2559
2579
|
|
|
2560
|
-
var itemProps =
|
|
2580
|
+
var itemProps = _extends((_extends4 = {}, _extends4[refKey] = handleRefs(ref, function (itemNode) {
|
|
2561
2581
|
if (itemNode) {
|
|
2562
2582
|
itemRefs.current[elementIds.getItemId(index)] = itemNode;
|
|
2563
2583
|
}
|
|
@@ -2620,29 +2640,29 @@ var ControlledPropUpdatedSelectedItem = process.env.NODE_ENV !== "production" ?
|
|
|
2620
2640
|
|
|
2621
2641
|
var stateChangeTypes$1 = /*#__PURE__*/Object.freeze({
|
|
2622
2642
|
__proto__: null,
|
|
2643
|
+
ControlledPropUpdatedSelectedItem: ControlledPropUpdatedSelectedItem,
|
|
2644
|
+
FunctionCloseMenu: FunctionCloseMenu,
|
|
2645
|
+
FunctionOpenMenu: FunctionOpenMenu,
|
|
2646
|
+
FunctionReset: FunctionReset$1,
|
|
2647
|
+
FunctionSelectItem: FunctionSelectItem,
|
|
2648
|
+
FunctionSetHighlightedIndex: FunctionSetHighlightedIndex,
|
|
2649
|
+
FunctionSetInputValue: FunctionSetInputValue,
|
|
2650
|
+
FunctionToggleMenu: FunctionToggleMenu,
|
|
2651
|
+
InputBlur: InputBlur,
|
|
2652
|
+
InputChange: InputChange,
|
|
2653
|
+
InputClick: InputClick,
|
|
2623
2654
|
InputKeyDownArrowDown: InputKeyDownArrowDown,
|
|
2624
2655
|
InputKeyDownArrowUp: InputKeyDownArrowUp,
|
|
2656
|
+
InputKeyDownEnd: InputKeyDownEnd,
|
|
2657
|
+
InputKeyDownEnter: InputKeyDownEnter,
|
|
2625
2658
|
InputKeyDownEscape: InputKeyDownEscape,
|
|
2626
2659
|
InputKeyDownHome: InputKeyDownHome,
|
|
2627
|
-
InputKeyDownEnd: InputKeyDownEnd,
|
|
2628
|
-
InputKeyDownPageUp: InputKeyDownPageUp,
|
|
2629
2660
|
InputKeyDownPageDown: InputKeyDownPageDown,
|
|
2630
|
-
|
|
2631
|
-
InputChange: InputChange,
|
|
2632
|
-
InputBlur: InputBlur,
|
|
2633
|
-
InputClick: InputClick,
|
|
2634
|
-
MenuMouseLeave: MenuMouseLeave,
|
|
2635
|
-
ItemMouseMove: ItemMouseMove,
|
|
2661
|
+
InputKeyDownPageUp: InputKeyDownPageUp,
|
|
2636
2662
|
ItemClick: ItemClick,
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
FunctionCloseMenu: FunctionCloseMenu,
|
|
2641
|
-
FunctionSetHighlightedIndex: FunctionSetHighlightedIndex,
|
|
2642
|
-
FunctionSelectItem: FunctionSelectItem,
|
|
2643
|
-
FunctionSetInputValue: FunctionSetInputValue,
|
|
2644
|
-
FunctionReset: FunctionReset$1,
|
|
2645
|
-
ControlledPropUpdatedSelectedItem: ControlledPropUpdatedSelectedItem
|
|
2663
|
+
ItemMouseMove: ItemMouseMove,
|
|
2664
|
+
MenuMouseLeave: MenuMouseLeave,
|
|
2665
|
+
ToggleButtonClick: ToggleButtonClick
|
|
2646
2666
|
});
|
|
2647
2667
|
|
|
2648
2668
|
function getInitialState$1(props) {
|
|
@@ -2652,18 +2672,18 @@ function getInitialState$1(props) {
|
|
|
2652
2672
|
if (inputValue === '' && selectedItem && props.defaultInputValue === undefined && props.initialInputValue === undefined && props.inputValue === undefined) {
|
|
2653
2673
|
inputValue = props.itemToString(selectedItem);
|
|
2654
2674
|
}
|
|
2655
|
-
return
|
|
2675
|
+
return _extends({}, initialState, {
|
|
2656
2676
|
inputValue: inputValue
|
|
2657
2677
|
});
|
|
2658
2678
|
}
|
|
2659
|
-
var propTypes$1 =
|
|
2660
|
-
items:
|
|
2661
|
-
isItemDisabled:
|
|
2662
|
-
inputValue:
|
|
2663
|
-
defaultInputValue:
|
|
2664
|
-
initialInputValue:
|
|
2665
|
-
inputId:
|
|
2666
|
-
onInputValueChange:
|
|
2679
|
+
var propTypes$1 = _extends({}, commonDropdownPropTypes, {
|
|
2680
|
+
items: PropTypes.array.isRequired,
|
|
2681
|
+
isItemDisabled: PropTypes.func,
|
|
2682
|
+
inputValue: PropTypes.string,
|
|
2683
|
+
defaultInputValue: PropTypes.string,
|
|
2684
|
+
initialInputValue: PropTypes.string,
|
|
2685
|
+
inputId: PropTypes.string,
|
|
2686
|
+
onInputValueChange: PropTypes.func
|
|
2667
2687
|
});
|
|
2668
2688
|
|
|
2669
2689
|
/**
|
|
@@ -2710,10 +2730,10 @@ var validatePropTypes$1 = noop;
|
|
|
2710
2730
|
/* istanbul ignore next */
|
|
2711
2731
|
if (process.env.NODE_ENV !== 'production') {
|
|
2712
2732
|
validatePropTypes$1 = function validatePropTypes(options, caller) {
|
|
2713
|
-
|
|
2733
|
+
PropTypes.checkPropTypes(propTypes$1, options, 'prop', caller.name);
|
|
2714
2734
|
};
|
|
2715
2735
|
}
|
|
2716
|
-
var defaultProps$1 =
|
|
2736
|
+
var defaultProps$1 = _extends({}, defaultProps$3, {
|
|
2717
2737
|
isItemDisabled: function isItemDisabled() {
|
|
2718
2738
|
return false;
|
|
2719
2739
|
}
|
|
@@ -2730,7 +2750,7 @@ function downshiftUseComboboxReducer(state, action) {
|
|
|
2730
2750
|
case ItemClick:
|
|
2731
2751
|
changes = {
|
|
2732
2752
|
isOpen: getDefaultValue$1(props, 'isOpen'),
|
|
2733
|
-
highlightedIndex:
|
|
2753
|
+
highlightedIndex: getDefaultHighlightedIndex(props),
|
|
2734
2754
|
selectedItem: props.items[action.index],
|
|
2735
2755
|
inputValue: props.itemToString(props.items[action.index])
|
|
2736
2756
|
};
|
|
@@ -2767,7 +2787,7 @@ function downshiftUseComboboxReducer(state, action) {
|
|
|
2767
2787
|
changes = getChangesOnSelection(props, state.highlightedIndex);
|
|
2768
2788
|
break;
|
|
2769
2789
|
case InputKeyDownEscape:
|
|
2770
|
-
changes =
|
|
2790
|
+
changes = _extends({
|
|
2771
2791
|
isOpen: false,
|
|
2772
2792
|
highlightedIndex: -1
|
|
2773
2793
|
}, !state.isOpen && {
|
|
@@ -2796,7 +2816,7 @@ function downshiftUseComboboxReducer(state, action) {
|
|
|
2796
2816
|
};
|
|
2797
2817
|
break;
|
|
2798
2818
|
case InputBlur:
|
|
2799
|
-
changes =
|
|
2819
|
+
changes = _extends({
|
|
2800
2820
|
isOpen: false,
|
|
2801
2821
|
highlightedIndex: -1
|
|
2802
2822
|
}, state.highlightedIndex >= 0 && ((_props$items = props.items) == null ? void 0 : _props$items.length) && action.selectItem && {
|
|
@@ -2807,7 +2827,7 @@ function downshiftUseComboboxReducer(state, action) {
|
|
|
2807
2827
|
case InputChange:
|
|
2808
2828
|
changes = {
|
|
2809
2829
|
isOpen: true,
|
|
2810
|
-
highlightedIndex:
|
|
2830
|
+
highlightedIndex: getDefaultHighlightedIndex(props),
|
|
2811
2831
|
inputValue: action.inputValue
|
|
2812
2832
|
};
|
|
2813
2833
|
break;
|
|
@@ -2831,7 +2851,7 @@ function downshiftUseComboboxReducer(state, action) {
|
|
|
2831
2851
|
default:
|
|
2832
2852
|
return downshiftCommonReducer(state, action, stateChangeTypes$1);
|
|
2833
2853
|
}
|
|
2834
|
-
return
|
|
2854
|
+
return _extends({}, state, changes);
|
|
2835
2855
|
}
|
|
2836
2856
|
/* eslint-enable complexity */
|
|
2837
2857
|
|
|
@@ -2846,7 +2866,7 @@ function useCombobox(userProps) {
|
|
|
2846
2866
|
}
|
|
2847
2867
|
validatePropTypes$1(userProps, useCombobox);
|
|
2848
2868
|
// Props defaults and destructuring.
|
|
2849
|
-
var props =
|
|
2869
|
+
var props = _extends({}, defaultProps$1, userProps);
|
|
2850
2870
|
var items = props.items,
|
|
2851
2871
|
scrollIntoView = props.scrollIntoView,
|
|
2852
2872
|
environment = props.environment,
|
|
@@ -3012,7 +3032,7 @@ function useCombobox(userProps) {
|
|
|
3012
3032
|
|
|
3013
3033
|
// Getter props.
|
|
3014
3034
|
var getLabelProps = React.useCallback(function (labelProps) {
|
|
3015
|
-
return
|
|
3035
|
+
return _extends({
|
|
3016
3036
|
id: elementIds.labelId,
|
|
3017
3037
|
htmlFor: elementIds.inputId
|
|
3018
3038
|
}, labelProps);
|
|
@@ -3024,12 +3044,12 @@ function useCombobox(userProps) {
|
|
|
3024
3044
|
_ref$refKey = _ref.refKey,
|
|
3025
3045
|
refKey = _ref$refKey === void 0 ? 'ref' : _ref$refKey,
|
|
3026
3046
|
ref = _ref.ref,
|
|
3027
|
-
rest =
|
|
3047
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$1);
|
|
3028
3048
|
var _ref2 = _temp2 === void 0 ? {} : _temp2,
|
|
3029
3049
|
_ref2$suppressRefErro = _ref2.suppressRefError,
|
|
3030
3050
|
suppressRefError = _ref2$suppressRefErro === void 0 ? false : _ref2$suppressRefErro;
|
|
3031
3051
|
setGetterPropCallInfo('getMenuProps', suppressRefError, refKey, menuRef);
|
|
3032
|
-
return
|
|
3052
|
+
return _extends((_extends2 = {}, _extends2[refKey] = handleRefs(ref, function (menuNode) {
|
|
3033
3053
|
menuRef.current = menuNode;
|
|
3034
3054
|
}), _extends2.id = elementIds.menuId, _extends2.role = 'listbox', _extends2['aria-labelledby'] = rest && rest['aria-label'] ? undefined : "" + elementIds.labelId, _extends2.onMouseLeave = callAllEventHandlers(onMouseLeave, function () {
|
|
3035
3055
|
dispatch({
|
|
@@ -3050,7 +3070,7 @@ function useCombobox(userProps) {
|
|
|
3050
3070
|
_ref3.onClick;
|
|
3051
3071
|
var onPress = _ref3.onPress,
|
|
3052
3072
|
disabledProp = _ref3.disabled,
|
|
3053
|
-
rest =
|
|
3073
|
+
rest = _objectWithoutPropertiesLoose(_ref3, _excluded2$1);
|
|
3054
3074
|
if (disabledProp !== undefined) {
|
|
3055
3075
|
console.warn('Passing "disabled" as an argument to getItemProps is not supported anymore. Please use the isItemDisabled prop from useCombobox.');
|
|
3056
3076
|
}
|
|
@@ -3084,7 +3104,7 @@ function useCombobox(userProps) {
|
|
|
3084
3104
|
return e.preventDefault();
|
|
3085
3105
|
}; // keep focus on the input after item click select.
|
|
3086
3106
|
|
|
3087
|
-
return
|
|
3107
|
+
return _extends((_extends3 = {}, _extends3[refKey] = handleRefs(ref, function (itemNode) {
|
|
3088
3108
|
if (itemNode) {
|
|
3089
3109
|
itemRefs.current[elementIds.getItemId(index)] = itemNode;
|
|
3090
3110
|
}
|
|
@@ -3101,16 +3121,16 @@ function useCombobox(userProps) {
|
|
|
3101
3121
|
_ref5$refKey = _ref5.refKey,
|
|
3102
3122
|
refKey = _ref5$refKey === void 0 ? 'ref' : _ref5$refKey,
|
|
3103
3123
|
ref = _ref5.ref,
|
|
3104
|
-
rest =
|
|
3124
|
+
rest = _objectWithoutPropertiesLoose(_ref5, _excluded3);
|
|
3105
3125
|
var latestState = latest.current.state;
|
|
3106
3126
|
var toggleButtonHandleClick = function toggleButtonHandleClick() {
|
|
3107
3127
|
dispatch({
|
|
3108
3128
|
type: ToggleButtonClick
|
|
3109
3129
|
});
|
|
3110
3130
|
};
|
|
3111
|
-
return
|
|
3131
|
+
return _extends((_extends4 = {}, _extends4[refKey] = handleRefs(ref, function (toggleButtonNode) {
|
|
3112
3132
|
toggleButtonRef.current = toggleButtonNode;
|
|
3113
|
-
}), _extends4['aria-controls'] = elementIds.menuId, _extends4['aria-expanded'] = latestState.isOpen, _extends4.id = elementIds.toggleButtonId, _extends4.tabIndex = -1, _extends4), !rest.disabled &&
|
|
3133
|
+
}), _extends4['aria-controls'] = elementIds.menuId, _extends4['aria-expanded'] = latestState.isOpen, _extends4.id = elementIds.toggleButtonId, _extends4.tabIndex = -1, _extends4), !rest.disabled && _extends({}, /* istanbul ignore next (react-native) */{
|
|
3114
3134
|
onPress: callAllEventHandlers(onPress, toggleButtonHandleClick)
|
|
3115
3135
|
} ), rest);
|
|
3116
3136
|
}, [dispatch, latest, elementIds]);
|
|
@@ -3126,7 +3146,7 @@ function useCombobox(userProps) {
|
|
|
3126
3146
|
_ref6$refKey = _ref6.refKey,
|
|
3127
3147
|
refKey = _ref6$refKey === void 0 ? 'ref' : _ref6$refKey,
|
|
3128
3148
|
ref = _ref6.ref,
|
|
3129
|
-
rest =
|
|
3149
|
+
rest = _objectWithoutPropertiesLoose(_ref6, _excluded4);
|
|
3130
3150
|
var _ref7 = _temp6 === void 0 ? {} : _temp6,
|
|
3131
3151
|
_ref7$suppressRefErro = _ref7.suppressRefError,
|
|
3132
3152
|
suppressRefError = _ref7$suppressRefErro === void 0 ? false : _ref7$suppressRefErro;
|
|
@@ -3179,7 +3199,7 @@ function useCombobox(userProps) {
|
|
|
3179
3199
|
});
|
|
3180
3200
|
});
|
|
3181
3201
|
}
|
|
3182
|
-
return
|
|
3202
|
+
return _extends((_extends5 = {}, _extends5[refKey] = handleRefs(ref, function (inputNode) {
|
|
3183
3203
|
inputRef.current = inputNode;
|
|
3184
3204
|
}), _extends5['aria-activedescendant'] = latestState.isOpen && latestState.highlightedIndex > -1 ? elementIds.getItemId(latestState.highlightedIndex) : '', _extends5['aria-autocomplete'] = 'list', _extends5['aria-controls'] = elementIds.menuId, _extends5['aria-expanded'] = latestState.isOpen, _extends5['aria-labelledby'] = rest && rest['aria-label'] ? undefined : elementIds.labelId, _extends5.autoComplete = 'off', _extends5.id = elementIds.inputId, _extends5.role = 'combobox', _extends5.value = latestState.inputValue, _extends5), eventHandlers, rest);
|
|
3185
3205
|
}, [dispatch, elementIds, environment, inputKeyDownHandlers, latest, mouseAndTouchTrackers, setGetterPropCallInfo]);
|
|
@@ -3332,17 +3352,17 @@ var propTypes = {
|
|
|
3332
3352
|
stateReducer: commonPropTypes.stateReducer,
|
|
3333
3353
|
itemToKey: commonPropTypes.itemToKey,
|
|
3334
3354
|
environment: commonPropTypes.environment,
|
|
3335
|
-
selectedItems:
|
|
3336
|
-
initialSelectedItems:
|
|
3337
|
-
defaultSelectedItems:
|
|
3338
|
-
getA11yStatusMessage:
|
|
3339
|
-
activeIndex:
|
|
3340
|
-
initialActiveIndex:
|
|
3341
|
-
defaultActiveIndex:
|
|
3342
|
-
onActiveIndexChange:
|
|
3343
|
-
onSelectedItemsChange:
|
|
3344
|
-
keyNavigationNext:
|
|
3345
|
-
keyNavigationPrevious:
|
|
3355
|
+
selectedItems: PropTypes.array,
|
|
3356
|
+
initialSelectedItems: PropTypes.array,
|
|
3357
|
+
defaultSelectedItems: PropTypes.array,
|
|
3358
|
+
getA11yStatusMessage: PropTypes.func,
|
|
3359
|
+
activeIndex: PropTypes.number,
|
|
3360
|
+
initialActiveIndex: PropTypes.number,
|
|
3361
|
+
defaultActiveIndex: PropTypes.number,
|
|
3362
|
+
onActiveIndexChange: PropTypes.func,
|
|
3363
|
+
onSelectedItemsChange: PropTypes.func,
|
|
3364
|
+
keyNavigationNext: PropTypes.string,
|
|
3365
|
+
keyNavigationPrevious: PropTypes.string
|
|
3346
3366
|
};
|
|
3347
3367
|
var defaultProps = {
|
|
3348
3368
|
itemToKey: defaultProps$3.itemToKey,
|
|
@@ -3357,7 +3377,7 @@ var validatePropTypes = noop;
|
|
|
3357
3377
|
/* istanbul ignore next */
|
|
3358
3378
|
if (process.env.NODE_ENV !== 'production') {
|
|
3359
3379
|
validatePropTypes = function validatePropTypes(options, caller) {
|
|
3360
|
-
|
|
3380
|
+
PropTypes.checkPropTypes(propTypes, options, 'prop', caller.name);
|
|
3361
3381
|
};
|
|
3362
3382
|
}
|
|
3363
3383
|
|
|
@@ -3377,19 +3397,19 @@ var FunctionReset = process.env.NODE_ENV !== "production" ? '__function_reset__'
|
|
|
3377
3397
|
|
|
3378
3398
|
var stateChangeTypes = /*#__PURE__*/Object.freeze({
|
|
3379
3399
|
__proto__: null,
|
|
3380
|
-
SelectedItemClick: SelectedItemClick,
|
|
3381
|
-
SelectedItemKeyDownDelete: SelectedItemKeyDownDelete,
|
|
3382
|
-
SelectedItemKeyDownBackspace: SelectedItemKeyDownBackspace,
|
|
3383
|
-
SelectedItemKeyDownNavigationNext: SelectedItemKeyDownNavigationNext,
|
|
3384
|
-
SelectedItemKeyDownNavigationPrevious: SelectedItemKeyDownNavigationPrevious,
|
|
3385
|
-
DropdownKeyDownNavigationPrevious: DropdownKeyDownNavigationPrevious,
|
|
3386
|
-
DropdownKeyDownBackspace: DropdownKeyDownBackspace,
|
|
3387
3400
|
DropdownClick: DropdownClick,
|
|
3401
|
+
DropdownKeyDownBackspace: DropdownKeyDownBackspace,
|
|
3402
|
+
DropdownKeyDownNavigationPrevious: DropdownKeyDownNavigationPrevious,
|
|
3388
3403
|
FunctionAddSelectedItem: FunctionAddSelectedItem,
|
|
3389
3404
|
FunctionRemoveSelectedItem: FunctionRemoveSelectedItem,
|
|
3390
|
-
|
|
3405
|
+
FunctionReset: FunctionReset,
|
|
3391
3406
|
FunctionSetActiveIndex: FunctionSetActiveIndex,
|
|
3392
|
-
|
|
3407
|
+
FunctionSetSelectedItems: FunctionSetSelectedItems,
|
|
3408
|
+
SelectedItemClick: SelectedItemClick,
|
|
3409
|
+
SelectedItemKeyDownBackspace: SelectedItemKeyDownBackspace,
|
|
3410
|
+
SelectedItemKeyDownDelete: SelectedItemKeyDownDelete,
|
|
3411
|
+
SelectedItemKeyDownNavigationNext: SelectedItemKeyDownNavigationNext,
|
|
3412
|
+
SelectedItemKeyDownNavigationPrevious: SelectedItemKeyDownNavigationPrevious
|
|
3393
3413
|
});
|
|
3394
3414
|
|
|
3395
3415
|
/* eslint-disable complexity */
|
|
@@ -3429,7 +3449,7 @@ function downshiftMultipleSelectionReducer(state, action) {
|
|
|
3429
3449
|
} else if (activeIndex === selectedItems.length - 1) {
|
|
3430
3450
|
newActiveIndex = selectedItems.length - 2;
|
|
3431
3451
|
}
|
|
3432
|
-
changes =
|
|
3452
|
+
changes = _extends({
|
|
3433
3453
|
selectedItems: [].concat(selectedItems.slice(0, activeIndex), selectedItems.slice(activeIndex + 1))
|
|
3434
3454
|
}, {
|
|
3435
3455
|
activeIndex: newActiveIndex
|
|
@@ -3501,7 +3521,7 @@ function downshiftMultipleSelectionReducer(state, action) {
|
|
|
3501
3521
|
default:
|
|
3502
3522
|
throw new Error('Reducer called without proper action type.');
|
|
3503
3523
|
}
|
|
3504
|
-
return
|
|
3524
|
+
return _extends({}, state, changes);
|
|
3505
3525
|
}
|
|
3506
3526
|
|
|
3507
3527
|
var _excluded = ["refKey", "ref", "onClick", "onKeyDown", "selectedItem", "index"],
|
|
@@ -3513,7 +3533,7 @@ function useMultipleSelection(userProps) {
|
|
|
3513
3533
|
}
|
|
3514
3534
|
validatePropTypes(userProps, useMultipleSelection);
|
|
3515
3535
|
// Props defaults and destructuring.
|
|
3516
|
-
var props =
|
|
3536
|
+
var props = _extends({}, defaultProps, userProps);
|
|
3517
3537
|
var getA11yStatusMessage = props.getA11yStatusMessage,
|
|
3518
3538
|
environment = props.environment,
|
|
3519
3539
|
keyNavigationNext = props.keyNavigationNext,
|
|
@@ -3606,7 +3626,7 @@ function useMultipleSelection(userProps) {
|
|
|
3606
3626
|
onKeyDown = _ref3.onKeyDown,
|
|
3607
3627
|
selectedItemProp = _ref3.selectedItem,
|
|
3608
3628
|
indexProp = _ref3.index,
|
|
3609
|
-
rest =
|
|
3629
|
+
rest = _objectWithoutPropertiesLoose(_ref3, _excluded);
|
|
3610
3630
|
var latestState = latest.current.state;
|
|
3611
3631
|
var _getItemAndIndex = getItemAndIndex(selectedItemProp, indexProp, latestState.selectedItems, 'Pass either item or index to getSelectedItemProps!'),
|
|
3612
3632
|
index = _getItemAndIndex[1];
|
|
@@ -3623,7 +3643,7 @@ function useMultipleSelection(userProps) {
|
|
|
3623
3643
|
selectedItemKeyDownHandlers[key](event);
|
|
3624
3644
|
}
|
|
3625
3645
|
};
|
|
3626
|
-
return
|
|
3646
|
+
return _extends((_extends2 = {}, _extends2[refKey] = handleRefs(ref, function (selectedItemNode) {
|
|
3627
3647
|
if (selectedItemNode) {
|
|
3628
3648
|
selectedItemRefs.current.push(selectedItemNode);
|
|
3629
3649
|
}
|
|
@@ -3639,7 +3659,7 @@ function useMultipleSelection(userProps) {
|
|
|
3639
3659
|
onClick = _ref4.onClick,
|
|
3640
3660
|
_ref4$preventKeyActio = _ref4.preventKeyAction,
|
|
3641
3661
|
preventKeyAction = _ref4$preventKeyActio === void 0 ? false : _ref4$preventKeyActio,
|
|
3642
|
-
rest =
|
|
3662
|
+
rest = _objectWithoutPropertiesLoose(_ref4, _excluded2);
|
|
3643
3663
|
var _ref5 = _temp3 === void 0 ? {} : _temp3,
|
|
3644
3664
|
_ref5$suppressRefErro = _ref5.suppressRefError,
|
|
3645
3665
|
suppressRefError = _ref5$suppressRefErro === void 0 ? false : _ref5$suppressRefErro;
|
|
@@ -3655,7 +3675,7 @@ function useMultipleSelection(userProps) {
|
|
|
3655
3675
|
type: DropdownClick
|
|
3656
3676
|
});
|
|
3657
3677
|
};
|
|
3658
|
-
return
|
|
3678
|
+
return _extends((_extends3 = {}, _extends3[refKey] = handleRefs(ref, function (dropdownNode) {
|
|
3659
3679
|
if (dropdownNode) {
|
|
3660
3680
|
dropdownRef.current = dropdownNode;
|
|
3661
3681
|
}
|
|
@@ -3708,7 +3728,7 @@ function useMultipleSelection(userProps) {
|
|
|
3708
3728
|
};
|
|
3709
3729
|
}
|
|
3710
3730
|
|
|
3711
|
-
exports
|
|
3731
|
+
exports.default = Downshift$1;
|
|
3712
3732
|
exports.resetIdCounter = resetIdCounter;
|
|
3713
3733
|
exports.useCombobox = useCombobox;
|
|
3714
3734
|
exports.useMultipleSelection = useMultipleSelection;
|