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