downshift 8.1.0 → 8.2.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 +78 -57
- package/dist/downshift.esm.js +77 -55
- package/dist/downshift.native.cjs.js +67 -135
- package/dist/downshift.nativeweb.cjs.js +78 -57
- package/dist/downshift.umd.js +1281 -1196
- 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/utils.d.ts +1 -1
- package/dist/src/hooks/utils.d.ts +1 -1
- package/dist/src/set-a11y-status.d.ts +1 -2
- package/dist/test/setup.d.ts +1 -1
- package/package.json +47 -43
- package/preact/dist/downshift.cjs.js +79 -58
- package/preact/dist/downshift.esm.js +78 -56
- package/preact/dist/downshift.umd.js +303 -283
- package/preact/dist/downshift.umd.js.map +1 -1
- package/preact/dist/downshift.umd.min.js +4 -3
- package/preact/dist/downshift.umd.min.js.map +1 -1
- package/typings/index.d.ts +9 -9
- package/CHANGELOG.md +0 -5
|
@@ -17,7 +17,7 @@ export declare const defaultProps: {
|
|
|
17
17
|
stateReducer: (s: Object, a: Object) => Object;
|
|
18
18
|
getA11ySelectionMessage: (selectionParameters: Object) => string;
|
|
19
19
|
scrollIntoView: typeof import("../../utils").scrollIntoView;
|
|
20
|
-
environment:
|
|
20
|
+
environment: (Window & typeof globalThis) | undefined;
|
|
21
21
|
};
|
|
22
22
|
export declare let validatePropTypes: (options: unknown, caller: Function) => void;
|
|
23
23
|
export {};
|
|
@@ -49,7 +49,7 @@ export namespace defaultProps {
|
|
|
49
49
|
export { stateReducer };
|
|
50
50
|
export { getA11ySelectionMessage };
|
|
51
51
|
export { scrollIntoView };
|
|
52
|
-
export const environment:
|
|
52
|
+
export const environment: (Window & typeof globalThis) | undefined;
|
|
53
53
|
}
|
|
54
54
|
/**
|
|
55
55
|
* Wraps the useEnhancedReducer and applies the controlled prop values before
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
export default setStatus;
|
|
2
1
|
/**
|
|
3
2
|
* @param {String} status the status message
|
|
4
3
|
* @param {Object} documentProp document passed by the user.
|
|
5
4
|
*/
|
|
6
|
-
|
|
5
|
+
export default function setStatus(status: string, documentProp: Object): void;
|
package/dist/test/setup.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import '@testing-library/jest-dom
|
|
1
|
+
import '@testing-library/jest-dom';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "downshift",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.2.0",
|
|
4
4
|
"description": "🏎 A set of primitives to build simple, flexible, WAI-ARIA compliant React autocomplete, combobox or select dropdown components.",
|
|
5
5
|
"main": "dist/downshift.cjs.js",
|
|
6
6
|
"react-native": "dist/downshift.native.cjs.js",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"docs:serve": "docusaurus serve --port 6006",
|
|
35
35
|
"docs:clear": "docusaurus clear",
|
|
36
36
|
"setup": "npm install && npm run validate",
|
|
37
|
-
"validate": "kcd-scripts validate lint,build-and-test,test:cover,test:ts,test:
|
|
37
|
+
"validate": "kcd-scripts validate lint,build-and-test,test:cover,test:ts,test:ssr,test:cypress"
|
|
38
38
|
},
|
|
39
39
|
"husky": {
|
|
40
40
|
"hooks": {
|
|
@@ -68,62 +68,66 @@
|
|
|
68
68
|
"react": ">=16.12.0"
|
|
69
69
|
},
|
|
70
70
|
"dependencies": {
|
|
71
|
-
"@babel/runtime": "^7.
|
|
72
|
-
"compute-scroll-into-view": "^
|
|
73
|
-
"prop-types": "^15.
|
|
74
|
-
"react-is": "^
|
|
75
|
-
"tslib": "^2.
|
|
71
|
+
"@babel/runtime": "^7.22.15",
|
|
72
|
+
"compute-scroll-into-view": "^3.0.3",
|
|
73
|
+
"prop-types": "^15.8.1",
|
|
74
|
+
"react-is": "^18.2.0",
|
|
75
|
+
"tslib": "^2.6.2"
|
|
76
76
|
},
|
|
77
77
|
"devDependencies": {
|
|
78
|
-
"@babel/helpers": "^7.
|
|
78
|
+
"@babel/helpers": "^7.22.15",
|
|
79
79
|
"@babel/plugin-proposal-private-methods": "^7.18.6",
|
|
80
80
|
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
|
|
81
|
-
"@cypress/webpack-preprocessor": "^
|
|
82
|
-
"@docusaurus/core": "
|
|
83
|
-
"@docusaurus/module-type-aliases": "
|
|
84
|
-
"@docusaurus/preset-classic": "
|
|
85
|
-
"@mdx-js/react": "^
|
|
86
|
-
"@rollup/plugin-babel": "^
|
|
87
|
-
"@rollup/plugin-commonjs": "^
|
|
88
|
-
"@rollup/plugin-typescript": "^
|
|
89
|
-
"@testing-library/cypress": "^
|
|
90
|
-
"@testing-library/dom": "^
|
|
91
|
-
"@testing-library/jest-dom": "^
|
|
81
|
+
"@cypress/webpack-preprocessor": "^6.0.0",
|
|
82
|
+
"@docusaurus/core": "3.0.0-alpha.0",
|
|
83
|
+
"@docusaurus/module-type-aliases": "3.0.0-alpha.0",
|
|
84
|
+
"@docusaurus/preset-classic": "3.0.0-alpha.0",
|
|
85
|
+
"@mdx-js/react": "^2.3.0",
|
|
86
|
+
"@rollup/plugin-babel": "^6.0.3",
|
|
87
|
+
"@rollup/plugin-commonjs": "^25.0.4",
|
|
88
|
+
"@rollup/plugin-typescript": "^11.1.3",
|
|
89
|
+
"@testing-library/cypress": "^10.0.1",
|
|
90
|
+
"@testing-library/dom": "^9.3.1",
|
|
91
|
+
"@testing-library/jest-dom": "^6.1.3",
|
|
92
92
|
"@testing-library/preact": "^2.0.1",
|
|
93
|
-
"@testing-library/react": "^
|
|
94
|
-
"@testing-library/react-hooks": "^7.0.1",
|
|
93
|
+
"@testing-library/react": "^14.0.0",
|
|
95
94
|
"@testing-library/user-event": "^14.4.3",
|
|
96
|
-
"@types/jest": "^
|
|
97
|
-
"@types/react": "^
|
|
98
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
99
|
-
"@typescript-eslint/parser": "^
|
|
95
|
+
"@types/jest": "^29.5.4",
|
|
96
|
+
"@types/react": "^18.2.21",
|
|
97
|
+
"@typescript-eslint/eslint-plugin": "^6.7.0",
|
|
98
|
+
"@typescript-eslint/parser": "^6.7.0",
|
|
100
99
|
"babel-plugin-macros": "^3.1.0",
|
|
101
100
|
"babel-plugin-no-side-effect-class-properties": "0.0.7",
|
|
102
101
|
"babel-preset-react-native": "^4.0.1",
|
|
103
102
|
"buble": "^0.20.0",
|
|
104
|
-
"cpy-cli": "^
|
|
103
|
+
"cpy-cli": "^5.0.0",
|
|
105
104
|
"cross-env": "^7.0.3",
|
|
106
|
-
"cypress": "
|
|
107
|
-
"eslint": "^
|
|
108
|
-
"eslint-plugin-cypress": "^2.
|
|
109
|
-
"eslint-plugin-react": "7.
|
|
110
|
-
"flow-bin": "^0.
|
|
105
|
+
"cypress": "13.2.0",
|
|
106
|
+
"eslint": "^8.49.0",
|
|
107
|
+
"eslint-plugin-cypress": "^2.14.0",
|
|
108
|
+
"eslint-plugin-react": "7.33.2",
|
|
109
|
+
"flow-bin": "^0.216.1",
|
|
111
110
|
"flow-coverage-report": "^0.8.0",
|
|
112
|
-
"get-pkg-repo": "
|
|
113
|
-
"kcd-scripts": "^
|
|
114
|
-
"node-polyfill-webpack-plugin": "^2.0.
|
|
111
|
+
"get-pkg-repo": "5.0.0",
|
|
112
|
+
"kcd-scripts": "^14.0.0",
|
|
113
|
+
"node-polyfill-webpack-plugin": "^2.0.1",
|
|
115
114
|
"npm-run-all": "^4.1.5",
|
|
116
|
-
"preact": "^10.
|
|
117
|
-
"prism-react-renderer": "^
|
|
118
|
-
"react": "^
|
|
119
|
-
"react-dom": "^
|
|
120
|
-
"react-native": "^0.
|
|
121
|
-
"react-test-renderer": "^
|
|
122
|
-
"serve": "^
|
|
123
|
-
"start-server-and-test": "^
|
|
124
|
-
"typescript": "^
|
|
115
|
+
"preact": "^10.17.1",
|
|
116
|
+
"prism-react-renderer": "^2.0.6",
|
|
117
|
+
"react": "^18.2.0",
|
|
118
|
+
"react-dom": "^18.2.0",
|
|
119
|
+
"react-native": "^0.72.4",
|
|
120
|
+
"react-test-renderer": "^18.2.0",
|
|
121
|
+
"serve": "^14.2.1",
|
|
122
|
+
"start-server-and-test": "^2.0.0",
|
|
123
|
+
"typescript": "^5.2.2"
|
|
125
124
|
},
|
|
126
125
|
"eslintConfig": {
|
|
126
|
+
"parserOptions": {
|
|
127
|
+
"ecmaVersion": 2023,
|
|
128
|
+
"project": "./tsconfig.json",
|
|
129
|
+
"sourceType": "module"
|
|
130
|
+
},
|
|
127
131
|
"settings": {
|
|
128
132
|
"import/no-unresolved": [
|
|
129
133
|
2,
|
|
@@ -6,9 +6,9 @@ var _objectWithoutPropertiesLoose = require('@babel/runtime/helpers/objectWithou
|
|
|
6
6
|
var _extends = require('@babel/runtime/helpers/extends');
|
|
7
7
|
var _assertThisInitialized = require('@babel/runtime/helpers/assertThisInitialized');
|
|
8
8
|
var _inheritsLoose = require('@babel/runtime/helpers/inheritsLoose');
|
|
9
|
-
var React = require('preact');
|
|
9
|
+
var React = require('preact/compat');
|
|
10
10
|
var reactIs = require('react-is');
|
|
11
|
-
var
|
|
11
|
+
var computeScrollIntoView = require('compute-scroll-into-view');
|
|
12
12
|
var PropTypes = require('prop-types');
|
|
13
13
|
var tslib = require('tslib');
|
|
14
14
|
|
|
@@ -19,7 +19,6 @@ var _extends__default = /*#__PURE__*/_interopDefaultLegacy(_extends);
|
|
|
19
19
|
var _assertThisInitialized__default = /*#__PURE__*/_interopDefaultLegacy(_assertThisInitialized);
|
|
20
20
|
var _inheritsLoose__default = /*#__PURE__*/_interopDefaultLegacy(_inheritsLoose);
|
|
21
21
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
22
|
-
var compute__default = /*#__PURE__*/_interopDefaultLegacy(compute);
|
|
23
22
|
var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
24
23
|
|
|
25
24
|
var idCounter = 0;
|
|
@@ -46,7 +45,7 @@ function scrollIntoView(node, menuNode) {
|
|
|
46
45
|
if (!node) {
|
|
47
46
|
return;
|
|
48
47
|
}
|
|
49
|
-
var actions =
|
|
48
|
+
var actions = computeScrollIntoView.compute(node, {
|
|
50
49
|
boundary: menuNode,
|
|
51
50
|
block: 'nearest',
|
|
52
51
|
scrollMode: 'if-needed'
|
|
@@ -389,7 +388,7 @@ function targetWithinDownshift(target, downshiftElements, environment, checkActi
|
|
|
389
388
|
if (checkActiveElement === void 0) {
|
|
390
389
|
checkActiveElement = true;
|
|
391
390
|
}
|
|
392
|
-
return downshiftElements.some(function (contextNode) {
|
|
391
|
+
return environment && downshiftElements.some(function (contextNode) {
|
|
393
392
|
return contextNode && (isOrContainsNode(contextNode, target, environment) || checkActiveElement && isOrContainsNode(contextNode, environment.document.activeElement, environment));
|
|
394
393
|
});
|
|
395
394
|
}
|
|
@@ -416,28 +415,12 @@ var cleanupStatus = debounce(function (documentProp) {
|
|
|
416
415
|
getStatusDiv(documentProp).textContent = '';
|
|
417
416
|
}, 500);
|
|
418
417
|
|
|
419
|
-
/**
|
|
420
|
-
* @param {String} status the status message
|
|
421
|
-
* @param {Object} documentProp document passed by the user.
|
|
422
|
-
*/
|
|
423
|
-
function setStatus(status, documentProp) {
|
|
424
|
-
var div = getStatusDiv(documentProp);
|
|
425
|
-
if (!status) {
|
|
426
|
-
return;
|
|
427
|
-
}
|
|
428
|
-
div.textContent = status;
|
|
429
|
-
cleanupStatus(documentProp);
|
|
430
|
-
}
|
|
431
|
-
|
|
432
418
|
/**
|
|
433
419
|
* Get the status node or create it if it does not already exist.
|
|
434
420
|
* @param {Object} documentProp document passed by the user.
|
|
435
421
|
* @return {HTMLElement} the status node.
|
|
436
422
|
*/
|
|
437
423
|
function getStatusDiv(documentProp) {
|
|
438
|
-
if (documentProp === void 0) {
|
|
439
|
-
documentProp = document;
|
|
440
|
-
}
|
|
441
424
|
var statusDiv = documentProp.getElementById('a11y-status-message');
|
|
442
425
|
if (statusDiv) {
|
|
443
426
|
return statusDiv;
|
|
@@ -461,6 +444,19 @@ function getStatusDiv(documentProp) {
|
|
|
461
444
|
return statusDiv;
|
|
462
445
|
}
|
|
463
446
|
|
|
447
|
+
/**
|
|
448
|
+
* @param {String} status the status message
|
|
449
|
+
* @param {Object} documentProp document passed by the user.
|
|
450
|
+
*/
|
|
451
|
+
function setStatus(status, documentProp) {
|
|
452
|
+
if (!status || !documentProp) {
|
|
453
|
+
return;
|
|
454
|
+
}
|
|
455
|
+
var div = getStatusDiv(documentProp);
|
|
456
|
+
div.textContent = status;
|
|
457
|
+
cleanupStatus(documentProp);
|
|
458
|
+
}
|
|
459
|
+
|
|
464
460
|
var unknown = process.env.NODE_ENV !== "production" ? '__autocomplete_unknown__' : 0;
|
|
465
461
|
var mouseUp = process.env.NODE_ENV !== "production" ? '__autocomplete_mouseup__' : 1;
|
|
466
462
|
var itemMouseEnter = process.env.NODE_ENV !== "production" ? '__autocomplete_item_mouseenter__' : 2;
|
|
@@ -521,7 +517,6 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
521
517
|
_this.getItemId = _this.props.getItemId || function (index) {
|
|
522
518
|
return _this.id + "-item-" + index;
|
|
523
519
|
};
|
|
524
|
-
_this.input = null;
|
|
525
520
|
_this.items = [];
|
|
526
521
|
// itemCount can be changed asynchronously
|
|
527
522
|
// from within downshift (so it can't come from a prop)
|
|
@@ -615,6 +610,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
615
610
|
_this.props.onInputValueChange(stateToSet.inputValue, _extends__default["default"]({}, _this.getStateAndHelpers(), stateToSet));
|
|
616
611
|
}
|
|
617
612
|
return _this.setState(function (state) {
|
|
613
|
+
var _newStateToSet;
|
|
618
614
|
state = _this.getState(state);
|
|
619
615
|
var newStateToSet = isStateToSetFunction ? stateToSet(state) : stateToSet;
|
|
620
616
|
|
|
@@ -633,7 +629,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
633
629
|
if (isItemSelected && newStateToSet.selectedItem !== state.selectedItem) {
|
|
634
630
|
onChangeArg = newStateToSet.selectedItem;
|
|
635
631
|
}
|
|
636
|
-
|
|
632
|
+
(_newStateToSet = newStateToSet).type || (_newStateToSet.type = unknown);
|
|
637
633
|
Object.keys(newStateToSet).forEach(function (key) {
|
|
638
634
|
// onStateChangeArg should only have the state that is
|
|
639
635
|
// actually changing
|
|
@@ -882,8 +878,13 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
882
878
|
// handle odd case for Safari and Firefox which
|
|
883
879
|
// don't give the button the focus properly.
|
|
884
880
|
/* istanbul ignore if (can't reasonably test this) */
|
|
885
|
-
if (_this.props.environment
|
|
886
|
-
|
|
881
|
+
if (_this.props.environment) {
|
|
882
|
+
var _this$props$environme = _this.props.environment.document,
|
|
883
|
+
body = _this$props$environme.body,
|
|
884
|
+
activeElement = _this$props$environme.activeElement;
|
|
885
|
+
if (body && body === activeElement) {
|
|
886
|
+
event.target.focus();
|
|
887
|
+
}
|
|
887
888
|
}
|
|
888
889
|
// to simplify testing components that use downshift, we'll not wrap this in a setTimeout
|
|
889
890
|
// if the NODE_ENV is test. With the proper build system, this should be dead code eliminated
|
|
@@ -905,7 +906,11 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
905
906
|
var blurTarget = event.target; // Save blur target for comparison with activeElement later
|
|
906
907
|
// Need setTimeout, so that when the user presses Tab, the activeElement is the next focused element, not body element
|
|
907
908
|
_this.internalSetTimeout(function () {
|
|
908
|
-
if (
|
|
909
|
+
if (_this.isMouseDown || !_this.props.environment) {
|
|
910
|
+
return;
|
|
911
|
+
}
|
|
912
|
+
var activeElement = _this.props.environment.document.activeElement;
|
|
913
|
+
if ((activeElement == null || activeElement.id !== _this.inputId) && activeElement !== blurTarget // Do nothing if we refocus the same element again (to solve issue in Safari on iOS)
|
|
909
914
|
) {
|
|
910
915
|
_this.reset({
|
|
911
916
|
type: blurButton
|
|
@@ -975,8 +980,13 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
975
980
|
_this.inputHandleBlur = function () {
|
|
976
981
|
// Need setTimeout, so that when the user presses Tab, the activeElement is the next focused element, not the body element
|
|
977
982
|
_this.internalSetTimeout(function () {
|
|
978
|
-
var
|
|
979
|
-
if (
|
|
983
|
+
var _activeElement$datase;
|
|
984
|
+
if (_this.isMouseDown || !_this.props.environment) {
|
|
985
|
+
return;
|
|
986
|
+
}
|
|
987
|
+
var activeElement = _this.props.environment.document.activeElement;
|
|
988
|
+
var downshiftButtonIsActive = (activeElement == null || (_activeElement$datase = activeElement.dataset) == null ? void 0 : _activeElement$datase.toggle) && _this._rootNode && _this._rootNode.contains(activeElement);
|
|
989
|
+
if (!downshiftButtonIsActive) {
|
|
980
990
|
_this.reset({
|
|
981
991
|
type: blurInput
|
|
982
992
|
});
|
|
@@ -1121,6 +1131,10 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1121
1131
|
}, cb);
|
|
1122
1132
|
};
|
|
1123
1133
|
_this.updateStatus = debounce(function () {
|
|
1134
|
+
var _this$props;
|
|
1135
|
+
if (!((_this$props = _this.props) != null && (_this$props = _this$props.environment) != null && _this$props.document)) {
|
|
1136
|
+
return;
|
|
1137
|
+
}
|
|
1124
1138
|
var state = _this.getState();
|
|
1125
1139
|
var item = _this.items[state.highlightedIndex];
|
|
1126
1140
|
var resultCount = _this.getItemCount();
|
|
@@ -1133,17 +1147,17 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1133
1147
|
_this.previousResultCount = resultCount;
|
|
1134
1148
|
setStatus(status, _this.props.environment.document);
|
|
1135
1149
|
}, 200);
|
|
1136
|
-
var _this$
|
|
1137
|
-
defaultHighlightedIndex = _this$
|
|
1138
|
-
_this$
|
|
1139
|
-
_highlightedIndex = _this$
|
|
1140
|
-
defaultIsOpen = _this$
|
|
1141
|
-
_this$
|
|
1142
|
-
_isOpen = _this$
|
|
1143
|
-
_this$
|
|
1144
|
-
_inputValue = _this$
|
|
1145
|
-
_this$
|
|
1146
|
-
_selectedItem = _this$
|
|
1150
|
+
var _this$props2 = _this.props,
|
|
1151
|
+
defaultHighlightedIndex = _this$props2.defaultHighlightedIndex,
|
|
1152
|
+
_this$props2$initialH = _this$props2.initialHighlightedIndex,
|
|
1153
|
+
_highlightedIndex = _this$props2$initialH === void 0 ? defaultHighlightedIndex : _this$props2$initialH,
|
|
1154
|
+
defaultIsOpen = _this$props2.defaultIsOpen,
|
|
1155
|
+
_this$props2$initialI = _this$props2.initialIsOpen,
|
|
1156
|
+
_isOpen = _this$props2$initialI === void 0 ? defaultIsOpen : _this$props2$initialI,
|
|
1157
|
+
_this$props2$initialI2 = _this$props2.initialInputValue,
|
|
1158
|
+
_inputValue = _this$props2$initialI2 === void 0 ? '' : _this$props2$initialI2,
|
|
1159
|
+
_this$props2$initialS = _this$props2.initialSelectedItem,
|
|
1160
|
+
_selectedItem = _this$props2$initialS === void 0 ? null : _this$props2$initialS;
|
|
1147
1161
|
var _state = _this.getState({
|
|
1148
1162
|
highlightedIndex: _highlightedIndex,
|
|
1149
1163
|
isOpen: _isOpen,
|
|
@@ -1196,7 +1210,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1196
1210
|
return itemCount;
|
|
1197
1211
|
};
|
|
1198
1212
|
_proto.getItemNodeFromIndex = function getItemNodeFromIndex(index) {
|
|
1199
|
-
return this.props.environment.document.getElementById(this.getItemId(index));
|
|
1213
|
+
return this.props.environment ? this.props.environment.document.getElementById(this.getItemId(index)) : null;
|
|
1200
1214
|
};
|
|
1201
1215
|
_proto.scrollHighlightedItemIntoView = function scrollHighlightedItemIntoView() {
|
|
1202
1216
|
/* istanbul ignore else (react-native) */
|
|
@@ -1283,8 +1297,12 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1283
1297
|
validateGetMenuPropsCalledCorrectly(this._menuNode, this.getMenuProps);
|
|
1284
1298
|
}
|
|
1285
1299
|
|
|
1286
|
-
/* istanbul ignore if (react-native) */
|
|
1287
|
-
{
|
|
1300
|
+
/* istanbul ignore if (react-native or SSR) */
|
|
1301
|
+
if (!this.props.environment) {
|
|
1302
|
+
this.cleanup = function () {
|
|
1303
|
+
_this4.internalClearTimeouts();
|
|
1304
|
+
};
|
|
1305
|
+
} else {
|
|
1288
1306
|
// this.isMouseDown helps us track whether the mouse is currently held down.
|
|
1289
1307
|
// This is useful when the user clicks on an item in the list, but holds the mouse
|
|
1290
1308
|
// down long enough for the list to disappear (because the blur event fires on the input)
|
|
@@ -1453,7 +1471,7 @@ var Downshift = /*#__PURE__*/function () {
|
|
|
1453
1471
|
return prevItem !== item;
|
|
1454
1472
|
},
|
|
1455
1473
|
environment: /* istanbul ignore next (ssr) */
|
|
1456
|
-
typeof window === 'undefined' ?
|
|
1474
|
+
typeof window === 'undefined' ? undefined : window,
|
|
1457
1475
|
stateReducer: function stateReducer(state, stateToSet) {
|
|
1458
1476
|
return stateToSet;
|
|
1459
1477
|
},
|
|
@@ -1694,7 +1712,7 @@ var defaultProps$3 = {
|
|
|
1694
1712
|
getA11ySelectionMessage: getA11ySelectionMessage,
|
|
1695
1713
|
scrollIntoView: scrollIntoView,
|
|
1696
1714
|
environment: /* istanbul ignore next (ssr) */
|
|
1697
|
-
typeof window === 'undefined' ?
|
|
1715
|
+
typeof window === 'undefined' ? undefined : window
|
|
1698
1716
|
};
|
|
1699
1717
|
function getDefaultValue$1(props, propKey, defaultStateValues) {
|
|
1700
1718
|
if (defaultStateValues === void 0) {
|
|
@@ -1773,7 +1791,7 @@ function useMouseAndTouchTracker(isOpen, downshiftElementRefs, environment, hand
|
|
|
1773
1791
|
isTouchMove: false
|
|
1774
1792
|
});
|
|
1775
1793
|
React.useEffect(function () {
|
|
1776
|
-
if (
|
|
1794
|
+
if (!environment) {
|
|
1777
1795
|
return;
|
|
1778
1796
|
}
|
|
1779
1797
|
|
|
@@ -1882,7 +1900,7 @@ function useA11yMessageSetter(getA11yMessage, dependencyArray, _ref3) {
|
|
|
1882
1900
|
rest = _objectWithoutPropertiesLoose__default["default"](_ref3, _excluded$3);
|
|
1883
1901
|
// Sets a11y status message on changes in state.
|
|
1884
1902
|
React.useEffect(function () {
|
|
1885
|
-
if (isInitialMount || false) {
|
|
1903
|
+
if (isInitialMount || false || !(environment != null && environment.document)) {
|
|
1886
1904
|
return;
|
|
1887
1905
|
}
|
|
1888
1906
|
updateA11yStatus(function () {
|
|
@@ -2079,7 +2097,6 @@ function getItemIndexByCharacterKey(_a) {
|
|
|
2079
2097
|
}
|
|
2080
2098
|
return highlightedIndex;
|
|
2081
2099
|
}
|
|
2082
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
2083
2100
|
var propTypes$2 = tslib.__assign(tslib.__assign({}, commonDropdownPropTypes), { items: PropTypes__default["default"].array.isRequired, isItemDisabled: PropTypes__default["default"].func, getA11ySelectionMessage: PropTypes__default["default"].func });
|
|
2084
2101
|
/**
|
|
2085
2102
|
* Default implementation for status message. Only added when menu is open.
|
|
@@ -2270,7 +2287,7 @@ function downshiftSelectReducer(state, action) {
|
|
|
2270
2287
|
}
|
|
2271
2288
|
/* eslint-enable complexity */
|
|
2272
2289
|
|
|
2273
|
-
var _excluded$2 = ["onMouseLeave", "refKey", "
|
|
2290
|
+
var _excluded$2 = ["onMouseLeave", "refKey", "ref"],
|
|
2274
2291
|
_excluded2$2 = ["onBlur", "onClick", "onPress", "onKeyDown", "refKey", "ref"],
|
|
2275
2292
|
_excluded3$1 = ["item", "index", "onMouseMove", "onClick", "onPress", "refKey", "disabled", "ref"];
|
|
2276
2293
|
useSelect.stateChangeTypes = stateChangeTypes$2;
|
|
@@ -2541,10 +2558,8 @@ function useSelect(userProps) {
|
|
|
2541
2558
|
var _ref = _temp === void 0 ? {} : _temp,
|
|
2542
2559
|
onMouseLeave = _ref.onMouseLeave,
|
|
2543
2560
|
_ref$refKey = _ref.refKey,
|
|
2544
|
-
refKey = _ref$refKey === void 0 ? 'ref' : _ref$refKey
|
|
2545
|
-
_ref.
|
|
2546
|
-
_ref.onBlur;
|
|
2547
|
-
var ref = _ref.ref,
|
|
2561
|
+
refKey = _ref$refKey === void 0 ? 'ref' : _ref$refKey,
|
|
2562
|
+
ref = _ref.ref,
|
|
2548
2563
|
rest = _objectWithoutPropertiesLoose__default["default"](_ref, _excluded$2);
|
|
2549
2564
|
var _ref2 = _temp2 === void 0 ? {} : _temp2,
|
|
2550
2565
|
_ref2$suppressRefErro = _ref2.suppressRefError,
|
|
@@ -3038,12 +3053,18 @@ function useCombobox(userProps) {
|
|
|
3038
3053
|
}, []);
|
|
3039
3054
|
// Reset itemRefs on close.
|
|
3040
3055
|
React.useEffect(function () {
|
|
3041
|
-
var _environment$document;
|
|
3042
3056
|
if (!isOpen) {
|
|
3043
3057
|
itemRefs.current = {};
|
|
3044
|
-
}
|
|
3045
|
-
|
|
3046
|
-
|
|
3058
|
+
}
|
|
3059
|
+
}, [isOpen]);
|
|
3060
|
+
// Reset itemRefs on close.
|
|
3061
|
+
React.useEffect(function () {
|
|
3062
|
+
var _inputRef$current;
|
|
3063
|
+
if (!isOpen || !(environment != null && environment.document) || !(inputRef != null && (_inputRef$current = inputRef.current) != null && _inputRef$current.focus)) {
|
|
3064
|
+
return;
|
|
3065
|
+
}
|
|
3066
|
+
if (environment.document.activeElement !== inputRef.current) {
|
|
3067
|
+
inputRef.current.focus();
|
|
3047
3068
|
}
|
|
3048
3069
|
}, [isOpen, environment]);
|
|
3049
3070
|
|
|
@@ -3257,7 +3278,7 @@ function useCombobox(userProps) {
|
|
|
3257
3278
|
};
|
|
3258
3279
|
var inputHandleBlur = function inputHandleBlur(event) {
|
|
3259
3280
|
/* istanbul ignore else */
|
|
3260
|
-
if (latestState.isOpen && !mouseAndTouchTrackersRef.current.isMouseDown) {
|
|
3281
|
+
if (environment != null && environment.document && latestState.isOpen && !mouseAndTouchTrackersRef.current.isMouseDown) {
|
|
3261
3282
|
var isBlurByTabChange = event.relatedTarget === null && environment.document.activeElement !== environment.document.body;
|
|
3262
3283
|
dispatch({
|
|
3263
3284
|
type: InputBlur,
|
|
@@ -3636,7 +3657,7 @@ function useMultipleSelection(userProps) {
|
|
|
3636
3657
|
// Effects.
|
|
3637
3658
|
/* Sets a11y status message on changes in selectedItem. */
|
|
3638
3659
|
React.useEffect(function () {
|
|
3639
|
-
if (isInitialMountRef.current || false) {
|
|
3660
|
+
if (isInitialMountRef.current || false || !(environment != null && environment.document)) {
|
|
3640
3661
|
return;
|
|
3641
3662
|
}
|
|
3642
3663
|
if (selectedItems.length < previousSelectedItemsRef.current.length) {
|