focus-trap-react 8.3.2 → 8.5.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 CHANGED
@@ -1,5 +1,29 @@
1
1
  # Changelog
2
2
 
3
+ ## 8.5.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 6ee37fb: Bump focus-trap from 6.3.0 to 6.4.0. There should be no changes in behavior as a result of this upgrade.
8
+
9
+ ## 8.4.2
10
+
11
+ ### Patch Changes
12
+
13
+ - f9a6d1a: Throw an error if a Fragment is given as the child container (currently, it appears to work, but the trap is actually not activated because focus-trap can't find the DOM element for the Fragment "container"). (Fixes #268)
14
+
15
+ ## 8.4.1
16
+
17
+ ### Patch Changes
18
+
19
+ - a4c3105: Update PropTypes for clickOutsideDeactivates to match latest focus-trap.
20
+
21
+ ## 8.4.0
22
+
23
+ ### Minor Changes
24
+
25
+ - 8d58bc8: Bump focus-trap to v6.3.0
26
+
3
27
  ## 8.3.2
4
28
 
5
29
  ### Patch Changes
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
- # focus-trap-react [![CI](https://github.com/focus-trap/focus-trap-react/workflows/CI/badge.svg?branch=master&event=push)](https://github.com/focus-trap/focus-trap-react/actions?query=workflow:CI+branch:master) [![license](https://badgen.now.sh/badge/license/MIT)](./LICENSE)
1
+ # focus-trap-react [![CI](https://github.com/focus-trap/focus-trap-react/workflows/CI/badge.svg?branch=master&event=push)](https://github.com/focus-trap/focus-trap-react/actions?query=workflow:CI+branch:master) [![Codecov](https://img.shields.io/codecov/c/github/focus-trap/focus-trap-react)](https://codecov.io/gh/focus-trap/focus-trap-react) [![license](https://badgen.now.sh/badge/license/MIT)](./LICENSE)
2
2
 
3
3
  <!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
4
- [![All Contributors](https://img.shields.io/badge/all_contributors-16-orange.svg?style=flat-square)](#contributors)
4
+ [![All Contributors](https://img.shields.io/badge/all_contributors-17-orange.svg?style=flat-square)](#contributors)
5
5
  <!-- ALL-CONTRIBUTORS-BADGE:END -->
6
6
 
7
7
  A React component that traps focus.
@@ -43,7 +43,7 @@ Why? Because this module's core functionality comes from focus-trap, which uses
43
43
 
44
44
  ## Usage
45
45
 
46
- You wrap any element that you want to act as a focus trap with the `<FocusTrap>` component. `<FocusTrap>` expects exactly one child element which can be any HTML element or other React component that contains focusable elements.
46
+ You wrap any element that you want to act as a focus trap with the `<FocusTrap>` component. `<FocusTrap>` expects exactly one child element which can be any HTML element or other React component that contains focusable elements. __It cannot be a Fragment__ because `<FocusTrap>` needs to be able to get a reference to the underlying HTML element, and Fragments do not have any representation in the DOM.
47
47
 
48
48
  For example:
49
49
 
@@ -69,11 +69,9 @@ Here's one more simple example:
69
69
  ```js
70
70
  const React = require('react');
71
71
  const ReactDOM = require('react-dom');
72
- const FocusTrap = require('../../dist/focus-trap-react');
72
+ const FocusTrap = require('focus-trap-react');
73
73
 
74
- const container = document.getElementById('demo-one');
75
-
76
- class DemoOne extends React.Component {
74
+ class Demo extends React.Component {
77
75
  constructor(props) {
78
76
  super(props);
79
77
 
@@ -85,13 +83,13 @@ class DemoOne extends React.Component {
85
83
  this.unmountTrap = this.unmountTrap.bind(this);
86
84
  }
87
85
 
88
- mountTrap() {
86
+ mountTrap = () => {
89
87
  this.setState({ activeTrap: true });
90
- }
88
+ };
91
89
 
92
- unmountTrap() {
90
+ unmountTrap = () => {
93
91
  this.setState({ activeTrap: false });
94
- }
92
+ };
95
93
 
96
94
  render() {
97
95
  const trap = this.state.activeTrap
@@ -134,7 +132,7 @@ class DemoOne extends React.Component {
134
132
  }
135
133
  }
136
134
 
137
- ReactDOM.render(<DemoOne />, container);
135
+ ReactDOM.render(<Demo />, document.getElementById('root'));
138
136
  ```
139
137
 
140
138
  ### Props
@@ -184,29 +182,31 @@ In alphabetical order:
184
182
  <!-- markdownlint-disable -->
185
183
  <table>
186
184
  <tr>
187
- <td align="center"><a href="http://davidtheclark.com/"><img src="https://avatars2.githubusercontent.com/u/628431?v=4" width="100px;" alt=""/><br /><sub><b>David Clark</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap-react/commits?author=davidtheclark" title="Code">💻</a> <a href="https://github.com/focus-trap/focus-trap-react/issues?q=author%3Adavidtheclark" title="Bug reports">🐛</a> <a href="#infra-davidtheclark" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="https://github.com/focus-trap/focus-trap-react/commits?author=davidtheclark" title="Tests">⚠️</a> <a href="https://github.com/focus-trap/focus-trap-react/commits?author=davidtheclark" title="Documentation">📖</a> <a href="#maintenance-davidtheclark" title="Maintenance">🚧</a></td>
188
- <td align="center"><a href="https://stefancameron.com/"><img src="https://avatars3.githubusercontent.com/u/2855350?v=4" 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>
189
- <td align="center"><a href="https://marais.io/"><img src="https://avatars2.githubusercontent.com/u/599459?v=4" width="100px;" alt=""/><br /><sub><b>Marais Rossouw</b></sub></a><br /><a href="#infra-maraisr" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a></td>
190
- <td align="center"><a href="https://github.com/liunate"><img src="https://avatars2.githubusercontent.com/u/38996291?v=4" 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>
191
- <td align="center"><a href="https://seanmcp.com/"><img src="https://avatars1.githubusercontent.com/u/6360367?v=4" 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>
192
- <td align="center"><a href="https://github.com/features/security"><img src="https://avatars1.githubusercontent.com/u/27347476?v=4" width="100px;" alt=""/><br /><sub><b>Dependabot</b></sub></a><br /><a href="#maintenance-dependabot" title="Maintenance">🚧</a></td>
193
- <td align="center"><a href="https://www.linkedin.com/in/rivajunior/"><img src="https://avatars1.githubusercontent.com/u/11370172?v=4" width="100px;" alt=""/><br /><sub><b>Rivaldo Junior</b></sub></a><br /><a href="#maintenance-rivajunior" title="Maintenance">🚧</a></td>
185
+ <td align="center"><a href="https://github.com/Ayc0"><img src="https://avatars3.githubusercontent.com/u/22725671?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Benjamin Koltes</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap-react/issues?q=author%3AAyc0" title="Bug reports">🐛</a></td>
186
+ <td align="center"><a href="https://ofcr.se/"><img src="https://avatars1.githubusercontent.com/u/813865?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Benjamin Tan</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap-react/commits?author=bnjmnt4n" title="Documentation">📖</a></td>
187
+ <td align="center"><a href="https://clintgoodman.com"><img src="https://avatars3.githubusercontent.com/u/5473697?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Clint Goodman</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap-react/commits?author=cgood92" title="Code">💻</a> <a href="https://github.com/focus-trap/focus-trap-react/commits?author=cgood92" title="Documentation">📖</a> <a href="#example-cgood92" title="Examples">💡</a> <a href="https://github.com/focus-trap/focus-trap-react/commits?author=cgood92" title="Tests">⚠️</a></td>
188
+ <td align="center"><a href="https://github.com/DSil"><img src="https://avatars1.githubusercontent.com/u/6265045?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Daniel</b></sub></a><br /><a href="#maintenance-DSil" title="Maintenance">🚧</a> <a href="https://github.com/focus-trap/focus-trap-react/commits?author=DSil" title="Tests">⚠️</a></td>
189
+ <td align="center"><a href="http://davidtheclark.com/"><img src="https://avatars2.githubusercontent.com/u/628431?v=4?s=100" width="100px;" alt=""/><br /><sub><b>David Clark</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap-react/commits?author=davidtheclark" title="Code">💻</a> <a href="https://github.com/focus-trap/focus-trap-react/issues?q=author%3Adavidtheclark" title="Bug reports">🐛</a> <a href="#infra-davidtheclark" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="https://github.com/focus-trap/focus-trap-react/commits?author=davidtheclark" title="Tests">⚠️</a> <a href="https://github.com/focus-trap/focus-trap-react/commits?author=davidtheclark" title="Documentation">📖</a> <a href="#maintenance-davidtheclark" title="Maintenance">🚧</a></td>
190
+ <td align="center"><a href="https://github.com/features/security"><img src="https://avatars1.githubusercontent.com/u/27347476?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Dependabot</b></sub></a><br /><a href="#maintenance-dependabot" title="Maintenance">🚧</a></td>
191
+ <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>
194
192
  </tr>
195
193
  <tr>
196
- <td align="center"><a href="http://kathleenmcmahon.dev/"><img src="https://avatars1.githubusercontent.com/u/11621935?v=4" width="100px;" alt=""/><br /><sub><b>Kathleen McMahon</b></sub></a><br /><a href="#maintenance-resource11" title="Maintenance">🚧</a></td>
197
- <td align="center"><a href="https://scottrippey.github.io/"><img src="https://avatars3.githubusercontent.com/u/430608?v=4" 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>
198
- <td align="center"><a href="https://github.com/DSil"><img src="https://avatars1.githubusercontent.com/u/6265045?v=4" width="100px;" alt=""/><br /><sub><b>Daniel</b></sub></a><br /><a href="#maintenance-DSil" title="Maintenance">🚧</a> <a href="https://github.com/focus-trap/focus-trap-react/commits?author=DSil" title="Tests">⚠️</a></td>
199
- <td align="center"><a href="https://github.com/Ayc0"><img src="https://avatars3.githubusercontent.com/u/22725671?v=4" width="100px;" alt=""/><br /><sub><b>Benjamin Koltes</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap-react/issues?q=author%3AAyc0" title="Bug reports">🐛</a></td>
200
- <td align="center"><a href="https://ofcr.se/"><img src="https://avatars1.githubusercontent.com/u/813865?v=4" width="100px;" alt=""/><br /><sub><b>Benjamin Tan</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap-react/commits?author=bnjmnt4n" title="Documentation">📖</a></td>
201
- <td align="center"><a href="https://recollectr.io"><img src="https://avatars2.githubusercontent.com/u/6835891?v=4" 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>
202
- <td align="center"><a href="http://josuzuki.me"><img src="https://avatars1.githubusercontent.com/u/9583920?v=4" 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>
194
+ <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>
195
+ <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>
196
+ <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>
197
+ <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>
198
+ <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>
199
+ <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>
200
+ <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>
203
201
  </tr>
204
202
  <tr>
205
- <td align="center"><a href="https://github.com/krikienoid"><img src="https://avatars3.githubusercontent.com/u/8528227?v=4" 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>
206
- <td align="center"><a href="https://clintgoodman.com"><img src="https://avatars3.githubusercontent.com/u/5473697?v=4" width="100px;" alt=""/><br /><sub><b>Clint Goodman</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap-react/commits?author=cgood92" title="Code">💻</a> <a href="https://github.com/focus-trap/focus-trap-react/commits?author=cgood92" title="Documentation">📖</a> <a href="#example-cgood92" title="Examples">💡</a> <a href="https://github.com/focus-trap/focus-trap-react/commits?author=cgood92" title="Tests">⚠️</a></td>
203
+ <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>
204
+ <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>
205
+ <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>
207
206
  </tr>
208
207
  </table>
209
208
 
210
- <!-- markdownlint-enable -->
209
+ <!-- markdownlint-restore -->
211
210
  <!-- prettier-ignore-end -->
211
+
212
212
  <!-- ALL-CONTRIBUTORS-LIST:END -->
@@ -18,7 +18,7 @@ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) ===
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
 
21
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
21
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
22
22
 
23
23
  function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
24
24
 
@@ -188,6 +188,10 @@ var FocusTrap = /*#__PURE__*/function (_React$Component) {
188
188
  var child = this.props.children ? React.Children.only(this.props.children) : undefined;
189
189
 
190
190
  if (child) {
191
+ if (child.type && child.type === React.Fragment) {
192
+ throw new Error('A focus-trap cannot use a Fragment as its child container. Try replacing it with a <div> element.');
193
+ }
194
+
191
195
  var composedRefCallback = function composedRefCallback(element) {
192
196
  var containerElements = _this2.props.containerElements;
193
197
 
@@ -226,7 +230,7 @@ FocusTrap.propTypes = {
226
230
  initialFocus: PropTypes.oneOfType([PropTypes.instanceOf(ElementType), PropTypes.string, PropTypes.func]),
227
231
  fallbackFocus: PropTypes.oneOfType([PropTypes.instanceOf(ElementType), PropTypes.string, PropTypes.func]),
228
232
  escapeDeactivates: PropTypes.bool,
229
- clickOutsideDeactivates: PropTypes.bool,
233
+ clickOutsideDeactivates: PropTypes.oneOfType([PropTypes.bool, PropTypes.func]),
230
234
  returnFocusOnDeactivate: PropTypes.bool,
231
235
  setReturnFocus: PropTypes.oneOfType([PropTypes.instanceOf(ElementType), PropTypes.string, PropTypes.func]),
232
236
  allowOutsideClick: PropTypes.oneOfType([PropTypes.bool, PropTypes.func]),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "focus-trap-react",
3
- "version": "8.3.2",
3
+ "version": "8.5.0",
4
4
  "description": "A React component that traps focus.",
5
5
  "main": "dist/focus-trap-react.js",
6
6
  "types": "index.d.ts",
@@ -19,12 +19,14 @@
19
19
  "lint": "eslint \"*.js\" \"src/**/*.js\" \"test/**/*.js\" \"demo/**/*.js\" \"cypress/**/*.js\"",
20
20
  "format": "prettier --write \"{*,src/**/*,test/**/*,demo/js/**/*,.github/workflows/*,cypress/**/*}.+(js|yml)\"",
21
21
  "format:check": "prettier --check \"{*,src/**/*,test/**/*,demo/js/**/*,.github/workflows/*,cypress/**/*}.+(js|yml)\"",
22
+ "format:watch": "onchange \"{*,src/**/*,test/**/*,demo/js/**/*,.github/workflows/*,cypress/**/*}.+(js|yml)\" -- prettier --write {{changed}}",
22
23
  "build": "babel src -d dist",
23
24
  "test:types": "tsc index.d.ts",
24
25
  "test:unit": "jest",
26
+ "test:coverage": "jest --coverage",
25
27
  "test:cypress": "start-server-and-test start 9966 'cypress open'",
26
- "test:cypress-ci": "start-server-and-test start 9966 'cypress run --browser $CYPRESS_BROWSER --headless'",
27
- "test": "yarn format:check && yarn lint && yarn test:unit && yarn test:types && CYPRESS_BROWSER=chrome yarn test:cypress-ci",
28
+ "test:cypress:ci": "start-server-and-test start 9966 'cypress run --browser $CYPRESS_BROWSER --headless'",
29
+ "test": "yarn format:check && yarn lint && yarn test:unit && yarn test:types && CYPRESS_BROWSER=chrome yarn test:cypress:ci",
28
30
  "prepare": "yarn build",
29
31
  "release": "yarn build && changeset publish"
30
32
  },
@@ -53,36 +55,43 @@
53
55
  },
54
56
  "homepage": "https://github.com/focus-trap/focus-trap-react#readme",
55
57
  "devDependencies": {
56
- "@babel/cli": "^7.12.8",
57
- "@babel/core": "^7.12.9",
58
- "@babel/plugin-proposal-class-properties": "^7.10.4",
59
- "@babel/preset-env": "^7.12.7",
60
- "@babel/preset-react": "^7.12.7",
61
- "@changesets/cli": "^2.12.0",
62
- "@testing-library/cypress": "^7.0.2",
63
- "@types/jquery": "^3.5.4",
64
- "all-contributors-cli": "^6.19.0",
58
+ "@babel/cli": "^7.13.16",
59
+ "@babel/core": "^7.13.16",
60
+ "@babel/plugin-proposal-class-properties": "^7.12.13",
61
+ "@babel/preset-env": "^7.13.15",
62
+ "@babel/preset-react": "^7.13.13",
63
+ "@changesets/cli": "^2.16.0",
64
+ "@testing-library/cypress": "^7.0.6",
65
+ "@testing-library/dom": "^7.30.3",
66
+ "@testing-library/jest-dom": "^5.11.10",
67
+ "@testing-library/react": "^11.2.6",
68
+ "@testing-library/user-event": "^13.1.5",
69
+ "@types/jquery": "^3.5.5",
70
+ "all-contributors-cli": "^6.20.0",
65
71
  "babel-eslint": "^10.1.0",
66
72
  "babel-jest": "^26.6.3",
67
73
  "babelify": "^10.0.0",
68
74
  "browserify": "^17.0.0",
69
75
  "budo": "^11.6.4",
70
- "cypress": "^6.0.1",
76
+ "cypress": "^7.1.0",
71
77
  "cypress-plugin-tab": "^1.0.5",
72
- "eslint": "^7.14.0",
73
- "eslint-config-prettier": "^6.15.0",
78
+ "eslint": "^7.24.0",
79
+ "eslint-config-prettier": "^8.2.0",
74
80
  "eslint-plugin-cypress": "^2.11.2",
75
- "eslint-plugin-react": "^7.21.5",
81
+ "eslint-plugin-react": "^7.23.2",
76
82
  "jest": "^26.6.3",
83
+ "jest-watch-typeahead": "^0.6.2",
84
+ "onchange": "^7.1.0",
77
85
  "prettier": "^2.2.1",
78
86
  "prop-types": "^15.7.2",
79
- "react": "^17.0.1",
80
- "react-dom": "^17.0.1",
81
- "start-server-and-test": "^1.11.6",
82
- "typescript": "^4.1.2"
87
+ "react": "^17.0.2",
88
+ "react-dom": "^17.0.2",
89
+ "regenerator-runtime": "^0.13.7",
90
+ "start-server-and-test": "^1.12.1",
91
+ "typescript": "^4.2.4"
83
92
  },
84
93
  "dependencies": {
85
- "focus-trap": "^6.2.2"
94
+ "focus-trap": "^6.4.0"
86
95
  },
87
96
  "peerDependencies": {
88
97
  "prop-types": "^15.7.2",
@@ -142,6 +142,12 @@ class FocusTrap extends React.Component {
142
142
  : undefined;
143
143
 
144
144
  if (child) {
145
+ if (child.type && child.type === React.Fragment) {
146
+ throw new Error(
147
+ 'A focus-trap cannot use a Fragment as its child container. Try replacing it with a <div> element.'
148
+ );
149
+ }
150
+
145
151
  const composedRefCallback = (element) => {
146
152
  const { containerElements } = this.props;
147
153
 
@@ -189,7 +195,10 @@ FocusTrap.propTypes = {
189
195
  PropTypes.func,
190
196
  ]),
191
197
  escapeDeactivates: PropTypes.bool,
192
- clickOutsideDeactivates: PropTypes.bool,
198
+ clickOutsideDeactivates: PropTypes.oneOfType([
199
+ PropTypes.bool,
200
+ PropTypes.func,
201
+ ]),
193
202
  returnFocusOnDeactivate: PropTypes.bool,
194
203
  setReturnFocus: PropTypes.oneOfType([
195
204
  PropTypes.instanceOf(ElementType),