focus-trap-react 8.9.0 → 8.10.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/CHANGELOG.md +18 -0
- package/README.md +22 -3
- package/dist/focus-trap-react.js +8 -4
- package/package.json +28 -27
- package/src/focus-trap-react.js +4 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 8.10.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 659d44e: Bumps focus-trap to v6.8.1. The big new feature is opt-in Shadow DOM support in focus-trap (in tabbable), and new tabbable options exposed in a new `focusTrapOptions.tabbableOptions` configuration option.
|
|
8
|
+
|
|
9
|
+
## 8.9.2
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 83e283c: Update focus-trap to v6.7.3 for bug fix related to elements with a negative `tabindex`.
|
|
14
|
+
|
|
15
|
+
## 8.9.1
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- 3eb9421: Bump focus-trap to v6.7.2 for bug fix.
|
|
20
|
+
|
|
3
21
|
## 8.9.0
|
|
4
22
|
|
|
5
23
|
### 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.
|
|
@@ -141,7 +141,9 @@ ReactDOM.render(<Demo />, document.getElementById('root'));
|
|
|
141
141
|
|
|
142
142
|
Type: `Object`, optional
|
|
143
143
|
|
|
144
|
-
Pass any of the options available in
|
|
144
|
+
Pass any of the options available in focus-trap's [createOptions](https://github.com/focus-trap/focus-trap#createoptions).
|
|
145
|
+
|
|
146
|
+
> ⚠️ See notes about __[testing in JSDom](#testing-in-jsdom)__ (e.g. using Jest) if that's what you currently use.
|
|
145
147
|
|
|
146
148
|
#### active
|
|
147
149
|
|
|
@@ -169,6 +171,20 @@ If `containerElements` is subsequently updated (i.e. after the trap has been cre
|
|
|
169
171
|
|
|
170
172
|
Using `containerElements` does require the use of React refs which, by nature, will require at least one state update in order to get the resolved elements into the prop, resulting in at least one additional render. In the normal case, this is likely more than acceptable, but if you really want to optimize things, then you could consider [using focus-trap directly](https://codesandbox.io/s/focus-trapreact-containerelements-demos-v5ydi) (see `Trap2.js`).
|
|
171
173
|
|
|
174
|
+
## Help
|
|
175
|
+
|
|
176
|
+
### Testing in JSDom
|
|
177
|
+
|
|
178
|
+
> ⚠️ JSDom is not officially supported. Your mileage may vary, and tests may break from one release to the next (even a patch or minor release).
|
|
179
|
+
>
|
|
180
|
+
> This topic is just here to help with what we know may affect your tests.
|
|
181
|
+
|
|
182
|
+
In general, a focus trap is best tested in a full browser environment such as Cypress, Playwright, or Nightwatch where a full DOM is available.
|
|
183
|
+
|
|
184
|
+
Sometimes, that's not entirely desirable, and depending on what you're testing, you may be able to get away with using JSDom (e.g. via Jest), but you'll have to configure your traps using the `focusTrapOptions.tabbableOptions.displayCheck: 'none'` option.
|
|
185
|
+
|
|
186
|
+
See [Testing focus-trap in JSDom](https://github.com/focus-trap/focus-trap#testing-in-jsdom) for more details.
|
|
187
|
+
|
|
172
188
|
## Contributing
|
|
173
189
|
|
|
174
190
|
See [CONTRIBUTING](CONTRIBUTING.md).
|
|
@@ -194,18 +210,21 @@ In alphabetical order:
|
|
|
194
210
|
<td align="center"><a href="https://github.com/jhnns"><img src="https://avatars.githubusercontent.com/u/781746?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Johannes Ewald</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap-react/commits?author=jhnns" title="Code">💻</a></td>
|
|
195
211
|
<td align="center"><a href="http://josuzuki.me"><img src="https://avatars1.githubusercontent.com/u/9583920?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Jonathan Suzuki</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap-react/issues?q=author%3AJoSuzuki" title="Bug reports">🐛</a></td>
|
|
196
212
|
<td align="center"><a href="http://kathleenmcmahon.dev/"><img src="https://avatars1.githubusercontent.com/u/11621935?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Kathleen McMahon</b></sub></a><br /><a href="#maintenance-resource11" title="Maintenance">🚧</a></td>
|
|
213
|
+
<td align="center"><a href="https://github.com/LoganDark"><img src="https://avatars.githubusercontent.com/u/4723091?v=4?s=100" width="100px;" alt=""/><br /><sub><b>LoganDark</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap-react/issues?q=author%3ALoganDark" title="Bug reports">🐛</a></td>
|
|
197
214
|
<td align="center"><a href="https://marais.io/"><img src="https://avatars2.githubusercontent.com/u/599459?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Marais Rossouw</b></sub></a><br /><a href="#infra-maraisr" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a></td>
|
|
198
215
|
<td align="center"><a href="https://github.com/liunate"><img src="https://avatars2.githubusercontent.com/u/38996291?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Nate Liu</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap-react/commits?author=liunate" title="Tests">⚠️</a></td>
|
|
199
216
|
<td align="center"><a href="https://www.linkedin.com/in/rivajunior/"><img src="https://avatars1.githubusercontent.com/u/11370172?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Rivaldo Junior</b></sub></a><br /><a href="#maintenance-rivajunior" title="Maintenance">🚧</a></td>
|
|
200
|
-
<td align="center"><a href="https://scottrippey.github.io/"><img src="https://avatars3.githubusercontent.com/u/430608?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Scott Rippey</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap-react/commits?author=scottrippey" title="Code">💻</a> <a href="https://github.com/focus-trap/focus-trap-react/issues?q=author%3Ascottrippey" title="Bug reports">🐛</a></td>
|
|
201
217
|
</tr>
|
|
202
218
|
<tr>
|
|
219
|
+
<td align="center"><a href="https://scottrippey.github.io/"><img src="https://avatars3.githubusercontent.com/u/430608?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Scott Rippey</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap-react/commits?author=scottrippey" title="Code">💻</a> <a href="https://github.com/focus-trap/focus-trap-react/issues?q=author%3Ascottrippey" title="Bug reports">🐛</a></td>
|
|
203
220
|
<td align="center"><a href="https://seanmcp.com/"><img src="https://avatars1.githubusercontent.com/u/6360367?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Sean McPherson</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap-react/commits?author=SeanMcP" title="Code">💻</a></td>
|
|
204
221
|
<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>
|
|
205
222
|
<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>
|
|
206
223
|
<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>
|
|
207
224
|
<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>
|
|
208
225
|
<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>
|
|
226
|
+
</tr>
|
|
227
|
+
<tr>
|
|
209
228
|
<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>
|
|
210
229
|
</tr>
|
|
211
230
|
</table>
|
package/dist/focus-trap-react.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof";
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
4
|
|
|
5
5
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
6
6
|
|
|
7
7
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
8
8
|
|
|
9
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
9
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
10
10
|
|
|
11
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
11
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
12
12
|
|
|
13
13
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
14
14
|
|
|
@@ -339,7 +339,11 @@ FocusTrap.propTypes = {
|
|
|
339
339
|
returnFocusOnDeactivate: PropTypes.bool,
|
|
340
340
|
setReturnFocus: PropTypes.oneOfType([PropTypes.instanceOf(ElementType), PropTypes.string, PropTypes.func]),
|
|
341
341
|
allowOutsideClick: PropTypes.oneOfType([PropTypes.bool, PropTypes.func]),
|
|
342
|
-
preventScroll: PropTypes.bool
|
|
342
|
+
preventScroll: PropTypes.bool,
|
|
343
|
+
tabbableOptions: PropTypes.shape({
|
|
344
|
+
displayCheck: PropTypes.oneOf(['full', 'non-zero-area', 'none']),
|
|
345
|
+
getShadowRoot: PropTypes.oneOfType([PropTypes.bool, PropTypes.func])
|
|
346
|
+
})
|
|
343
347
|
}),
|
|
344
348
|
containerElements: PropTypes.arrayOf(PropTypes.instanceOf(ElementType)),
|
|
345
349
|
children: PropTypes.oneOfType([PropTypes.element, // React element
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "focus-trap-react",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.10.0",
|
|
4
4
|
"description": "A React component that traps focus.",
|
|
5
5
|
"main": "dist/focus-trap-react.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
"test:cypress:ci": "start-server-and-test start 9966 'cypress run --browser $CYPRESS_BROWSER --headless'",
|
|
29
29
|
"test": "yarn format:check && yarn lint && yarn test:unit && yarn test:types && CYPRESS_BROWSER=chrome yarn test:cypress:ci",
|
|
30
30
|
"prepare": "yarn build",
|
|
31
|
+
"prepublishOnly": "yarn test && yarn build",
|
|
31
32
|
"release": "yarn build && changeset publish"
|
|
32
33
|
},
|
|
33
34
|
"repository": {
|
|
@@ -55,46 +56,46 @@
|
|
|
55
56
|
},
|
|
56
57
|
"homepage": "https://github.com/focus-trap/focus-trap-react#readme",
|
|
57
58
|
"devDependencies": {
|
|
58
|
-
"@babel/cli": "^7.
|
|
59
|
-
"@babel/core": "^7.
|
|
60
|
-
"@babel/eslint-parser": "^7.
|
|
61
|
-
"@babel/plugin-proposal-class-properties": "^7.16.
|
|
62
|
-
"@babel/preset-env": "^7.16.
|
|
63
|
-
"@babel/preset-react": "^7.16.
|
|
64
|
-
"@changesets/cli": "^2.
|
|
59
|
+
"@babel/cli": "^7.17.6",
|
|
60
|
+
"@babel/core": "^7.17.9",
|
|
61
|
+
"@babel/eslint-parser": "^7.17.0",
|
|
62
|
+
"@babel/plugin-proposal-class-properties": "^7.16.5",
|
|
63
|
+
"@babel/preset-env": "^7.16.11",
|
|
64
|
+
"@babel/preset-react": "^7.16.7",
|
|
65
|
+
"@changesets/cli": "^2.22.0",
|
|
65
66
|
"@testing-library/cypress": "^8.0.2",
|
|
66
|
-
"@testing-library/dom": "^8.
|
|
67
|
-
"@testing-library/jest-dom": "^5.16.
|
|
68
|
-
"@testing-library/react": "^
|
|
69
|
-
"@testing-library/user-event": "^
|
|
70
|
-
"@types/jquery": "^3.5.
|
|
67
|
+
"@testing-library/dom": "^8.13.0",
|
|
68
|
+
"@testing-library/jest-dom": "^5.16.4",
|
|
69
|
+
"@testing-library/react": "^13.1.1",
|
|
70
|
+
"@testing-library/user-event": "^14.1.1",
|
|
71
|
+
"@types/jquery": "^3.5.14",
|
|
71
72
|
"all-contributors-cli": "^6.20.0",
|
|
72
|
-
"babel-jest": "^27.
|
|
73
|
+
"babel-jest": "^27.5.1",
|
|
73
74
|
"babelify": "^10.0.0",
|
|
74
75
|
"browserify": "^17.0.0",
|
|
75
|
-
"budo": "^11.
|
|
76
|
-
"cypress": "^9.
|
|
76
|
+
"budo": "^11.7.0",
|
|
77
|
+
"cypress": "^9.5.4",
|
|
77
78
|
"cypress-plugin-tab": "^1.0.5",
|
|
78
|
-
"eslint": "^8.
|
|
79
|
-
"eslint-config-prettier": "^8.
|
|
79
|
+
"eslint": "^8.13.0",
|
|
80
|
+
"eslint-config-prettier": "^8.5.0",
|
|
80
81
|
"eslint-plugin-cypress": "^2.12.1",
|
|
81
|
-
"eslint-plugin-react": "^7.
|
|
82
|
-
"jest": "^27.
|
|
82
|
+
"eslint-plugin-react": "^7.29.4",
|
|
83
|
+
"jest": "^27.5.1",
|
|
83
84
|
"jest-watch-typeahead": "^1.0.0",
|
|
84
85
|
"onchange": "^7.1.0",
|
|
85
|
-
"prettier": "^2.
|
|
86
|
-
"prop-types": "^15.
|
|
87
|
-
"react": "^
|
|
88
|
-
"react-dom": "^
|
|
86
|
+
"prettier": "^2.6.2",
|
|
87
|
+
"prop-types": "^15.8.1",
|
|
88
|
+
"react": "^18.0.0",
|
|
89
|
+
"react-dom": "^18.0.0",
|
|
89
90
|
"regenerator-runtime": "^0.13.9",
|
|
90
91
|
"start-server-and-test": "^1.14.0",
|
|
91
|
-
"typescript": "^4.
|
|
92
|
+
"typescript": "^4.6.3"
|
|
92
93
|
},
|
|
93
94
|
"dependencies": {
|
|
94
|
-
"focus-trap": "^6.
|
|
95
|
+
"focus-trap": "^6.8.1"
|
|
95
96
|
},
|
|
96
97
|
"peerDependencies": {
|
|
97
|
-
"prop-types": "^15.
|
|
98
|
+
"prop-types": "^15.8.1",
|
|
98
99
|
"react": ">=16.0.0",
|
|
99
100
|
"react-dom": ">=16.0.0"
|
|
100
101
|
}
|
package/src/focus-trap-react.js
CHANGED
|
@@ -311,6 +311,10 @@ FocusTrap.propTypes = {
|
|
|
311
311
|
]),
|
|
312
312
|
allowOutsideClick: PropTypes.oneOfType([PropTypes.bool, PropTypes.func]),
|
|
313
313
|
preventScroll: PropTypes.bool,
|
|
314
|
+
tabbableOptions: PropTypes.shape({
|
|
315
|
+
displayCheck: PropTypes.oneOf(['full', 'non-zero-area', 'none']),
|
|
316
|
+
getShadowRoot: PropTypes.oneOfType([PropTypes.bool, PropTypes.func]),
|
|
317
|
+
}),
|
|
314
318
|
}),
|
|
315
319
|
containerElements: PropTypes.arrayOf(PropTypes.instanceOf(ElementType)),
|
|
316
320
|
children: PropTypes.oneOfType([
|