downshift 9.0.4 → 9.0.6
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 +256 -236
- package/dist/downshift.esm.js +94 -66
- package/dist/downshift.native.cjs.js +256 -236
- package/dist/downshift.nativeweb.cjs.js +256 -236
- package/dist/downshift.umd.js +135 -110
- 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 +218 -198
- package/preact/dist/downshift.esm.js +94 -66
- package/preact/dist/downshift.umd.js +189 -165
- 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
|
/**
|
|
@@ -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
|
_ref3.onKeyDown;
|
|
850
842
|
_ref3.onKeyUp;
|
|
851
843
|
_ref3.onBlur;
|
|
852
|
-
var rest =
|
|
844
|
+
var rest = _objectWithoutPropertiesLoose(_ref3, _excluded2$3);
|
|
853
845
|
var _this$getState5 = _this.getState(),
|
|
854
846
|
isOpen = _this$getState5.isOpen;
|
|
855
847
|
var enabledEventHandlers = /* istanbul ignore next (react-native) */
|
|
@@ -857,7 +849,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
857
849
|
onPress: callAllEventHandlers(onPress, _this.buttonHandleClick)
|
|
858
850
|
} ;
|
|
859
851
|
var eventHandlers = rest.disabled ? {} : enabledEventHandlers;
|
|
860
|
-
return
|
|
852
|
+
return _extends({
|
|
861
853
|
type: 'button',
|
|
862
854
|
role: 'button',
|
|
863
855
|
'aria-label': isOpen ? 'close menu' : 'open menu',
|
|
@@ -923,7 +915,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
923
915
|
//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ BUTTON
|
|
924
916
|
/////////////////////////////// LABEL
|
|
925
917
|
_this.getLabelProps = function (props) {
|
|
926
|
-
return
|
|
918
|
+
return _extends({
|
|
927
919
|
htmlFor: _this.inputId,
|
|
928
920
|
id: _this.labelId
|
|
929
921
|
}, props);
|
|
@@ -937,7 +929,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
937
929
|
onChange = _ref4.onChange,
|
|
938
930
|
onInput = _ref4.onInput;
|
|
939
931
|
_ref4.onChangeText;
|
|
940
|
-
var rest =
|
|
932
|
+
var rest = _objectWithoutPropertiesLoose(_ref4, _excluded3$2);
|
|
941
933
|
var onChangeKey;
|
|
942
934
|
var eventHandlers = {};
|
|
943
935
|
|
|
@@ -953,7 +945,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
953
945
|
var _eventHandlers;
|
|
954
946
|
eventHandlers = (_eventHandlers = {}, _eventHandlers[onChangeKey] = callAllEventHandlers(onChange, onInput, _this.inputHandleChange), _eventHandlers.onKeyDown = callAllEventHandlers(onKeyDown, _this.inputHandleKeyDown), _eventHandlers.onBlur = callAllEventHandlers(onBlur, _this.inputHandleBlur), _eventHandlers);
|
|
955
947
|
}
|
|
956
|
-
return
|
|
948
|
+
return _extends({
|
|
957
949
|
'aria-autocomplete': 'list',
|
|
958
950
|
'aria-activedescendant': isOpen && typeof highlightedIndex === 'number' && highlightedIndex >= 0 ? _this.getItemId(highlightedIndex) : undefined,
|
|
959
951
|
'aria-controls': isOpen ? _this.menuId : undefined,
|
|
@@ -1006,14 +998,14 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1006
998
|
_ref5$refKey = _ref5.refKey,
|
|
1007
999
|
refKey = _ref5$refKey === void 0 ? 'ref' : _ref5$refKey,
|
|
1008
1000
|
ref = _ref5.ref,
|
|
1009
|
-
props =
|
|
1001
|
+
props = _objectWithoutPropertiesLoose(_ref5, _excluded4$2);
|
|
1010
1002
|
var _ref6 = _temp6 === void 0 ? {} : _temp6,
|
|
1011
1003
|
_ref6$suppressRefErro = _ref6.suppressRefError,
|
|
1012
1004
|
suppressRefError = _ref6$suppressRefErro === void 0 ? false : _ref6$suppressRefErro;
|
|
1013
1005
|
_this.getMenuProps.called = true;
|
|
1014
1006
|
_this.getMenuProps.refKey = refKey;
|
|
1015
1007
|
_this.getMenuProps.suppressRefError = suppressRefError;
|
|
1016
|
-
return
|
|
1008
|
+
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);
|
|
1017
1009
|
};
|
|
1018
1010
|
//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ MENU
|
|
1019
1011
|
/////////////////////////////// ITEM
|
|
@@ -1027,7 +1019,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1027
1019
|
var index = _ref7.index,
|
|
1028
1020
|
_ref7$item = _ref7.item,
|
|
1029
1021
|
item = _ref7$item === void 0 ? process.env.NODE_ENV === 'production' ? /* istanbul ignore next */undefined : requiredProp('getItemProps', 'item') : _ref7$item,
|
|
1030
|
-
rest =
|
|
1022
|
+
rest = _objectWithoutPropertiesLoose(_ref7, _excluded5);
|
|
1031
1023
|
if (index === undefined) {
|
|
1032
1024
|
_this.items.push(item);
|
|
1033
1025
|
index = _this.items.indexOf(item);
|
|
@@ -1074,7 +1066,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1074
1066
|
var eventHandlers = rest.disabled ? {
|
|
1075
1067
|
onMouseDown: enabledEventHandlers.onMouseDown
|
|
1076
1068
|
} : enabledEventHandlers;
|
|
1077
|
-
return
|
|
1069
|
+
return _extends({
|
|
1078
1070
|
id: _this.getItemId(index),
|
|
1079
1071
|
role: 'option',
|
|
1080
1072
|
'aria-selected': _this.getState().highlightedIndex === index
|
|
@@ -1091,7 +1083,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1091
1083
|
otherStateToSet = pickState(otherStateToSet);
|
|
1092
1084
|
_this.internalSetState(function (_ref8) {
|
|
1093
1085
|
var selectedItem = _ref8.selectedItem;
|
|
1094
|
-
return
|
|
1086
|
+
return _extends({
|
|
1095
1087
|
isOpen: _this.props.defaultIsOpen,
|
|
1096
1088
|
highlightedIndex: _this.props.defaultHighlightedIndex,
|
|
1097
1089
|
inputValue: _this.props.itemToString(selectedItem)
|
|
@@ -1105,7 +1097,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1105
1097
|
otherStateToSet = pickState(otherStateToSet);
|
|
1106
1098
|
_this.internalSetState(function (_ref9) {
|
|
1107
1099
|
var isOpen = _ref9.isOpen;
|
|
1108
|
-
return
|
|
1100
|
+
return _extends({
|
|
1109
1101
|
isOpen: !isOpen
|
|
1110
1102
|
}, isOpen && {
|
|
1111
1103
|
highlightedIndex: _this.props.defaultHighlightedIndex
|
|
@@ -1140,7 +1132,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1140
1132
|
var state = _this.getState();
|
|
1141
1133
|
var item = _this.items[state.highlightedIndex];
|
|
1142
1134
|
var resultCount = _this.getItemCount();
|
|
1143
|
-
var status = _this.props.getA11yStatusMessage(
|
|
1135
|
+
var status = _this.props.getA11yStatusMessage(_extends({
|
|
1144
1136
|
itemToString: _this.props.itemToString,
|
|
1145
1137
|
previousResultCount: _this.previousResultCount,
|
|
1146
1138
|
resultCount: resultCount,
|
|
@@ -1172,7 +1164,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1172
1164
|
_this.state = _state;
|
|
1173
1165
|
return _this;
|
|
1174
1166
|
}
|
|
1175
|
-
|
|
1167
|
+
_inheritsLoose(Downshift, _Component);
|
|
1176
1168
|
var _proto = Downshift.prototype;
|
|
1177
1169
|
/**
|
|
1178
1170
|
* Clear all running timeouts
|
|
@@ -1485,49 +1477,49 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1485
1477
|
return Downshift;
|
|
1486
1478
|
}();
|
|
1487
1479
|
process.env.NODE_ENV !== "production" ? Downshift.propTypes = {
|
|
1488
|
-
children:
|
|
1489
|
-
defaultHighlightedIndex:
|
|
1490
|
-
defaultIsOpen:
|
|
1491
|
-
initialHighlightedIndex:
|
|
1492
|
-
initialSelectedItem:
|
|
1493
|
-
initialInputValue:
|
|
1494
|
-
initialIsOpen:
|
|
1495
|
-
getA11yStatusMessage:
|
|
1496
|
-
itemToString:
|
|
1497
|
-
onChange:
|
|
1498
|
-
onSelect:
|
|
1499
|
-
onStateChange:
|
|
1500
|
-
onInputValueChange:
|
|
1501
|
-
onUserAction:
|
|
1502
|
-
onOuterClick:
|
|
1503
|
-
selectedItemChanged:
|
|
1504
|
-
stateReducer:
|
|
1505
|
-
itemCount:
|
|
1506
|
-
id:
|
|
1507
|
-
environment:
|
|
1508
|
-
addEventListener:
|
|
1509
|
-
removeEventListener:
|
|
1510
|
-
document:
|
|
1511
|
-
createElement:
|
|
1512
|
-
getElementById:
|
|
1513
|
-
activeElement:
|
|
1514
|
-
body:
|
|
1480
|
+
children: PropTypes.func,
|
|
1481
|
+
defaultHighlightedIndex: PropTypes.number,
|
|
1482
|
+
defaultIsOpen: PropTypes.bool,
|
|
1483
|
+
initialHighlightedIndex: PropTypes.number,
|
|
1484
|
+
initialSelectedItem: PropTypes.any,
|
|
1485
|
+
initialInputValue: PropTypes.string,
|
|
1486
|
+
initialIsOpen: PropTypes.bool,
|
|
1487
|
+
getA11yStatusMessage: PropTypes.func,
|
|
1488
|
+
itemToString: PropTypes.func,
|
|
1489
|
+
onChange: PropTypes.func,
|
|
1490
|
+
onSelect: PropTypes.func,
|
|
1491
|
+
onStateChange: PropTypes.func,
|
|
1492
|
+
onInputValueChange: PropTypes.func,
|
|
1493
|
+
onUserAction: PropTypes.func,
|
|
1494
|
+
onOuterClick: PropTypes.func,
|
|
1495
|
+
selectedItemChanged: PropTypes.func,
|
|
1496
|
+
stateReducer: PropTypes.func,
|
|
1497
|
+
itemCount: PropTypes.number,
|
|
1498
|
+
id: PropTypes.string,
|
|
1499
|
+
environment: PropTypes.shape({
|
|
1500
|
+
addEventListener: PropTypes.func.isRequired,
|
|
1501
|
+
removeEventListener: PropTypes.func.isRequired,
|
|
1502
|
+
document: PropTypes.shape({
|
|
1503
|
+
createElement: PropTypes.func.isRequired,
|
|
1504
|
+
getElementById: PropTypes.func.isRequired,
|
|
1505
|
+
activeElement: PropTypes.any.isRequired,
|
|
1506
|
+
body: PropTypes.any.isRequired
|
|
1515
1507
|
}).isRequired,
|
|
1516
|
-
Node:
|
|
1508
|
+
Node: PropTypes.func.isRequired
|
|
1517
1509
|
}),
|
|
1518
|
-
suppressRefError:
|
|
1519
|
-
scrollIntoView:
|
|
1510
|
+
suppressRefError: PropTypes.bool,
|
|
1511
|
+
scrollIntoView: PropTypes.func,
|
|
1520
1512
|
// things we keep in state for uncontrolled components
|
|
1521
1513
|
// but can accept as props for controlled components
|
|
1522
1514
|
/* eslint-disable react/no-unused-prop-types */
|
|
1523
|
-
selectedItem:
|
|
1524
|
-
isOpen:
|
|
1525
|
-
inputValue:
|
|
1526
|
-
highlightedIndex:
|
|
1527
|
-
labelId:
|
|
1528
|
-
inputId:
|
|
1529
|
-
menuId:
|
|
1530
|
-
getItemId:
|
|
1515
|
+
selectedItem: PropTypes.any,
|
|
1516
|
+
isOpen: PropTypes.bool,
|
|
1517
|
+
inputValue: PropTypes.string,
|
|
1518
|
+
highlightedIndex: PropTypes.number,
|
|
1519
|
+
labelId: PropTypes.string,
|
|
1520
|
+
inputId: PropTypes.string,
|
|
1521
|
+
menuId: PropTypes.string,
|
|
1522
|
+
getItemId: PropTypes.func
|
|
1531
1523
|
/* eslint-enable react/no-unused-prop-types */
|
|
1532
1524
|
} : void 0;
|
|
1533
1525
|
var Downshift$1 = Downshift;
|
|
@@ -1572,7 +1564,7 @@ function callOnChangeProps(action, state, newState) {
|
|
|
1572
1564
|
}
|
|
1573
1565
|
});
|
|
1574
1566
|
if (props.onStateChange && Object.keys(changes).length) {
|
|
1575
|
-
props.onStateChange(
|
|
1567
|
+
props.onStateChange(_extends({
|
|
1576
1568
|
type: type
|
|
1577
1569
|
}, changes));
|
|
1578
1570
|
}
|
|
@@ -1582,7 +1574,7 @@ function invokeOnChangeHandler(key, action, state, newState) {
|
|
|
1582
1574
|
type = action.type;
|
|
1583
1575
|
var handler = "on" + capitalizeString(key) + "Change";
|
|
1584
1576
|
if (props[handler] && newState[key] !== undefined && newState[key] !== state[key]) {
|
|
1585
|
-
props[handler](
|
|
1577
|
+
props[handler](_extends({
|
|
1586
1578
|
type: type
|
|
1587
1579
|
}, newState));
|
|
1588
1580
|
}
|
|
@@ -1610,7 +1602,7 @@ var updateA11yStatus = debounce(function (status, document) {
|
|
|
1610
1602
|
var useIsomorphicLayoutEffect = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined' ? React.useLayoutEffect : React.useEffect;
|
|
1611
1603
|
|
|
1612
1604
|
// istanbul ignore next
|
|
1613
|
-
var useElementIds = 'useId' in
|
|
1605
|
+
var useElementIds = 'useId' in React // Avoid conditional useId call
|
|
1614
1606
|
? function useElementIds(_ref) {
|
|
1615
1607
|
var id = _ref.id,
|
|
1616
1608
|
labelId = _ref.labelId,
|
|
@@ -1619,7 +1611,7 @@ var useElementIds = 'useId' in React__default["default"] // Avoid conditional us
|
|
|
1619
1611
|
toggleButtonId = _ref.toggleButtonId,
|
|
1620
1612
|
inputId = _ref.inputId;
|
|
1621
1613
|
// Avoid conditional useId call
|
|
1622
|
-
var reactId = "downshift-" +
|
|
1614
|
+
var reactId = "downshift-" + React.useId();
|
|
1623
1615
|
if (!id) {
|
|
1624
1616
|
id = reactId;
|
|
1625
1617
|
}
|
|
@@ -1698,7 +1690,7 @@ function useEnhancedReducer(reducer, props, createInitialState, isStateEqual) {
|
|
|
1698
1690
|
actionRef.current = action;
|
|
1699
1691
|
state = getState(state, action.props);
|
|
1700
1692
|
var changes = reducer(state, action);
|
|
1701
|
-
var newState = action.props.stateReducer(state,
|
|
1693
|
+
var newState = action.props.stateReducer(state, _extends({}, action, {
|
|
1702
1694
|
changes: changes
|
|
1703
1695
|
}));
|
|
1704
1696
|
return newState;
|
|
@@ -1708,7 +1700,7 @@ function useEnhancedReducer(reducer, props, createInitialState, isStateEqual) {
|
|
|
1708
1700
|
dispatch = _useReducer[1];
|
|
1709
1701
|
var propsRef = useLatestRef(props);
|
|
1710
1702
|
var dispatchWithProps = React.useCallback(function (action) {
|
|
1711
|
-
return dispatch(
|
|
1703
|
+
return dispatch(_extends({
|
|
1712
1704
|
props: propsRef.current
|
|
1713
1705
|
}, action));
|
|
1714
1706
|
}, [propsRef]);
|
|
@@ -1779,7 +1771,7 @@ function getInitialValue$1(props, propKey, defaultStateValues) {
|
|
|
1779
1771
|
function getInitialState$2(props) {
|
|
1780
1772
|
var selectedItem = getInitialValue$1(props, 'selectedItem');
|
|
1781
1773
|
var isOpen = getInitialValue$1(props, 'isOpen');
|
|
1782
|
-
var highlightedIndex =
|
|
1774
|
+
var highlightedIndex = getInitialHighlightedIndex(props);
|
|
1783
1775
|
var inputValue = getInitialValue$1(props, 'inputValue');
|
|
1784
1776
|
return {
|
|
1785
1777
|
highlightedIndex: highlightedIndex < 0 && selectedItem && isOpen ? props.items.findIndex(function (item) {
|
|
@@ -1803,10 +1795,10 @@ function getHighlightedIndexOnOpen(props, state, offset) {
|
|
|
1803
1795
|
}
|
|
1804
1796
|
|
|
1805
1797
|
// initialHighlightedIndex will give value to highlightedIndex on initial state only.
|
|
1806
|
-
if (initialHighlightedIndex !== undefined && highlightedIndex === initialHighlightedIndex && !isItemDisabled(items[initialHighlightedIndex])) {
|
|
1798
|
+
if (initialHighlightedIndex !== undefined && highlightedIndex === initialHighlightedIndex && !isItemDisabled(items[initialHighlightedIndex], initialHighlightedIndex)) {
|
|
1807
1799
|
return initialHighlightedIndex;
|
|
1808
1800
|
}
|
|
1809
|
-
if (defaultHighlightedIndex !== undefined && !isItemDisabled(items[defaultHighlightedIndex])) {
|
|
1801
|
+
if (defaultHighlightedIndex !== undefined && !isItemDisabled(items[defaultHighlightedIndex], defaultHighlightedIndex)) {
|
|
1810
1802
|
return defaultHighlightedIndex;
|
|
1811
1803
|
}
|
|
1812
1804
|
if (selectedItem) {
|
|
@@ -1814,10 +1806,10 @@ function getHighlightedIndexOnOpen(props, state, offset) {
|
|
|
1814
1806
|
return itemToKey(selectedItem) === itemToKey(item);
|
|
1815
1807
|
});
|
|
1816
1808
|
}
|
|
1817
|
-
if (offset < 0 && !isItemDisabled(items[items.length - 1])) {
|
|
1809
|
+
if (offset < 0 && !isItemDisabled(items[items.length - 1], items.length - 1)) {
|
|
1818
1810
|
return items.length - 1;
|
|
1819
1811
|
}
|
|
1820
|
-
if (offset > 0 && !isItemDisabled(items[0])) {
|
|
1812
|
+
if (offset > 0 && !isItemDisabled(items[0], 0)) {
|
|
1821
1813
|
return 0;
|
|
1822
1814
|
}
|
|
1823
1815
|
return -1;
|
|
@@ -2027,10 +2019,10 @@ function getChangesOnSelection(props, highlightedIndex, inputValue) {
|
|
|
2027
2019
|
inputValue = true;
|
|
2028
2020
|
}
|
|
2029
2021
|
var shouldSelect = ((_props$items = props.items) == null ? void 0 : _props$items.length) && highlightedIndex >= 0;
|
|
2030
|
-
return
|
|
2022
|
+
return _extends({
|
|
2031
2023
|
isOpen: false,
|
|
2032
2024
|
highlightedIndex: -1
|
|
2033
|
-
}, shouldSelect &&
|
|
2025
|
+
}, shouldSelect && _extends({
|
|
2034
2026
|
selectedItem: props.items[highlightedIndex],
|
|
2035
2027
|
isOpen: getDefaultValue$1(props, 'isOpen'),
|
|
2036
2028
|
highlightedIndex: getDefaultValue$1(props, 'highlightedIndex')
|
|
@@ -2055,8 +2047,8 @@ function isDropdownsStateEqual(prevState, newState) {
|
|
|
2055
2047
|
* Tracks if it's the first render.
|
|
2056
2048
|
*/
|
|
2057
2049
|
function useIsInitialMount() {
|
|
2058
|
-
var isInitialMountRef =
|
|
2059
|
-
|
|
2050
|
+
var isInitialMountRef = React.useRef(true);
|
|
2051
|
+
React.useEffect(function () {
|
|
2060
2052
|
isInitialMountRef.current = false;
|
|
2061
2053
|
return function () {
|
|
2062
2054
|
isInitialMountRef.current = true;
|
|
@@ -2065,46 +2057,74 @@ function useIsInitialMount() {
|
|
|
2065
2057
|
return isInitialMountRef.current;
|
|
2066
2058
|
}
|
|
2067
2059
|
|
|
2060
|
+
/**
|
|
2061
|
+
* Returns the new highlightedIndex based on the defaultHighlightedIndex prop, if it's not disabled.
|
|
2062
|
+
*
|
|
2063
|
+
* @param {Object} props Props from useCombobox or useSelect.
|
|
2064
|
+
* @returns {number} The highlighted index.
|
|
2065
|
+
*/
|
|
2066
|
+
function getDefaultHighlightedIndex(props) {
|
|
2067
|
+
var highlightedIndex = getDefaultValue$1(props, 'highlightedIndex');
|
|
2068
|
+
if (highlightedIndex > -1 && props.isItemDisabled(props.items[highlightedIndex], highlightedIndex)) {
|
|
2069
|
+
return -1;
|
|
2070
|
+
}
|
|
2071
|
+
return highlightedIndex;
|
|
2072
|
+
}
|
|
2073
|
+
|
|
2074
|
+
/**
|
|
2075
|
+
* Returns the new highlightedIndex based on the initialHighlightedIndex prop, if not disabled.
|
|
2076
|
+
*
|
|
2077
|
+
* @param {Object} props Props from useCombobox or useSelect.
|
|
2078
|
+
* @returns {number} The highlighted index.
|
|
2079
|
+
*/
|
|
2080
|
+
function getInitialHighlightedIndex(props) {
|
|
2081
|
+
var highlightedIndex = getInitialValue$1(props, 'highlightedIndex');
|
|
2082
|
+
if (highlightedIndex > -1 && props.isItemDisabled(props.items[highlightedIndex], highlightedIndex)) {
|
|
2083
|
+
return -1;
|
|
2084
|
+
}
|
|
2085
|
+
return highlightedIndex;
|
|
2086
|
+
}
|
|
2087
|
+
|
|
2068
2088
|
// Shared between all exports.
|
|
2069
2089
|
var commonPropTypes = {
|
|
2070
|
-
environment:
|
|
2071
|
-
addEventListener:
|
|
2072
|
-
removeEventListener:
|
|
2073
|
-
document:
|
|
2074
|
-
createElement:
|
|
2075
|
-
getElementById:
|
|
2076
|
-
activeElement:
|
|
2077
|
-
body:
|
|
2090
|
+
environment: PropTypes.shape({
|
|
2091
|
+
addEventListener: PropTypes.func.isRequired,
|
|
2092
|
+
removeEventListener: PropTypes.func.isRequired,
|
|
2093
|
+
document: PropTypes.shape({
|
|
2094
|
+
createElement: PropTypes.func.isRequired,
|
|
2095
|
+
getElementById: PropTypes.func.isRequired,
|
|
2096
|
+
activeElement: PropTypes.any.isRequired,
|
|
2097
|
+
body: PropTypes.any.isRequired
|
|
2078
2098
|
}).isRequired,
|
|
2079
|
-
Node:
|
|
2099
|
+
Node: PropTypes.func.isRequired
|
|
2080
2100
|
}),
|
|
2081
|
-
itemToString:
|
|
2082
|
-
itemToKey:
|
|
2083
|
-
stateReducer:
|
|
2101
|
+
itemToString: PropTypes.func,
|
|
2102
|
+
itemToKey: PropTypes.func,
|
|
2103
|
+
stateReducer: PropTypes.func
|
|
2084
2104
|
};
|
|
2085
2105
|
|
|
2086
2106
|
// Shared between useSelect, useCombobox, Downshift.
|
|
2087
|
-
var commonDropdownPropTypes =
|
|
2088
|
-
getA11yStatusMessage:
|
|
2089
|
-
highlightedIndex:
|
|
2090
|
-
defaultHighlightedIndex:
|
|
2091
|
-
initialHighlightedIndex:
|
|
2092
|
-
isOpen:
|
|
2093
|
-
defaultIsOpen:
|
|
2094
|
-
initialIsOpen:
|
|
2095
|
-
selectedItem:
|
|
2096
|
-
initialSelectedItem:
|
|
2097
|
-
defaultSelectedItem:
|
|
2098
|
-
id:
|
|
2099
|
-
labelId:
|
|
2100
|
-
menuId:
|
|
2101
|
-
getItemId:
|
|
2102
|
-
toggleButtonId:
|
|
2103
|
-
onSelectedItemChange:
|
|
2104
|
-
onHighlightedIndexChange:
|
|
2105
|
-
onStateChange:
|
|
2106
|
-
onIsOpenChange:
|
|
2107
|
-
scrollIntoView:
|
|
2107
|
+
var commonDropdownPropTypes = _extends({}, commonPropTypes, {
|
|
2108
|
+
getA11yStatusMessage: PropTypes.func,
|
|
2109
|
+
highlightedIndex: PropTypes.number,
|
|
2110
|
+
defaultHighlightedIndex: PropTypes.number,
|
|
2111
|
+
initialHighlightedIndex: PropTypes.number,
|
|
2112
|
+
isOpen: PropTypes.bool,
|
|
2113
|
+
defaultIsOpen: PropTypes.bool,
|
|
2114
|
+
initialIsOpen: PropTypes.bool,
|
|
2115
|
+
selectedItem: PropTypes.any,
|
|
2116
|
+
initialSelectedItem: PropTypes.any,
|
|
2117
|
+
defaultSelectedItem: PropTypes.any,
|
|
2118
|
+
id: PropTypes.string,
|
|
2119
|
+
labelId: PropTypes.string,
|
|
2120
|
+
menuId: PropTypes.string,
|
|
2121
|
+
getItemId: PropTypes.func,
|
|
2122
|
+
toggleButtonId: PropTypes.string,
|
|
2123
|
+
onSelectedItemChange: PropTypes.func,
|
|
2124
|
+
onHighlightedIndexChange: PropTypes.func,
|
|
2125
|
+
onStateChange: PropTypes.func,
|
|
2126
|
+
onIsOpenChange: PropTypes.func,
|
|
2127
|
+
scrollIntoView: PropTypes.func
|
|
2108
2128
|
});
|
|
2109
2129
|
|
|
2110
2130
|
function downshiftCommonReducer(state, action, stateChangeTypes) {
|
|
@@ -2142,7 +2162,7 @@ function downshiftCommonReducer(state, action, stateChangeTypes) {
|
|
|
2142
2162
|
break;
|
|
2143
2163
|
case stateChangeTypes.FunctionSetHighlightedIndex:
|
|
2144
2164
|
changes = {
|
|
2145
|
-
highlightedIndex: action.highlightedIndex
|
|
2165
|
+
highlightedIndex: props.isItemDisabled(props.items[action.highlightedIndex], action.highlightedIndex) ? -1 : action.highlightedIndex
|
|
2146
2166
|
};
|
|
2147
2167
|
break;
|
|
2148
2168
|
case stateChangeTypes.FunctionSetInputValue:
|
|
@@ -2152,7 +2172,7 @@ function downshiftCommonReducer(state, action, stateChangeTypes) {
|
|
|
2152
2172
|
break;
|
|
2153
2173
|
case stateChangeTypes.FunctionReset:
|
|
2154
2174
|
changes = {
|
|
2155
|
-
highlightedIndex:
|
|
2175
|
+
highlightedIndex: getDefaultHighlightedIndex(props),
|
|
2156
2176
|
isOpen: getDefaultValue$1(props, 'isOpen'),
|
|
2157
2177
|
selectedItem: getDefaultValue$1(props, 'selectedItem'),
|
|
2158
2178
|
inputValue: getDefaultValue$1(props, 'inputValue')
|
|
@@ -2161,7 +2181,7 @@ function downshiftCommonReducer(state, action, stateChangeTypes) {
|
|
|
2161
2181
|
default:
|
|
2162
2182
|
throw new Error('Reducer called without proper action type.');
|
|
2163
2183
|
}
|
|
2164
|
-
return
|
|
2184
|
+
return _extends({}, state, changes);
|
|
2165
2185
|
}
|
|
2166
2186
|
/* eslint-enable complexity */
|
|
2167
2187
|
|
|
@@ -2180,7 +2200,7 @@ function getItemIndexByCharacterKey(_a) {
|
|
|
2180
2200
|
}
|
|
2181
2201
|
return highlightedIndex;
|
|
2182
2202
|
}
|
|
2183
|
-
var propTypes$2 = tslib.__assign(tslib.__assign({}, commonDropdownPropTypes), { items:
|
|
2203
|
+
var propTypes$2 = tslib.__assign(tslib.__assign({}, commonDropdownPropTypes), { items: PropTypes.array.isRequired, isItemDisabled: PropTypes.func });
|
|
2184
2204
|
var defaultProps$2 = tslib.__assign(tslib.__assign({}, defaultProps$3), { isItemDisabled: function () {
|
|
2185
2205
|
return false;
|
|
2186
2206
|
} });
|
|
@@ -2189,7 +2209,7 @@ var validatePropTypes$2 = noop;
|
|
|
2189
2209
|
/* istanbul ignore next */
|
|
2190
2210
|
if (process.env.NODE_ENV !== 'production') {
|
|
2191
2211
|
validatePropTypes$2 = function (options, caller) {
|
|
2192
|
-
|
|
2212
|
+
PropTypes.checkPropTypes(propTypes$2, options, 'prop', caller.name);
|
|
2193
2213
|
};
|
|
2194
2214
|
}
|
|
2195
2215
|
|
|
@@ -2218,28 +2238,28 @@ var FunctionReset$2 = process.env.NODE_ENV !== "production" ? '__function_reset_
|
|
|
2218
2238
|
|
|
2219
2239
|
var stateChangeTypes$2 = /*#__PURE__*/Object.freeze({
|
|
2220
2240
|
__proto__: null,
|
|
2241
|
+
FunctionCloseMenu: FunctionCloseMenu$1,
|
|
2242
|
+
FunctionOpenMenu: FunctionOpenMenu$1,
|
|
2243
|
+
FunctionReset: FunctionReset$2,
|
|
2244
|
+
FunctionSelectItem: FunctionSelectItem$1,
|
|
2245
|
+
FunctionSetHighlightedIndex: FunctionSetHighlightedIndex$1,
|
|
2246
|
+
FunctionSetInputValue: FunctionSetInputValue$1,
|
|
2247
|
+
FunctionToggleMenu: FunctionToggleMenu$1,
|
|
2248
|
+
ItemClick: ItemClick$1,
|
|
2249
|
+
ItemMouseMove: ItemMouseMove$1,
|
|
2250
|
+
MenuMouseLeave: MenuMouseLeave$1,
|
|
2251
|
+
ToggleButtonBlur: ToggleButtonBlur,
|
|
2221
2252
|
ToggleButtonClick: ToggleButtonClick$1,
|
|
2222
2253
|
ToggleButtonKeyDownArrowDown: ToggleButtonKeyDownArrowDown,
|
|
2223
2254
|
ToggleButtonKeyDownArrowUp: ToggleButtonKeyDownArrowUp,
|
|
2224
2255
|
ToggleButtonKeyDownCharacter: ToggleButtonKeyDownCharacter,
|
|
2225
|
-
ToggleButtonKeyDownEscape: ToggleButtonKeyDownEscape,
|
|
2226
|
-
ToggleButtonKeyDownHome: ToggleButtonKeyDownHome,
|
|
2227
2256
|
ToggleButtonKeyDownEnd: ToggleButtonKeyDownEnd,
|
|
2228
2257
|
ToggleButtonKeyDownEnter: ToggleButtonKeyDownEnter,
|
|
2229
|
-
|
|
2230
|
-
|
|
2258
|
+
ToggleButtonKeyDownEscape: ToggleButtonKeyDownEscape,
|
|
2259
|
+
ToggleButtonKeyDownHome: ToggleButtonKeyDownHome,
|
|
2231
2260
|
ToggleButtonKeyDownPageDown: ToggleButtonKeyDownPageDown,
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
ItemMouseMove: ItemMouseMove$1,
|
|
2235
|
-
ItemClick: ItemClick$1,
|
|
2236
|
-
FunctionToggleMenu: FunctionToggleMenu$1,
|
|
2237
|
-
FunctionOpenMenu: FunctionOpenMenu$1,
|
|
2238
|
-
FunctionCloseMenu: FunctionCloseMenu$1,
|
|
2239
|
-
FunctionSetHighlightedIndex: FunctionSetHighlightedIndex$1,
|
|
2240
|
-
FunctionSelectItem: FunctionSelectItem$1,
|
|
2241
|
-
FunctionSetInputValue: FunctionSetInputValue$1,
|
|
2242
|
-
FunctionReset: FunctionReset$2
|
|
2261
|
+
ToggleButtonKeyDownPageUp: ToggleButtonKeyDownPageUp,
|
|
2262
|
+
ToggleButtonKeyDownSpaceButton: ToggleButtonKeyDownSpaceButton
|
|
2243
2263
|
});
|
|
2244
2264
|
|
|
2245
2265
|
/* eslint-disable complexity */
|
|
@@ -2253,7 +2273,7 @@ function downshiftSelectReducer(state, action) {
|
|
|
2253
2273
|
case ItemClick$1:
|
|
2254
2274
|
changes = {
|
|
2255
2275
|
isOpen: getDefaultValue$1(props, 'isOpen'),
|
|
2256
|
-
highlightedIndex:
|
|
2276
|
+
highlightedIndex: getDefaultHighlightedIndex(props),
|
|
2257
2277
|
selectedItem: props.items[action.index]
|
|
2258
2278
|
};
|
|
2259
2279
|
break;
|
|
@@ -2332,7 +2352,7 @@ function downshiftSelectReducer(state, action) {
|
|
|
2332
2352
|
};
|
|
2333
2353
|
break;
|
|
2334
2354
|
case ToggleButtonBlur:
|
|
2335
|
-
changes =
|
|
2355
|
+
changes = _extends({
|
|
2336
2356
|
isOpen: false,
|
|
2337
2357
|
highlightedIndex: -1
|
|
2338
2358
|
}, state.highlightedIndex >= 0 && ((_props$items = props.items) == null ? void 0 : _props$items.length) && {
|
|
@@ -2347,7 +2367,7 @@ function downshiftSelectReducer(state, action) {
|
|
|
2347
2367
|
default:
|
|
2348
2368
|
return downshiftCommonReducer(state, action, stateChangeTypes$2);
|
|
2349
2369
|
}
|
|
2350
|
-
return
|
|
2370
|
+
return _extends({}, state, changes);
|
|
2351
2371
|
}
|
|
2352
2372
|
/* eslint-enable complexity */
|
|
2353
2373
|
|
|
@@ -2362,7 +2382,7 @@ function useSelect(userProps) {
|
|
|
2362
2382
|
}
|
|
2363
2383
|
validatePropTypes$2(userProps, useSelect);
|
|
2364
2384
|
// Props defaults and destructuring.
|
|
2365
|
-
var props =
|
|
2385
|
+
var props = _extends({}, defaultProps$2, userProps);
|
|
2366
2386
|
var scrollIntoView = props.scrollIntoView,
|
|
2367
2387
|
environment = props.environment,
|
|
2368
2388
|
getA11yStatusMessage = props.getA11yStatusMessage;
|
|
@@ -2578,12 +2598,12 @@ function useSelect(userProps) {
|
|
|
2578
2598
|
var getLabelProps = React.useCallback(function (_temp) {
|
|
2579
2599
|
var _ref = _temp === void 0 ? {} : _temp,
|
|
2580
2600
|
onClick = _ref.onClick,
|
|
2581
|
-
labelProps =
|
|
2601
|
+
labelProps = _objectWithoutPropertiesLoose(_ref, _excluded$2);
|
|
2582
2602
|
var labelHandleClick = function labelHandleClick() {
|
|
2583
2603
|
var _toggleButtonRef$curr;
|
|
2584
2604
|
(_toggleButtonRef$curr = toggleButtonRef.current) == null || _toggleButtonRef$curr.focus();
|
|
2585
2605
|
};
|
|
2586
|
-
return
|
|
2606
|
+
return _extends({
|
|
2587
2607
|
id: elementIds.labelId,
|
|
2588
2608
|
htmlFor: elementIds.toggleButtonId,
|
|
2589
2609
|
onClick: callAllEventHandlers(onClick, labelHandleClick)
|
|
@@ -2596,7 +2616,7 @@ function useSelect(userProps) {
|
|
|
2596
2616
|
_ref2$refKey = _ref2.refKey,
|
|
2597
2617
|
refKey = _ref2$refKey === void 0 ? 'ref' : _ref2$refKey,
|
|
2598
2618
|
ref = _ref2.ref,
|
|
2599
|
-
rest =
|
|
2619
|
+
rest = _objectWithoutPropertiesLoose(_ref2, _excluded2$2);
|
|
2600
2620
|
var _ref3 = _temp3 === void 0 ? {} : _temp3,
|
|
2601
2621
|
_ref3$suppressRefErro = _ref3.suppressRefError,
|
|
2602
2622
|
suppressRefError = _ref3$suppressRefErro === void 0 ? false : _ref3$suppressRefErro;
|
|
@@ -2606,7 +2626,7 @@ function useSelect(userProps) {
|
|
|
2606
2626
|
});
|
|
2607
2627
|
};
|
|
2608
2628
|
setGetterPropCallInfo('getMenuProps', suppressRefError, refKey, menuRef);
|
|
2609
|
-
return
|
|
2629
|
+
return _extends((_extends2 = {}, _extends2[refKey] = handleRefs(ref, function (menuNode) {
|
|
2610
2630
|
menuRef.current = menuNode;
|
|
2611
2631
|
}), _extends2.id = elementIds.menuId, _extends2.role = 'listbox', _extends2['aria-labelledby'] = rest && rest['aria-label'] ? undefined : "" + elementIds.labelId, _extends2.onMouseLeave = callAllEventHandlers(onMouseLeave, menuHandleMouseLeave), _extends2), rest);
|
|
2612
2632
|
}, [dispatch, setGetterPropCallInfo, elementIds]);
|
|
@@ -2620,7 +2640,7 @@ function useSelect(userProps) {
|
|
|
2620
2640
|
var _ref4$refKey = _ref4.refKey,
|
|
2621
2641
|
refKey = _ref4$refKey === void 0 ? 'ref' : _ref4$refKey,
|
|
2622
2642
|
ref = _ref4.ref,
|
|
2623
|
-
rest =
|
|
2643
|
+
rest = _objectWithoutPropertiesLoose(_ref4, _excluded3$1);
|
|
2624
2644
|
var _ref5 = _temp5 === void 0 ? {} : _temp5,
|
|
2625
2645
|
_ref5$suppressRefErro = _ref5.suppressRefError,
|
|
2626
2646
|
suppressRefError = _ref5$suppressRefErro === void 0 ? false : _ref5$suppressRefErro;
|
|
@@ -2637,7 +2657,7 @@ function useSelect(userProps) {
|
|
|
2637
2657
|
});
|
|
2638
2658
|
}
|
|
2639
2659
|
};
|
|
2640
|
-
var toggleProps =
|
|
2660
|
+
var toggleProps = _extends((_extends3 = {}, _extends3[refKey] = handleRefs(ref, function (toggleButtonNode) {
|
|
2641
2661
|
toggleButtonRef.current = toggleButtonNode;
|
|
2642
2662
|
}), _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);
|
|
2643
2663
|
if (!rest.disabled) {
|
|
@@ -2662,7 +2682,7 @@ function useSelect(userProps) {
|
|
|
2662
2682
|
refKey = _ref6$refKey === void 0 ? 'ref' : _ref6$refKey,
|
|
2663
2683
|
disabledProp = _ref6.disabled,
|
|
2664
2684
|
ref = _ref6.ref,
|
|
2665
|
-
rest =
|
|
2685
|
+
rest = _objectWithoutPropertiesLoose(_ref6, _excluded4$1);
|
|
2666
2686
|
if (disabledProp !== undefined) {
|
|
2667
2687
|
console.warn('Passing "disabled" as an argument to getItemProps is not supported anymore. Please use the isItemDisabled prop from useSelect.');
|
|
2668
2688
|
}
|
|
@@ -2694,11 +2714,11 @@ function useSelect(userProps) {
|
|
|
2694
2714
|
return e.preventDefault();
|
|
2695
2715
|
}; // keep focus on the toggle after item click select.
|
|
2696
2716
|
|
|
2697
|
-
var itemProps =
|
|
2717
|
+
var itemProps = _extends((_extends4 = {}, _extends4[refKey] = handleRefs(ref, function (itemNode) {
|
|
2698
2718
|
if (itemNode) {
|
|
2699
2719
|
itemRefs.current[elementIds.getItemId(index)] = itemNode;
|
|
2700
2720
|
}
|
|
2701
|
-
}), _extends4['aria-disabled'] = disabled, _extends4['aria-selected'] =
|
|
2721
|
+
}), _extends4['aria-disabled'] = disabled, _extends4['aria-selected'] = item === latestState.selectedItem, _extends4.id = elementIds.getItemId(index), _extends4.role = 'option', _extends4), rest);
|
|
2702
2722
|
if (!disabled) {
|
|
2703
2723
|
/* istanbul ignore next (react-native) */
|
|
2704
2724
|
{
|
|
@@ -2757,29 +2777,29 @@ var ControlledPropUpdatedSelectedItem = process.env.NODE_ENV !== "production" ?
|
|
|
2757
2777
|
|
|
2758
2778
|
var stateChangeTypes$1 = /*#__PURE__*/Object.freeze({
|
|
2759
2779
|
__proto__: null,
|
|
2780
|
+
ControlledPropUpdatedSelectedItem: ControlledPropUpdatedSelectedItem,
|
|
2781
|
+
FunctionCloseMenu: FunctionCloseMenu,
|
|
2782
|
+
FunctionOpenMenu: FunctionOpenMenu,
|
|
2783
|
+
FunctionReset: FunctionReset$1,
|
|
2784
|
+
FunctionSelectItem: FunctionSelectItem,
|
|
2785
|
+
FunctionSetHighlightedIndex: FunctionSetHighlightedIndex,
|
|
2786
|
+
FunctionSetInputValue: FunctionSetInputValue,
|
|
2787
|
+
FunctionToggleMenu: FunctionToggleMenu,
|
|
2788
|
+
InputBlur: InputBlur,
|
|
2789
|
+
InputChange: InputChange,
|
|
2790
|
+
InputClick: InputClick,
|
|
2760
2791
|
InputKeyDownArrowDown: InputKeyDownArrowDown,
|
|
2761
2792
|
InputKeyDownArrowUp: InputKeyDownArrowUp,
|
|
2793
|
+
InputKeyDownEnd: InputKeyDownEnd,
|
|
2794
|
+
InputKeyDownEnter: InputKeyDownEnter,
|
|
2762
2795
|
InputKeyDownEscape: InputKeyDownEscape,
|
|
2763
2796
|
InputKeyDownHome: InputKeyDownHome,
|
|
2764
|
-
InputKeyDownEnd: InputKeyDownEnd,
|
|
2765
|
-
InputKeyDownPageUp: InputKeyDownPageUp,
|
|
2766
2797
|
InputKeyDownPageDown: InputKeyDownPageDown,
|
|
2767
|
-
|
|
2768
|
-
InputChange: InputChange,
|
|
2769
|
-
InputBlur: InputBlur,
|
|
2770
|
-
InputClick: InputClick,
|
|
2771
|
-
MenuMouseLeave: MenuMouseLeave,
|
|
2772
|
-
ItemMouseMove: ItemMouseMove,
|
|
2798
|
+
InputKeyDownPageUp: InputKeyDownPageUp,
|
|
2773
2799
|
ItemClick: ItemClick,
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
FunctionCloseMenu: FunctionCloseMenu,
|
|
2778
|
-
FunctionSetHighlightedIndex: FunctionSetHighlightedIndex,
|
|
2779
|
-
FunctionSelectItem: FunctionSelectItem,
|
|
2780
|
-
FunctionSetInputValue: FunctionSetInputValue,
|
|
2781
|
-
FunctionReset: FunctionReset$1,
|
|
2782
|
-
ControlledPropUpdatedSelectedItem: ControlledPropUpdatedSelectedItem
|
|
2800
|
+
ItemMouseMove: ItemMouseMove,
|
|
2801
|
+
MenuMouseLeave: MenuMouseLeave,
|
|
2802
|
+
ToggleButtonClick: ToggleButtonClick
|
|
2783
2803
|
});
|
|
2784
2804
|
|
|
2785
2805
|
function getInitialState$1(props) {
|
|
@@ -2789,18 +2809,18 @@ function getInitialState$1(props) {
|
|
|
2789
2809
|
if (inputValue === '' && selectedItem && props.defaultInputValue === undefined && props.initialInputValue === undefined && props.inputValue === undefined) {
|
|
2790
2810
|
inputValue = props.itemToString(selectedItem);
|
|
2791
2811
|
}
|
|
2792
|
-
return
|
|
2812
|
+
return _extends({}, initialState, {
|
|
2793
2813
|
inputValue: inputValue
|
|
2794
2814
|
});
|
|
2795
2815
|
}
|
|
2796
|
-
var propTypes$1 =
|
|
2797
|
-
items:
|
|
2798
|
-
isItemDisabled:
|
|
2799
|
-
inputValue:
|
|
2800
|
-
defaultInputValue:
|
|
2801
|
-
initialInputValue:
|
|
2802
|
-
inputId:
|
|
2803
|
-
onInputValueChange:
|
|
2816
|
+
var propTypes$1 = _extends({}, commonDropdownPropTypes, {
|
|
2817
|
+
items: PropTypes.array.isRequired,
|
|
2818
|
+
isItemDisabled: PropTypes.func,
|
|
2819
|
+
inputValue: PropTypes.string,
|
|
2820
|
+
defaultInputValue: PropTypes.string,
|
|
2821
|
+
initialInputValue: PropTypes.string,
|
|
2822
|
+
inputId: PropTypes.string,
|
|
2823
|
+
onInputValueChange: PropTypes.func
|
|
2804
2824
|
});
|
|
2805
2825
|
|
|
2806
2826
|
/**
|
|
@@ -2847,10 +2867,10 @@ var validatePropTypes$1 = noop;
|
|
|
2847
2867
|
/* istanbul ignore next */
|
|
2848
2868
|
if (process.env.NODE_ENV !== 'production') {
|
|
2849
2869
|
validatePropTypes$1 = function validatePropTypes(options, caller) {
|
|
2850
|
-
|
|
2870
|
+
PropTypes.checkPropTypes(propTypes$1, options, 'prop', caller.name);
|
|
2851
2871
|
};
|
|
2852
2872
|
}
|
|
2853
|
-
var defaultProps$1 =
|
|
2873
|
+
var defaultProps$1 = _extends({}, defaultProps$3, {
|
|
2854
2874
|
isItemDisabled: function isItemDisabled() {
|
|
2855
2875
|
return false;
|
|
2856
2876
|
}
|
|
@@ -2867,7 +2887,7 @@ function downshiftUseComboboxReducer(state, action) {
|
|
|
2867
2887
|
case ItemClick:
|
|
2868
2888
|
changes = {
|
|
2869
2889
|
isOpen: getDefaultValue$1(props, 'isOpen'),
|
|
2870
|
-
highlightedIndex:
|
|
2890
|
+
highlightedIndex: getDefaultHighlightedIndex(props),
|
|
2871
2891
|
selectedItem: props.items[action.index],
|
|
2872
2892
|
inputValue: props.itemToString(props.items[action.index])
|
|
2873
2893
|
};
|
|
@@ -2904,7 +2924,7 @@ function downshiftUseComboboxReducer(state, action) {
|
|
|
2904
2924
|
changes = getChangesOnSelection(props, state.highlightedIndex);
|
|
2905
2925
|
break;
|
|
2906
2926
|
case InputKeyDownEscape:
|
|
2907
|
-
changes =
|
|
2927
|
+
changes = _extends({
|
|
2908
2928
|
isOpen: false,
|
|
2909
2929
|
highlightedIndex: -1
|
|
2910
2930
|
}, !state.isOpen && {
|
|
@@ -2933,7 +2953,7 @@ function downshiftUseComboboxReducer(state, action) {
|
|
|
2933
2953
|
};
|
|
2934
2954
|
break;
|
|
2935
2955
|
case InputBlur:
|
|
2936
|
-
changes =
|
|
2956
|
+
changes = _extends({
|
|
2937
2957
|
isOpen: false,
|
|
2938
2958
|
highlightedIndex: -1
|
|
2939
2959
|
}, state.highlightedIndex >= 0 && ((_props$items = props.items) == null ? void 0 : _props$items.length) && action.selectItem && {
|
|
@@ -2944,7 +2964,7 @@ function downshiftUseComboboxReducer(state, action) {
|
|
|
2944
2964
|
case InputChange:
|
|
2945
2965
|
changes = {
|
|
2946
2966
|
isOpen: true,
|
|
2947
|
-
highlightedIndex:
|
|
2967
|
+
highlightedIndex: getDefaultHighlightedIndex(props),
|
|
2948
2968
|
inputValue: action.inputValue
|
|
2949
2969
|
};
|
|
2950
2970
|
break;
|
|
@@ -2968,7 +2988,7 @@ function downshiftUseComboboxReducer(state, action) {
|
|
|
2968
2988
|
default:
|
|
2969
2989
|
return downshiftCommonReducer(state, action, stateChangeTypes$1);
|
|
2970
2990
|
}
|
|
2971
|
-
return
|
|
2991
|
+
return _extends({}, state, changes);
|
|
2972
2992
|
}
|
|
2973
2993
|
/* eslint-enable complexity */
|
|
2974
2994
|
|
|
@@ -2983,7 +3003,7 @@ function useCombobox(userProps) {
|
|
|
2983
3003
|
}
|
|
2984
3004
|
validatePropTypes$1(userProps, useCombobox);
|
|
2985
3005
|
// Props defaults and destructuring.
|
|
2986
|
-
var props =
|
|
3006
|
+
var props = _extends({}, defaultProps$1, userProps);
|
|
2987
3007
|
var items = props.items,
|
|
2988
3008
|
scrollIntoView = props.scrollIntoView,
|
|
2989
3009
|
environment = props.environment,
|
|
@@ -3149,7 +3169,7 @@ function useCombobox(userProps) {
|
|
|
3149
3169
|
|
|
3150
3170
|
// Getter props.
|
|
3151
3171
|
var getLabelProps = React.useCallback(function (labelProps) {
|
|
3152
|
-
return
|
|
3172
|
+
return _extends({
|
|
3153
3173
|
id: elementIds.labelId,
|
|
3154
3174
|
htmlFor: elementIds.inputId
|
|
3155
3175
|
}, labelProps);
|
|
@@ -3161,12 +3181,12 @@ function useCombobox(userProps) {
|
|
|
3161
3181
|
_ref$refKey = _ref.refKey,
|
|
3162
3182
|
refKey = _ref$refKey === void 0 ? 'ref' : _ref$refKey,
|
|
3163
3183
|
ref = _ref.ref,
|
|
3164
|
-
rest =
|
|
3184
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$1);
|
|
3165
3185
|
var _ref2 = _temp2 === void 0 ? {} : _temp2,
|
|
3166
3186
|
_ref2$suppressRefErro = _ref2.suppressRefError,
|
|
3167
3187
|
suppressRefError = _ref2$suppressRefErro === void 0 ? false : _ref2$suppressRefErro;
|
|
3168
3188
|
setGetterPropCallInfo('getMenuProps', suppressRefError, refKey, menuRef);
|
|
3169
|
-
return
|
|
3189
|
+
return _extends((_extends2 = {}, _extends2[refKey] = handleRefs(ref, function (menuNode) {
|
|
3170
3190
|
menuRef.current = menuNode;
|
|
3171
3191
|
}), _extends2.id = elementIds.menuId, _extends2.role = 'listbox', _extends2['aria-labelledby'] = rest && rest['aria-label'] ? undefined : "" + elementIds.labelId, _extends2.onMouseLeave = callAllEventHandlers(onMouseLeave, function () {
|
|
3172
3192
|
dispatch({
|
|
@@ -3187,7 +3207,7 @@ function useCombobox(userProps) {
|
|
|
3187
3207
|
onClick = _ref3.onClick;
|
|
3188
3208
|
_ref3.onPress;
|
|
3189
3209
|
var disabledProp = _ref3.disabled,
|
|
3190
|
-
rest =
|
|
3210
|
+
rest = _objectWithoutPropertiesLoose(_ref3, _excluded2$1);
|
|
3191
3211
|
if (disabledProp !== undefined) {
|
|
3192
3212
|
console.warn('Passing "disabled" as an argument to getItemProps is not supported anymore. Please use the isItemDisabled prop from useCombobox.');
|
|
3193
3213
|
}
|
|
@@ -3221,11 +3241,11 @@ function useCombobox(userProps) {
|
|
|
3221
3241
|
return e.preventDefault();
|
|
3222
3242
|
}; // keep focus on the input after item click select.
|
|
3223
3243
|
|
|
3224
|
-
return
|
|
3244
|
+
return _extends((_extends3 = {}, _extends3[refKey] = handleRefs(ref, function (itemNode) {
|
|
3225
3245
|
if (itemNode) {
|
|
3226
3246
|
itemRefs.current[elementIds.getItemId(index)] = itemNode;
|
|
3227
3247
|
}
|
|
3228
|
-
}), _extends3['aria-disabled'] = disabled, _extends3['aria-selected'] =
|
|
3248
|
+
}), _extends3['aria-disabled'] = disabled, _extends3['aria-selected'] = index === latestState.highlightedIndex, _extends3.id = elementIds.getItemId(index), _extends3.role = 'option', _extends3), !disabled && (_ref4 = {}, _ref4[onSelectKey] = callAllEventHandlers(customClickHandler, itemHandleClick), _ref4), {
|
|
3229
3249
|
onMouseMove: callAllEventHandlers(onMouseMove, itemHandleMouseMove),
|
|
3230
3250
|
onMouseDown: callAllEventHandlers(onMouseDown, itemHandleMouseDown)
|
|
3231
3251
|
}, rest);
|
|
@@ -3238,16 +3258,16 @@ function useCombobox(userProps) {
|
|
|
3238
3258
|
_ref5$refKey = _ref5.refKey,
|
|
3239
3259
|
refKey = _ref5$refKey === void 0 ? 'ref' : _ref5$refKey,
|
|
3240
3260
|
ref = _ref5.ref,
|
|
3241
|
-
rest =
|
|
3261
|
+
rest = _objectWithoutPropertiesLoose(_ref5, _excluded3);
|
|
3242
3262
|
var latestState = latest.current.state;
|
|
3243
3263
|
var toggleButtonHandleClick = function toggleButtonHandleClick() {
|
|
3244
3264
|
dispatch({
|
|
3245
3265
|
type: ToggleButtonClick
|
|
3246
3266
|
});
|
|
3247
3267
|
};
|
|
3248
|
-
return
|
|
3268
|
+
return _extends((_extends4 = {}, _extends4[refKey] = handleRefs(ref, function (toggleButtonNode) {
|
|
3249
3269
|
toggleButtonRef.current = toggleButtonNode;
|
|
3250
|
-
}), _extends4['aria-controls'] = elementIds.menuId, _extends4['aria-expanded'] = latestState.isOpen, _extends4.id = elementIds.toggleButtonId, _extends4.tabIndex = -1, _extends4), !rest.disabled &&
|
|
3270
|
+
}), _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) */{
|
|
3251
3271
|
onPress: callAllEventHandlers(onPress, toggleButtonHandleClick)
|
|
3252
3272
|
} ), rest);
|
|
3253
3273
|
}, [dispatch, latest, elementIds]);
|
|
@@ -3263,7 +3283,7 @@ function useCombobox(userProps) {
|
|
|
3263
3283
|
_ref6$refKey = _ref6.refKey,
|
|
3264
3284
|
refKey = _ref6$refKey === void 0 ? 'ref' : _ref6$refKey,
|
|
3265
3285
|
ref = _ref6.ref,
|
|
3266
|
-
rest =
|
|
3286
|
+
rest = _objectWithoutPropertiesLoose(_ref6, _excluded4);
|
|
3267
3287
|
var _ref7 = _temp6 === void 0 ? {} : _temp6,
|
|
3268
3288
|
_ref7$suppressRefErro = _ref7.suppressRefError,
|
|
3269
3289
|
suppressRefError = _ref7$suppressRefErro === void 0 ? false : _ref7$suppressRefErro;
|
|
@@ -3304,7 +3324,7 @@ function useCombobox(userProps) {
|
|
|
3304
3324
|
var _eventHandlers;
|
|
3305
3325
|
eventHandlers = (_eventHandlers = {}, _eventHandlers[onChangeKey] = callAllEventHandlers(onChange, onInput, inputHandleChange), _eventHandlers.onKeyDown = callAllEventHandlers(onKeyDown, inputHandleKeyDown), _eventHandlers.onBlur = callAllEventHandlers(onBlur, inputHandleBlur), _eventHandlers.onClick = callAllEventHandlers(onClick, inputHandleClick), _eventHandlers);
|
|
3306
3326
|
}
|
|
3307
|
-
return
|
|
3327
|
+
return _extends((_extends5 = {}, _extends5[refKey] = handleRefs(ref, function (inputNode) {
|
|
3308
3328
|
inputRef.current = inputNode;
|
|
3309
3329
|
}), _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);
|
|
3310
3330
|
}, [dispatch, elementIds, environment, inputKeyDownHandlers, latest, mouseAndTouchTrackers, setGetterPropCallInfo]);
|
|
@@ -3457,17 +3477,17 @@ var propTypes = {
|
|
|
3457
3477
|
stateReducer: commonPropTypes.stateReducer,
|
|
3458
3478
|
itemToKey: commonPropTypes.itemToKey,
|
|
3459
3479
|
environment: commonPropTypes.environment,
|
|
3460
|
-
selectedItems:
|
|
3461
|
-
initialSelectedItems:
|
|
3462
|
-
defaultSelectedItems:
|
|
3463
|
-
getA11yStatusMessage:
|
|
3464
|
-
activeIndex:
|
|
3465
|
-
initialActiveIndex:
|
|
3466
|
-
defaultActiveIndex:
|
|
3467
|
-
onActiveIndexChange:
|
|
3468
|
-
onSelectedItemsChange:
|
|
3469
|
-
keyNavigationNext:
|
|
3470
|
-
keyNavigationPrevious:
|
|
3480
|
+
selectedItems: PropTypes.array,
|
|
3481
|
+
initialSelectedItems: PropTypes.array,
|
|
3482
|
+
defaultSelectedItems: PropTypes.array,
|
|
3483
|
+
getA11yStatusMessage: PropTypes.func,
|
|
3484
|
+
activeIndex: PropTypes.number,
|
|
3485
|
+
initialActiveIndex: PropTypes.number,
|
|
3486
|
+
defaultActiveIndex: PropTypes.number,
|
|
3487
|
+
onActiveIndexChange: PropTypes.func,
|
|
3488
|
+
onSelectedItemsChange: PropTypes.func,
|
|
3489
|
+
keyNavigationNext: PropTypes.string,
|
|
3490
|
+
keyNavigationPrevious: PropTypes.string
|
|
3471
3491
|
};
|
|
3472
3492
|
var defaultProps = {
|
|
3473
3493
|
itemToKey: defaultProps$3.itemToKey,
|
|
@@ -3482,7 +3502,7 @@ var validatePropTypes = noop;
|
|
|
3482
3502
|
/* istanbul ignore next */
|
|
3483
3503
|
if (process.env.NODE_ENV !== 'production') {
|
|
3484
3504
|
validatePropTypes = function validatePropTypes(options, caller) {
|
|
3485
|
-
|
|
3505
|
+
PropTypes.checkPropTypes(propTypes, options, 'prop', caller.name);
|
|
3486
3506
|
};
|
|
3487
3507
|
}
|
|
3488
3508
|
|
|
@@ -3502,19 +3522,19 @@ var FunctionReset = process.env.NODE_ENV !== "production" ? '__function_reset__'
|
|
|
3502
3522
|
|
|
3503
3523
|
var stateChangeTypes = /*#__PURE__*/Object.freeze({
|
|
3504
3524
|
__proto__: null,
|
|
3505
|
-
SelectedItemClick: SelectedItemClick,
|
|
3506
|
-
SelectedItemKeyDownDelete: SelectedItemKeyDownDelete,
|
|
3507
|
-
SelectedItemKeyDownBackspace: SelectedItemKeyDownBackspace,
|
|
3508
|
-
SelectedItemKeyDownNavigationNext: SelectedItemKeyDownNavigationNext,
|
|
3509
|
-
SelectedItemKeyDownNavigationPrevious: SelectedItemKeyDownNavigationPrevious,
|
|
3510
|
-
DropdownKeyDownNavigationPrevious: DropdownKeyDownNavigationPrevious,
|
|
3511
|
-
DropdownKeyDownBackspace: DropdownKeyDownBackspace,
|
|
3512
3525
|
DropdownClick: DropdownClick,
|
|
3526
|
+
DropdownKeyDownBackspace: DropdownKeyDownBackspace,
|
|
3527
|
+
DropdownKeyDownNavigationPrevious: DropdownKeyDownNavigationPrevious,
|
|
3513
3528
|
FunctionAddSelectedItem: FunctionAddSelectedItem,
|
|
3514
3529
|
FunctionRemoveSelectedItem: FunctionRemoveSelectedItem,
|
|
3515
|
-
|
|
3530
|
+
FunctionReset: FunctionReset,
|
|
3516
3531
|
FunctionSetActiveIndex: FunctionSetActiveIndex,
|
|
3517
|
-
|
|
3532
|
+
FunctionSetSelectedItems: FunctionSetSelectedItems,
|
|
3533
|
+
SelectedItemClick: SelectedItemClick,
|
|
3534
|
+
SelectedItemKeyDownBackspace: SelectedItemKeyDownBackspace,
|
|
3535
|
+
SelectedItemKeyDownDelete: SelectedItemKeyDownDelete,
|
|
3536
|
+
SelectedItemKeyDownNavigationNext: SelectedItemKeyDownNavigationNext,
|
|
3537
|
+
SelectedItemKeyDownNavigationPrevious: SelectedItemKeyDownNavigationPrevious
|
|
3518
3538
|
});
|
|
3519
3539
|
|
|
3520
3540
|
/* eslint-disable complexity */
|
|
@@ -3554,7 +3574,7 @@ function downshiftMultipleSelectionReducer(state, action) {
|
|
|
3554
3574
|
} else if (activeIndex === selectedItems.length - 1) {
|
|
3555
3575
|
newActiveIndex = selectedItems.length - 2;
|
|
3556
3576
|
}
|
|
3557
|
-
changes =
|
|
3577
|
+
changes = _extends({
|
|
3558
3578
|
selectedItems: [].concat(selectedItems.slice(0, activeIndex), selectedItems.slice(activeIndex + 1))
|
|
3559
3579
|
}, {
|
|
3560
3580
|
activeIndex: newActiveIndex
|
|
@@ -3626,7 +3646,7 @@ function downshiftMultipleSelectionReducer(state, action) {
|
|
|
3626
3646
|
default:
|
|
3627
3647
|
throw new Error('Reducer called without proper action type.');
|
|
3628
3648
|
}
|
|
3629
|
-
return
|
|
3649
|
+
return _extends({}, state, changes);
|
|
3630
3650
|
}
|
|
3631
3651
|
|
|
3632
3652
|
var _excluded = ["refKey", "ref", "onClick", "onKeyDown", "selectedItem", "index"],
|
|
@@ -3638,7 +3658,7 @@ function useMultipleSelection(userProps) {
|
|
|
3638
3658
|
}
|
|
3639
3659
|
validatePropTypes(userProps, useMultipleSelection);
|
|
3640
3660
|
// Props defaults and destructuring.
|
|
3641
|
-
var props =
|
|
3661
|
+
var props = _extends({}, defaultProps, userProps);
|
|
3642
3662
|
var getA11yStatusMessage = props.getA11yStatusMessage,
|
|
3643
3663
|
environment = props.environment,
|
|
3644
3664
|
keyNavigationNext = props.keyNavigationNext,
|
|
@@ -3731,7 +3751,7 @@ function useMultipleSelection(userProps) {
|
|
|
3731
3751
|
onKeyDown = _ref3.onKeyDown,
|
|
3732
3752
|
selectedItemProp = _ref3.selectedItem,
|
|
3733
3753
|
indexProp = _ref3.index,
|
|
3734
|
-
rest =
|
|
3754
|
+
rest = _objectWithoutPropertiesLoose(_ref3, _excluded);
|
|
3735
3755
|
var latestState = latest.current.state;
|
|
3736
3756
|
var _getItemAndIndex = getItemAndIndex(selectedItemProp, indexProp, latestState.selectedItems, 'Pass either item or index to getSelectedItemProps!'),
|
|
3737
3757
|
index = _getItemAndIndex[1];
|
|
@@ -3748,7 +3768,7 @@ function useMultipleSelection(userProps) {
|
|
|
3748
3768
|
selectedItemKeyDownHandlers[key](event);
|
|
3749
3769
|
}
|
|
3750
3770
|
};
|
|
3751
|
-
return
|
|
3771
|
+
return _extends((_extends2 = {}, _extends2[refKey] = handleRefs(ref, function (selectedItemNode) {
|
|
3752
3772
|
if (selectedItemNode) {
|
|
3753
3773
|
selectedItemRefs.current.push(selectedItemNode);
|
|
3754
3774
|
}
|
|
@@ -3764,7 +3784,7 @@ function useMultipleSelection(userProps) {
|
|
|
3764
3784
|
onClick = _ref4.onClick,
|
|
3765
3785
|
_ref4$preventKeyActio = _ref4.preventKeyAction,
|
|
3766
3786
|
preventKeyAction = _ref4$preventKeyActio === void 0 ? false : _ref4$preventKeyActio,
|
|
3767
|
-
rest =
|
|
3787
|
+
rest = _objectWithoutPropertiesLoose(_ref4, _excluded2);
|
|
3768
3788
|
var _ref5 = _temp3 === void 0 ? {} : _temp3,
|
|
3769
3789
|
_ref5$suppressRefErro = _ref5.suppressRefError,
|
|
3770
3790
|
suppressRefError = _ref5$suppressRefErro === void 0 ? false : _ref5$suppressRefErro;
|
|
@@ -3780,7 +3800,7 @@ function useMultipleSelection(userProps) {
|
|
|
3780
3800
|
type: DropdownClick
|
|
3781
3801
|
});
|
|
3782
3802
|
};
|
|
3783
|
-
return
|
|
3803
|
+
return _extends((_extends3 = {}, _extends3[refKey] = handleRefs(ref, function (dropdownNode) {
|
|
3784
3804
|
if (dropdownNode) {
|
|
3785
3805
|
dropdownRef.current = dropdownNode;
|
|
3786
3806
|
}
|
|
@@ -3833,7 +3853,7 @@ function useMultipleSelection(userProps) {
|
|
|
3833
3853
|
};
|
|
3834
3854
|
}
|
|
3835
3855
|
|
|
3836
|
-
exports
|
|
3856
|
+
exports.default = Downshift$1;
|
|
3837
3857
|
exports.resetIdCounter = resetIdCounter;
|
|
3838
3858
|
exports.useCombobox = useCombobox;
|
|
3839
3859
|
exports.useMultipleSelection = useMultipleSelection;
|