downshift 9.0.3 → 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
- package/typings/index.d.ts +2 -2
package/dist/downshift.cjs.js
CHANGED
|
@@ -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
|
/**
|
|
@@ -148,7 +140,7 @@ function generateId() {
|
|
|
148
140
|
*/
|
|
149
141
|
function resetIdCounter() {
|
|
150
142
|
// istanbul ignore next
|
|
151
|
-
if ('useId' in
|
|
143
|
+
if ('useId' in React) {
|
|
152
144
|
console.warn("It is not necessary to call resetIdCounter when using React 18+");
|
|
153
145
|
return;
|
|
154
146
|
}
|
|
@@ -482,23 +474,23 @@ var touchEnd = process.env.NODE_ENV !== "production" ? '__autocomplete_touchend_
|
|
|
482
474
|
|
|
483
475
|
var stateChangeTypes$3 = /*#__PURE__*/Object.freeze({
|
|
484
476
|
__proto__: null,
|
|
485
|
-
|
|
486
|
-
|
|
477
|
+
blurButton: blurButton,
|
|
478
|
+
blurInput: blurInput,
|
|
479
|
+
changeInput: changeInput,
|
|
480
|
+
clickButton: clickButton,
|
|
481
|
+
clickItem: clickItem,
|
|
482
|
+
controlledPropUpdatedSelectedItem: controlledPropUpdatedSelectedItem,
|
|
487
483
|
itemMouseEnter: itemMouseEnter,
|
|
488
|
-
keyDownArrowUp: keyDownArrowUp,
|
|
489
484
|
keyDownArrowDown: keyDownArrowDown,
|
|
490
|
-
|
|
485
|
+
keyDownArrowUp: keyDownArrowUp,
|
|
486
|
+
keyDownEnd: keyDownEnd,
|
|
491
487
|
keyDownEnter: keyDownEnter,
|
|
488
|
+
keyDownEscape: keyDownEscape,
|
|
492
489
|
keyDownHome: keyDownHome,
|
|
493
|
-
keyDownEnd: keyDownEnd,
|
|
494
|
-
clickItem: clickItem,
|
|
495
|
-
blurInput: blurInput,
|
|
496
|
-
changeInput: changeInput,
|
|
497
490
|
keyDownSpaceButton: keyDownSpaceButton,
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
touchEnd: touchEnd
|
|
491
|
+
mouseUp: mouseUp,
|
|
492
|
+
touchEnd: touchEnd,
|
|
493
|
+
unknown: unknown
|
|
502
494
|
});
|
|
503
495
|
|
|
504
496
|
var _excluded$3 = ["refKey", "ref"],
|
|
@@ -561,7 +553,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
561
553
|
otherStateToSet = {};
|
|
562
554
|
}
|
|
563
555
|
otherStateToSet = pickState(otherStateToSet);
|
|
564
|
-
_this.internalSetState(
|
|
556
|
+
_this.internalSetState(_extends({
|
|
565
557
|
highlightedIndex: highlightedIndex
|
|
566
558
|
}, otherStateToSet));
|
|
567
559
|
};
|
|
@@ -575,7 +567,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
575
567
|
};
|
|
576
568
|
_this.selectItem = function (item, otherStateToSet, cb) {
|
|
577
569
|
otherStateToSet = pickState(otherStateToSet);
|
|
578
|
-
_this.internalSetState(
|
|
570
|
+
_this.internalSetState(_extends({
|
|
579
571
|
isOpen: _this.props.defaultIsOpen,
|
|
580
572
|
highlightedIndex: _this.props.defaultHighlightedIndex,
|
|
581
573
|
selectedItem: item,
|
|
@@ -611,7 +603,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
611
603
|
// preserving the cursor position.
|
|
612
604
|
// See https://github.com/downshift-js/downshift/issues/217 for more info.
|
|
613
605
|
if (!isStateToSetFunction && stateToSet.hasOwnProperty('inputValue')) {
|
|
614
|
-
_this.props.onInputValueChange(stateToSet.inputValue,
|
|
606
|
+
_this.props.onInputValueChange(stateToSet.inputValue, _extends({}, _this.getStateAndHelpers(), stateToSet));
|
|
615
607
|
}
|
|
616
608
|
return _this.setState(function (state) {
|
|
617
609
|
var _newStateToSet;
|
|
@@ -659,7 +651,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
659
651
|
// if stateToSet is a function, then we weren't able to call onInputValueChange
|
|
660
652
|
// earlier, so we'll call it now that we know what the inputValue state will be.
|
|
661
653
|
if (isStateToSetFunction && newStateToSet.hasOwnProperty('inputValue')) {
|
|
662
|
-
_this.props.onInputValueChange(newStateToSet.inputValue,
|
|
654
|
+
_this.props.onInputValueChange(newStateToSet.inputValue, _extends({}, _this.getStateAndHelpers(), newStateToSet));
|
|
663
655
|
}
|
|
664
656
|
return nextState;
|
|
665
657
|
}, function () {
|
|
@@ -693,7 +685,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
693
685
|
_ref$refKey = _ref.refKey,
|
|
694
686
|
refKey = _ref$refKey === void 0 ? 'ref' : _ref$refKey,
|
|
695
687
|
ref = _ref.ref,
|
|
696
|
-
rest =
|
|
688
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$3);
|
|
697
689
|
var _ref2 = _temp2 === void 0 ? {} : _temp2,
|
|
698
690
|
_ref2$suppressRefErro = _ref2.suppressRefError,
|
|
699
691
|
suppressRefError = _ref2$suppressRefErro === void 0 ? false : _ref2$suppressRefErro;
|
|
@@ -704,7 +696,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
704
696
|
_this.getRootProps.suppressRefError = suppressRefError;
|
|
705
697
|
var _this$getState = _this.getState(),
|
|
706
698
|
isOpen = _this$getState.isOpen;
|
|
707
|
-
return
|
|
699
|
+
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);
|
|
708
700
|
};
|
|
709
701
|
//\\\\\\\\\\\\\\\\\\\\\\\\\\ ROOT
|
|
710
702
|
_this.keyDownHandlers = {
|
|
@@ -783,7 +775,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
783
775
|
},
|
|
784
776
|
Escape: function Escape(event) {
|
|
785
777
|
event.preventDefault();
|
|
786
|
-
this.reset(
|
|
778
|
+
this.reset(_extends({
|
|
787
779
|
type: keyDownEscape
|
|
788
780
|
}, !this.state.isOpen && {
|
|
789
781
|
selectedItem: null,
|
|
@@ -792,7 +784,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
792
784
|
}
|
|
793
785
|
};
|
|
794
786
|
//////////////////////////// BUTTON
|
|
795
|
-
_this.buttonKeyDownHandlers =
|
|
787
|
+
_this.buttonKeyDownHandlers = _extends({}, _this.keyDownHandlers, {
|
|
796
788
|
' ': function _(event) {
|
|
797
789
|
event.preventDefault();
|
|
798
790
|
this.toggleMenu({
|
|
@@ -800,7 +792,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
800
792
|
});
|
|
801
793
|
}
|
|
802
794
|
});
|
|
803
|
-
_this.inputKeyDownHandlers =
|
|
795
|
+
_this.inputKeyDownHandlers = _extends({}, _this.keyDownHandlers, {
|
|
804
796
|
Home: function Home(event) {
|
|
805
797
|
var _this$getState3 = this.getState(),
|
|
806
798
|
isOpen = _this$getState3.isOpen;
|
|
@@ -849,7 +841,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
849
841
|
var onKeyDown = _ref3.onKeyDown,
|
|
850
842
|
onKeyUp = _ref3.onKeyUp,
|
|
851
843
|
onBlur = _ref3.onBlur,
|
|
852
|
-
rest =
|
|
844
|
+
rest = _objectWithoutPropertiesLoose(_ref3, _excluded2$3);
|
|
853
845
|
var _this$getState5 = _this.getState(),
|
|
854
846
|
isOpen = _this$getState5.isOpen;
|
|
855
847
|
var enabledEventHandlers = {
|
|
@@ -859,7 +851,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
859
851
|
onBlur: callAllEventHandlers(onBlur, _this.buttonHandleBlur)
|
|
860
852
|
};
|
|
861
853
|
var eventHandlers = rest.disabled ? {} : enabledEventHandlers;
|
|
862
|
-
return
|
|
854
|
+
return _extends({
|
|
863
855
|
type: 'button',
|
|
864
856
|
role: 'button',
|
|
865
857
|
'aria-label': isOpen ? 'close menu' : 'open menu',
|
|
@@ -925,7 +917,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
925
917
|
//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ BUTTON
|
|
926
918
|
/////////////////////////////// LABEL
|
|
927
919
|
_this.getLabelProps = function (props) {
|
|
928
|
-
return
|
|
920
|
+
return _extends({
|
|
929
921
|
htmlFor: _this.inputId,
|
|
930
922
|
id: _this.labelId
|
|
931
923
|
}, props);
|
|
@@ -939,7 +931,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
939
931
|
onChange = _ref4.onChange,
|
|
940
932
|
onInput = _ref4.onInput;
|
|
941
933
|
_ref4.onChangeText;
|
|
942
|
-
var rest =
|
|
934
|
+
var rest = _objectWithoutPropertiesLoose(_ref4, _excluded3$2);
|
|
943
935
|
var onChangeKey;
|
|
944
936
|
var eventHandlers = {};
|
|
945
937
|
|
|
@@ -955,7 +947,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
955
947
|
var _eventHandlers;
|
|
956
948
|
eventHandlers = (_eventHandlers = {}, _eventHandlers[onChangeKey] = callAllEventHandlers(onChange, onInput, _this.inputHandleChange), _eventHandlers.onKeyDown = callAllEventHandlers(onKeyDown, _this.inputHandleKeyDown), _eventHandlers.onBlur = callAllEventHandlers(onBlur, _this.inputHandleBlur), _eventHandlers);
|
|
957
949
|
}
|
|
958
|
-
return
|
|
950
|
+
return _extends({
|
|
959
951
|
'aria-autocomplete': 'list',
|
|
960
952
|
'aria-activedescendant': isOpen && typeof highlightedIndex === 'number' && highlightedIndex >= 0 ? _this.getItemId(highlightedIndex) : undefined,
|
|
961
953
|
'aria-controls': isOpen ? _this.menuId : undefined,
|
|
@@ -1008,14 +1000,14 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1008
1000
|
_ref5$refKey = _ref5.refKey,
|
|
1009
1001
|
refKey = _ref5$refKey === void 0 ? 'ref' : _ref5$refKey,
|
|
1010
1002
|
ref = _ref5.ref,
|
|
1011
|
-
props =
|
|
1003
|
+
props = _objectWithoutPropertiesLoose(_ref5, _excluded4$2);
|
|
1012
1004
|
var _ref6 = _temp6 === void 0 ? {} : _temp6,
|
|
1013
1005
|
_ref6$suppressRefErro = _ref6.suppressRefError,
|
|
1014
1006
|
suppressRefError = _ref6$suppressRefErro === void 0 ? false : _ref6$suppressRefErro;
|
|
1015
1007
|
_this.getMenuProps.called = true;
|
|
1016
1008
|
_this.getMenuProps.refKey = refKey;
|
|
1017
1009
|
_this.getMenuProps.suppressRefError = suppressRefError;
|
|
1018
|
-
return
|
|
1010
|
+
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);
|
|
1019
1011
|
};
|
|
1020
1012
|
//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ MENU
|
|
1021
1013
|
/////////////////////////////// ITEM
|
|
@@ -1029,7 +1021,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1029
1021
|
var index = _ref7.index,
|
|
1030
1022
|
_ref7$item = _ref7.item,
|
|
1031
1023
|
item = _ref7$item === void 0 ? process.env.NODE_ENV === 'production' ? /* istanbul ignore next */undefined : requiredProp('getItemProps', 'item') : _ref7$item,
|
|
1032
|
-
rest =
|
|
1024
|
+
rest = _objectWithoutPropertiesLoose(_ref7, _excluded5);
|
|
1033
1025
|
if (index === undefined) {
|
|
1034
1026
|
_this.items.push(item);
|
|
1035
1027
|
index = _this.items.indexOf(item);
|
|
@@ -1076,7 +1068,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1076
1068
|
var eventHandlers = rest.disabled ? {
|
|
1077
1069
|
onMouseDown: enabledEventHandlers.onMouseDown
|
|
1078
1070
|
} : enabledEventHandlers;
|
|
1079
|
-
return
|
|
1071
|
+
return _extends({
|
|
1080
1072
|
id: _this.getItemId(index),
|
|
1081
1073
|
role: 'option',
|
|
1082
1074
|
'aria-selected': _this.getState().highlightedIndex === index
|
|
@@ -1093,7 +1085,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1093
1085
|
otherStateToSet = pickState(otherStateToSet);
|
|
1094
1086
|
_this.internalSetState(function (_ref8) {
|
|
1095
1087
|
var selectedItem = _ref8.selectedItem;
|
|
1096
|
-
return
|
|
1088
|
+
return _extends({
|
|
1097
1089
|
isOpen: _this.props.defaultIsOpen,
|
|
1098
1090
|
highlightedIndex: _this.props.defaultHighlightedIndex,
|
|
1099
1091
|
inputValue: _this.props.itemToString(selectedItem)
|
|
@@ -1107,7 +1099,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1107
1099
|
otherStateToSet = pickState(otherStateToSet);
|
|
1108
1100
|
_this.internalSetState(function (_ref9) {
|
|
1109
1101
|
var isOpen = _ref9.isOpen;
|
|
1110
|
-
return
|
|
1102
|
+
return _extends({
|
|
1111
1103
|
isOpen: !isOpen
|
|
1112
1104
|
}, isOpen && {
|
|
1113
1105
|
highlightedIndex: _this.props.defaultHighlightedIndex
|
|
@@ -1142,7 +1134,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1142
1134
|
var state = _this.getState();
|
|
1143
1135
|
var item = _this.items[state.highlightedIndex];
|
|
1144
1136
|
var resultCount = _this.getItemCount();
|
|
1145
|
-
var status = _this.props.getA11yStatusMessage(
|
|
1137
|
+
var status = _this.props.getA11yStatusMessage(_extends({
|
|
1146
1138
|
itemToString: _this.props.itemToString,
|
|
1147
1139
|
previousResultCount: _this.previousResultCount,
|
|
1148
1140
|
resultCount: resultCount,
|
|
@@ -1174,7 +1166,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1174
1166
|
_this.state = _state;
|
|
1175
1167
|
return _this;
|
|
1176
1168
|
}
|
|
1177
|
-
|
|
1169
|
+
_inheritsLoose(Downshift, _Component);
|
|
1178
1170
|
var _proto = Downshift.prototype;
|
|
1179
1171
|
/**
|
|
1180
1172
|
* Clear all running timeouts
|
|
@@ -1487,49 +1479,49 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1487
1479
|
return Downshift;
|
|
1488
1480
|
}();
|
|
1489
1481
|
process.env.NODE_ENV !== "production" ? Downshift.propTypes = {
|
|
1490
|
-
children:
|
|
1491
|
-
defaultHighlightedIndex:
|
|
1492
|
-
defaultIsOpen:
|
|
1493
|
-
initialHighlightedIndex:
|
|
1494
|
-
initialSelectedItem:
|
|
1495
|
-
initialInputValue:
|
|
1496
|
-
initialIsOpen:
|
|
1497
|
-
getA11yStatusMessage:
|
|
1498
|
-
itemToString:
|
|
1499
|
-
onChange:
|
|
1500
|
-
onSelect:
|
|
1501
|
-
onStateChange:
|
|
1502
|
-
onInputValueChange:
|
|
1503
|
-
onUserAction:
|
|
1504
|
-
onOuterClick:
|
|
1505
|
-
selectedItemChanged:
|
|
1506
|
-
stateReducer:
|
|
1507
|
-
itemCount:
|
|
1508
|
-
id:
|
|
1509
|
-
environment:
|
|
1510
|
-
addEventListener:
|
|
1511
|
-
removeEventListener:
|
|
1512
|
-
document:
|
|
1513
|
-
createElement:
|
|
1514
|
-
getElementById:
|
|
1515
|
-
activeElement:
|
|
1516
|
-
body:
|
|
1482
|
+
children: PropTypes.func,
|
|
1483
|
+
defaultHighlightedIndex: PropTypes.number,
|
|
1484
|
+
defaultIsOpen: PropTypes.bool,
|
|
1485
|
+
initialHighlightedIndex: PropTypes.number,
|
|
1486
|
+
initialSelectedItem: PropTypes.any,
|
|
1487
|
+
initialInputValue: PropTypes.string,
|
|
1488
|
+
initialIsOpen: PropTypes.bool,
|
|
1489
|
+
getA11yStatusMessage: PropTypes.func,
|
|
1490
|
+
itemToString: PropTypes.func,
|
|
1491
|
+
onChange: PropTypes.func,
|
|
1492
|
+
onSelect: PropTypes.func,
|
|
1493
|
+
onStateChange: PropTypes.func,
|
|
1494
|
+
onInputValueChange: PropTypes.func,
|
|
1495
|
+
onUserAction: PropTypes.func,
|
|
1496
|
+
onOuterClick: PropTypes.func,
|
|
1497
|
+
selectedItemChanged: PropTypes.func,
|
|
1498
|
+
stateReducer: PropTypes.func,
|
|
1499
|
+
itemCount: PropTypes.number,
|
|
1500
|
+
id: PropTypes.string,
|
|
1501
|
+
environment: PropTypes.shape({
|
|
1502
|
+
addEventListener: PropTypes.func.isRequired,
|
|
1503
|
+
removeEventListener: PropTypes.func.isRequired,
|
|
1504
|
+
document: PropTypes.shape({
|
|
1505
|
+
createElement: PropTypes.func.isRequired,
|
|
1506
|
+
getElementById: PropTypes.func.isRequired,
|
|
1507
|
+
activeElement: PropTypes.any.isRequired,
|
|
1508
|
+
body: PropTypes.any.isRequired
|
|
1517
1509
|
}).isRequired,
|
|
1518
|
-
Node:
|
|
1510
|
+
Node: PropTypes.func.isRequired
|
|
1519
1511
|
}),
|
|
1520
|
-
suppressRefError:
|
|
1521
|
-
scrollIntoView:
|
|
1512
|
+
suppressRefError: PropTypes.bool,
|
|
1513
|
+
scrollIntoView: PropTypes.func,
|
|
1522
1514
|
// things we keep in state for uncontrolled components
|
|
1523
1515
|
// but can accept as props for controlled components
|
|
1524
1516
|
/* eslint-disable react/no-unused-prop-types */
|
|
1525
|
-
selectedItem:
|
|
1526
|
-
isOpen:
|
|
1527
|
-
inputValue:
|
|
1528
|
-
highlightedIndex:
|
|
1529
|
-
labelId:
|
|
1530
|
-
inputId:
|
|
1531
|
-
menuId:
|
|
1532
|
-
getItemId:
|
|
1517
|
+
selectedItem: PropTypes.any,
|
|
1518
|
+
isOpen: PropTypes.bool,
|
|
1519
|
+
inputValue: PropTypes.string,
|
|
1520
|
+
highlightedIndex: PropTypes.number,
|
|
1521
|
+
labelId: PropTypes.string,
|
|
1522
|
+
inputId: PropTypes.string,
|
|
1523
|
+
menuId: PropTypes.string,
|
|
1524
|
+
getItemId: PropTypes.func
|
|
1533
1525
|
/* eslint-enable react/no-unused-prop-types */
|
|
1534
1526
|
} : void 0;
|
|
1535
1527
|
var Downshift$1 = Downshift;
|
|
@@ -1574,7 +1566,7 @@ function callOnChangeProps(action, state, newState) {
|
|
|
1574
1566
|
}
|
|
1575
1567
|
});
|
|
1576
1568
|
if (props.onStateChange && Object.keys(changes).length) {
|
|
1577
|
-
props.onStateChange(
|
|
1569
|
+
props.onStateChange(_extends({
|
|
1578
1570
|
type: type
|
|
1579
1571
|
}, changes));
|
|
1580
1572
|
}
|
|
@@ -1584,7 +1576,7 @@ function invokeOnChangeHandler(key, action, state, newState) {
|
|
|
1584
1576
|
type = action.type;
|
|
1585
1577
|
var handler = "on" + capitalizeString(key) + "Change";
|
|
1586
1578
|
if (props[handler] && newState[key] !== undefined && newState[key] !== state[key]) {
|
|
1587
|
-
props[handler](
|
|
1579
|
+
props[handler](_extends({
|
|
1588
1580
|
type: type
|
|
1589
1581
|
}, newState));
|
|
1590
1582
|
}
|
|
@@ -1612,7 +1604,7 @@ var updateA11yStatus = debounce(function (status, document) {
|
|
|
1612
1604
|
var useIsomorphicLayoutEffect = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined' ? React.useLayoutEffect : React.useEffect;
|
|
1613
1605
|
|
|
1614
1606
|
// istanbul ignore next
|
|
1615
|
-
var useElementIds = 'useId' in
|
|
1607
|
+
var useElementIds = 'useId' in React // Avoid conditional useId call
|
|
1616
1608
|
? function useElementIds(_ref) {
|
|
1617
1609
|
var id = _ref.id,
|
|
1618
1610
|
labelId = _ref.labelId,
|
|
@@ -1621,7 +1613,7 @@ var useElementIds = 'useId' in React__default["default"] // Avoid conditional us
|
|
|
1621
1613
|
toggleButtonId = _ref.toggleButtonId,
|
|
1622
1614
|
inputId = _ref.inputId;
|
|
1623
1615
|
// Avoid conditional useId call
|
|
1624
|
-
var reactId = "downshift-" +
|
|
1616
|
+
var reactId = "downshift-" + React.useId();
|
|
1625
1617
|
if (!id) {
|
|
1626
1618
|
id = reactId;
|
|
1627
1619
|
}
|
|
@@ -1703,7 +1695,7 @@ function useEnhancedReducer(reducer, props, createInitialState, isStateEqual) {
|
|
|
1703
1695
|
actionRef.current = action;
|
|
1704
1696
|
state = getState(state, action.props);
|
|
1705
1697
|
var changes = reducer(state, action);
|
|
1706
|
-
var newState = action.props.stateReducer(state,
|
|
1698
|
+
var newState = action.props.stateReducer(state, _extends({}, action, {
|
|
1707
1699
|
changes: changes
|
|
1708
1700
|
}));
|
|
1709
1701
|
return newState;
|
|
@@ -1713,7 +1705,7 @@ function useEnhancedReducer(reducer, props, createInitialState, isStateEqual) {
|
|
|
1713
1705
|
dispatch = _useReducer[1];
|
|
1714
1706
|
var propsRef = useLatestRef(props);
|
|
1715
1707
|
var dispatchWithProps = React.useCallback(function (action) {
|
|
1716
|
-
return dispatch(
|
|
1708
|
+
return dispatch(_extends({
|
|
1717
1709
|
props: propsRef.current
|
|
1718
1710
|
}, action));
|
|
1719
1711
|
}, [propsRef]);
|
|
@@ -1784,7 +1776,7 @@ function getInitialValue$1(props, propKey, defaultStateValues) {
|
|
|
1784
1776
|
function getInitialState$2(props) {
|
|
1785
1777
|
var selectedItem = getInitialValue$1(props, 'selectedItem');
|
|
1786
1778
|
var isOpen = getInitialValue$1(props, 'isOpen');
|
|
1787
|
-
var highlightedIndex =
|
|
1779
|
+
var highlightedIndex = getInitialHighlightedIndex(props);
|
|
1788
1780
|
var inputValue = getInitialValue$1(props, 'inputValue');
|
|
1789
1781
|
return {
|
|
1790
1782
|
highlightedIndex: highlightedIndex < 0 && selectedItem && isOpen ? props.items.findIndex(function (item) {
|
|
@@ -1808,10 +1800,10 @@ function getHighlightedIndexOnOpen(props, state, offset) {
|
|
|
1808
1800
|
}
|
|
1809
1801
|
|
|
1810
1802
|
// initialHighlightedIndex will give value to highlightedIndex on initial state only.
|
|
1811
|
-
if (initialHighlightedIndex !== undefined && highlightedIndex === initialHighlightedIndex && !isItemDisabled(items[initialHighlightedIndex])) {
|
|
1803
|
+
if (initialHighlightedIndex !== undefined && highlightedIndex === initialHighlightedIndex && !isItemDisabled(items[initialHighlightedIndex], initialHighlightedIndex)) {
|
|
1812
1804
|
return initialHighlightedIndex;
|
|
1813
1805
|
}
|
|
1814
|
-
if (defaultHighlightedIndex !== undefined && !isItemDisabled(items[defaultHighlightedIndex])) {
|
|
1806
|
+
if (defaultHighlightedIndex !== undefined && !isItemDisabled(items[defaultHighlightedIndex], defaultHighlightedIndex)) {
|
|
1815
1807
|
return defaultHighlightedIndex;
|
|
1816
1808
|
}
|
|
1817
1809
|
if (selectedItem) {
|
|
@@ -1819,10 +1811,10 @@ function getHighlightedIndexOnOpen(props, state, offset) {
|
|
|
1819
1811
|
return itemToKey(selectedItem) === itemToKey(item);
|
|
1820
1812
|
});
|
|
1821
1813
|
}
|
|
1822
|
-
if (offset < 0 && !isItemDisabled(items[items.length - 1])) {
|
|
1814
|
+
if (offset < 0 && !isItemDisabled(items[items.length - 1], items.length - 1)) {
|
|
1823
1815
|
return items.length - 1;
|
|
1824
1816
|
}
|
|
1825
|
-
if (offset > 0 && !isItemDisabled(items[0])) {
|
|
1817
|
+
if (offset > 0 && !isItemDisabled(items[0], 0)) {
|
|
1826
1818
|
return 0;
|
|
1827
1819
|
}
|
|
1828
1820
|
return -1;
|
|
@@ -2032,10 +2024,10 @@ function getChangesOnSelection(props, highlightedIndex, inputValue) {
|
|
|
2032
2024
|
inputValue = true;
|
|
2033
2025
|
}
|
|
2034
2026
|
var shouldSelect = ((_props$items = props.items) == null ? void 0 : _props$items.length) && highlightedIndex >= 0;
|
|
2035
|
-
return
|
|
2027
|
+
return _extends({
|
|
2036
2028
|
isOpen: false,
|
|
2037
2029
|
highlightedIndex: -1
|
|
2038
|
-
}, shouldSelect &&
|
|
2030
|
+
}, shouldSelect && _extends({
|
|
2039
2031
|
selectedItem: props.items[highlightedIndex],
|
|
2040
2032
|
isOpen: getDefaultValue$1(props, 'isOpen'),
|
|
2041
2033
|
highlightedIndex: getDefaultValue$1(props, 'highlightedIndex')
|
|
@@ -2060,8 +2052,8 @@ function isDropdownsStateEqual(prevState, newState) {
|
|
|
2060
2052
|
* Tracks if it's the first render.
|
|
2061
2053
|
*/
|
|
2062
2054
|
function useIsInitialMount() {
|
|
2063
|
-
var isInitialMountRef =
|
|
2064
|
-
|
|
2055
|
+
var isInitialMountRef = React.useRef(true);
|
|
2056
|
+
React.useEffect(function () {
|
|
2065
2057
|
isInitialMountRef.current = false;
|
|
2066
2058
|
return function () {
|
|
2067
2059
|
isInitialMountRef.current = true;
|
|
@@ -2070,46 +2062,74 @@ function useIsInitialMount() {
|
|
|
2070
2062
|
return isInitialMountRef.current;
|
|
2071
2063
|
}
|
|
2072
2064
|
|
|
2065
|
+
/**
|
|
2066
|
+
* Returns the new highlightedIndex based on the defaultHighlightedIndex prop, if it's not disabled.
|
|
2067
|
+
*
|
|
2068
|
+
* @param {Object} props Props from useCombobox or useSelect.
|
|
2069
|
+
* @returns {number} The highlighted index.
|
|
2070
|
+
*/
|
|
2071
|
+
function getDefaultHighlightedIndex(props) {
|
|
2072
|
+
var highlightedIndex = getDefaultValue$1(props, 'highlightedIndex');
|
|
2073
|
+
if (highlightedIndex > -1 && props.isItemDisabled(props.items[highlightedIndex], highlightedIndex)) {
|
|
2074
|
+
return -1;
|
|
2075
|
+
}
|
|
2076
|
+
return highlightedIndex;
|
|
2077
|
+
}
|
|
2078
|
+
|
|
2079
|
+
/**
|
|
2080
|
+
* Returns the new highlightedIndex based on the initialHighlightedIndex prop, if not disabled.
|
|
2081
|
+
*
|
|
2082
|
+
* @param {Object} props Props from useCombobox or useSelect.
|
|
2083
|
+
* @returns {number} The highlighted index.
|
|
2084
|
+
*/
|
|
2085
|
+
function getInitialHighlightedIndex(props) {
|
|
2086
|
+
var highlightedIndex = getInitialValue$1(props, 'highlightedIndex');
|
|
2087
|
+
if (highlightedIndex > -1 && props.isItemDisabled(props.items[highlightedIndex], highlightedIndex)) {
|
|
2088
|
+
return -1;
|
|
2089
|
+
}
|
|
2090
|
+
return highlightedIndex;
|
|
2091
|
+
}
|
|
2092
|
+
|
|
2073
2093
|
// Shared between all exports.
|
|
2074
2094
|
var commonPropTypes = {
|
|
2075
|
-
environment:
|
|
2076
|
-
addEventListener:
|
|
2077
|
-
removeEventListener:
|
|
2078
|
-
document:
|
|
2079
|
-
createElement:
|
|
2080
|
-
getElementById:
|
|
2081
|
-
activeElement:
|
|
2082
|
-
body:
|
|
2095
|
+
environment: PropTypes.shape({
|
|
2096
|
+
addEventListener: PropTypes.func.isRequired,
|
|
2097
|
+
removeEventListener: PropTypes.func.isRequired,
|
|
2098
|
+
document: PropTypes.shape({
|
|
2099
|
+
createElement: PropTypes.func.isRequired,
|
|
2100
|
+
getElementById: PropTypes.func.isRequired,
|
|
2101
|
+
activeElement: PropTypes.any.isRequired,
|
|
2102
|
+
body: PropTypes.any.isRequired
|
|
2083
2103
|
}).isRequired,
|
|
2084
|
-
Node:
|
|
2104
|
+
Node: PropTypes.func.isRequired
|
|
2085
2105
|
}),
|
|
2086
|
-
itemToString:
|
|
2087
|
-
itemToKey:
|
|
2088
|
-
stateReducer:
|
|
2106
|
+
itemToString: PropTypes.func,
|
|
2107
|
+
itemToKey: PropTypes.func,
|
|
2108
|
+
stateReducer: PropTypes.func
|
|
2089
2109
|
};
|
|
2090
2110
|
|
|
2091
2111
|
// Shared between useSelect, useCombobox, Downshift.
|
|
2092
|
-
var commonDropdownPropTypes =
|
|
2093
|
-
getA11yStatusMessage:
|
|
2094
|
-
highlightedIndex:
|
|
2095
|
-
defaultHighlightedIndex:
|
|
2096
|
-
initialHighlightedIndex:
|
|
2097
|
-
isOpen:
|
|
2098
|
-
defaultIsOpen:
|
|
2099
|
-
initialIsOpen:
|
|
2100
|
-
selectedItem:
|
|
2101
|
-
initialSelectedItem:
|
|
2102
|
-
defaultSelectedItem:
|
|
2103
|
-
id:
|
|
2104
|
-
labelId:
|
|
2105
|
-
menuId:
|
|
2106
|
-
getItemId:
|
|
2107
|
-
toggleButtonId:
|
|
2108
|
-
onSelectedItemChange:
|
|
2109
|
-
onHighlightedIndexChange:
|
|
2110
|
-
onStateChange:
|
|
2111
|
-
onIsOpenChange:
|
|
2112
|
-
scrollIntoView:
|
|
2112
|
+
var commonDropdownPropTypes = _extends({}, commonPropTypes, {
|
|
2113
|
+
getA11yStatusMessage: PropTypes.func,
|
|
2114
|
+
highlightedIndex: PropTypes.number,
|
|
2115
|
+
defaultHighlightedIndex: PropTypes.number,
|
|
2116
|
+
initialHighlightedIndex: PropTypes.number,
|
|
2117
|
+
isOpen: PropTypes.bool,
|
|
2118
|
+
defaultIsOpen: PropTypes.bool,
|
|
2119
|
+
initialIsOpen: PropTypes.bool,
|
|
2120
|
+
selectedItem: PropTypes.any,
|
|
2121
|
+
initialSelectedItem: PropTypes.any,
|
|
2122
|
+
defaultSelectedItem: PropTypes.any,
|
|
2123
|
+
id: PropTypes.string,
|
|
2124
|
+
labelId: PropTypes.string,
|
|
2125
|
+
menuId: PropTypes.string,
|
|
2126
|
+
getItemId: PropTypes.func,
|
|
2127
|
+
toggleButtonId: PropTypes.string,
|
|
2128
|
+
onSelectedItemChange: PropTypes.func,
|
|
2129
|
+
onHighlightedIndexChange: PropTypes.func,
|
|
2130
|
+
onStateChange: PropTypes.func,
|
|
2131
|
+
onIsOpenChange: PropTypes.func,
|
|
2132
|
+
scrollIntoView: PropTypes.func
|
|
2113
2133
|
});
|
|
2114
2134
|
|
|
2115
2135
|
function downshiftCommonReducer(state, action, stateChangeTypes) {
|
|
@@ -2147,7 +2167,7 @@ function downshiftCommonReducer(state, action, stateChangeTypes) {
|
|
|
2147
2167
|
break;
|
|
2148
2168
|
case stateChangeTypes.FunctionSetHighlightedIndex:
|
|
2149
2169
|
changes = {
|
|
2150
|
-
highlightedIndex: action.highlightedIndex
|
|
2170
|
+
highlightedIndex: props.isItemDisabled(props.items[action.highlightedIndex], action.highlightedIndex) ? -1 : action.highlightedIndex
|
|
2151
2171
|
};
|
|
2152
2172
|
break;
|
|
2153
2173
|
case stateChangeTypes.FunctionSetInputValue:
|
|
@@ -2157,7 +2177,7 @@ function downshiftCommonReducer(state, action, stateChangeTypes) {
|
|
|
2157
2177
|
break;
|
|
2158
2178
|
case stateChangeTypes.FunctionReset:
|
|
2159
2179
|
changes = {
|
|
2160
|
-
highlightedIndex:
|
|
2180
|
+
highlightedIndex: getDefaultHighlightedIndex(props),
|
|
2161
2181
|
isOpen: getDefaultValue$1(props, 'isOpen'),
|
|
2162
2182
|
selectedItem: getDefaultValue$1(props, 'selectedItem'),
|
|
2163
2183
|
inputValue: getDefaultValue$1(props, 'inputValue')
|
|
@@ -2166,7 +2186,7 @@ function downshiftCommonReducer(state, action, stateChangeTypes) {
|
|
|
2166
2186
|
default:
|
|
2167
2187
|
throw new Error('Reducer called without proper action type.');
|
|
2168
2188
|
}
|
|
2169
|
-
return
|
|
2189
|
+
return _extends({}, state, changes);
|
|
2170
2190
|
}
|
|
2171
2191
|
/* eslint-enable complexity */
|
|
2172
2192
|
|
|
@@ -2185,7 +2205,7 @@ function getItemIndexByCharacterKey(_a) {
|
|
|
2185
2205
|
}
|
|
2186
2206
|
return highlightedIndex;
|
|
2187
2207
|
}
|
|
2188
|
-
var propTypes$2 = tslib.__assign(tslib.__assign({}, commonDropdownPropTypes), { items:
|
|
2208
|
+
var propTypes$2 = tslib.__assign(tslib.__assign({}, commonDropdownPropTypes), { items: PropTypes.array.isRequired, isItemDisabled: PropTypes.func });
|
|
2189
2209
|
var defaultProps$2 = tslib.__assign(tslib.__assign({}, defaultProps$3), { isItemDisabled: function () {
|
|
2190
2210
|
return false;
|
|
2191
2211
|
} });
|
|
@@ -2194,7 +2214,7 @@ var validatePropTypes$2 = noop;
|
|
|
2194
2214
|
/* istanbul ignore next */
|
|
2195
2215
|
if (process.env.NODE_ENV !== 'production') {
|
|
2196
2216
|
validatePropTypes$2 = function (options, caller) {
|
|
2197
|
-
|
|
2217
|
+
PropTypes.checkPropTypes(propTypes$2, options, 'prop', caller.name);
|
|
2198
2218
|
};
|
|
2199
2219
|
}
|
|
2200
2220
|
|
|
@@ -2223,28 +2243,28 @@ var FunctionReset$2 = process.env.NODE_ENV !== "production" ? '__function_reset_
|
|
|
2223
2243
|
|
|
2224
2244
|
var stateChangeTypes$2 = /*#__PURE__*/Object.freeze({
|
|
2225
2245
|
__proto__: null,
|
|
2246
|
+
FunctionCloseMenu: FunctionCloseMenu$1,
|
|
2247
|
+
FunctionOpenMenu: FunctionOpenMenu$1,
|
|
2248
|
+
FunctionReset: FunctionReset$2,
|
|
2249
|
+
FunctionSelectItem: FunctionSelectItem$1,
|
|
2250
|
+
FunctionSetHighlightedIndex: FunctionSetHighlightedIndex$1,
|
|
2251
|
+
FunctionSetInputValue: FunctionSetInputValue$1,
|
|
2252
|
+
FunctionToggleMenu: FunctionToggleMenu$1,
|
|
2253
|
+
ItemClick: ItemClick$1,
|
|
2254
|
+
ItemMouseMove: ItemMouseMove$1,
|
|
2255
|
+
MenuMouseLeave: MenuMouseLeave$1,
|
|
2256
|
+
ToggleButtonBlur: ToggleButtonBlur,
|
|
2226
2257
|
ToggleButtonClick: ToggleButtonClick$1,
|
|
2227
2258
|
ToggleButtonKeyDownArrowDown: ToggleButtonKeyDownArrowDown,
|
|
2228
2259
|
ToggleButtonKeyDownArrowUp: ToggleButtonKeyDownArrowUp,
|
|
2229
2260
|
ToggleButtonKeyDownCharacter: ToggleButtonKeyDownCharacter,
|
|
2230
|
-
ToggleButtonKeyDownEscape: ToggleButtonKeyDownEscape,
|
|
2231
|
-
ToggleButtonKeyDownHome: ToggleButtonKeyDownHome,
|
|
2232
2261
|
ToggleButtonKeyDownEnd: ToggleButtonKeyDownEnd,
|
|
2233
2262
|
ToggleButtonKeyDownEnter: ToggleButtonKeyDownEnter,
|
|
2234
|
-
|
|
2235
|
-
|
|
2263
|
+
ToggleButtonKeyDownEscape: ToggleButtonKeyDownEscape,
|
|
2264
|
+
ToggleButtonKeyDownHome: ToggleButtonKeyDownHome,
|
|
2236
2265
|
ToggleButtonKeyDownPageDown: ToggleButtonKeyDownPageDown,
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
ItemMouseMove: ItemMouseMove$1,
|
|
2240
|
-
ItemClick: ItemClick$1,
|
|
2241
|
-
FunctionToggleMenu: FunctionToggleMenu$1,
|
|
2242
|
-
FunctionOpenMenu: FunctionOpenMenu$1,
|
|
2243
|
-
FunctionCloseMenu: FunctionCloseMenu$1,
|
|
2244
|
-
FunctionSetHighlightedIndex: FunctionSetHighlightedIndex$1,
|
|
2245
|
-
FunctionSelectItem: FunctionSelectItem$1,
|
|
2246
|
-
FunctionSetInputValue: FunctionSetInputValue$1,
|
|
2247
|
-
FunctionReset: FunctionReset$2
|
|
2266
|
+
ToggleButtonKeyDownPageUp: ToggleButtonKeyDownPageUp,
|
|
2267
|
+
ToggleButtonKeyDownSpaceButton: ToggleButtonKeyDownSpaceButton
|
|
2248
2268
|
});
|
|
2249
2269
|
|
|
2250
2270
|
/* eslint-disable complexity */
|
|
@@ -2258,7 +2278,7 @@ function downshiftSelectReducer(state, action) {
|
|
|
2258
2278
|
case ItemClick$1:
|
|
2259
2279
|
changes = {
|
|
2260
2280
|
isOpen: getDefaultValue$1(props, 'isOpen'),
|
|
2261
|
-
highlightedIndex:
|
|
2281
|
+
highlightedIndex: getDefaultHighlightedIndex(props),
|
|
2262
2282
|
selectedItem: props.items[action.index]
|
|
2263
2283
|
};
|
|
2264
2284
|
break;
|
|
@@ -2337,7 +2357,7 @@ function downshiftSelectReducer(state, action) {
|
|
|
2337
2357
|
};
|
|
2338
2358
|
break;
|
|
2339
2359
|
case ToggleButtonBlur:
|
|
2340
|
-
changes =
|
|
2360
|
+
changes = _extends({
|
|
2341
2361
|
isOpen: false,
|
|
2342
2362
|
highlightedIndex: -1
|
|
2343
2363
|
}, state.highlightedIndex >= 0 && ((_props$items = props.items) == null ? void 0 : _props$items.length) && {
|
|
@@ -2352,7 +2372,7 @@ function downshiftSelectReducer(state, action) {
|
|
|
2352
2372
|
default:
|
|
2353
2373
|
return downshiftCommonReducer(state, action, stateChangeTypes$2);
|
|
2354
2374
|
}
|
|
2355
|
-
return
|
|
2375
|
+
return _extends({}, state, changes);
|
|
2356
2376
|
}
|
|
2357
2377
|
/* eslint-enable complexity */
|
|
2358
2378
|
|
|
@@ -2367,7 +2387,7 @@ function useSelect(userProps) {
|
|
|
2367
2387
|
}
|
|
2368
2388
|
validatePropTypes$2(userProps, useSelect);
|
|
2369
2389
|
// Props defaults and destructuring.
|
|
2370
|
-
var props =
|
|
2390
|
+
var props = _extends({}, defaultProps$2, userProps);
|
|
2371
2391
|
var scrollIntoView = props.scrollIntoView,
|
|
2372
2392
|
environment = props.environment,
|
|
2373
2393
|
getA11yStatusMessage = props.getA11yStatusMessage;
|
|
@@ -2583,12 +2603,12 @@ function useSelect(userProps) {
|
|
|
2583
2603
|
var getLabelProps = React.useCallback(function (_temp) {
|
|
2584
2604
|
var _ref = _temp === void 0 ? {} : _temp,
|
|
2585
2605
|
onClick = _ref.onClick,
|
|
2586
|
-
labelProps =
|
|
2606
|
+
labelProps = _objectWithoutPropertiesLoose(_ref, _excluded$2);
|
|
2587
2607
|
var labelHandleClick = function labelHandleClick() {
|
|
2588
2608
|
var _toggleButtonRef$curr;
|
|
2589
2609
|
(_toggleButtonRef$curr = toggleButtonRef.current) == null || _toggleButtonRef$curr.focus();
|
|
2590
2610
|
};
|
|
2591
|
-
return
|
|
2611
|
+
return _extends({
|
|
2592
2612
|
id: elementIds.labelId,
|
|
2593
2613
|
htmlFor: elementIds.toggleButtonId,
|
|
2594
2614
|
onClick: callAllEventHandlers(onClick, labelHandleClick)
|
|
@@ -2601,7 +2621,7 @@ function useSelect(userProps) {
|
|
|
2601
2621
|
_ref2$refKey = _ref2.refKey,
|
|
2602
2622
|
refKey = _ref2$refKey === void 0 ? 'ref' : _ref2$refKey,
|
|
2603
2623
|
ref = _ref2.ref,
|
|
2604
|
-
rest =
|
|
2624
|
+
rest = _objectWithoutPropertiesLoose(_ref2, _excluded2$2);
|
|
2605
2625
|
var _ref3 = _temp3 === void 0 ? {} : _temp3,
|
|
2606
2626
|
_ref3$suppressRefErro = _ref3.suppressRefError,
|
|
2607
2627
|
suppressRefError = _ref3$suppressRefErro === void 0 ? false : _ref3$suppressRefErro;
|
|
@@ -2611,7 +2631,7 @@ function useSelect(userProps) {
|
|
|
2611
2631
|
});
|
|
2612
2632
|
};
|
|
2613
2633
|
setGetterPropCallInfo('getMenuProps', suppressRefError, refKey, menuRef);
|
|
2614
|
-
return
|
|
2634
|
+
return _extends((_extends2 = {}, _extends2[refKey] = handleRefs(ref, function (menuNode) {
|
|
2615
2635
|
menuRef.current = menuNode;
|
|
2616
2636
|
}), _extends2.id = elementIds.menuId, _extends2.role = 'listbox', _extends2['aria-labelledby'] = rest && rest['aria-label'] ? undefined : "" + elementIds.labelId, _extends2.onMouseLeave = callAllEventHandlers(onMouseLeave, menuHandleMouseLeave), _extends2), rest);
|
|
2617
2637
|
}, [dispatch, setGetterPropCallInfo, elementIds]);
|
|
@@ -2625,7 +2645,7 @@ function useSelect(userProps) {
|
|
|
2625
2645
|
_ref4$refKey = _ref4.refKey,
|
|
2626
2646
|
refKey = _ref4$refKey === void 0 ? 'ref' : _ref4$refKey,
|
|
2627
2647
|
ref = _ref4.ref,
|
|
2628
|
-
rest =
|
|
2648
|
+
rest = _objectWithoutPropertiesLoose(_ref4, _excluded3$1);
|
|
2629
2649
|
var _ref5 = _temp5 === void 0 ? {} : _temp5,
|
|
2630
2650
|
_ref5$suppressRefErro = _ref5.suppressRefError,
|
|
2631
2651
|
suppressRefError = _ref5$suppressRefErro === void 0 ? false : _ref5$suppressRefErro;
|
|
@@ -2653,7 +2673,7 @@ function useSelect(userProps) {
|
|
|
2653
2673
|
});
|
|
2654
2674
|
}
|
|
2655
2675
|
};
|
|
2656
|
-
var toggleProps =
|
|
2676
|
+
var toggleProps = _extends((_extends3 = {}, _extends3[refKey] = handleRefs(ref, function (toggleButtonNode) {
|
|
2657
2677
|
toggleButtonRef.current = toggleButtonNode;
|
|
2658
2678
|
}), _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);
|
|
2659
2679
|
if (!rest.disabled) {
|
|
@@ -2679,7 +2699,7 @@ function useSelect(userProps) {
|
|
|
2679
2699
|
refKey = _ref6$refKey === void 0 ? 'ref' : _ref6$refKey,
|
|
2680
2700
|
disabledProp = _ref6.disabled,
|
|
2681
2701
|
ref = _ref6.ref,
|
|
2682
|
-
rest =
|
|
2702
|
+
rest = _objectWithoutPropertiesLoose(_ref6, _excluded4$1);
|
|
2683
2703
|
if (disabledProp !== undefined) {
|
|
2684
2704
|
console.warn('Passing "disabled" as an argument to getItemProps is not supported anymore. Please use the isItemDisabled prop from useSelect.');
|
|
2685
2705
|
}
|
|
@@ -2711,7 +2731,7 @@ function useSelect(userProps) {
|
|
|
2711
2731
|
return e.preventDefault();
|
|
2712
2732
|
}; // keep focus on the toggle after item click select.
|
|
2713
2733
|
|
|
2714
|
-
var itemProps =
|
|
2734
|
+
var itemProps = _extends((_extends4 = {}, _extends4[refKey] = handleRefs(ref, function (itemNode) {
|
|
2715
2735
|
if (itemNode) {
|
|
2716
2736
|
itemRefs.current[elementIds.getItemId(index)] = itemNode;
|
|
2717
2737
|
}
|
|
@@ -2774,29 +2794,29 @@ var ControlledPropUpdatedSelectedItem = process.env.NODE_ENV !== "production" ?
|
|
|
2774
2794
|
|
|
2775
2795
|
var stateChangeTypes$1 = /*#__PURE__*/Object.freeze({
|
|
2776
2796
|
__proto__: null,
|
|
2797
|
+
ControlledPropUpdatedSelectedItem: ControlledPropUpdatedSelectedItem,
|
|
2798
|
+
FunctionCloseMenu: FunctionCloseMenu,
|
|
2799
|
+
FunctionOpenMenu: FunctionOpenMenu,
|
|
2800
|
+
FunctionReset: FunctionReset$1,
|
|
2801
|
+
FunctionSelectItem: FunctionSelectItem,
|
|
2802
|
+
FunctionSetHighlightedIndex: FunctionSetHighlightedIndex,
|
|
2803
|
+
FunctionSetInputValue: FunctionSetInputValue,
|
|
2804
|
+
FunctionToggleMenu: FunctionToggleMenu,
|
|
2805
|
+
InputBlur: InputBlur,
|
|
2806
|
+
InputChange: InputChange,
|
|
2807
|
+
InputClick: InputClick,
|
|
2777
2808
|
InputKeyDownArrowDown: InputKeyDownArrowDown,
|
|
2778
2809
|
InputKeyDownArrowUp: InputKeyDownArrowUp,
|
|
2810
|
+
InputKeyDownEnd: InputKeyDownEnd,
|
|
2811
|
+
InputKeyDownEnter: InputKeyDownEnter,
|
|
2779
2812
|
InputKeyDownEscape: InputKeyDownEscape,
|
|
2780
2813
|
InputKeyDownHome: InputKeyDownHome,
|
|
2781
|
-
InputKeyDownEnd: InputKeyDownEnd,
|
|
2782
|
-
InputKeyDownPageUp: InputKeyDownPageUp,
|
|
2783
2814
|
InputKeyDownPageDown: InputKeyDownPageDown,
|
|
2784
|
-
|
|
2785
|
-
InputChange: InputChange,
|
|
2786
|
-
InputBlur: InputBlur,
|
|
2787
|
-
InputClick: InputClick,
|
|
2788
|
-
MenuMouseLeave: MenuMouseLeave,
|
|
2789
|
-
ItemMouseMove: ItemMouseMove,
|
|
2815
|
+
InputKeyDownPageUp: InputKeyDownPageUp,
|
|
2790
2816
|
ItemClick: ItemClick,
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
FunctionCloseMenu: FunctionCloseMenu,
|
|
2795
|
-
FunctionSetHighlightedIndex: FunctionSetHighlightedIndex,
|
|
2796
|
-
FunctionSelectItem: FunctionSelectItem,
|
|
2797
|
-
FunctionSetInputValue: FunctionSetInputValue,
|
|
2798
|
-
FunctionReset: FunctionReset$1,
|
|
2799
|
-
ControlledPropUpdatedSelectedItem: ControlledPropUpdatedSelectedItem
|
|
2817
|
+
ItemMouseMove: ItemMouseMove,
|
|
2818
|
+
MenuMouseLeave: MenuMouseLeave,
|
|
2819
|
+
ToggleButtonClick: ToggleButtonClick
|
|
2800
2820
|
});
|
|
2801
2821
|
|
|
2802
2822
|
function getInitialState$1(props) {
|
|
@@ -2806,18 +2826,18 @@ function getInitialState$1(props) {
|
|
|
2806
2826
|
if (inputValue === '' && selectedItem && props.defaultInputValue === undefined && props.initialInputValue === undefined && props.inputValue === undefined) {
|
|
2807
2827
|
inputValue = props.itemToString(selectedItem);
|
|
2808
2828
|
}
|
|
2809
|
-
return
|
|
2829
|
+
return _extends({}, initialState, {
|
|
2810
2830
|
inputValue: inputValue
|
|
2811
2831
|
});
|
|
2812
2832
|
}
|
|
2813
|
-
var propTypes$1 =
|
|
2814
|
-
items:
|
|
2815
|
-
isItemDisabled:
|
|
2816
|
-
inputValue:
|
|
2817
|
-
defaultInputValue:
|
|
2818
|
-
initialInputValue:
|
|
2819
|
-
inputId:
|
|
2820
|
-
onInputValueChange:
|
|
2833
|
+
var propTypes$1 = _extends({}, commonDropdownPropTypes, {
|
|
2834
|
+
items: PropTypes.array.isRequired,
|
|
2835
|
+
isItemDisabled: PropTypes.func,
|
|
2836
|
+
inputValue: PropTypes.string,
|
|
2837
|
+
defaultInputValue: PropTypes.string,
|
|
2838
|
+
initialInputValue: PropTypes.string,
|
|
2839
|
+
inputId: PropTypes.string,
|
|
2840
|
+
onInputValueChange: PropTypes.func
|
|
2821
2841
|
});
|
|
2822
2842
|
|
|
2823
2843
|
/**
|
|
@@ -2864,10 +2884,10 @@ var validatePropTypes$1 = noop;
|
|
|
2864
2884
|
/* istanbul ignore next */
|
|
2865
2885
|
if (process.env.NODE_ENV !== 'production') {
|
|
2866
2886
|
validatePropTypes$1 = function validatePropTypes(options, caller) {
|
|
2867
|
-
|
|
2887
|
+
PropTypes.checkPropTypes(propTypes$1, options, 'prop', caller.name);
|
|
2868
2888
|
};
|
|
2869
2889
|
}
|
|
2870
|
-
var defaultProps$1 =
|
|
2890
|
+
var defaultProps$1 = _extends({}, defaultProps$3, {
|
|
2871
2891
|
isItemDisabled: function isItemDisabled() {
|
|
2872
2892
|
return false;
|
|
2873
2893
|
}
|
|
@@ -2884,7 +2904,7 @@ function downshiftUseComboboxReducer(state, action) {
|
|
|
2884
2904
|
case ItemClick:
|
|
2885
2905
|
changes = {
|
|
2886
2906
|
isOpen: getDefaultValue$1(props, 'isOpen'),
|
|
2887
|
-
highlightedIndex:
|
|
2907
|
+
highlightedIndex: getDefaultHighlightedIndex(props),
|
|
2888
2908
|
selectedItem: props.items[action.index],
|
|
2889
2909
|
inputValue: props.itemToString(props.items[action.index])
|
|
2890
2910
|
};
|
|
@@ -2921,7 +2941,7 @@ function downshiftUseComboboxReducer(state, action) {
|
|
|
2921
2941
|
changes = getChangesOnSelection(props, state.highlightedIndex);
|
|
2922
2942
|
break;
|
|
2923
2943
|
case InputKeyDownEscape:
|
|
2924
|
-
changes =
|
|
2944
|
+
changes = _extends({
|
|
2925
2945
|
isOpen: false,
|
|
2926
2946
|
highlightedIndex: -1
|
|
2927
2947
|
}, !state.isOpen && {
|
|
@@ -2950,7 +2970,7 @@ function downshiftUseComboboxReducer(state, action) {
|
|
|
2950
2970
|
};
|
|
2951
2971
|
break;
|
|
2952
2972
|
case InputBlur:
|
|
2953
|
-
changes =
|
|
2973
|
+
changes = _extends({
|
|
2954
2974
|
isOpen: false,
|
|
2955
2975
|
highlightedIndex: -1
|
|
2956
2976
|
}, state.highlightedIndex >= 0 && ((_props$items = props.items) == null ? void 0 : _props$items.length) && action.selectItem && {
|
|
@@ -2961,7 +2981,7 @@ function downshiftUseComboboxReducer(state, action) {
|
|
|
2961
2981
|
case InputChange:
|
|
2962
2982
|
changes = {
|
|
2963
2983
|
isOpen: true,
|
|
2964
|
-
highlightedIndex:
|
|
2984
|
+
highlightedIndex: getDefaultHighlightedIndex(props),
|
|
2965
2985
|
inputValue: action.inputValue
|
|
2966
2986
|
};
|
|
2967
2987
|
break;
|
|
@@ -2985,7 +3005,7 @@ function downshiftUseComboboxReducer(state, action) {
|
|
|
2985
3005
|
default:
|
|
2986
3006
|
return downshiftCommonReducer(state, action, stateChangeTypes$1);
|
|
2987
3007
|
}
|
|
2988
|
-
return
|
|
3008
|
+
return _extends({}, state, changes);
|
|
2989
3009
|
}
|
|
2990
3010
|
/* eslint-enable complexity */
|
|
2991
3011
|
|
|
@@ -3000,7 +3020,7 @@ function useCombobox(userProps) {
|
|
|
3000
3020
|
}
|
|
3001
3021
|
validatePropTypes$1(userProps, useCombobox);
|
|
3002
3022
|
// Props defaults and destructuring.
|
|
3003
|
-
var props =
|
|
3023
|
+
var props = _extends({}, defaultProps$1, userProps);
|
|
3004
3024
|
var items = props.items,
|
|
3005
3025
|
scrollIntoView = props.scrollIntoView,
|
|
3006
3026
|
environment = props.environment,
|
|
@@ -3166,7 +3186,7 @@ function useCombobox(userProps) {
|
|
|
3166
3186
|
|
|
3167
3187
|
// Getter props.
|
|
3168
3188
|
var getLabelProps = React.useCallback(function (labelProps) {
|
|
3169
|
-
return
|
|
3189
|
+
return _extends({
|
|
3170
3190
|
id: elementIds.labelId,
|
|
3171
3191
|
htmlFor: elementIds.inputId
|
|
3172
3192
|
}, labelProps);
|
|
@@ -3178,12 +3198,12 @@ function useCombobox(userProps) {
|
|
|
3178
3198
|
_ref$refKey = _ref.refKey,
|
|
3179
3199
|
refKey = _ref$refKey === void 0 ? 'ref' : _ref$refKey,
|
|
3180
3200
|
ref = _ref.ref,
|
|
3181
|
-
rest =
|
|
3201
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$1);
|
|
3182
3202
|
var _ref2 = _temp2 === void 0 ? {} : _temp2,
|
|
3183
3203
|
_ref2$suppressRefErro = _ref2.suppressRefError,
|
|
3184
3204
|
suppressRefError = _ref2$suppressRefErro === void 0 ? false : _ref2$suppressRefErro;
|
|
3185
3205
|
setGetterPropCallInfo('getMenuProps', suppressRefError, refKey, menuRef);
|
|
3186
|
-
return
|
|
3206
|
+
return _extends((_extends2 = {}, _extends2[refKey] = handleRefs(ref, function (menuNode) {
|
|
3187
3207
|
menuRef.current = menuNode;
|
|
3188
3208
|
}), _extends2.id = elementIds.menuId, _extends2.role = 'listbox', _extends2['aria-labelledby'] = rest && rest['aria-label'] ? undefined : "" + elementIds.labelId, _extends2.onMouseLeave = callAllEventHandlers(onMouseLeave, function () {
|
|
3189
3209
|
dispatch({
|
|
@@ -3204,7 +3224,7 @@ function useCombobox(userProps) {
|
|
|
3204
3224
|
onClick = _ref3.onClick;
|
|
3205
3225
|
_ref3.onPress;
|
|
3206
3226
|
var disabledProp = _ref3.disabled,
|
|
3207
|
-
rest =
|
|
3227
|
+
rest = _objectWithoutPropertiesLoose(_ref3, _excluded2$1);
|
|
3208
3228
|
if (disabledProp !== undefined) {
|
|
3209
3229
|
console.warn('Passing "disabled" as an argument to getItemProps is not supported anymore. Please use the isItemDisabled prop from useCombobox.');
|
|
3210
3230
|
}
|
|
@@ -3238,7 +3258,7 @@ function useCombobox(userProps) {
|
|
|
3238
3258
|
return e.preventDefault();
|
|
3239
3259
|
}; // keep focus on the input after item click select.
|
|
3240
3260
|
|
|
3241
|
-
return
|
|
3261
|
+
return _extends((_extends3 = {}, _extends3[refKey] = handleRefs(ref, function (itemNode) {
|
|
3242
3262
|
if (itemNode) {
|
|
3243
3263
|
itemRefs.current[elementIds.getItemId(index)] = itemNode;
|
|
3244
3264
|
}
|
|
@@ -3255,16 +3275,16 @@ function useCombobox(userProps) {
|
|
|
3255
3275
|
var _ref5$refKey = _ref5.refKey,
|
|
3256
3276
|
refKey = _ref5$refKey === void 0 ? 'ref' : _ref5$refKey,
|
|
3257
3277
|
ref = _ref5.ref,
|
|
3258
|
-
rest =
|
|
3278
|
+
rest = _objectWithoutPropertiesLoose(_ref5, _excluded3);
|
|
3259
3279
|
var latestState = latest.current.state;
|
|
3260
3280
|
var toggleButtonHandleClick = function toggleButtonHandleClick() {
|
|
3261
3281
|
dispatch({
|
|
3262
3282
|
type: ToggleButtonClick
|
|
3263
3283
|
});
|
|
3264
3284
|
};
|
|
3265
|
-
return
|
|
3285
|
+
return _extends((_extends4 = {}, _extends4[refKey] = handleRefs(ref, function (toggleButtonNode) {
|
|
3266
3286
|
toggleButtonRef.current = toggleButtonNode;
|
|
3267
|
-
}), _extends4['aria-controls'] = elementIds.menuId, _extends4['aria-expanded'] = latestState.isOpen, _extends4.id = elementIds.toggleButtonId, _extends4.tabIndex = -1, _extends4), !rest.disabled &&
|
|
3287
|
+
}), _extends4['aria-controls'] = elementIds.menuId, _extends4['aria-expanded'] = latestState.isOpen, _extends4.id = elementIds.toggleButtonId, _extends4.tabIndex = -1, _extends4), !rest.disabled && _extends({}, {
|
|
3268
3288
|
onClick: callAllEventHandlers(onClick, toggleButtonHandleClick)
|
|
3269
3289
|
}), rest);
|
|
3270
3290
|
}, [dispatch, latest, elementIds]);
|
|
@@ -3280,7 +3300,7 @@ function useCombobox(userProps) {
|
|
|
3280
3300
|
_ref6$refKey = _ref6.refKey,
|
|
3281
3301
|
refKey = _ref6$refKey === void 0 ? 'ref' : _ref6$refKey,
|
|
3282
3302
|
ref = _ref6.ref,
|
|
3283
|
-
rest =
|
|
3303
|
+
rest = _objectWithoutPropertiesLoose(_ref6, _excluded4);
|
|
3284
3304
|
var _ref7 = _temp6 === void 0 ? {} : _temp6,
|
|
3285
3305
|
_ref7$suppressRefErro = _ref7.suppressRefError,
|
|
3286
3306
|
suppressRefError = _ref7$suppressRefErro === void 0 ? false : _ref7$suppressRefErro;
|
|
@@ -3321,7 +3341,7 @@ function useCombobox(userProps) {
|
|
|
3321
3341
|
var _eventHandlers;
|
|
3322
3342
|
eventHandlers = (_eventHandlers = {}, _eventHandlers[onChangeKey] = callAllEventHandlers(onChange, onInput, inputHandleChange), _eventHandlers.onKeyDown = callAllEventHandlers(onKeyDown, inputHandleKeyDown), _eventHandlers.onBlur = callAllEventHandlers(onBlur, inputHandleBlur), _eventHandlers.onClick = callAllEventHandlers(onClick, inputHandleClick), _eventHandlers);
|
|
3323
3343
|
}
|
|
3324
|
-
return
|
|
3344
|
+
return _extends((_extends5 = {}, _extends5[refKey] = handleRefs(ref, function (inputNode) {
|
|
3325
3345
|
inputRef.current = inputNode;
|
|
3326
3346
|
}), _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);
|
|
3327
3347
|
}, [dispatch, elementIds, environment, inputKeyDownHandlers, latest, mouseAndTouchTrackers, setGetterPropCallInfo]);
|
|
@@ -3474,17 +3494,17 @@ var propTypes = {
|
|
|
3474
3494
|
stateReducer: commonPropTypes.stateReducer,
|
|
3475
3495
|
itemToKey: commonPropTypes.itemToKey,
|
|
3476
3496
|
environment: commonPropTypes.environment,
|
|
3477
|
-
selectedItems:
|
|
3478
|
-
initialSelectedItems:
|
|
3479
|
-
defaultSelectedItems:
|
|
3480
|
-
getA11yStatusMessage:
|
|
3481
|
-
activeIndex:
|
|
3482
|
-
initialActiveIndex:
|
|
3483
|
-
defaultActiveIndex:
|
|
3484
|
-
onActiveIndexChange:
|
|
3485
|
-
onSelectedItemsChange:
|
|
3486
|
-
keyNavigationNext:
|
|
3487
|
-
keyNavigationPrevious:
|
|
3497
|
+
selectedItems: PropTypes.array,
|
|
3498
|
+
initialSelectedItems: PropTypes.array,
|
|
3499
|
+
defaultSelectedItems: PropTypes.array,
|
|
3500
|
+
getA11yStatusMessage: PropTypes.func,
|
|
3501
|
+
activeIndex: PropTypes.number,
|
|
3502
|
+
initialActiveIndex: PropTypes.number,
|
|
3503
|
+
defaultActiveIndex: PropTypes.number,
|
|
3504
|
+
onActiveIndexChange: PropTypes.func,
|
|
3505
|
+
onSelectedItemsChange: PropTypes.func,
|
|
3506
|
+
keyNavigationNext: PropTypes.string,
|
|
3507
|
+
keyNavigationPrevious: PropTypes.string
|
|
3488
3508
|
};
|
|
3489
3509
|
var defaultProps = {
|
|
3490
3510
|
itemToKey: defaultProps$3.itemToKey,
|
|
@@ -3499,7 +3519,7 @@ var validatePropTypes = noop;
|
|
|
3499
3519
|
/* istanbul ignore next */
|
|
3500
3520
|
if (process.env.NODE_ENV !== 'production') {
|
|
3501
3521
|
validatePropTypes = function validatePropTypes(options, caller) {
|
|
3502
|
-
|
|
3522
|
+
PropTypes.checkPropTypes(propTypes, options, 'prop', caller.name);
|
|
3503
3523
|
};
|
|
3504
3524
|
}
|
|
3505
3525
|
|
|
@@ -3519,19 +3539,19 @@ var FunctionReset = process.env.NODE_ENV !== "production" ? '__function_reset__'
|
|
|
3519
3539
|
|
|
3520
3540
|
var stateChangeTypes = /*#__PURE__*/Object.freeze({
|
|
3521
3541
|
__proto__: null,
|
|
3522
|
-
SelectedItemClick: SelectedItemClick,
|
|
3523
|
-
SelectedItemKeyDownDelete: SelectedItemKeyDownDelete,
|
|
3524
|
-
SelectedItemKeyDownBackspace: SelectedItemKeyDownBackspace,
|
|
3525
|
-
SelectedItemKeyDownNavigationNext: SelectedItemKeyDownNavigationNext,
|
|
3526
|
-
SelectedItemKeyDownNavigationPrevious: SelectedItemKeyDownNavigationPrevious,
|
|
3527
|
-
DropdownKeyDownNavigationPrevious: DropdownKeyDownNavigationPrevious,
|
|
3528
|
-
DropdownKeyDownBackspace: DropdownKeyDownBackspace,
|
|
3529
3542
|
DropdownClick: DropdownClick,
|
|
3543
|
+
DropdownKeyDownBackspace: DropdownKeyDownBackspace,
|
|
3544
|
+
DropdownKeyDownNavigationPrevious: DropdownKeyDownNavigationPrevious,
|
|
3530
3545
|
FunctionAddSelectedItem: FunctionAddSelectedItem,
|
|
3531
3546
|
FunctionRemoveSelectedItem: FunctionRemoveSelectedItem,
|
|
3532
|
-
|
|
3547
|
+
FunctionReset: FunctionReset,
|
|
3533
3548
|
FunctionSetActiveIndex: FunctionSetActiveIndex,
|
|
3534
|
-
|
|
3549
|
+
FunctionSetSelectedItems: FunctionSetSelectedItems,
|
|
3550
|
+
SelectedItemClick: SelectedItemClick,
|
|
3551
|
+
SelectedItemKeyDownBackspace: SelectedItemKeyDownBackspace,
|
|
3552
|
+
SelectedItemKeyDownDelete: SelectedItemKeyDownDelete,
|
|
3553
|
+
SelectedItemKeyDownNavigationNext: SelectedItemKeyDownNavigationNext,
|
|
3554
|
+
SelectedItemKeyDownNavigationPrevious: SelectedItemKeyDownNavigationPrevious
|
|
3535
3555
|
});
|
|
3536
3556
|
|
|
3537
3557
|
/* eslint-disable complexity */
|
|
@@ -3571,7 +3591,7 @@ function downshiftMultipleSelectionReducer(state, action) {
|
|
|
3571
3591
|
} else if (activeIndex === selectedItems.length - 1) {
|
|
3572
3592
|
newActiveIndex = selectedItems.length - 2;
|
|
3573
3593
|
}
|
|
3574
|
-
changes =
|
|
3594
|
+
changes = _extends({
|
|
3575
3595
|
selectedItems: [].concat(selectedItems.slice(0, activeIndex), selectedItems.slice(activeIndex + 1))
|
|
3576
3596
|
}, {
|
|
3577
3597
|
activeIndex: newActiveIndex
|
|
@@ -3643,7 +3663,7 @@ function downshiftMultipleSelectionReducer(state, action) {
|
|
|
3643
3663
|
default:
|
|
3644
3664
|
throw new Error('Reducer called without proper action type.');
|
|
3645
3665
|
}
|
|
3646
|
-
return
|
|
3666
|
+
return _extends({}, state, changes);
|
|
3647
3667
|
}
|
|
3648
3668
|
|
|
3649
3669
|
var _excluded = ["refKey", "ref", "onClick", "onKeyDown", "selectedItem", "index"],
|
|
@@ -3655,7 +3675,7 @@ function useMultipleSelection(userProps) {
|
|
|
3655
3675
|
}
|
|
3656
3676
|
validatePropTypes(userProps, useMultipleSelection);
|
|
3657
3677
|
// Props defaults and destructuring.
|
|
3658
|
-
var props =
|
|
3678
|
+
var props = _extends({}, defaultProps, userProps);
|
|
3659
3679
|
var getA11yStatusMessage = props.getA11yStatusMessage,
|
|
3660
3680
|
environment = props.environment,
|
|
3661
3681
|
keyNavigationNext = props.keyNavigationNext,
|
|
@@ -3748,7 +3768,7 @@ function useMultipleSelection(userProps) {
|
|
|
3748
3768
|
onKeyDown = _ref3.onKeyDown,
|
|
3749
3769
|
selectedItemProp = _ref3.selectedItem,
|
|
3750
3770
|
indexProp = _ref3.index,
|
|
3751
|
-
rest =
|
|
3771
|
+
rest = _objectWithoutPropertiesLoose(_ref3, _excluded);
|
|
3752
3772
|
var latestState = latest.current.state;
|
|
3753
3773
|
var _getItemAndIndex = getItemAndIndex(selectedItemProp, indexProp, latestState.selectedItems, 'Pass either item or index to getSelectedItemProps!'),
|
|
3754
3774
|
index = _getItemAndIndex[1];
|
|
@@ -3765,7 +3785,7 @@ function useMultipleSelection(userProps) {
|
|
|
3765
3785
|
selectedItemKeyDownHandlers[key](event);
|
|
3766
3786
|
}
|
|
3767
3787
|
};
|
|
3768
|
-
return
|
|
3788
|
+
return _extends((_extends2 = {}, _extends2[refKey] = handleRefs(ref, function (selectedItemNode) {
|
|
3769
3789
|
if (selectedItemNode) {
|
|
3770
3790
|
selectedItemRefs.current.push(selectedItemNode);
|
|
3771
3791
|
}
|
|
@@ -3781,7 +3801,7 @@ function useMultipleSelection(userProps) {
|
|
|
3781
3801
|
onClick = _ref4.onClick,
|
|
3782
3802
|
_ref4$preventKeyActio = _ref4.preventKeyAction,
|
|
3783
3803
|
preventKeyAction = _ref4$preventKeyActio === void 0 ? false : _ref4$preventKeyActio,
|
|
3784
|
-
rest =
|
|
3804
|
+
rest = _objectWithoutPropertiesLoose(_ref4, _excluded2);
|
|
3785
3805
|
var _ref5 = _temp3 === void 0 ? {} : _temp3,
|
|
3786
3806
|
_ref5$suppressRefErro = _ref5.suppressRefError,
|
|
3787
3807
|
suppressRefError = _ref5$suppressRefErro === void 0 ? false : _ref5$suppressRefErro;
|
|
@@ -3797,7 +3817,7 @@ function useMultipleSelection(userProps) {
|
|
|
3797
3817
|
type: DropdownClick
|
|
3798
3818
|
});
|
|
3799
3819
|
};
|
|
3800
|
-
return
|
|
3820
|
+
return _extends((_extends3 = {}, _extends3[refKey] = handleRefs(ref, function (dropdownNode) {
|
|
3801
3821
|
if (dropdownNode) {
|
|
3802
3822
|
dropdownRef.current = dropdownNode;
|
|
3803
3823
|
}
|
|
@@ -3850,7 +3870,7 @@ function useMultipleSelection(userProps) {
|
|
|
3850
3870
|
};
|
|
3851
3871
|
}
|
|
3852
3872
|
|
|
3853
|
-
exports
|
|
3873
|
+
exports.default = Downshift$1;
|
|
3854
3874
|
exports.resetIdCounter = resetIdCounter;
|
|
3855
3875
|
exports.useCombobox = useCombobox;
|
|
3856
3876
|
exports.useMultipleSelection = useMultipleSelection;
|