downshift 6.1.4 β 6.1.7
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 +2 -1
- package/dist/downshift.cjs.js +20 -20
- package/dist/downshift.esm.js +20 -20
- package/dist/downshift.native.cjs.js +20 -20
- package/dist/downshift.umd.js +45 -20
- package/dist/downshift.umd.js.map +1 -1
- package/dist/downshift.umd.min.js +16 -2
- package/dist/downshift.umd.min.js.map +1 -1
- package/dist/src/utils.d.ts +1 -1
- package/package.json +3 -2
- package/preact/dist/downshift.cjs.js +20 -20
- package/preact/dist/downshift.esm.js +20 -20
- package/preact/dist/downshift.umd.js +45 -20
- package/preact/dist/downshift.umd.js.map +1 -1
- package/preact/dist/downshift.umd.min.js +15 -1
- package/preact/dist/downshift.umd.min.js.map +1 -1
- package/typings/index.d.ts +11 -2
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ autocomplete, combobox or select dropdown components.</p>
|
|
|
10
10
|
> [Read the docs](https://downshift-js.com) |
|
|
11
11
|
> [See the intro blog post](https://kentcdodds.com/blog/introducing-downshift-for-react)
|
|
12
12
|
> |
|
|
13
|
-
> [Listen to the Episode 79 of the Full Stack Radio podcast](https://
|
|
13
|
+
> [Listen to the Episode 79 of the Full Stack Radio podcast](https://fullstackradio.com/79)
|
|
14
14
|
|
|
15
15
|
<hr />
|
|
16
16
|
|
|
@@ -1404,6 +1404,7 @@ Thanks goes to these people ([emoji key][emojis]):
|
|
|
1404
1404
|
<td align="center"><a href="http://nickdeom.com"><img src="https://avatars2.githubusercontent.com/u/56491159?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Nick Deom</b></sub></a><br /><a href="https://github.com/downshift-js/downshift/commits?author=ndeom" title="Code">π»</a> <a href="https://github.com/downshift-js/downshift/issues?q=author%3Andeom" title="Bug reports">π</a></td>
|
|
1405
1405
|
<td align="center"><a href="https://github.com/clementgarbay"><img src="https://avatars3.githubusercontent.com/u/12433625?v=4?s=100" width="100px;" alt=""/><br /><sub><b>ClΓ©ment Garbay</b></sub></a><br /><a href="https://github.com/downshift-js/downshift/commits?author=clementgarbay" title="Code">π»</a></td>
|
|
1406
1406
|
<td align="center"><a href="https://github.com/KaiminHuang"><img src="https://avatars.githubusercontent.com/u/5600404?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Kaimin Huang</b></sub></a><br /><a href="https://github.com/downshift-js/downshift/commits?author=KaiminHuang" title="Code">π»</a> <a href="https://github.com/downshift-js/downshift/issues?q=author%3AKaiminHuang" title="Bug reports">π</a></td>
|
|
1407
|
+
<td align="center"><a href="http://theredcircuit.com"><img src="https://avatars.githubusercontent.com/u/1242456?v=4?s=100" width="100px;" alt=""/><br /><sub><b>David Welling</b></sub></a><br /><a href="https://github.com/downshift-js/downshift/commits?author=davewelling" title="Code">π»</a> <a href="https://github.com/downshift-js/downshift/issues?q=author%3Adavewelling" title="Bug reports">π</a></td>
|
|
1407
1408
|
</tr>
|
|
1408
1409
|
</table>
|
|
1409
1410
|
|
package/dist/downshift.cjs.js
CHANGED
|
@@ -10,6 +10,7 @@ var PropTypes = require('prop-types');
|
|
|
10
10
|
var react = require('react');
|
|
11
11
|
var reactIs = require('react-is');
|
|
12
12
|
var computeScrollIntoView = require('compute-scroll-into-view');
|
|
13
|
+
var tslib = require('tslib');
|
|
13
14
|
|
|
14
15
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
15
16
|
|
|
@@ -169,7 +170,7 @@ function resetIdCounter() {
|
|
|
169
170
|
}
|
|
170
171
|
/**
|
|
171
172
|
* Default implementation for status message. Only added when menu is open.
|
|
172
|
-
* Will
|
|
173
|
+
* Will specify if there are results in the list, and if so, how many,
|
|
173
174
|
* and what keys are relevant.
|
|
174
175
|
*
|
|
175
176
|
* @param {Object} param the downshift state and other relevant properties
|
|
@@ -2268,24 +2269,25 @@ function downshiftCommonReducer(state, action, stateChangeTypes) {
|
|
|
2268
2269
|
}
|
|
2269
2270
|
/* eslint-enable complexity */
|
|
2270
2271
|
|
|
2271
|
-
function getItemIndexByCharacterKey(
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2272
|
+
function getItemIndexByCharacterKey(_a) {
|
|
2273
|
+
var keysSoFar = _a.keysSoFar, highlightedIndex = _a.highlightedIndex, items = _a.items, itemToString = _a.itemToString, getItemNodeFromIndex = _a.getItemNodeFromIndex;
|
|
2274
|
+
var lowerCasedKeysSoFar = keysSoFar.toLowerCase();
|
|
2275
|
+
for (var index = 0; index < items.length; index++) {
|
|
2276
|
+
var offsetIndex = (index + highlightedIndex + 1) % items.length;
|
|
2277
|
+
var item = items[offsetIndex];
|
|
2276
2278
|
if (item !== undefined &&
|
|
2277
2279
|
itemToString(item)
|
|
2278
2280
|
.toLowerCase()
|
|
2279
2281
|
.startsWith(lowerCasedKeysSoFar)) {
|
|
2280
|
-
|
|
2281
|
-
if (!element
|
|
2282
|
+
var element = getItemNodeFromIndex(offsetIndex);
|
|
2283
|
+
if (!(element === null || element === void 0 ? void 0 : element.hasAttribute('disabled'))) {
|
|
2282
2284
|
return offsetIndex;
|
|
2283
2285
|
}
|
|
2284
2286
|
}
|
|
2285
2287
|
}
|
|
2286
2288
|
return highlightedIndex;
|
|
2287
2289
|
}
|
|
2288
|
-
|
|
2290
|
+
var propTypes$2 = {
|
|
2289
2291
|
items: PropTypes__default['default'].array.isRequired,
|
|
2290
2292
|
itemToString: PropTypes__default['default'].func,
|
|
2291
2293
|
getA11yStatusMessage: PropTypes__default['default'].func,
|
|
@@ -2316,9 +2318,9 @@ const propTypes$2 = {
|
|
|
2316
2318
|
document: PropTypes__default['default'].shape({
|
|
2317
2319
|
getElementById: PropTypes__default['default'].func,
|
|
2318
2320
|
activeElement: PropTypes__default['default'].any,
|
|
2319
|
-
body: PropTypes__default['default'].any
|
|
2320
|
-
})
|
|
2321
|
-
})
|
|
2321
|
+
body: PropTypes__default['default'].any
|
|
2322
|
+
})
|
|
2323
|
+
})
|
|
2322
2324
|
};
|
|
2323
2325
|
/**
|
|
2324
2326
|
* Default implementation for status message. Only added when menu is open.
|
|
@@ -2328,7 +2330,8 @@ const propTypes$2 = {
|
|
|
2328
2330
|
* @param {Object} param the downshift state and other relevant properties
|
|
2329
2331
|
* @return {String} the a11y status message
|
|
2330
2332
|
*/
|
|
2331
|
-
function getA11yStatusMessage(
|
|
2333
|
+
function getA11yStatusMessage(_a) {
|
|
2334
|
+
var isOpen = _a.isOpen, resultCount = _a.resultCount, previousResultCount = _a.previousResultCount;
|
|
2332
2335
|
if (!isOpen) {
|
|
2333
2336
|
return '';
|
|
2334
2337
|
}
|
|
@@ -2336,19 +2339,16 @@ function getA11yStatusMessage({ isOpen, resultCount, previousResultCount, }) {
|
|
|
2336
2339
|
return 'No results are available.';
|
|
2337
2340
|
}
|
|
2338
2341
|
if (resultCount !== previousResultCount) {
|
|
2339
|
-
return
|
|
2342
|
+
return resultCount + " result" + (resultCount === 1 ? ' is' : 's are') + " available, use up and down arrow keys to navigate. Press Enter or Space Bar keys to select.";
|
|
2340
2343
|
}
|
|
2341
2344
|
return '';
|
|
2342
2345
|
}
|
|
2343
|
-
|
|
2344
|
-
...defaultProps$3,
|
|
2345
|
-
getA11yStatusMessage,
|
|
2346
|
-
};
|
|
2346
|
+
var defaultProps$2 = tslib.__assign(tslib.__assign({}, defaultProps$3), { getA11yStatusMessage: getA11yStatusMessage });
|
|
2347
2347
|
// eslint-disable-next-line import/no-mutable-exports
|
|
2348
|
-
|
|
2348
|
+
var validatePropTypes$2 = noop;
|
|
2349
2349
|
/* istanbul ignore next */
|
|
2350
2350
|
if (process.env.NODE_ENV !== 'production') {
|
|
2351
|
-
validatePropTypes$2 = (options, caller)
|
|
2351
|
+
validatePropTypes$2 = function (options, caller) {
|
|
2352
2352
|
PropTypes__default['default'].checkPropTypes(propTypes$2, options, 'prop', caller.name);
|
|
2353
2353
|
};
|
|
2354
2354
|
}
|
package/dist/downshift.esm.js
CHANGED
|
@@ -6,6 +6,7 @@ import PropTypes from 'prop-types';
|
|
|
6
6
|
import { cloneElement, Component, useRef, useEffect, useCallback, useLayoutEffect, useReducer, useMemo } from 'react';
|
|
7
7
|
import { isForwardRef } from 'react-is';
|
|
8
8
|
import computeScrollIntoView from 'compute-scroll-into-view';
|
|
9
|
+
import { __assign } from 'tslib';
|
|
9
10
|
|
|
10
11
|
var idCounter = 0;
|
|
11
12
|
/**
|
|
@@ -156,7 +157,7 @@ function resetIdCounter() {
|
|
|
156
157
|
}
|
|
157
158
|
/**
|
|
158
159
|
* Default implementation for status message. Only added when menu is open.
|
|
159
|
-
* Will
|
|
160
|
+
* Will specify if there are results in the list, and if so, how many,
|
|
160
161
|
* and what keys are relevant.
|
|
161
162
|
*
|
|
162
163
|
* @param {Object} param the downshift state and other relevant properties
|
|
@@ -2255,24 +2256,25 @@ function downshiftCommonReducer(state, action, stateChangeTypes) {
|
|
|
2255
2256
|
}
|
|
2256
2257
|
/* eslint-enable complexity */
|
|
2257
2258
|
|
|
2258
|
-
function getItemIndexByCharacterKey(
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2259
|
+
function getItemIndexByCharacterKey(_a) {
|
|
2260
|
+
var keysSoFar = _a.keysSoFar, highlightedIndex = _a.highlightedIndex, items = _a.items, itemToString = _a.itemToString, getItemNodeFromIndex = _a.getItemNodeFromIndex;
|
|
2261
|
+
var lowerCasedKeysSoFar = keysSoFar.toLowerCase();
|
|
2262
|
+
for (var index = 0; index < items.length; index++) {
|
|
2263
|
+
var offsetIndex = (index + highlightedIndex + 1) % items.length;
|
|
2264
|
+
var item = items[offsetIndex];
|
|
2263
2265
|
if (item !== undefined &&
|
|
2264
2266
|
itemToString(item)
|
|
2265
2267
|
.toLowerCase()
|
|
2266
2268
|
.startsWith(lowerCasedKeysSoFar)) {
|
|
2267
|
-
|
|
2268
|
-
if (!element
|
|
2269
|
+
var element = getItemNodeFromIndex(offsetIndex);
|
|
2270
|
+
if (!(element === null || element === void 0 ? void 0 : element.hasAttribute('disabled'))) {
|
|
2269
2271
|
return offsetIndex;
|
|
2270
2272
|
}
|
|
2271
2273
|
}
|
|
2272
2274
|
}
|
|
2273
2275
|
return highlightedIndex;
|
|
2274
2276
|
}
|
|
2275
|
-
|
|
2277
|
+
var propTypes$2 = {
|
|
2276
2278
|
items: PropTypes.array.isRequired,
|
|
2277
2279
|
itemToString: PropTypes.func,
|
|
2278
2280
|
getA11yStatusMessage: PropTypes.func,
|
|
@@ -2303,9 +2305,9 @@ const propTypes$2 = {
|
|
|
2303
2305
|
document: PropTypes.shape({
|
|
2304
2306
|
getElementById: PropTypes.func,
|
|
2305
2307
|
activeElement: PropTypes.any,
|
|
2306
|
-
body: PropTypes.any
|
|
2307
|
-
})
|
|
2308
|
-
})
|
|
2308
|
+
body: PropTypes.any
|
|
2309
|
+
})
|
|
2310
|
+
})
|
|
2309
2311
|
};
|
|
2310
2312
|
/**
|
|
2311
2313
|
* Default implementation for status message. Only added when menu is open.
|
|
@@ -2315,7 +2317,8 @@ const propTypes$2 = {
|
|
|
2315
2317
|
* @param {Object} param the downshift state and other relevant properties
|
|
2316
2318
|
* @return {String} the a11y status message
|
|
2317
2319
|
*/
|
|
2318
|
-
function getA11yStatusMessage(
|
|
2320
|
+
function getA11yStatusMessage(_a) {
|
|
2321
|
+
var isOpen = _a.isOpen, resultCount = _a.resultCount, previousResultCount = _a.previousResultCount;
|
|
2319
2322
|
if (!isOpen) {
|
|
2320
2323
|
return '';
|
|
2321
2324
|
}
|
|
@@ -2323,19 +2326,16 @@ function getA11yStatusMessage({ isOpen, resultCount, previousResultCount, }) {
|
|
|
2323
2326
|
return 'No results are available.';
|
|
2324
2327
|
}
|
|
2325
2328
|
if (resultCount !== previousResultCount) {
|
|
2326
|
-
return
|
|
2329
|
+
return resultCount + " result" + (resultCount === 1 ? ' is' : 's are') + " available, use up and down arrow keys to navigate. Press Enter or Space Bar keys to select.";
|
|
2327
2330
|
}
|
|
2328
2331
|
return '';
|
|
2329
2332
|
}
|
|
2330
|
-
|
|
2331
|
-
...defaultProps$3,
|
|
2332
|
-
getA11yStatusMessage,
|
|
2333
|
-
};
|
|
2333
|
+
var defaultProps$2 = __assign(__assign({}, defaultProps$3), { getA11yStatusMessage: getA11yStatusMessage });
|
|
2334
2334
|
// eslint-disable-next-line import/no-mutable-exports
|
|
2335
|
-
|
|
2335
|
+
var validatePropTypes$2 = noop;
|
|
2336
2336
|
/* istanbul ignore next */
|
|
2337
2337
|
if (process.env.NODE_ENV !== 'production') {
|
|
2338
|
-
validatePropTypes$2 = (options, caller)
|
|
2338
|
+
validatePropTypes$2 = function (options, caller) {
|
|
2339
2339
|
PropTypes.checkPropTypes(propTypes$2, options, 'prop', caller.name);
|
|
2340
2340
|
};
|
|
2341
2341
|
}
|
|
@@ -10,6 +10,7 @@ var PropTypes = require('prop-types');
|
|
|
10
10
|
var react = require('react');
|
|
11
11
|
var reactIs = require('react-is');
|
|
12
12
|
var computeScrollIntoView = require('compute-scroll-into-view');
|
|
13
|
+
var tslib = require('tslib');
|
|
13
14
|
|
|
14
15
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
15
16
|
|
|
@@ -169,7 +170,7 @@ function resetIdCounter() {
|
|
|
169
170
|
}
|
|
170
171
|
/**
|
|
171
172
|
* Default implementation for status message. Only added when menu is open.
|
|
172
|
-
* Will
|
|
173
|
+
* Will specify if there are results in the list, and if so, how many,
|
|
173
174
|
* and what keys are relevant.
|
|
174
175
|
*
|
|
175
176
|
* @param {Object} param the downshift state and other relevant properties
|
|
@@ -2197,24 +2198,25 @@ function downshiftCommonReducer(state, action, stateChangeTypes) {
|
|
|
2197
2198
|
}
|
|
2198
2199
|
/* eslint-enable complexity */
|
|
2199
2200
|
|
|
2200
|
-
function getItemIndexByCharacterKey(
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2201
|
+
function getItemIndexByCharacterKey(_a) {
|
|
2202
|
+
var keysSoFar = _a.keysSoFar, highlightedIndex = _a.highlightedIndex, items = _a.items, itemToString = _a.itemToString, getItemNodeFromIndex = _a.getItemNodeFromIndex;
|
|
2203
|
+
var lowerCasedKeysSoFar = keysSoFar.toLowerCase();
|
|
2204
|
+
for (var index = 0; index < items.length; index++) {
|
|
2205
|
+
var offsetIndex = (index + highlightedIndex + 1) % items.length;
|
|
2206
|
+
var item = items[offsetIndex];
|
|
2205
2207
|
if (item !== undefined &&
|
|
2206
2208
|
itemToString(item)
|
|
2207
2209
|
.toLowerCase()
|
|
2208
2210
|
.startsWith(lowerCasedKeysSoFar)) {
|
|
2209
|
-
|
|
2210
|
-
if (!element
|
|
2211
|
+
var element = getItemNodeFromIndex(offsetIndex);
|
|
2212
|
+
if (!(element === null || element === void 0 ? void 0 : element.hasAttribute('disabled'))) {
|
|
2211
2213
|
return offsetIndex;
|
|
2212
2214
|
}
|
|
2213
2215
|
}
|
|
2214
2216
|
}
|
|
2215
2217
|
return highlightedIndex;
|
|
2216
2218
|
}
|
|
2217
|
-
|
|
2219
|
+
var propTypes$2 = {
|
|
2218
2220
|
items: PropTypes__default['default'].array.isRequired,
|
|
2219
2221
|
itemToString: PropTypes__default['default'].func,
|
|
2220
2222
|
getA11yStatusMessage: PropTypes__default['default'].func,
|
|
@@ -2245,9 +2247,9 @@ const propTypes$2 = {
|
|
|
2245
2247
|
document: PropTypes__default['default'].shape({
|
|
2246
2248
|
getElementById: PropTypes__default['default'].func,
|
|
2247
2249
|
activeElement: PropTypes__default['default'].any,
|
|
2248
|
-
body: PropTypes__default['default'].any
|
|
2249
|
-
})
|
|
2250
|
-
})
|
|
2250
|
+
body: PropTypes__default['default'].any
|
|
2251
|
+
})
|
|
2252
|
+
})
|
|
2251
2253
|
};
|
|
2252
2254
|
/**
|
|
2253
2255
|
* Default implementation for status message. Only added when menu is open.
|
|
@@ -2257,7 +2259,8 @@ const propTypes$2 = {
|
|
|
2257
2259
|
* @param {Object} param the downshift state and other relevant properties
|
|
2258
2260
|
* @return {String} the a11y status message
|
|
2259
2261
|
*/
|
|
2260
|
-
function getA11yStatusMessage(
|
|
2262
|
+
function getA11yStatusMessage(_a) {
|
|
2263
|
+
var isOpen = _a.isOpen, resultCount = _a.resultCount, previousResultCount = _a.previousResultCount;
|
|
2261
2264
|
if (!isOpen) {
|
|
2262
2265
|
return '';
|
|
2263
2266
|
}
|
|
@@ -2265,19 +2268,16 @@ function getA11yStatusMessage({ isOpen, resultCount, previousResultCount, }) {
|
|
|
2265
2268
|
return 'No results are available.';
|
|
2266
2269
|
}
|
|
2267
2270
|
if (resultCount !== previousResultCount) {
|
|
2268
|
-
return
|
|
2271
|
+
return resultCount + " result" + (resultCount === 1 ? ' is' : 's are') + " available, use up and down arrow keys to navigate. Press Enter or Space Bar keys to select.";
|
|
2269
2272
|
}
|
|
2270
2273
|
return '';
|
|
2271
2274
|
}
|
|
2272
|
-
|
|
2273
|
-
...defaultProps$3,
|
|
2274
|
-
getA11yStatusMessage,
|
|
2275
|
-
};
|
|
2275
|
+
var defaultProps$2 = tslib.__assign(tslib.__assign({}, defaultProps$3), { getA11yStatusMessage: getA11yStatusMessage });
|
|
2276
2276
|
// eslint-disable-next-line import/no-mutable-exports
|
|
2277
|
-
|
|
2277
|
+
var validatePropTypes$2 = noop;
|
|
2278
2278
|
/* istanbul ignore next */
|
|
2279
2279
|
if (process.env.NODE_ENV !== 'production') {
|
|
2280
|
-
validatePropTypes$2 = (options, caller)
|
|
2280
|
+
validatePropTypes$2 = function (options, caller) {
|
|
2281
2281
|
PropTypes__default['default'].checkPropTypes(propTypes$2, options, 'prop', caller.name);
|
|
2282
2282
|
};
|
|
2283
2283
|
}
|
package/dist/downshift.umd.js
CHANGED
|
@@ -1448,7 +1448,7 @@
|
|
|
1448
1448
|
}
|
|
1449
1449
|
/**
|
|
1450
1450
|
* Default implementation for status message. Only added when menu is open.
|
|
1451
|
-
* Will
|
|
1451
|
+
* Will specify if there are results in the list, and if so, how many,
|
|
1452
1452
|
* and what keys are relevant.
|
|
1453
1453
|
*
|
|
1454
1454
|
* @param {Object} param the downshift state and other relevant properties
|
|
@@ -3537,24 +3537,51 @@
|
|
|
3537
3537
|
}
|
|
3538
3538
|
/* eslint-enable complexity */
|
|
3539
3539
|
|
|
3540
|
-
|
|
3541
|
-
|
|
3542
|
-
|
|
3543
|
-
|
|
3544
|
-
|
|
3540
|
+
/*! *****************************************************************************
|
|
3541
|
+
Copyright (c) Microsoft Corporation.
|
|
3542
|
+
|
|
3543
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
3544
|
+
purpose with or without fee is hereby granted.
|
|
3545
|
+
|
|
3546
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
3547
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
3548
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
3549
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
3550
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
3551
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
3552
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
3553
|
+
***************************************************************************** */
|
|
3554
|
+
|
|
3555
|
+
var __assign = function() {
|
|
3556
|
+
__assign = Object.assign || function __assign(t) {
|
|
3557
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
3558
|
+
s = arguments[i];
|
|
3559
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
3560
|
+
}
|
|
3561
|
+
return t;
|
|
3562
|
+
};
|
|
3563
|
+
return __assign.apply(this, arguments);
|
|
3564
|
+
};
|
|
3565
|
+
|
|
3566
|
+
function getItemIndexByCharacterKey(_a) {
|
|
3567
|
+
var keysSoFar = _a.keysSoFar, highlightedIndex = _a.highlightedIndex, items = _a.items, itemToString = _a.itemToString, getItemNodeFromIndex = _a.getItemNodeFromIndex;
|
|
3568
|
+
var lowerCasedKeysSoFar = keysSoFar.toLowerCase();
|
|
3569
|
+
for (var index = 0; index < items.length; index++) {
|
|
3570
|
+
var offsetIndex = (index + highlightedIndex + 1) % items.length;
|
|
3571
|
+
var item = items[offsetIndex];
|
|
3545
3572
|
if (item !== undefined &&
|
|
3546
3573
|
itemToString(item)
|
|
3547
3574
|
.toLowerCase()
|
|
3548
3575
|
.startsWith(lowerCasedKeysSoFar)) {
|
|
3549
|
-
|
|
3550
|
-
if (!element
|
|
3576
|
+
var element = getItemNodeFromIndex(offsetIndex);
|
|
3577
|
+
if (!(element === null || element === void 0 ? void 0 : element.hasAttribute('disabled'))) {
|
|
3551
3578
|
return offsetIndex;
|
|
3552
3579
|
}
|
|
3553
3580
|
}
|
|
3554
3581
|
}
|
|
3555
3582
|
return highlightedIndex;
|
|
3556
3583
|
}
|
|
3557
|
-
|
|
3584
|
+
var propTypes$2 = {
|
|
3558
3585
|
items: PropTypes.array.isRequired,
|
|
3559
3586
|
itemToString: PropTypes.func,
|
|
3560
3587
|
getA11yStatusMessage: PropTypes.func,
|
|
@@ -3585,9 +3612,9 @@
|
|
|
3585
3612
|
document: PropTypes.shape({
|
|
3586
3613
|
getElementById: PropTypes.func,
|
|
3587
3614
|
activeElement: PropTypes.any,
|
|
3588
|
-
body: PropTypes.any
|
|
3589
|
-
})
|
|
3590
|
-
})
|
|
3615
|
+
body: PropTypes.any
|
|
3616
|
+
})
|
|
3617
|
+
})
|
|
3591
3618
|
};
|
|
3592
3619
|
/**
|
|
3593
3620
|
* Default implementation for status message. Only added when menu is open.
|
|
@@ -3597,7 +3624,8 @@
|
|
|
3597
3624
|
* @param {Object} param the downshift state and other relevant properties
|
|
3598
3625
|
* @return {String} the a11y status message
|
|
3599
3626
|
*/
|
|
3600
|
-
function getA11yStatusMessage(
|
|
3627
|
+
function getA11yStatusMessage(_a) {
|
|
3628
|
+
var isOpen = _a.isOpen, resultCount = _a.resultCount, previousResultCount = _a.previousResultCount;
|
|
3601
3629
|
if (!isOpen) {
|
|
3602
3630
|
return '';
|
|
3603
3631
|
}
|
|
@@ -3605,19 +3633,16 @@
|
|
|
3605
3633
|
return 'No results are available.';
|
|
3606
3634
|
}
|
|
3607
3635
|
if (resultCount !== previousResultCount) {
|
|
3608
|
-
return
|
|
3636
|
+
return resultCount + " result" + (resultCount === 1 ? ' is' : 's are') + " available, use up and down arrow keys to navigate. Press Enter or Space Bar keys to select.";
|
|
3609
3637
|
}
|
|
3610
3638
|
return '';
|
|
3611
3639
|
}
|
|
3612
|
-
|
|
3613
|
-
...defaultProps$3,
|
|
3614
|
-
getA11yStatusMessage,
|
|
3615
|
-
};
|
|
3640
|
+
var defaultProps$2 = __assign(__assign({}, defaultProps$3), { getA11yStatusMessage: getA11yStatusMessage });
|
|
3616
3641
|
// eslint-disable-next-line import/no-mutable-exports
|
|
3617
|
-
|
|
3642
|
+
var validatePropTypes$2 = noop;
|
|
3618
3643
|
/* istanbul ignore next */
|
|
3619
3644
|
{
|
|
3620
|
-
validatePropTypes$2 = (options, caller)
|
|
3645
|
+
validatePropTypes$2 = function (options, caller) {
|
|
3621
3646
|
PropTypes.checkPropTypes(propTypes$2, options, 'prop', caller.name);
|
|
3622
3647
|
};
|
|
3623
3648
|
}
|