downshift 7.6.0 → 8.0.0-beta.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/README.md +12 -2
- package/dist/downshift.cjs.js +348 -355
- package/dist/downshift.esm.js +260 -268
- package/dist/downshift.native.cjs.js +333 -339
- package/dist/downshift.nativeweb.cjs.js +348 -354
- package/dist/downshift.umd.js +351 -355
- 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/useSelect/types.d.ts +1 -1
- package/dist/src/hooks/useSelect/utils.d.ts +2 -1
- package/dist/src/hooks/utils.d.ts +60 -5
- package/dist/src/utils.d.ts +22 -23
- package/dist/test/downshift.test.d.ts +3 -0
- package/dist/test/useCombobox.test.d.ts +3 -0
- package/dist/test/useMultipleSelect.test.d.ts +3 -0
- package/dist/test/useSelect.test.d.ts +3 -0
- package/package.json +4 -1
- package/preact/dist/downshift.cjs.js +341 -350
- package/preact/dist/downshift.esm.js +253 -263
- package/preact/dist/downshift.umd.js +340 -349
- package/preact/dist/downshift.umd.js.map +1 -1
- package/preact/dist/downshift.umd.min.js +2 -2
- package/preact/dist/downshift.umd.min.js.map +1 -1
- package/typings/index.d.ts +203 -52
- package/CHANGELOG.md +0 -5
package/dist/downshift.esm.js
CHANGED
|
@@ -3,7 +3,7 @@ import _extends from '@babel/runtime/helpers/esm/extends';
|
|
|
3
3
|
import _assertThisInitialized from '@babel/runtime/helpers/esm/assertThisInitialized';
|
|
4
4
|
import _inheritsLoose from '@babel/runtime/helpers/esm/inheritsLoose';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
|
-
import { cloneElement, Component, useRef, useEffect, useCallback, useLayoutEffect, useReducer, useMemo } from 'react';
|
|
6
|
+
import React, { cloneElement, Component, useRef, useEffect, useCallback, useLayoutEffect, useReducer, useMemo } from 'react';
|
|
7
7
|
import { isForwardRef } from 'react-is';
|
|
8
8
|
import compute from 'compute-scroll-into-view';
|
|
9
9
|
import { __assign } from 'tslib';
|
|
@@ -136,6 +136,11 @@ function generateId() {
|
|
|
136
136
|
* Resets idCounter to 0. Used for SSR.
|
|
137
137
|
*/
|
|
138
138
|
function resetIdCounter() {
|
|
139
|
+
// istanbul ignore next
|
|
140
|
+
if ('useId' in React) {
|
|
141
|
+
console.warn("It is not necessary to call resetIdCounter when using React 18+");
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
139
144
|
idCounter = 0;
|
|
140
145
|
}
|
|
141
146
|
|
|
@@ -281,70 +286,70 @@ function isPlainObject(obj) {
|
|
|
281
286
|
}
|
|
282
287
|
|
|
283
288
|
/**
|
|
284
|
-
* Returns the
|
|
285
|
-
* it will wrap to either 0 or itemCount - 1.
|
|
289
|
+
* Returns the next non-disabled highlightedIndex value.
|
|
286
290
|
*
|
|
287
|
-
* @param {number}
|
|
288
|
-
* @param {number}
|
|
289
|
-
* @param {
|
|
290
|
-
* @param {
|
|
291
|
-
* @param {boolean} circular
|
|
292
|
-
* @returns {number} The
|
|
291
|
+
* @param {number} start The current highlightedIndex.
|
|
292
|
+
* @param {number} offset The offset from the current highlightedIndex to start searching.
|
|
293
|
+
* @param {unknown[]} items The items array.
|
|
294
|
+
* @param {(item: unknown, index: number) => boolean} isItemDisabled Function that tells if an item is disabled or not.
|
|
295
|
+
* @param {boolean?} circular If the search reaches the end, if it can search again starting from the other end.
|
|
296
|
+
* @returns {number} The next highlightedIndex.
|
|
293
297
|
*/
|
|
294
|
-
function
|
|
298
|
+
function getHighlightedIndex(start, offset, items, isItemDisabled, circular) {
|
|
295
299
|
if (circular === void 0) {
|
|
296
|
-
circular =
|
|
300
|
+
circular = false;
|
|
297
301
|
}
|
|
298
|
-
|
|
302
|
+
var count = items.length;
|
|
303
|
+
if (count === 0) {
|
|
299
304
|
return -1;
|
|
300
305
|
}
|
|
301
|
-
var itemsLastIndex =
|
|
302
|
-
if (typeof
|
|
303
|
-
|
|
306
|
+
var itemsLastIndex = count - 1;
|
|
307
|
+
if (typeof start !== 'number' || start < 0 || start > itemsLastIndex) {
|
|
308
|
+
start = offset > 0 ? -1 : itemsLastIndex + 1;
|
|
304
309
|
}
|
|
305
|
-
var
|
|
306
|
-
if (
|
|
307
|
-
|
|
308
|
-
} else if (
|
|
309
|
-
|
|
310
|
+
var current = start + offset;
|
|
311
|
+
if (current < 0) {
|
|
312
|
+
current = circular ? itemsLastIndex : 0;
|
|
313
|
+
} else if (current > itemsLastIndex) {
|
|
314
|
+
current = circular ? 0 : itemsLastIndex;
|
|
310
315
|
}
|
|
311
|
-
var
|
|
312
|
-
if (
|
|
313
|
-
return
|
|
316
|
+
var highlightedIndex = getNonDisabledIndex(current, offset < 0, items, isItemDisabled, circular);
|
|
317
|
+
if (highlightedIndex === -1) {
|
|
318
|
+
return start >= count ? -1 : start;
|
|
314
319
|
}
|
|
315
|
-
return
|
|
320
|
+
return highlightedIndex;
|
|
316
321
|
}
|
|
317
322
|
|
|
318
323
|
/**
|
|
319
|
-
* Returns the next
|
|
324
|
+
* Returns the next non-disabled highlightedIndex value.
|
|
320
325
|
*
|
|
321
|
-
* @param {number}
|
|
322
|
-
* @param {
|
|
323
|
-
* @param {
|
|
324
|
-
* @param {
|
|
325
|
-
* @param {boolean} circular
|
|
326
|
-
* @returns {number} The
|
|
326
|
+
* @param {number} start The current highlightedIndex.
|
|
327
|
+
* @param {boolean} backwards If true, it will search backwards from the start.
|
|
328
|
+
* @param {unknown[]} items The items array.
|
|
329
|
+
* @param {(item: unknown, index: number) => boolean} isItemDisabled Function that tells if an item is disabled or not.
|
|
330
|
+
* @param {boolean} circular If the search reaches the end, if it can search again starting from the other end.
|
|
331
|
+
* @returns {number} The next non-disabled index.
|
|
327
332
|
*/
|
|
328
|
-
function
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
return baseIndex;
|
|
333
|
+
function getNonDisabledIndex(start, backwards, items, isItemDisabled, circular) {
|
|
334
|
+
if (circular === void 0) {
|
|
335
|
+
circular = false;
|
|
332
336
|
}
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
337
|
+
var count = items.length;
|
|
338
|
+
if (backwards) {
|
|
339
|
+
for (var index = start; index >= 0; index--) {
|
|
340
|
+
if (!isItemDisabled(items[index], index)) {
|
|
336
341
|
return index;
|
|
337
342
|
}
|
|
338
343
|
}
|
|
339
344
|
} else {
|
|
340
|
-
for (var _index =
|
|
341
|
-
if (!
|
|
345
|
+
for (var _index = start; _index < count; _index++) {
|
|
346
|
+
if (!isItemDisabled(items[_index], _index)) {
|
|
342
347
|
return _index;
|
|
343
348
|
}
|
|
344
349
|
}
|
|
345
350
|
}
|
|
346
351
|
if (circular) {
|
|
347
|
-
return
|
|
352
|
+
return getNonDisabledIndex(backwards ? count - 1 : 0, backwards, items, isItemDisabled);
|
|
348
353
|
}
|
|
349
354
|
return -1;
|
|
350
355
|
}
|
|
@@ -524,6 +529,10 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
524
529
|
_this.unsetItemCount = function () {
|
|
525
530
|
_this.itemCount = null;
|
|
526
531
|
};
|
|
532
|
+
_this.isItemDisabled = function (_item, index) {
|
|
533
|
+
var currentElementNode = _this.getItemNodeFromIndex(index);
|
|
534
|
+
return currentElementNode && currentElementNode.hasAttribute('disabled');
|
|
535
|
+
};
|
|
527
536
|
_this.setHighlightedIndex = function (highlightedIndex, otherStateToSet) {
|
|
528
537
|
if (highlightedIndex === void 0) {
|
|
529
538
|
highlightedIndex = _this.props.defaultHighlightedIndex;
|
|
@@ -674,7 +683,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
674
683
|
_this.getRootProps.suppressRefError = suppressRefError;
|
|
675
684
|
var _this$getState = _this.getState(),
|
|
676
685
|
isOpen = _this$getState.isOpen;
|
|
677
|
-
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 :
|
|
686
|
+
return _extends((_extends2 = {}, _extends2[refKey] = handleRefs(ref, _this.rootRef), _extends2.role = 'combobox', _extends2['aria-expanded'] = isOpen, _extends2['aria-haspopup'] = 'listbox', _extends2['aria-owns'] = isOpen ? _this.menuId : undefined, _extends2['aria-labelledby'] = _this.labelId, _extends2), rest);
|
|
678
687
|
};
|
|
679
688
|
//\\\\\\\\\\\\\\\\\\\\\\\\\\ ROOT
|
|
680
689
|
_this.keyDownHandlers = {
|
|
@@ -695,9 +704,9 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
695
704
|
if (itemCount > 0) {
|
|
696
705
|
var _this2$getState = _this2.getState(),
|
|
697
706
|
highlightedIndex = _this2$getState.highlightedIndex;
|
|
698
|
-
var nextHighlightedIndex =
|
|
699
|
-
|
|
700
|
-
});
|
|
707
|
+
var nextHighlightedIndex = getHighlightedIndex(highlightedIndex, 1, {
|
|
708
|
+
length: itemCount
|
|
709
|
+
}, _this2.isItemDisabled, true);
|
|
701
710
|
_this2.setHighlightedIndex(nextHighlightedIndex, {
|
|
702
711
|
type: keyDownArrowDown
|
|
703
712
|
});
|
|
@@ -722,9 +731,9 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
722
731
|
if (itemCount > 0) {
|
|
723
732
|
var _this3$getState = _this3.getState(),
|
|
724
733
|
highlightedIndex = _this3$getState.highlightedIndex;
|
|
725
|
-
var nextHighlightedIndex =
|
|
726
|
-
|
|
727
|
-
});
|
|
734
|
+
var nextHighlightedIndex = getHighlightedIndex(highlightedIndex, -1, {
|
|
735
|
+
length: itemCount
|
|
736
|
+
}, _this3.isItemDisabled, true);
|
|
728
737
|
_this3.setHighlightedIndex(nextHighlightedIndex, {
|
|
729
738
|
type: keyDownArrowUp
|
|
730
739
|
});
|
|
@@ -772,7 +781,6 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
772
781
|
});
|
|
773
782
|
_this.inputKeyDownHandlers = _extends({}, _this.keyDownHandlers, {
|
|
774
783
|
Home: function Home(event) {
|
|
775
|
-
var _this4 = this;
|
|
776
784
|
var _this$getState3 = this.getState(),
|
|
777
785
|
isOpen = _this$getState3.isOpen;
|
|
778
786
|
if (!isOpen) {
|
|
@@ -785,15 +793,14 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
785
793
|
}
|
|
786
794
|
|
|
787
795
|
// get next non-disabled starting downwards from 0 if that's disabled.
|
|
788
|
-
var newHighlightedIndex =
|
|
789
|
-
|
|
790
|
-
},
|
|
796
|
+
var newHighlightedIndex = getNonDisabledIndex(0, false, {
|
|
797
|
+
length: itemCount
|
|
798
|
+
}, this.isItemDisabled);
|
|
791
799
|
this.setHighlightedIndex(newHighlightedIndex, {
|
|
792
800
|
type: keyDownHome
|
|
793
801
|
});
|
|
794
802
|
},
|
|
795
803
|
End: function End(event) {
|
|
796
|
-
var _this5 = this;
|
|
797
804
|
var _this$getState4 = this.getState(),
|
|
798
805
|
isOpen = _this$getState4.isOpen;
|
|
799
806
|
if (!isOpen) {
|
|
@@ -806,9 +813,9 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
806
813
|
}
|
|
807
814
|
|
|
808
815
|
// get next non-disabled starting upwards from last index if that's disabled.
|
|
809
|
-
var newHighlightedIndex =
|
|
810
|
-
|
|
811
|
-
},
|
|
816
|
+
var newHighlightedIndex = getNonDisabledIndex(itemCount - 1, true, {
|
|
817
|
+
length: itemCount
|
|
818
|
+
}, this.isItemDisabled);
|
|
812
819
|
this.setHighlightedIndex(newHighlightedIndex, {
|
|
813
820
|
type: keyDownEnd
|
|
814
821
|
});
|
|
@@ -920,8 +927,8 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
920
927
|
}
|
|
921
928
|
return _extends({
|
|
922
929
|
'aria-autocomplete': 'list',
|
|
923
|
-
'aria-activedescendant': isOpen && typeof highlightedIndex === 'number' && highlightedIndex >= 0 ? _this.getItemId(highlightedIndex) :
|
|
924
|
-
'aria-controls': isOpen ? _this.menuId :
|
|
930
|
+
'aria-activedescendant': isOpen && typeof highlightedIndex === 'number' && highlightedIndex >= 0 ? _this.getItemId(highlightedIndex) : undefined,
|
|
931
|
+
'aria-controls': isOpen ? _this.menuId : undefined,
|
|
925
932
|
'aria-labelledby': rest && rest['aria-label'] ? undefined : _this.labelId,
|
|
926
933
|
// https://developer.mozilla.org/en-US/docs/Web/Security/Securing_your_site/Turning_off_form_autocompletion
|
|
927
934
|
// revert back since autocomplete="nope" is ignored on latest Chrome and Opera
|
|
@@ -973,7 +980,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
973
980
|
_this.getMenuProps.called = true;
|
|
974
981
|
_this.getMenuProps.refKey = refKey;
|
|
975
982
|
_this.getMenuProps.suppressRefError = suppressRefError;
|
|
976
|
-
return _extends((_extends3 = {}, _extends3[refKey] = handleRefs(ref, _this.menuRef), _extends3.role = 'listbox', _extends3['aria-labelledby'] = props && props['aria-label'] ?
|
|
983
|
+
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);
|
|
977
984
|
};
|
|
978
985
|
//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ MENU
|
|
979
986
|
/////////////////////////////// ITEM
|
|
@@ -1178,14 +1185,13 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1178
1185
|
}
|
|
1179
1186
|
};
|
|
1180
1187
|
_proto.moveHighlightedIndex = function moveHighlightedIndex(amount, otherStateToSet) {
|
|
1181
|
-
var _this6 = this;
|
|
1182
1188
|
var itemCount = this.getItemCount();
|
|
1183
1189
|
var _this$getState8 = this.getState(),
|
|
1184
1190
|
highlightedIndex = _this$getState8.highlightedIndex;
|
|
1185
1191
|
if (itemCount > 0) {
|
|
1186
|
-
var nextHighlightedIndex =
|
|
1187
|
-
|
|
1188
|
-
});
|
|
1192
|
+
var nextHighlightedIndex = getHighlightedIndex(highlightedIndex, amount, {
|
|
1193
|
+
length: itemCount
|
|
1194
|
+
}, this.isItemDisabled, true);
|
|
1189
1195
|
this.setHighlightedIndex(nextHighlightedIndex, otherStateToSet);
|
|
1190
1196
|
}
|
|
1191
1197
|
};
|
|
@@ -1250,7 +1256,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1250
1256
|
};
|
|
1251
1257
|
};
|
|
1252
1258
|
_proto.componentDidMount = function componentDidMount() {
|
|
1253
|
-
var
|
|
1259
|
+
var _this4 = this;
|
|
1254
1260
|
/* istanbul ignore if (react-native) */
|
|
1255
1261
|
if (process.env.NODE_ENV !== 'production' && !false && this.getMenuProps.called && !this.getMenuProps.suppressRefError) {
|
|
1256
1262
|
validateGetMenuPropsCalledCorrectly(this._menuNode, this.getMenuProps);
|
|
@@ -1264,18 +1270,18 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1264
1270
|
// this.isMouseDown is used in the blur handler on the input to determine whether the blur event should
|
|
1265
1271
|
// trigger hiding the menu.
|
|
1266
1272
|
var onMouseDown = function onMouseDown() {
|
|
1267
|
-
|
|
1273
|
+
_this4.isMouseDown = true;
|
|
1268
1274
|
};
|
|
1269
1275
|
var onMouseUp = function onMouseUp(event) {
|
|
1270
|
-
|
|
1276
|
+
_this4.isMouseDown = false;
|
|
1271
1277
|
// if the target element or the activeElement is within a downshift node
|
|
1272
1278
|
// then we don't want to reset downshift
|
|
1273
|
-
var contextWithinDownshift = targetWithinDownshift(event.target, [
|
|
1274
|
-
if (!contextWithinDownshift &&
|
|
1275
|
-
|
|
1279
|
+
var contextWithinDownshift = targetWithinDownshift(event.target, [_this4._rootNode, _this4._menuNode], _this4.props.environment);
|
|
1280
|
+
if (!contextWithinDownshift && _this4.getState().isOpen) {
|
|
1281
|
+
_this4.reset({
|
|
1276
1282
|
type: mouseUp
|
|
1277
1283
|
}, function () {
|
|
1278
|
-
return
|
|
1284
|
+
return _this4.props.onOuterClick(_this4.getStateAndHelpers());
|
|
1279
1285
|
});
|
|
1280
1286
|
}
|
|
1281
1287
|
};
|
|
@@ -1286,18 +1292,18 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1286
1292
|
// If the user taps outside of Downshift, the component should be reset,
|
|
1287
1293
|
// but not if the user is swiping
|
|
1288
1294
|
var onTouchStart = function onTouchStart() {
|
|
1289
|
-
|
|
1295
|
+
_this4.isTouchMove = false;
|
|
1290
1296
|
};
|
|
1291
1297
|
var onTouchMove = function onTouchMove() {
|
|
1292
|
-
|
|
1298
|
+
_this4.isTouchMove = true;
|
|
1293
1299
|
};
|
|
1294
1300
|
var onTouchEnd = function onTouchEnd(event) {
|
|
1295
|
-
var contextWithinDownshift = targetWithinDownshift(event.target, [
|
|
1296
|
-
if (!
|
|
1297
|
-
|
|
1301
|
+
var contextWithinDownshift = targetWithinDownshift(event.target, [_this4._rootNode, _this4._menuNode], _this4.props.environment, false);
|
|
1302
|
+
if (!_this4.isTouchMove && !contextWithinDownshift && _this4.getState().isOpen) {
|
|
1303
|
+
_this4.reset({
|
|
1298
1304
|
type: touchEnd
|
|
1299
1305
|
}, function () {
|
|
1300
|
-
return
|
|
1306
|
+
return _this4.props.onOuterClick(_this4.getStateAndHelpers());
|
|
1301
1307
|
});
|
|
1302
1308
|
}
|
|
1303
1309
|
};
|
|
@@ -1308,8 +1314,8 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1308
1314
|
environment.addEventListener('touchmove', onTouchMove);
|
|
1309
1315
|
environment.addEventListener('touchend', onTouchEnd);
|
|
1310
1316
|
this.cleanup = function () {
|
|
1311
|
-
|
|
1312
|
-
|
|
1317
|
+
_this4.internalClearTimeouts();
|
|
1318
|
+
_this4.updateStatus.cancel();
|
|
1313
1319
|
environment.removeEventListener('mousedown', onMouseDown);
|
|
1314
1320
|
environment.removeEventListener('mouseup', onMouseUp);
|
|
1315
1321
|
environment.removeEventListener('touchstart', onTouchStart);
|
|
@@ -1457,13 +1463,15 @@ process.env.NODE_ENV !== "production" ? Downshift.propTypes = {
|
|
|
1457
1463
|
itemCount: PropTypes.number,
|
|
1458
1464
|
id: PropTypes.string,
|
|
1459
1465
|
environment: PropTypes.shape({
|
|
1460
|
-
addEventListener: PropTypes.func,
|
|
1461
|
-
removeEventListener: PropTypes.func,
|
|
1466
|
+
addEventListener: PropTypes.func.isRequired,
|
|
1467
|
+
removeEventListener: PropTypes.func.isRequired,
|
|
1462
1468
|
document: PropTypes.shape({
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1469
|
+
createElement: PropTypes.func.isRequired,
|
|
1470
|
+
getElementById: PropTypes.func.isRequired,
|
|
1471
|
+
activeElement: PropTypes.any.isRequired,
|
|
1472
|
+
body: PropTypes.any.isRequired
|
|
1473
|
+
}).isRequired,
|
|
1474
|
+
Node: PropTypes.func.isRequired
|
|
1467
1475
|
}),
|
|
1468
1476
|
suppressRefError: PropTypes.bool,
|
|
1469
1477
|
scrollIntoView: PropTypes.func,
|
|
@@ -1571,14 +1579,21 @@ var updateA11yStatus = debounce(function (getA11yMessage, document) {
|
|
|
1571
1579
|
|
|
1572
1580
|
// istanbul ignore next
|
|
1573
1581
|
var useIsomorphicLayoutEffect = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined' ? useLayoutEffect : useEffect;
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1582
|
+
|
|
1583
|
+
// istanbul ignore next
|
|
1584
|
+
var useElementIds = 'useId' in React // Avoid conditional useId call
|
|
1585
|
+
? function useElementIds(_ref) {
|
|
1586
|
+
var id = _ref.id,
|
|
1577
1587
|
labelId = _ref.labelId,
|
|
1578
1588
|
menuId = _ref.menuId,
|
|
1579
1589
|
getItemId = _ref.getItemId,
|
|
1580
1590
|
toggleButtonId = _ref.toggleButtonId,
|
|
1581
1591
|
inputId = _ref.inputId;
|
|
1592
|
+
// Avoid conditional useId call
|
|
1593
|
+
var reactId = "downshift-" + React.useId();
|
|
1594
|
+
if (!id) {
|
|
1595
|
+
id = reactId;
|
|
1596
|
+
}
|
|
1582
1597
|
var elementIdsRef = useRef({
|
|
1583
1598
|
labelId: labelId || id + "-label",
|
|
1584
1599
|
menuId: menuId || id + "-menu",
|
|
@@ -1589,7 +1604,25 @@ function useElementIds(_ref) {
|
|
|
1589
1604
|
inputId: inputId || id + "-input"
|
|
1590
1605
|
});
|
|
1591
1606
|
return elementIdsRef.current;
|
|
1592
|
-
}
|
|
1607
|
+
} : function useElementIds(_ref2) {
|
|
1608
|
+
var _ref2$id = _ref2.id,
|
|
1609
|
+
id = _ref2$id === void 0 ? "downshift-" + generateId() : _ref2$id,
|
|
1610
|
+
labelId = _ref2.labelId,
|
|
1611
|
+
menuId = _ref2.menuId,
|
|
1612
|
+
getItemId = _ref2.getItemId,
|
|
1613
|
+
toggleButtonId = _ref2.toggleButtonId,
|
|
1614
|
+
inputId = _ref2.inputId;
|
|
1615
|
+
var elementIdsRef = useRef({
|
|
1616
|
+
labelId: labelId || id + "-label",
|
|
1617
|
+
menuId: menuId || id + "-menu",
|
|
1618
|
+
getItemId: getItemId || function (index) {
|
|
1619
|
+
return id + "-item-" + index;
|
|
1620
|
+
},
|
|
1621
|
+
toggleButtonId: toggleButtonId || id + "-toggle-button",
|
|
1622
|
+
inputId: inputId || id + "-input"
|
|
1623
|
+
});
|
|
1624
|
+
return elementIdsRef.current;
|
|
1625
|
+
};
|
|
1593
1626
|
function getItemAndIndex(itemProp, indexProp, items, errorMessage) {
|
|
1594
1627
|
var item, index;
|
|
1595
1628
|
if (itemProp === undefined) {
|
|
@@ -1866,12 +1899,12 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
1866
1899
|
return setGetterPropCallInfo;
|
|
1867
1900
|
};
|
|
1868
1901
|
}
|
|
1869
|
-
function useA11yMessageSetter(getA11yMessage, dependencyArray,
|
|
1870
|
-
var isInitialMount =
|
|
1871
|
-
highlightedIndex =
|
|
1872
|
-
items =
|
|
1873
|
-
environment =
|
|
1874
|
-
rest = _objectWithoutPropertiesLoose(
|
|
1902
|
+
function useA11yMessageSetter(getA11yMessage, dependencyArray, _ref3) {
|
|
1903
|
+
var isInitialMount = _ref3.isInitialMount,
|
|
1904
|
+
highlightedIndex = _ref3.highlightedIndex,
|
|
1905
|
+
items = _ref3.items,
|
|
1906
|
+
environment = _ref3.environment,
|
|
1907
|
+
rest = _objectWithoutPropertiesLoose(_ref3, _excluded$3);
|
|
1875
1908
|
// Sets a11y status message on changes in state.
|
|
1876
1909
|
useEffect(function () {
|
|
1877
1910
|
if (isInitialMount || false) {
|
|
@@ -1887,13 +1920,13 @@ function useA11yMessageSetter(getA11yMessage, dependencyArray, _ref2) {
|
|
|
1887
1920
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1888
1921
|
}, dependencyArray);
|
|
1889
1922
|
}
|
|
1890
|
-
function useScrollIntoView(
|
|
1891
|
-
var highlightedIndex =
|
|
1892
|
-
isOpen =
|
|
1893
|
-
itemRefs =
|
|
1894
|
-
getItemNodeFromIndex =
|
|
1895
|
-
menuElement =
|
|
1896
|
-
scrollIntoViewProp =
|
|
1923
|
+
function useScrollIntoView(_ref4) {
|
|
1924
|
+
var highlightedIndex = _ref4.highlightedIndex,
|
|
1925
|
+
isOpen = _ref4.isOpen,
|
|
1926
|
+
itemRefs = _ref4.itemRefs,
|
|
1927
|
+
getItemNodeFromIndex = _ref4.getItemNodeFromIndex,
|
|
1928
|
+
menuElement = _ref4.menuElement,
|
|
1929
|
+
scrollIntoViewProp = _ref4.scrollIntoView;
|
|
1897
1930
|
// used not to scroll on highlight by mouse.
|
|
1898
1931
|
var shouldScrollRef = useRef(true);
|
|
1899
1932
|
// Scroll on highlighted item if change comes from keyboard.
|
|
@@ -1915,10 +1948,10 @@ function useScrollIntoView(_ref3) {
|
|
|
1915
1948
|
var useControlPropsValidator = noop;
|
|
1916
1949
|
/* istanbul ignore next */
|
|
1917
1950
|
if (process.env.NODE_ENV !== 'production') {
|
|
1918
|
-
useControlPropsValidator = function useControlPropsValidator(
|
|
1919
|
-
var isInitialMount =
|
|
1920
|
-
props =
|
|
1921
|
-
state =
|
|
1951
|
+
useControlPropsValidator = function useControlPropsValidator(_ref5) {
|
|
1952
|
+
var isInitialMount = _ref5.isInitialMount,
|
|
1953
|
+
props = _ref5.props,
|
|
1954
|
+
state = _ref5.state;
|
|
1922
1955
|
// used for checking when props are moving from controlled to uncontrolled.
|
|
1923
1956
|
var prevPropsRef = useRef(props);
|
|
1924
1957
|
useEffect(function () {
|
|
@@ -1957,6 +1990,47 @@ function getChangesOnSelection(props, highlightedIndex, inputValue) {
|
|
|
1957
1990
|
}));
|
|
1958
1991
|
}
|
|
1959
1992
|
|
|
1993
|
+
// Shared between all exports.
|
|
1994
|
+
var commonPropTypes = {
|
|
1995
|
+
environment: PropTypes.shape({
|
|
1996
|
+
addEventListener: PropTypes.func.isRequired,
|
|
1997
|
+
removeEventListener: PropTypes.func.isRequired,
|
|
1998
|
+
document: PropTypes.shape({
|
|
1999
|
+
createElement: PropTypes.func.isRequired,
|
|
2000
|
+
getElementById: PropTypes.func.isRequired,
|
|
2001
|
+
activeElement: PropTypes.any.isRequired,
|
|
2002
|
+
body: PropTypes.any.isRequired
|
|
2003
|
+
}).isRequired,
|
|
2004
|
+
Node: PropTypes.func.isRequired
|
|
2005
|
+
}),
|
|
2006
|
+
itemToString: PropTypes.func,
|
|
2007
|
+
stateReducer: PropTypes.func
|
|
2008
|
+
};
|
|
2009
|
+
|
|
2010
|
+
// Shared between useSelect, useCombobox, Downshift.
|
|
2011
|
+
var commonDropdownPropTypes = _extends({}, commonPropTypes, {
|
|
2012
|
+
getA11yStatusMessage: PropTypes.func,
|
|
2013
|
+
highlightedIndex: PropTypes.number,
|
|
2014
|
+
defaultHighlightedIndex: PropTypes.number,
|
|
2015
|
+
initialHighlightedIndex: PropTypes.number,
|
|
2016
|
+
isOpen: PropTypes.bool,
|
|
2017
|
+
defaultIsOpen: PropTypes.bool,
|
|
2018
|
+
initialIsOpen: PropTypes.bool,
|
|
2019
|
+
selectedItem: PropTypes.any,
|
|
2020
|
+
initialSelectedItem: PropTypes.any,
|
|
2021
|
+
defaultSelectedItem: PropTypes.any,
|
|
2022
|
+
id: PropTypes.string,
|
|
2023
|
+
labelId: PropTypes.string,
|
|
2024
|
+
menuId: PropTypes.string,
|
|
2025
|
+
getItemId: PropTypes.func,
|
|
2026
|
+
toggleButtonId: PropTypes.string,
|
|
2027
|
+
onSelectedItemChange: PropTypes.func,
|
|
2028
|
+
onHighlightedIndexChange: PropTypes.func,
|
|
2029
|
+
onStateChange: PropTypes.func,
|
|
2030
|
+
onIsOpenChange: PropTypes.func,
|
|
2031
|
+
scrollIntoView: PropTypes.func
|
|
2032
|
+
});
|
|
2033
|
+
|
|
1960
2034
|
function downshiftCommonReducer(state, action, stateChangeTypes) {
|
|
1961
2035
|
var type = action.type,
|
|
1962
2036
|
props = action.props;
|
|
@@ -2016,56 +2090,22 @@ function downshiftCommonReducer(state, action, stateChangeTypes) {
|
|
|
2016
2090
|
/* eslint-enable complexity */
|
|
2017
2091
|
|
|
2018
2092
|
function getItemIndexByCharacterKey(_a) {
|
|
2019
|
-
var keysSoFar = _a.keysSoFar, highlightedIndex = _a.highlightedIndex, items = _a.items, itemToString = _a.itemToString,
|
|
2093
|
+
var keysSoFar = _a.keysSoFar, highlightedIndex = _a.highlightedIndex, items = _a.items, itemToString = _a.itemToString, isItemDisabled = _a.isItemDisabled;
|
|
2020
2094
|
var lowerCasedKeysSoFar = keysSoFar.toLowerCase();
|
|
2021
2095
|
for (var index = 0; index < items.length; index++) {
|
|
2022
2096
|
// if we already have a search query in progress, we also consider the current highlighted item.
|
|
2023
2097
|
var offsetIndex = (index + highlightedIndex + (keysSoFar.length < 2 ? 1 : 0)) % items.length;
|
|
2024
2098
|
var item = items[offsetIndex];
|
|
2025
2099
|
if (item !== undefined &&
|
|
2026
|
-
itemToString(item).toLowerCase().startsWith(lowerCasedKeysSoFar)
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
return offsetIndex;
|
|
2030
|
-
}
|
|
2100
|
+
itemToString(item).toLowerCase().startsWith(lowerCasedKeysSoFar) &&
|
|
2101
|
+
!isItemDisabled(item, offsetIndex)) {
|
|
2102
|
+
return offsetIndex;
|
|
2031
2103
|
}
|
|
2032
2104
|
}
|
|
2033
2105
|
return highlightedIndex;
|
|
2034
2106
|
}
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
itemToString: PropTypes.func,
|
|
2038
|
-
getA11yStatusMessage: PropTypes.func,
|
|
2039
|
-
getA11ySelectionMessage: PropTypes.func,
|
|
2040
|
-
highlightedIndex: PropTypes.number,
|
|
2041
|
-
defaultHighlightedIndex: PropTypes.number,
|
|
2042
|
-
initialHighlightedIndex: PropTypes.number,
|
|
2043
|
-
isOpen: PropTypes.bool,
|
|
2044
|
-
defaultIsOpen: PropTypes.bool,
|
|
2045
|
-
initialIsOpen: PropTypes.bool,
|
|
2046
|
-
selectedItem: PropTypes.any,
|
|
2047
|
-
initialSelectedItem: PropTypes.any,
|
|
2048
|
-
defaultSelectedItem: PropTypes.any,
|
|
2049
|
-
id: PropTypes.string,
|
|
2050
|
-
labelId: PropTypes.string,
|
|
2051
|
-
menuId: PropTypes.string,
|
|
2052
|
-
getItemId: PropTypes.func,
|
|
2053
|
-
toggleButtonId: PropTypes.string,
|
|
2054
|
-
stateReducer: PropTypes.func,
|
|
2055
|
-
onSelectedItemChange: PropTypes.func,
|
|
2056
|
-
onHighlightedIndexChange: PropTypes.func,
|
|
2057
|
-
onStateChange: PropTypes.func,
|
|
2058
|
-
onIsOpenChange: PropTypes.func,
|
|
2059
|
-
environment: PropTypes.shape({
|
|
2060
|
-
addEventListener: PropTypes.func,
|
|
2061
|
-
removeEventListener: PropTypes.func,
|
|
2062
|
-
document: PropTypes.shape({
|
|
2063
|
-
getElementById: PropTypes.func,
|
|
2064
|
-
activeElement: PropTypes.any,
|
|
2065
|
-
body: PropTypes.any
|
|
2066
|
-
})
|
|
2067
|
-
})
|
|
2068
|
-
};
|
|
2107
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
2108
|
+
var propTypes$2 = __assign(__assign({}, commonDropdownPropTypes), { items: PropTypes.array.isRequired, isItemDisabled: PropTypes.func, getA11ySelectionMessage: PropTypes.func });
|
|
2069
2109
|
/**
|
|
2070
2110
|
* Default implementation for status message. Only added when menu is open.
|
|
2071
2111
|
* Will specift if there are results in the list, and if so, how many,
|
|
@@ -2087,7 +2127,9 @@ function getA11yStatusMessage(_a) {
|
|
|
2087
2127
|
}
|
|
2088
2128
|
return '';
|
|
2089
2129
|
}
|
|
2090
|
-
var defaultProps$2 = __assign(__assign({}, defaultProps$3), { getA11yStatusMessage: getA11yStatusMessage
|
|
2130
|
+
var defaultProps$2 = __assign(__assign({}, defaultProps$3), { getA11yStatusMessage: getA11yStatusMessage, isItemDisabled: function () {
|
|
2131
|
+
return false;
|
|
2132
|
+
} });
|
|
2091
2133
|
// eslint-disable-next-line import/no-mutable-exports
|
|
2092
2134
|
var validatePropTypes$2 = noop;
|
|
2093
2135
|
/* istanbul ignore next */
|
|
@@ -2171,7 +2213,7 @@ function downshiftSelectReducer(state, action) {
|
|
|
2171
2213
|
highlightedIndex: prevHighlightedIndex,
|
|
2172
2214
|
items: props.items,
|
|
2173
2215
|
itemToString: props.itemToString,
|
|
2174
|
-
|
|
2216
|
+
isItemDisabled: props.isItemDisabled
|
|
2175
2217
|
});
|
|
2176
2218
|
changes = {
|
|
2177
2219
|
inputValue: inputValue,
|
|
@@ -2182,7 +2224,7 @@ function downshiftSelectReducer(state, action) {
|
|
|
2182
2224
|
break;
|
|
2183
2225
|
case ToggleButtonKeyDownArrowDown:
|
|
2184
2226
|
{
|
|
2185
|
-
var _highlightedIndex = state.isOpen ?
|
|
2227
|
+
var _highlightedIndex = state.isOpen ? getHighlightedIndex(state.highlightedIndex, 1, props.items, props.isItemDisabled) : altKey && state.selectedItem == null ? -1 : getHighlightedIndexOnOpen(props, state, 1);
|
|
2186
2228
|
changes = {
|
|
2187
2229
|
highlightedIndex: _highlightedIndex,
|
|
2188
2230
|
isOpen: true
|
|
@@ -2193,7 +2235,7 @@ function downshiftSelectReducer(state, action) {
|
|
|
2193
2235
|
if (state.isOpen && altKey) {
|
|
2194
2236
|
changes = getChangesOnSelection(props, state.highlightedIndex, false);
|
|
2195
2237
|
} else {
|
|
2196
|
-
var _highlightedIndex2 = state.isOpen ?
|
|
2238
|
+
var _highlightedIndex2 = state.isOpen ? getHighlightedIndex(state.highlightedIndex, -1, props.items, props.isItemDisabled) : getHighlightedIndexOnOpen(props, state, -1);
|
|
2197
2239
|
changes = {
|
|
2198
2240
|
highlightedIndex: _highlightedIndex2,
|
|
2199
2241
|
isOpen: true
|
|
@@ -2207,24 +2249,24 @@ function downshiftSelectReducer(state, action) {
|
|
|
2207
2249
|
break;
|
|
2208
2250
|
case ToggleButtonKeyDownHome:
|
|
2209
2251
|
changes = {
|
|
2210
|
-
highlightedIndex:
|
|
2252
|
+
highlightedIndex: getNonDisabledIndex(0, false, props.items, props.isItemDisabled),
|
|
2211
2253
|
isOpen: true
|
|
2212
2254
|
};
|
|
2213
2255
|
break;
|
|
2214
2256
|
case ToggleButtonKeyDownEnd:
|
|
2215
2257
|
changes = {
|
|
2216
|
-
highlightedIndex:
|
|
2258
|
+
highlightedIndex: getNonDisabledIndex(props.items.length - 1, true, props.items, props.isItemDisabled),
|
|
2217
2259
|
isOpen: true
|
|
2218
2260
|
};
|
|
2219
2261
|
break;
|
|
2220
2262
|
case ToggleButtonKeyDownPageUp:
|
|
2221
2263
|
changes = {
|
|
2222
|
-
highlightedIndex:
|
|
2264
|
+
highlightedIndex: getHighlightedIndex(state.highlightedIndex, -10, props.items, props.isItemDisabled)
|
|
2223
2265
|
};
|
|
2224
2266
|
break;
|
|
2225
2267
|
case ToggleButtonKeyDownPageDown:
|
|
2226
2268
|
changes = {
|
|
2227
|
-
highlightedIndex:
|
|
2269
|
+
highlightedIndex: getHighlightedIndex(state.highlightedIndex, 10, props.items, props.isItemDisabled)
|
|
2228
2270
|
};
|
|
2229
2271
|
break;
|
|
2230
2272
|
case ToggleButtonKeyDownEscape:
|
|
@@ -2255,7 +2297,7 @@ function downshiftSelectReducer(state, action) {
|
|
|
2255
2297
|
|
|
2256
2298
|
var _excluded$2 = ["onMouseLeave", "refKey", "onKeyDown", "onBlur", "ref"],
|
|
2257
2299
|
_excluded2$2 = ["onBlur", "onClick", "onPress", "onKeyDown", "refKey", "ref"],
|
|
2258
|
-
_excluded3$1 = ["item", "index", "onMouseMove", "onClick", "onPress", "refKey", "
|
|
2300
|
+
_excluded3$1 = ["item", "index", "onMouseMove", "onClick", "onPress", "refKey", "disabled", "ref"];
|
|
2259
2301
|
useSelect.stateChangeTypes = stateChangeTypes$2;
|
|
2260
2302
|
function useSelect(userProps) {
|
|
2261
2303
|
if (userProps === void 0) {
|
|
@@ -2391,7 +2433,6 @@ function useSelect(userProps) {
|
|
|
2391
2433
|
event.preventDefault();
|
|
2392
2434
|
dispatch({
|
|
2393
2435
|
type: ToggleButtonKeyDownArrowDown,
|
|
2394
|
-
getItemNodeFromIndex: getItemNodeFromIndex,
|
|
2395
2436
|
altKey: event.altKey
|
|
2396
2437
|
});
|
|
2397
2438
|
},
|
|
@@ -2399,22 +2440,19 @@ function useSelect(userProps) {
|
|
|
2399
2440
|
event.preventDefault();
|
|
2400
2441
|
dispatch({
|
|
2401
2442
|
type: ToggleButtonKeyDownArrowUp,
|
|
2402
|
-
getItemNodeFromIndex: getItemNodeFromIndex,
|
|
2403
2443
|
altKey: event.altKey
|
|
2404
2444
|
});
|
|
2405
2445
|
},
|
|
2406
2446
|
Home: function Home(event) {
|
|
2407
2447
|
event.preventDefault();
|
|
2408
2448
|
dispatch({
|
|
2409
|
-
type: ToggleButtonKeyDownHome
|
|
2410
|
-
getItemNodeFromIndex: getItemNodeFromIndex
|
|
2449
|
+
type: ToggleButtonKeyDownHome
|
|
2411
2450
|
});
|
|
2412
2451
|
},
|
|
2413
2452
|
End: function End(event) {
|
|
2414
2453
|
event.preventDefault();
|
|
2415
2454
|
dispatch({
|
|
2416
|
-
type: ToggleButtonKeyDownEnd
|
|
2417
|
-
getItemNodeFromIndex: getItemNodeFromIndex
|
|
2455
|
+
type: ToggleButtonKeyDownEnd
|
|
2418
2456
|
});
|
|
2419
2457
|
},
|
|
2420
2458
|
Escape: function Escape() {
|
|
@@ -2434,8 +2472,7 @@ function useSelect(userProps) {
|
|
|
2434
2472
|
if (latest.current.state.isOpen) {
|
|
2435
2473
|
event.preventDefault();
|
|
2436
2474
|
dispatch({
|
|
2437
|
-
type: ToggleButtonKeyDownPageUp
|
|
2438
|
-
getItemNodeFromIndex: getItemNodeFromIndex
|
|
2475
|
+
type: ToggleButtonKeyDownPageUp
|
|
2439
2476
|
});
|
|
2440
2477
|
}
|
|
2441
2478
|
},
|
|
@@ -2443,8 +2480,7 @@ function useSelect(userProps) {
|
|
|
2443
2480
|
if (latest.current.state.isOpen) {
|
|
2444
2481
|
event.preventDefault();
|
|
2445
2482
|
dispatch({
|
|
2446
|
-
type: ToggleButtonKeyDownPageDown
|
|
2447
|
-
getItemNodeFromIndex: getItemNodeFromIndex
|
|
2483
|
+
type: ToggleButtonKeyDownPageDown
|
|
2448
2484
|
});
|
|
2449
2485
|
}
|
|
2450
2486
|
},
|
|
@@ -2460,8 +2496,7 @@ function useSelect(userProps) {
|
|
|
2460
2496
|
if (currentState.inputValue) {
|
|
2461
2497
|
dispatch({
|
|
2462
2498
|
type: ToggleButtonKeyDownCharacter,
|
|
2463
|
-
key: ' '
|
|
2464
|
-
getItemNodeFromIndex: getItemNodeFromIndex
|
|
2499
|
+
key: ' '
|
|
2465
2500
|
});
|
|
2466
2501
|
} else {
|
|
2467
2502
|
dispatch({
|
|
@@ -2470,7 +2505,7 @@ function useSelect(userProps) {
|
|
|
2470
2505
|
}
|
|
2471
2506
|
}
|
|
2472
2507
|
};
|
|
2473
|
-
}, [dispatch,
|
|
2508
|
+
}, [dispatch, latest]);
|
|
2474
2509
|
|
|
2475
2510
|
// Action functions.
|
|
2476
2511
|
var toggleMenu = useCallback(function () {
|
|
@@ -2575,8 +2610,7 @@ function useSelect(userProps) {
|
|
|
2575
2610
|
} else if (isAcceptedCharacterKey(key)) {
|
|
2576
2611
|
dispatch({
|
|
2577
2612
|
type: ToggleButtonKeyDownCharacter,
|
|
2578
|
-
key: key
|
|
2579
|
-
getItemNodeFromIndex: getItemNodeFromIndex
|
|
2613
|
+
key: key
|
|
2580
2614
|
});
|
|
2581
2615
|
}
|
|
2582
2616
|
};
|
|
@@ -2592,7 +2626,7 @@ function useSelect(userProps) {
|
|
|
2592
2626
|
}
|
|
2593
2627
|
setGetterPropCallInfo('getToggleButtonProps', suppressRefError, refKey, toggleButtonRef);
|
|
2594
2628
|
return toggleProps;
|
|
2595
|
-
}, [latest, elementIds, setGetterPropCallInfo, dispatch, mouseAndTouchTrackersRef, toggleButtonKeyDownHandlers
|
|
2629
|
+
}, [latest, elementIds, setGetterPropCallInfo, dispatch, mouseAndTouchTrackersRef, toggleButtonKeyDownHandlers]);
|
|
2596
2630
|
var getItemProps = useCallback(function (_temp5) {
|
|
2597
2631
|
var _extends4;
|
|
2598
2632
|
var _ref5 = _temp5 === void 0 ? {} : _temp5,
|
|
@@ -2603,15 +2637,19 @@ function useSelect(userProps) {
|
|
|
2603
2637
|
_ref5.onPress;
|
|
2604
2638
|
var _ref5$refKey = _ref5.refKey,
|
|
2605
2639
|
refKey = _ref5$refKey === void 0 ? 'ref' : _ref5$refKey,
|
|
2640
|
+
disabledProp = _ref5.disabled,
|
|
2606
2641
|
ref = _ref5.ref,
|
|
2607
|
-
disabled = _ref5.disabled,
|
|
2608
2642
|
rest = _objectWithoutPropertiesLoose(_ref5, _excluded3$1);
|
|
2643
|
+
if (disabledProp !== undefined) {
|
|
2644
|
+
console.warn('Passing "disabled" as an argument to getItemProps is not supported anymore. Please use the isItemDisabled prop from useSelect.');
|
|
2645
|
+
}
|
|
2609
2646
|
var _latest$current = latest.current,
|
|
2610
2647
|
latestState = _latest$current.state,
|
|
2611
2648
|
latestProps = _latest$current.props;
|
|
2612
2649
|
var _getItemAndIndex = getItemAndIndex(itemProp, indexProp, latestProps.items, 'Pass either item or index to getItemProps!'),
|
|
2613
2650
|
item = _getItemAndIndex[0],
|
|
2614
2651
|
index = _getItemAndIndex[1];
|
|
2652
|
+
var disabled = latestProps.isItemDisabled(item, index);
|
|
2615
2653
|
var itemHandleMouseMove = function itemHandleMouseMove() {
|
|
2616
2654
|
if (index === latestState.highlightedIndex) {
|
|
2617
2655
|
return;
|
|
@@ -2629,16 +2667,11 @@ function useSelect(userProps) {
|
|
|
2629
2667
|
index: index
|
|
2630
2668
|
});
|
|
2631
2669
|
};
|
|
2632
|
-
var itemProps = _extends((_extends4 = {
|
|
2633
|
-
disabled: disabled,
|
|
2634
|
-
role: 'option',
|
|
2635
|
-
'aria-selected': "" + (item === selectedItem),
|
|
2636
|
-
id: elementIds.getItemId(index)
|
|
2637
|
-
}, _extends4[refKey] = handleRefs(ref, function (itemNode) {
|
|
2670
|
+
var itemProps = _extends((_extends4 = {}, _extends4[refKey] = handleRefs(ref, function (itemNode) {
|
|
2638
2671
|
if (itemNode) {
|
|
2639
2672
|
itemRefs.current[elementIds.getItemId(index)] = itemNode;
|
|
2640
2673
|
}
|
|
2641
|
-
}), _extends4), rest);
|
|
2674
|
+
}), _extends4['aria-disabled'] = disabled, _extends4['aria-selected'] = "" + (item === latestState.selectedItem), _extends4.id = elementIds.getItemId(index), _extends4.role = 'option', _extends4), rest);
|
|
2642
2675
|
if (!disabled) {
|
|
2643
2676
|
/* istanbul ignore next (react-native) */
|
|
2644
2677
|
{
|
|
@@ -2647,7 +2680,7 @@ function useSelect(userProps) {
|
|
|
2647
2680
|
}
|
|
2648
2681
|
itemProps.onMouseMove = callAllEventHandlers(onMouseMove, itemHandleMouseMove);
|
|
2649
2682
|
return itemProps;
|
|
2650
|
-
}, [latest,
|
|
2683
|
+
}, [latest, elementIds, shouldScrollRef, dispatch]);
|
|
2651
2684
|
return {
|
|
2652
2685
|
// prop getters.
|
|
2653
2686
|
getToggleButtonProps: getToggleButtonProps,
|
|
@@ -2680,7 +2713,7 @@ var InputKeyDownPageDown = process.env.NODE_ENV !== "production" ? '__input_keyd
|
|
|
2680
2713
|
var InputKeyDownEnter = process.env.NODE_ENV !== "production" ? '__input_keydown_enter__' : 7;
|
|
2681
2714
|
var InputChange = process.env.NODE_ENV !== "production" ? '__input_change__' : 8;
|
|
2682
2715
|
var InputBlur = process.env.NODE_ENV !== "production" ? '__input_blur__' : 9;
|
|
2683
|
-
var
|
|
2716
|
+
var InputClick = process.env.NODE_ENV !== "production" ? '__input_click__' : 10;
|
|
2684
2717
|
var MenuMouseLeave = process.env.NODE_ENV !== "production" ? '__menu_mouse_leave__' : 11;
|
|
2685
2718
|
var ItemMouseMove = process.env.NODE_ENV !== "production" ? '__item_mouse_move__' : 12;
|
|
2686
2719
|
var ItemClick = process.env.NODE_ENV !== "production" ? '__item_click__' : 13;
|
|
@@ -2706,7 +2739,7 @@ var stateChangeTypes$1 = /*#__PURE__*/Object.freeze({
|
|
|
2706
2739
|
InputKeyDownEnter: InputKeyDownEnter,
|
|
2707
2740
|
InputChange: InputChange,
|
|
2708
2741
|
InputBlur: InputBlur,
|
|
2709
|
-
|
|
2742
|
+
InputClick: InputClick,
|
|
2710
2743
|
MenuMouseLeave: MenuMouseLeave,
|
|
2711
2744
|
ItemMouseMove: ItemMouseMove,
|
|
2712
2745
|
ItemClick: ItemClick,
|
|
@@ -2732,46 +2765,17 @@ function getInitialState$1(props) {
|
|
|
2732
2765
|
inputValue: inputValue
|
|
2733
2766
|
});
|
|
2734
2767
|
}
|
|
2735
|
-
var propTypes$1 = {
|
|
2768
|
+
var propTypes$1 = _extends({}, commonDropdownPropTypes, {
|
|
2736
2769
|
items: PropTypes.array.isRequired,
|
|
2737
|
-
|
|
2770
|
+
isItemDisabled: PropTypes.func,
|
|
2738
2771
|
selectedItemChanged: PropTypes.func,
|
|
2739
|
-
getA11yStatusMessage: PropTypes.func,
|
|
2740
2772
|
getA11ySelectionMessage: PropTypes.func,
|
|
2741
|
-
highlightedIndex: PropTypes.number,
|
|
2742
|
-
defaultHighlightedIndex: PropTypes.number,
|
|
2743
|
-
initialHighlightedIndex: PropTypes.number,
|
|
2744
|
-
isOpen: PropTypes.bool,
|
|
2745
|
-
defaultIsOpen: PropTypes.bool,
|
|
2746
|
-
initialIsOpen: PropTypes.bool,
|
|
2747
|
-
selectedItem: PropTypes.any,
|
|
2748
|
-
initialSelectedItem: PropTypes.any,
|
|
2749
|
-
defaultSelectedItem: PropTypes.any,
|
|
2750
2773
|
inputValue: PropTypes.string,
|
|
2751
2774
|
defaultInputValue: PropTypes.string,
|
|
2752
2775
|
initialInputValue: PropTypes.string,
|
|
2753
|
-
id: PropTypes.string,
|
|
2754
|
-
labelId: PropTypes.string,
|
|
2755
|
-
menuId: PropTypes.string,
|
|
2756
|
-
getItemId: PropTypes.func,
|
|
2757
2776
|
inputId: PropTypes.string,
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
onSelectedItemChange: PropTypes.func,
|
|
2761
|
-
onHighlightedIndexChange: PropTypes.func,
|
|
2762
|
-
onStateChange: PropTypes.func,
|
|
2763
|
-
onIsOpenChange: PropTypes.func,
|
|
2764
|
-
onInputValueChange: PropTypes.func,
|
|
2765
|
-
environment: PropTypes.shape({
|
|
2766
|
-
addEventListener: PropTypes.func,
|
|
2767
|
-
removeEventListener: PropTypes.func,
|
|
2768
|
-
document: PropTypes.shape({
|
|
2769
|
-
getElementById: PropTypes.func,
|
|
2770
|
-
activeElement: PropTypes.any,
|
|
2771
|
-
body: PropTypes.any
|
|
2772
|
-
})
|
|
2773
|
-
})
|
|
2774
|
-
};
|
|
2777
|
+
onInputValueChange: PropTypes.func
|
|
2778
|
+
});
|
|
2775
2779
|
|
|
2776
2780
|
/**
|
|
2777
2781
|
* The useCombobox version of useControlledReducer, which also
|
|
@@ -2820,7 +2824,10 @@ var defaultProps$1 = _extends({}, defaultProps$3, {
|
|
|
2820
2824
|
selectedItemChanged: function selectedItemChanged(prevItem, item) {
|
|
2821
2825
|
return prevItem !== item;
|
|
2822
2826
|
},
|
|
2823
|
-
getA11yStatusMessage: getA11yStatusMessage$1
|
|
2827
|
+
getA11yStatusMessage: getA11yStatusMessage$1,
|
|
2828
|
+
isItemDisabled: function isItemDisabled() {
|
|
2829
|
+
return false;
|
|
2830
|
+
}
|
|
2824
2831
|
});
|
|
2825
2832
|
|
|
2826
2833
|
/* eslint-disable complexity */
|
|
@@ -2842,11 +2849,11 @@ function downshiftUseComboboxReducer(state, action) {
|
|
|
2842
2849
|
case InputKeyDownArrowDown:
|
|
2843
2850
|
if (state.isOpen) {
|
|
2844
2851
|
changes = {
|
|
2845
|
-
highlightedIndex:
|
|
2852
|
+
highlightedIndex: getHighlightedIndex(state.highlightedIndex, 1, props.items, props.isItemDisabled, true)
|
|
2846
2853
|
};
|
|
2847
2854
|
} else {
|
|
2848
2855
|
changes = {
|
|
2849
|
-
highlightedIndex: altKey && state.selectedItem == null ? -1 : getHighlightedIndexOnOpen(props, state, 1
|
|
2856
|
+
highlightedIndex: altKey && state.selectedItem == null ? -1 : getHighlightedIndexOnOpen(props, state, 1),
|
|
2850
2857
|
isOpen: props.items.length >= 0
|
|
2851
2858
|
};
|
|
2852
2859
|
}
|
|
@@ -2857,12 +2864,12 @@ function downshiftUseComboboxReducer(state, action) {
|
|
|
2857
2864
|
changes = getChangesOnSelection(props, state.highlightedIndex);
|
|
2858
2865
|
} else {
|
|
2859
2866
|
changes = {
|
|
2860
|
-
highlightedIndex:
|
|
2867
|
+
highlightedIndex: getHighlightedIndex(state.highlightedIndex, -1, props.items, props.isItemDisabled, true)
|
|
2861
2868
|
};
|
|
2862
2869
|
}
|
|
2863
2870
|
} else {
|
|
2864
2871
|
changes = {
|
|
2865
|
-
highlightedIndex: getHighlightedIndexOnOpen(props, state, -1
|
|
2872
|
+
highlightedIndex: getHighlightedIndexOnOpen(props, state, -1),
|
|
2866
2873
|
isOpen: props.items.length >= 0
|
|
2867
2874
|
};
|
|
2868
2875
|
}
|
|
@@ -2881,22 +2888,22 @@ function downshiftUseComboboxReducer(state, action) {
|
|
|
2881
2888
|
break;
|
|
2882
2889
|
case InputKeyDownPageUp:
|
|
2883
2890
|
changes = {
|
|
2884
|
-
highlightedIndex:
|
|
2891
|
+
highlightedIndex: getHighlightedIndex(state.highlightedIndex, -10, props.items, props.isItemDisabled, true)
|
|
2885
2892
|
};
|
|
2886
2893
|
break;
|
|
2887
2894
|
case InputKeyDownPageDown:
|
|
2888
2895
|
changes = {
|
|
2889
|
-
highlightedIndex:
|
|
2896
|
+
highlightedIndex: getHighlightedIndex(state.highlightedIndex, 10, props.items, props.isItemDisabled, true)
|
|
2890
2897
|
};
|
|
2891
2898
|
break;
|
|
2892
2899
|
case InputKeyDownHome:
|
|
2893
2900
|
changes = {
|
|
2894
|
-
highlightedIndex:
|
|
2901
|
+
highlightedIndex: getNonDisabledIndex(0, false, props.items, props.isItemDisabled)
|
|
2895
2902
|
};
|
|
2896
2903
|
break;
|
|
2897
2904
|
case InputKeyDownEnd:
|
|
2898
2905
|
changes = {
|
|
2899
|
-
highlightedIndex:
|
|
2906
|
+
highlightedIndex: getNonDisabledIndex(props.items.length - 1, true, props.items, props.isItemDisabled)
|
|
2900
2907
|
};
|
|
2901
2908
|
break;
|
|
2902
2909
|
case InputBlur:
|
|
@@ -2915,10 +2922,10 @@ function downshiftUseComboboxReducer(state, action) {
|
|
|
2915
2922
|
inputValue: action.inputValue
|
|
2916
2923
|
};
|
|
2917
2924
|
break;
|
|
2918
|
-
case
|
|
2925
|
+
case InputClick:
|
|
2919
2926
|
changes = {
|
|
2920
|
-
isOpen:
|
|
2921
|
-
highlightedIndex: getHighlightedIndexOnOpen(props, state, 0)
|
|
2927
|
+
isOpen: !state.isOpen,
|
|
2928
|
+
highlightedIndex: state.isOpen ? -1 : getHighlightedIndexOnOpen(props, state, 0)
|
|
2922
2929
|
};
|
|
2923
2930
|
break;
|
|
2924
2931
|
case FunctionSelectItem:
|
|
@@ -2942,7 +2949,7 @@ function downshiftUseComboboxReducer(state, action) {
|
|
|
2942
2949
|
var _excluded$1 = ["onMouseLeave", "refKey", "ref"],
|
|
2943
2950
|
_excluded2$1 = ["item", "index", "refKey", "ref", "onMouseMove", "onMouseDown", "onClick", "onPress", "disabled"],
|
|
2944
2951
|
_excluded3 = ["onClick", "onPress", "refKey", "ref"],
|
|
2945
|
-
_excluded4 = ["onKeyDown", "onChange", "onInput", "
|
|
2952
|
+
_excluded4 = ["onKeyDown", "onChange", "onInput", "onBlur", "onChangeText", "onClick", "refKey", "ref"];
|
|
2946
2953
|
useCombobox.stateChangeTypes = stateChangeTypes$1;
|
|
2947
2954
|
function useCombobox(userProps) {
|
|
2948
2955
|
if (userProps === void 0) {
|
|
@@ -3066,16 +3073,14 @@ function useCombobox(userProps) {
|
|
|
3066
3073
|
event.preventDefault();
|
|
3067
3074
|
dispatch({
|
|
3068
3075
|
type: InputKeyDownArrowDown,
|
|
3069
|
-
altKey: event.altKey
|
|
3070
|
-
getItemNodeFromIndex: getItemNodeFromIndex
|
|
3076
|
+
altKey: event.altKey
|
|
3071
3077
|
});
|
|
3072
3078
|
},
|
|
3073
3079
|
ArrowUp: function ArrowUp(event) {
|
|
3074
3080
|
event.preventDefault();
|
|
3075
3081
|
dispatch({
|
|
3076
3082
|
type: InputKeyDownArrowUp,
|
|
3077
|
-
altKey: event.altKey
|
|
3078
|
-
getItemNodeFromIndex: getItemNodeFromIndex
|
|
3083
|
+
altKey: event.altKey
|
|
3079
3084
|
});
|
|
3080
3085
|
},
|
|
3081
3086
|
Home: function Home(event) {
|
|
@@ -3084,8 +3089,7 @@ function useCombobox(userProps) {
|
|
|
3084
3089
|
}
|
|
3085
3090
|
event.preventDefault();
|
|
3086
3091
|
dispatch({
|
|
3087
|
-
type: InputKeyDownHome
|
|
3088
|
-
getItemNodeFromIndex: getItemNodeFromIndex
|
|
3092
|
+
type: InputKeyDownHome
|
|
3089
3093
|
});
|
|
3090
3094
|
},
|
|
3091
3095
|
End: function End(event) {
|
|
@@ -3094,8 +3098,7 @@ function useCombobox(userProps) {
|
|
|
3094
3098
|
}
|
|
3095
3099
|
event.preventDefault();
|
|
3096
3100
|
dispatch({
|
|
3097
|
-
type: InputKeyDownEnd
|
|
3098
|
-
getItemNodeFromIndex: getItemNodeFromIndex
|
|
3101
|
+
type: InputKeyDownEnd
|
|
3099
3102
|
});
|
|
3100
3103
|
},
|
|
3101
3104
|
Escape: function Escape(event) {
|
|
@@ -3116,16 +3119,14 @@ function useCombobox(userProps) {
|
|
|
3116
3119
|
}
|
|
3117
3120
|
event.preventDefault();
|
|
3118
3121
|
dispatch({
|
|
3119
|
-
type: InputKeyDownEnter
|
|
3120
|
-
getItemNodeFromIndex: getItemNodeFromIndex
|
|
3122
|
+
type: InputKeyDownEnter
|
|
3121
3123
|
});
|
|
3122
3124
|
},
|
|
3123
3125
|
PageUp: function PageUp(event) {
|
|
3124
3126
|
if (latest.current.state.isOpen) {
|
|
3125
3127
|
event.preventDefault();
|
|
3126
3128
|
dispatch({
|
|
3127
|
-
type: InputKeyDownPageUp
|
|
3128
|
-
getItemNodeFromIndex: getItemNodeFromIndex
|
|
3129
|
+
type: InputKeyDownPageUp
|
|
3129
3130
|
});
|
|
3130
3131
|
}
|
|
3131
3132
|
},
|
|
@@ -3133,13 +3134,12 @@ function useCombobox(userProps) {
|
|
|
3133
3134
|
if (latest.current.state.isOpen) {
|
|
3134
3135
|
event.preventDefault();
|
|
3135
3136
|
dispatch({
|
|
3136
|
-
type: InputKeyDownPageDown
|
|
3137
|
-
getItemNodeFromIndex: getItemNodeFromIndex
|
|
3137
|
+
type: InputKeyDownPageDown
|
|
3138
3138
|
});
|
|
3139
3139
|
}
|
|
3140
3140
|
}
|
|
3141
3141
|
};
|
|
3142
|
-
}, [dispatch, latest
|
|
3142
|
+
}, [dispatch, latest]);
|
|
3143
3143
|
|
|
3144
3144
|
// Getter props.
|
|
3145
3145
|
var getLabelProps = useCallback(function (labelProps) {
|
|
@@ -3180,13 +3180,18 @@ function useCombobox(userProps) {
|
|
|
3180
3180
|
onMouseDown = _ref3.onMouseDown,
|
|
3181
3181
|
onClick = _ref3.onClick;
|
|
3182
3182
|
_ref3.onPress;
|
|
3183
|
-
var
|
|
3183
|
+
var disabledProp = _ref3.disabled,
|
|
3184
3184
|
rest = _objectWithoutPropertiesLoose(_ref3, _excluded2$1);
|
|
3185
|
+
if (disabledProp !== undefined) {
|
|
3186
|
+
console.warn('Passing "disabled" as an argument to getItemProps is not supported anymore. Please use the isItemDisabled prop from useCombobox.');
|
|
3187
|
+
}
|
|
3185
3188
|
var _latest$current = latest.current,
|
|
3186
3189
|
latestProps = _latest$current.props,
|
|
3187
3190
|
latestState = _latest$current.state;
|
|
3188
3191
|
var _getItemAndIndex = getItemAndIndex(itemProp, indexProp, latestProps.items, 'Pass either item or index to getItemProps!'),
|
|
3192
|
+
item = _getItemAndIndex[0],
|
|
3189
3193
|
index = _getItemAndIndex[1];
|
|
3194
|
+
var disabled = latestProps.isItemDisabled(item, index);
|
|
3190
3195
|
var onSelectKey = 'onClick';
|
|
3191
3196
|
var customClickHandler = onClick;
|
|
3192
3197
|
var itemHandleMouseMove = function itemHandleMouseMove() {
|
|
@@ -3213,7 +3218,7 @@ function useCombobox(userProps) {
|
|
|
3213
3218
|
if (itemNode) {
|
|
3214
3219
|
itemRefs.current[elementIds.getItemId(index)] = itemNode;
|
|
3215
3220
|
}
|
|
3216
|
-
}), _extends3
|
|
3221
|
+
}), _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), {
|
|
3217
3222
|
onMouseMove: callAllEventHandlers(onMouseMove, itemHandleMouseMove),
|
|
3218
3223
|
onMouseDown: callAllEventHandlers(onMouseDown, itemHandleMouseDown)
|
|
3219
3224
|
}, rest);
|
|
@@ -3245,10 +3250,10 @@ function useCombobox(userProps) {
|
|
|
3245
3250
|
onKeyDown = _ref6.onKeyDown,
|
|
3246
3251
|
onChange = _ref6.onChange,
|
|
3247
3252
|
onInput = _ref6.onInput,
|
|
3248
|
-
onFocus = _ref6.onFocus,
|
|
3249
3253
|
onBlur = _ref6.onBlur;
|
|
3250
3254
|
_ref6.onChangeText;
|
|
3251
|
-
var
|
|
3255
|
+
var onClick = _ref6.onClick,
|
|
3256
|
+
_ref6$refKey = _ref6.refKey,
|
|
3252
3257
|
refKey = _ref6$refKey === void 0 ? 'ref' : _ref6$refKey,
|
|
3253
3258
|
ref = _ref6.ref,
|
|
3254
3259
|
rest = _objectWithoutPropertiesLoose(_ref6, _excluded4);
|
|
@@ -3278,12 +3283,10 @@ function useCombobox(userProps) {
|
|
|
3278
3283
|
});
|
|
3279
3284
|
}
|
|
3280
3285
|
};
|
|
3281
|
-
var
|
|
3282
|
-
|
|
3283
|
-
|
|
3284
|
-
|
|
3285
|
-
});
|
|
3286
|
-
}
|
|
3286
|
+
var inputHandleClick = function inputHandleClick() {
|
|
3287
|
+
dispatch({
|
|
3288
|
+
type: InputClick
|
|
3289
|
+
});
|
|
3287
3290
|
};
|
|
3288
3291
|
|
|
3289
3292
|
/* istanbul ignore next (preact) */
|
|
@@ -3291,11 +3294,11 @@ function useCombobox(userProps) {
|
|
|
3291
3294
|
var eventHandlers = {};
|
|
3292
3295
|
if (!rest.disabled) {
|
|
3293
3296
|
var _eventHandlers;
|
|
3294
|
-
eventHandlers = (_eventHandlers = {}, _eventHandlers[onChangeKey] = callAllEventHandlers(onChange, onInput, inputHandleChange), _eventHandlers.onKeyDown = callAllEventHandlers(onKeyDown, inputHandleKeyDown), _eventHandlers.onBlur = callAllEventHandlers(onBlur, inputHandleBlur), _eventHandlers.
|
|
3297
|
+
eventHandlers = (_eventHandlers = {}, _eventHandlers[onChangeKey] = callAllEventHandlers(onChange, onInput, inputHandleChange), _eventHandlers.onKeyDown = callAllEventHandlers(onKeyDown, inputHandleKeyDown), _eventHandlers.onBlur = callAllEventHandlers(onBlur, inputHandleBlur), _eventHandlers.onClick = callAllEventHandlers(onClick, inputHandleClick), _eventHandlers);
|
|
3295
3298
|
}
|
|
3296
3299
|
return _extends((_extends5 = {}, _extends5[refKey] = handleRefs(ref, function (inputNode) {
|
|
3297
3300
|
inputRef.current = inputNode;
|
|
3298
|
-
}), _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 :
|
|
3301
|
+
}), _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);
|
|
3299
3302
|
}, [dispatch, inputKeyDownHandlers, latest, mouseAndTouchTrackersRef, setGetterPropCallInfo, elementIds]);
|
|
3300
3303
|
|
|
3301
3304
|
// returns
|
|
@@ -3442,30 +3445,19 @@ function getA11yRemovalMessage(selectionParameters) {
|
|
|
3442
3445
|
itemToStringLocal = selectionParameters.itemToString;
|
|
3443
3446
|
return itemToStringLocal(removedSelectedItem) + " has been removed.";
|
|
3444
3447
|
}
|
|
3445
|
-
var propTypes = {
|
|
3448
|
+
var propTypes = _extends({}, commonPropTypes, {
|
|
3446
3449
|
selectedItems: PropTypes.array,
|
|
3447
3450
|
initialSelectedItems: PropTypes.array,
|
|
3448
3451
|
defaultSelectedItems: PropTypes.array,
|
|
3449
|
-
itemToString: PropTypes.func,
|
|
3450
3452
|
getA11yRemovalMessage: PropTypes.func,
|
|
3451
|
-
stateReducer: PropTypes.func,
|
|
3452
3453
|
activeIndex: PropTypes.number,
|
|
3453
3454
|
initialActiveIndex: PropTypes.number,
|
|
3454
3455
|
defaultActiveIndex: PropTypes.number,
|
|
3455
3456
|
onActiveIndexChange: PropTypes.func,
|
|
3456
3457
|
onSelectedItemsChange: PropTypes.func,
|
|
3457
3458
|
keyNavigationNext: PropTypes.string,
|
|
3458
|
-
keyNavigationPrevious: PropTypes.string
|
|
3459
|
-
|
|
3460
|
-
addEventListener: PropTypes.func,
|
|
3461
|
-
removeEventListener: PropTypes.func,
|
|
3462
|
-
document: PropTypes.shape({
|
|
3463
|
-
getElementById: PropTypes.func,
|
|
3464
|
-
activeElement: PropTypes.any,
|
|
3465
|
-
body: PropTypes.any
|
|
3466
|
-
})
|
|
3467
|
-
})
|
|
3468
|
-
};
|
|
3459
|
+
keyNavigationPrevious: PropTypes.string
|
|
3460
|
+
});
|
|
3469
3461
|
var defaultProps = {
|
|
3470
3462
|
itemToString: defaultProps$3.itemToString,
|
|
3471
3463
|
stateReducer: defaultProps$3.stateReducer,
|