focus-trap-react 7.0.0 → 7.0.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 +4 -0
- package/dist/focus-trap-react.js +7 -5
- package/package.json +4 -7
- package/src/focus-trap-react.js +7 -4
package/CHANGELOG.md
CHANGED
package/dist/focus-trap-react.js
CHANGED
|
@@ -151,25 +151,27 @@ var FocusTrap = /*#__PURE__*/function (_React$Component) {
|
|
|
151
151
|
}]);
|
|
152
152
|
|
|
153
153
|
return FocusTrap;
|
|
154
|
-
}(React.Component);
|
|
154
|
+
}(React.Component); // support server-side rendering where `Element` will not be defined
|
|
155
155
|
|
|
156
|
+
|
|
157
|
+
var ElementType = typeof Element === 'undefined' ? Function : Element;
|
|
156
158
|
FocusTrap.propTypes = {
|
|
157
159
|
active: PropTypes.bool,
|
|
158
160
|
paused: PropTypes.bool,
|
|
159
161
|
focusTrapOptions: PropTypes.shape({
|
|
160
162
|
onActivate: PropTypes.func,
|
|
161
163
|
onDeactivate: PropTypes.func,
|
|
162
|
-
initialFocus: PropTypes.oneOfType([PropTypes.instanceOf(
|
|
163
|
-
fallbackFocus: PropTypes.oneOfType([PropTypes.instanceOf(
|
|
164
|
+
initialFocus: PropTypes.oneOfType([PropTypes.instanceOf(ElementType), PropTypes.string, PropTypes.func]),
|
|
165
|
+
fallbackFocus: PropTypes.oneOfType([PropTypes.instanceOf(ElementType), PropTypes.string, PropTypes.func]),
|
|
164
166
|
escapeDeactivates: PropTypes.bool,
|
|
165
167
|
clickOutsideDeactivates: PropTypes.bool,
|
|
166
168
|
returnFocusOnDeactivate: PropTypes.bool,
|
|
167
|
-
setReturnFocus: PropTypes.oneOfType([PropTypes.instanceOf(
|
|
169
|
+
setReturnFocus: PropTypes.oneOfType([PropTypes.instanceOf(ElementType), PropTypes.string, PropTypes.func]),
|
|
168
170
|
allowOutsideClick: PropTypes.func,
|
|
169
171
|
preventScroll: PropTypes.bool
|
|
170
172
|
}),
|
|
171
173
|
children: PropTypes.oneOfType([PropTypes.element, // React element
|
|
172
|
-
PropTypes.instanceOf(
|
|
174
|
+
PropTypes.instanceOf(ElementType) // DOM element
|
|
173
175
|
]) // NOTE: _createFocusTrap is internal, for testing purposes only, so we don't
|
|
174
176
|
// specify it here. It's expected to be set to the function returned from
|
|
175
177
|
// require('focus-trap'), or one with a compatible interface.
|
package/package.json
CHANGED
|
@@ -1,23 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "focus-trap-react",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.1",
|
|
4
4
|
"description": "A React component that traps focus.",
|
|
5
5
|
"main": "dist/focus-trap-react.js",
|
|
6
|
-
"engines": {
|
|
7
|
-
"npm": ">=6.14.5"
|
|
8
|
-
},
|
|
9
6
|
"types": "index.d.ts",
|
|
10
7
|
"scripts": {
|
|
11
8
|
"demo-bundle": "browserify demo/js -t babelify --extension=.jsx -o demo/demo-bundle.js",
|
|
12
|
-
"prestart": "
|
|
9
|
+
"prestart": "yarn build",
|
|
13
10
|
"start": "budo demo/js/index.js:demo-bundle.js --dir demo --live -- -t babelify --extension=.jsx",
|
|
14
11
|
"lint": "eslint \"src/**/*.js\" \"test/**/*.js\" \"demo/**/*.js\"",
|
|
15
12
|
"format": "prettier --write \"src/**/*.js\" \"test/**/*.js\" \"demo/js/**/*.js\"",
|
|
16
13
|
"format-check": "prettier --check \"src/**/*.js\" \"test/**/*.js\" \"demo/js/**/*.js\"",
|
|
17
14
|
"build": "babel src -d dist",
|
|
18
15
|
"test-unit": "jest",
|
|
19
|
-
"test": "
|
|
20
|
-
"prepublishOnly": "
|
|
16
|
+
"test": "yarn format-check && yarn lint && jest",
|
|
17
|
+
"prepublishOnly": "yarn test && yarn build"
|
|
21
18
|
},
|
|
22
19
|
"repository": {
|
|
23
20
|
"type": "git",
|
package/src/focus-trap-react.js
CHANGED
|
@@ -113,6 +113,9 @@ class FocusTrap extends React.Component {
|
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
+
// support server-side rendering where `Element` will not be defined
|
|
117
|
+
const ElementType = typeof Element === 'undefined' ? Function : Element;
|
|
118
|
+
|
|
116
119
|
FocusTrap.propTypes = {
|
|
117
120
|
active: PropTypes.bool,
|
|
118
121
|
paused: PropTypes.bool,
|
|
@@ -120,12 +123,12 @@ FocusTrap.propTypes = {
|
|
|
120
123
|
onActivate: PropTypes.func,
|
|
121
124
|
onDeactivate: PropTypes.func,
|
|
122
125
|
initialFocus: PropTypes.oneOfType([
|
|
123
|
-
PropTypes.instanceOf(
|
|
126
|
+
PropTypes.instanceOf(ElementType),
|
|
124
127
|
PropTypes.string,
|
|
125
128
|
PropTypes.func
|
|
126
129
|
]),
|
|
127
130
|
fallbackFocus: PropTypes.oneOfType([
|
|
128
|
-
PropTypes.instanceOf(
|
|
131
|
+
PropTypes.instanceOf(ElementType),
|
|
129
132
|
PropTypes.string,
|
|
130
133
|
PropTypes.func
|
|
131
134
|
]),
|
|
@@ -133,7 +136,7 @@ FocusTrap.propTypes = {
|
|
|
133
136
|
clickOutsideDeactivates: PropTypes.bool,
|
|
134
137
|
returnFocusOnDeactivate: PropTypes.bool,
|
|
135
138
|
setReturnFocus: PropTypes.oneOfType([
|
|
136
|
-
PropTypes.instanceOf(
|
|
139
|
+
PropTypes.instanceOf(ElementType),
|
|
137
140
|
PropTypes.string,
|
|
138
141
|
PropTypes.func
|
|
139
142
|
]),
|
|
@@ -142,7 +145,7 @@ FocusTrap.propTypes = {
|
|
|
142
145
|
}),
|
|
143
146
|
children: PropTypes.oneOfType([
|
|
144
147
|
PropTypes.element, // React element
|
|
145
|
-
PropTypes.instanceOf(
|
|
148
|
+
PropTypes.instanceOf(ElementType) // DOM element
|
|
146
149
|
])
|
|
147
150
|
|
|
148
151
|
// NOTE: _createFocusTrap is internal, for testing purposes only, so we don't
|