focus-trap-react 8.6.0 → 8.8.1
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/CHANGELOG.md +25 -0
- package/README.md +3 -1
- package/dist/focus-trap-react.js +9 -5
- package/package.json +21 -21
- package/src/focus-trap-react.js +9 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 8.8.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- a2806a0: Fix SSR issues when accessing `document` object (#482)
|
|
8
|
+
|
|
9
|
+
## 8.8.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- c8e46c2: Support new `document` option introduced in focus-trap v6.7.0 (#460)
|
|
14
|
+
- 5ee587c: Bump focus-trap dependency to v6.7.1
|
|
15
|
+
|
|
16
|
+
## 8.7.1
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- 111a27f: Update focus-trap to v6.6.1, to get tabbable at v5.2.1, to get bug fix for disabled fieldsets.
|
|
21
|
+
|
|
22
|
+
## 8.7.0
|
|
23
|
+
|
|
24
|
+
### Minor Changes
|
|
25
|
+
|
|
26
|
+
- 7fbe8ca: Update to support new features in `focus-trap@6.6.0` including `initialFocus` which can now be false to prevent initial focus, and `escapeDeactivates` which can now alternately be a function that returns a boolean instead of a straight boolean.
|
|
27
|
+
|
|
3
28
|
## 8.6.0
|
|
4
29
|
|
|
5
30
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# focus-trap-react [](https://github.com/focus-trap/focus-trap-react/actions?query=workflow:CI+branch:master) [](https://codecov.io/gh/focus-trap/focus-trap-react) [](./LICENSE)
|
|
2
2
|
|
|
3
3
|
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
|
|
4
|
-
[](#contributors)
|
|
5
5
|
<!-- ALL-CONTRIBUTORS-BADGE:END -->
|
|
6
6
|
|
|
7
7
|
A React component that traps focus.
|
|
@@ -203,7 +203,9 @@ In alphabetical order:
|
|
|
203
203
|
<td align="center"><a href="https://recollectr.io"><img src="https://avatars2.githubusercontent.com/u/6835891?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Slapbox</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap-react/commits?author=Slapbox" title="Documentation">📖</a></td>
|
|
204
204
|
<td align="center"><a href="https://stefancameron.com/"><img src="https://avatars3.githubusercontent.com/u/2855350?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Stefan Cameron</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap-react/commits?author=stefcameron" title="Code">💻</a> <a href="https://github.com/focus-trap/focus-trap-react/issues?q=author%3Astefcameron" title="Bug reports">🐛</a> <a href="#infra-stefcameron" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="https://github.com/focus-trap/focus-trap-react/commits?author=stefcameron" title="Tests">⚠️</a> <a href="https://github.com/focus-trap/focus-trap-react/commits?author=stefcameron" title="Documentation">📖</a> <a href="#maintenance-stefcameron" title="Maintenance">🚧</a></td>
|
|
205
205
|
<td align="center"><a href="http://tylerhawkins.info/201R/"><img src="https://avatars0.githubusercontent.com/u/13806458?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Tyler Hawkins</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap-react/commits?author=thawkin3" title="Documentation">📖</a> <a href="#example-thawkin3" title="Examples">💡</a> <a href="https://github.com/focus-trap/focus-trap-react/commits?author=thawkin3" title="Tests">⚠️</a> <a href="#tool-thawkin3" title="Tools">🔧</a></td>
|
|
206
|
+
<td align="center"><a href="https://github.com/wandroll"><img src="https://avatars.githubusercontent.com/u/4492317?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Wandrille Verlut</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap-react/commits?author=wandroll" title="Code">💻</a> <a href="https://github.com/focus-trap/focus-trap-react/commits?author=wandroll" title="Tests">⚠️</a></td>
|
|
206
207
|
<td align="center"><a href="https://github.com/krikienoid"><img src="https://avatars3.githubusercontent.com/u/8528227?v=4?s=100" width="100px;" alt=""/><br /><sub><b>krikienoid</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap-react/issues?q=author%3Akrikienoid" title="Bug reports">🐛</a></td>
|
|
208
|
+
<td align="center"><a href="https://github.com/syntactic-salt"><img src="https://avatars.githubusercontent.com/u/9385662?v=4?s=100" width="100px;" alt=""/><br /><sub><b>syntactic-salt</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap-react/issues?q=author%3Asyntactic-salt" title="Bug reports">🐛</a></td>
|
|
207
209
|
</tr>
|
|
208
210
|
</table>
|
|
209
211
|
|
package/dist/focus-trap-react.js
CHANGED
|
@@ -14,7 +14,7 @@ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || func
|
|
|
14
14
|
|
|
15
15
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
16
16
|
|
|
17
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
17
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
18
18
|
|
|
19
19
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
20
20
|
|
|
@@ -129,8 +129,11 @@ var FocusTrap = /*#__PURE__*/function (_React$Component) {
|
|
|
129
129
|
}, {
|
|
130
130
|
key: "updatePreviousElement",
|
|
131
131
|
value: function updatePreviousElement() {
|
|
132
|
-
if
|
|
133
|
-
|
|
132
|
+
// SSR: careful to check if `document` exists before accessing it as a variable
|
|
133
|
+
var currentDocument = this.props.focusTrapOptions.document || (typeof document !== 'undefined' ? document : undefined);
|
|
134
|
+
|
|
135
|
+
if (currentDocument) {
|
|
136
|
+
this.previouslyFocusedElement = currentDocument.activeElement;
|
|
134
137
|
}
|
|
135
138
|
}
|
|
136
139
|
}, {
|
|
@@ -283,15 +286,16 @@ FocusTrap.propTypes = {
|
|
|
283
286
|
active: PropTypes.bool,
|
|
284
287
|
paused: PropTypes.bool,
|
|
285
288
|
focusTrapOptions: PropTypes.shape({
|
|
289
|
+
document: PropTypes.object,
|
|
286
290
|
onActivate: PropTypes.func,
|
|
287
291
|
onPostActivate: PropTypes.func,
|
|
288
292
|
checkCanFocusTrap: PropTypes.func,
|
|
289
293
|
onDeactivate: PropTypes.func,
|
|
290
294
|
onPostDeactivate: PropTypes.func,
|
|
291
295
|
checkCanReturnFocus: PropTypes.func,
|
|
292
|
-
initialFocus: PropTypes.oneOfType([PropTypes.instanceOf(ElementType), PropTypes.string, PropTypes.func]),
|
|
296
|
+
initialFocus: PropTypes.oneOfType([PropTypes.instanceOf(ElementType), PropTypes.string, PropTypes.func, PropTypes.bool]),
|
|
293
297
|
fallbackFocus: PropTypes.oneOfType([PropTypes.instanceOf(ElementType), PropTypes.string, PropTypes.func]),
|
|
294
|
-
escapeDeactivates: PropTypes.bool,
|
|
298
|
+
escapeDeactivates: PropTypes.oneOfType([PropTypes.bool, PropTypes.func]),
|
|
295
299
|
clickOutsideDeactivates: PropTypes.oneOfType([PropTypes.bool, PropTypes.func]),
|
|
296
300
|
returnFocusOnDeactivate: PropTypes.bool,
|
|
297
301
|
setReturnFocus: PropTypes.oneOfType([PropTypes.instanceOf(ElementType), PropTypes.string, PropTypes.func]),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "focus-trap-react",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.8.1",
|
|
4
4
|
"description": "A React component that traps focus.",
|
|
5
5
|
"main": "dist/focus-trap-react.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -55,43 +55,43 @@
|
|
|
55
55
|
},
|
|
56
56
|
"homepage": "https://github.com/focus-trap/focus-trap-react#readme",
|
|
57
57
|
"devDependencies": {
|
|
58
|
-
"@babel/cli": "^7.
|
|
59
|
-
"@babel/core": "^7.
|
|
58
|
+
"@babel/cli": "^7.15.7",
|
|
59
|
+
"@babel/core": "^7.15.5",
|
|
60
60
|
"@babel/plugin-proposal-class-properties": "^7.12.13",
|
|
61
|
-
"@babel/preset-env": "^7.
|
|
61
|
+
"@babel/preset-env": "^7.15.6",
|
|
62
62
|
"@babel/preset-react": "^7.14.5",
|
|
63
|
-
"@changesets/cli": "^2.
|
|
64
|
-
"@testing-library/cypress": "^
|
|
65
|
-
"@testing-library/dom": "^
|
|
63
|
+
"@changesets/cli": "^2.17.0",
|
|
64
|
+
"@testing-library/cypress": "^8.0.1",
|
|
65
|
+
"@testing-library/dom": "^8.5.0",
|
|
66
66
|
"@testing-library/jest-dom": "^5.14.1",
|
|
67
|
-
"@testing-library/react": "^
|
|
68
|
-
"@testing-library/user-event": "^13.1
|
|
69
|
-
"@types/jquery": "^3.5.
|
|
67
|
+
"@testing-library/react": "^12.1.0",
|
|
68
|
+
"@testing-library/user-event": "^13.2.1",
|
|
69
|
+
"@types/jquery": "^3.5.6",
|
|
70
70
|
"all-contributors-cli": "^6.20.0",
|
|
71
71
|
"babel-eslint": "^10.1.0",
|
|
72
|
-
"babel-jest": "^27.
|
|
72
|
+
"babel-jest": "^27.2.1",
|
|
73
73
|
"babelify": "^10.0.0",
|
|
74
74
|
"browserify": "^17.0.0",
|
|
75
75
|
"budo": "^11.6.4",
|
|
76
|
-
"cypress": "^
|
|
76
|
+
"cypress": "^8.4.1",
|
|
77
77
|
"cypress-plugin-tab": "^1.0.5",
|
|
78
|
-
"eslint": "^7.
|
|
78
|
+
"eslint": "^7.32.0",
|
|
79
79
|
"eslint-config-prettier": "^8.3.0",
|
|
80
|
-
"eslint-plugin-cypress": "^2.
|
|
81
|
-
"eslint-plugin-react": "^7.
|
|
82
|
-
"jest": "^27.
|
|
80
|
+
"eslint-plugin-cypress": "^2.12.1",
|
|
81
|
+
"eslint-plugin-react": "^7.26.0",
|
|
82
|
+
"jest": "^27.2.1",
|
|
83
83
|
"jest-watch-typeahead": "^0.6.4",
|
|
84
84
|
"onchange": "^7.1.0",
|
|
85
|
-
"prettier": "^2.
|
|
85
|
+
"prettier": "^2.4.1",
|
|
86
86
|
"prop-types": "^15.7.2",
|
|
87
87
|
"react": "^17.0.2",
|
|
88
88
|
"react-dom": "^17.0.2",
|
|
89
|
-
"regenerator-runtime": "^0.13.
|
|
90
|
-
"start-server-and-test": "^1.
|
|
91
|
-
"typescript": "^4.3
|
|
89
|
+
"regenerator-runtime": "^0.13.9",
|
|
90
|
+
"start-server-and-test": "^1.14.0",
|
|
91
|
+
"typescript": "^4.4.3"
|
|
92
92
|
},
|
|
93
93
|
"dependencies": {
|
|
94
|
-
"focus-trap": "^6.
|
|
94
|
+
"focus-trap": "^6.7.1"
|
|
95
95
|
},
|
|
96
96
|
"peerDependencies": {
|
|
97
97
|
"prop-types": "^15.7.2",
|
package/src/focus-trap-react.js
CHANGED
|
@@ -87,8 +87,12 @@ class FocusTrap extends React.Component {
|
|
|
87
87
|
|
|
88
88
|
/** Update the previously focused element with the currently focused element. */
|
|
89
89
|
updatePreviousElement() {
|
|
90
|
-
if
|
|
91
|
-
|
|
90
|
+
// SSR: careful to check if `document` exists before accessing it as a variable
|
|
91
|
+
const currentDocument =
|
|
92
|
+
this.props.focusTrapOptions.document ||
|
|
93
|
+
(typeof document !== 'undefined' ? document : undefined);
|
|
94
|
+
if (currentDocument) {
|
|
95
|
+
this.previouslyFocusedElement = currentDocument.activeElement;
|
|
92
96
|
}
|
|
93
97
|
}
|
|
94
98
|
|
|
@@ -241,6 +245,7 @@ FocusTrap.propTypes = {
|
|
|
241
245
|
active: PropTypes.bool,
|
|
242
246
|
paused: PropTypes.bool,
|
|
243
247
|
focusTrapOptions: PropTypes.shape({
|
|
248
|
+
document: PropTypes.object,
|
|
244
249
|
onActivate: PropTypes.func,
|
|
245
250
|
onPostActivate: PropTypes.func,
|
|
246
251
|
checkCanFocusTrap: PropTypes.func,
|
|
@@ -251,13 +256,14 @@ FocusTrap.propTypes = {
|
|
|
251
256
|
PropTypes.instanceOf(ElementType),
|
|
252
257
|
PropTypes.string,
|
|
253
258
|
PropTypes.func,
|
|
259
|
+
PropTypes.bool,
|
|
254
260
|
]),
|
|
255
261
|
fallbackFocus: PropTypes.oneOfType([
|
|
256
262
|
PropTypes.instanceOf(ElementType),
|
|
257
263
|
PropTypes.string,
|
|
258
264
|
PropTypes.func,
|
|
259
265
|
]),
|
|
260
|
-
escapeDeactivates: PropTypes.bool,
|
|
266
|
+
escapeDeactivates: PropTypes.oneOfType([PropTypes.bool, PropTypes.func]),
|
|
261
267
|
clickOutsideDeactivates: PropTypes.oneOfType([
|
|
262
268
|
PropTypes.bool,
|
|
263
269
|
PropTypes.func,
|