@instructure/ui-modal 8.33.1 → 8.33.2
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 +6 -0
- package/es/Modal/ModalBody/index.js +29 -25
- package/es/Modal/ModalBody/props.js +1 -1
- package/es/Modal/ModalBody/styles.js +0 -1
- package/es/Modal/ModalBody/theme.js +0 -1
- package/es/Modal/ModalFooter/index.js +2 -14
- package/es/Modal/ModalFooter/props.js +1 -0
- package/es/Modal/ModalFooter/styles.js +0 -1
- package/es/Modal/ModalFooter/theme.js +4 -4
- package/es/Modal/ModalHeader/index.js +2 -16
- package/es/Modal/ModalHeader/props.js +1 -0
- package/es/Modal/ModalHeader/styles.js +1 -2
- package/es/Modal/ModalHeader/theme.js +3 -3
- package/es/Modal/ModalLocator.js +9 -6
- package/es/Modal/index.js +29 -53
- package/es/Modal/locator.js +1 -0
- package/es/Modal/props.js +1 -0
- package/es/Modal/styles.js +2 -3
- package/es/Modal/theme.js +7 -7
- package/lib/Modal/ModalBody/index.js +29 -36
- package/lib/Modal/ModalBody/props.js +1 -5
- package/lib/Modal/ModalBody/styles.js +0 -2
- package/lib/Modal/ModalBody/theme.js +0 -2
- package/lib/Modal/ModalFooter/index.js +2 -22
- package/lib/Modal/ModalFooter/props.js +1 -3
- package/lib/Modal/ModalFooter/styles.js +0 -2
- package/lib/Modal/ModalFooter/theme.js +4 -5
- package/lib/Modal/ModalHeader/index.js +2 -29
- package/lib/Modal/ModalHeader/props.js +1 -3
- package/lib/Modal/ModalHeader/styles.js +1 -3
- package/lib/Modal/ModalHeader/theme.js +3 -4
- package/lib/Modal/ModalLocator.js +7 -8
- package/lib/Modal/index.js +29 -72
- package/lib/Modal/locator.js +0 -2
- package/lib/Modal/props.js +1 -9
- package/lib/Modal/styles.js +2 -4
- package/lib/Modal/theme.js +7 -8
- package/lib/index.js +0 -1
- package/package.json +21 -20
- package/src/Modal/ModalBody/index.tsx +30 -3
- package/src/Modal/ModalBody/props.ts +5 -1
- package/tsconfig.build.json +1 -0
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/Modal/ModalBody/index.d.ts +17 -4
- package/types/Modal/ModalBody/index.d.ts.map +1 -1
- package/types/Modal/ModalBody/props.d.ts +4 -1
- package/types/Modal/ModalBody/props.d.ts.map +1 -1
package/lib/Modal/index.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
6
|
-
|
|
7
5
|
Object.defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
@@ -27,47 +25,26 @@ Object.defineProperty(exports, "ModalHeader", {
|
|
|
27
25
|
}
|
|
28
26
|
});
|
|
29
27
|
exports.default = void 0;
|
|
30
|
-
|
|
31
28
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
32
|
-
|
|
33
29
|
var _react = _interopRequireWildcard(require("react"));
|
|
34
|
-
|
|
35
30
|
var _passthroughProps = require("@instructure/ui-react-utils/lib/passthroughProps.js");
|
|
36
|
-
|
|
37
31
|
var _safeCloneElement = require("@instructure/ui-react-utils/lib/safeCloneElement.js");
|
|
38
|
-
|
|
39
32
|
var _matchComponentTypes = require("@instructure/ui-react-utils/lib/matchComponentTypes.js");
|
|
40
|
-
|
|
41
33
|
var _createChainedFunction = require("@instructure/ui-utils/lib/createChainedFunction.js");
|
|
42
|
-
|
|
43
34
|
var _testable = require("@instructure/ui-testable/lib/testable.js");
|
|
44
|
-
|
|
45
35
|
var _Transition = require("@instructure/ui-motion/lib/Transition");
|
|
46
|
-
|
|
47
36
|
var _Portal = require("@instructure/ui-portal/lib/Portal");
|
|
48
|
-
|
|
49
37
|
var _Dialog = require("@instructure/ui-dialog/lib/Dialog");
|
|
50
|
-
|
|
51
38
|
var _Mask = require("@instructure/ui-overlays/lib/Mask");
|
|
52
|
-
|
|
53
39
|
var _ModalHeader = require("./ModalHeader");
|
|
54
|
-
|
|
55
40
|
var _ModalBody = require("./ModalBody");
|
|
56
|
-
|
|
57
41
|
var _ModalFooter = require("./ModalFooter");
|
|
58
|
-
|
|
59
42
|
var _emotion = require("@instructure/emotion");
|
|
60
|
-
|
|
61
43
|
var _styles = _interopRequireDefault(require("./styles"));
|
|
62
|
-
|
|
63
44
|
var _theme = _interopRequireDefault(require("./theme"));
|
|
64
|
-
|
|
65
45
|
var _props = require("./props");
|
|
66
|
-
|
|
67
46
|
const _excluded = ["open", "onOpen", "onClose", "mountNode", "insertAt", "transition", "onEnter", "onEntering", "onEntered", "onExit", "onExiting", "onExited", "constrain", "overflow"];
|
|
68
|
-
|
|
69
47
|
var _dec, _dec2, _class, _class2;
|
|
70
|
-
|
|
71
48
|
/**
|
|
72
49
|
---
|
|
73
50
|
category: components
|
|
@@ -81,65 +58,50 @@ let Modal = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _d
|
|
|
81
58
|
this._DOMNode = null;
|
|
82
59
|
this._content = null;
|
|
83
60
|
this.ref = null;
|
|
84
|
-
|
|
85
61
|
this.handleRef = el => {
|
|
86
62
|
this.ref = el;
|
|
87
63
|
};
|
|
88
|
-
|
|
89
64
|
this.handlePortalOpen = DOMNode => {
|
|
90
65
|
this.DOMNode = DOMNode;
|
|
91
66
|
};
|
|
92
|
-
|
|
93
67
|
this.handleTransitionExited = () => {
|
|
94
68
|
this.setState({
|
|
95
69
|
transitioning: false
|
|
96
70
|
});
|
|
97
71
|
};
|
|
98
|
-
|
|
99
72
|
this.contentRef = el => {
|
|
100
73
|
this._content = el;
|
|
101
|
-
|
|
102
74
|
if (typeof this.props.contentRef === 'function') {
|
|
103
75
|
this.props.contentRef(el);
|
|
104
76
|
}
|
|
105
77
|
};
|
|
106
|
-
|
|
107
78
|
this.state = {
|
|
108
79
|
transitioning: false
|
|
109
80
|
};
|
|
110
81
|
}
|
|
111
|
-
|
|
112
82
|
componentDidMount() {
|
|
113
83
|
var _this$props$makeStyle, _this$props;
|
|
114
|
-
|
|
115
84
|
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
116
85
|
}
|
|
117
|
-
|
|
118
86
|
componentDidUpdate(prevProps) {
|
|
119
87
|
var _this$props$makeStyle2, _this$props2;
|
|
120
|
-
|
|
121
88
|
if (prevProps.open && !this.props.open) {
|
|
122
89
|
// closing
|
|
123
90
|
this.setState({
|
|
124
91
|
transitioning: prevProps.transition !== null
|
|
125
92
|
});
|
|
126
93
|
}
|
|
127
|
-
|
|
128
94
|
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
129
95
|
}
|
|
130
|
-
|
|
131
96
|
get defaultFocusElement() {
|
|
132
97
|
return this.props.defaultFocusElement;
|
|
133
98
|
}
|
|
134
|
-
|
|
135
99
|
get DOMNode() {
|
|
136
100
|
return this._DOMNode;
|
|
137
101
|
}
|
|
138
|
-
|
|
139
102
|
set DOMNode(el) {
|
|
140
103
|
this._DOMNode = el;
|
|
141
104
|
}
|
|
142
|
-
|
|
143
105
|
get maskPlacement() {
|
|
144
106
|
if (this.props.overflow === 'fit') {
|
|
145
107
|
return 'stretch';
|
|
@@ -147,12 +109,11 @@ let Modal = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _d
|
|
|
147
109
|
return 'center';
|
|
148
110
|
}
|
|
149
111
|
}
|
|
150
|
-
|
|
151
112
|
renderChildren() {
|
|
152
113
|
const _this$props3 = this.props,
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
114
|
+
children = _this$props3.children,
|
|
115
|
+
variant = _this$props3.variant,
|
|
116
|
+
overflow = _this$props3.overflow;
|
|
156
117
|
return _react.Children.map(children, child => {
|
|
157
118
|
if (!child) return; // ignore null, falsy children
|
|
158
119
|
|
|
@@ -168,18 +129,17 @@ let Modal = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _d
|
|
|
168
129
|
}
|
|
169
130
|
});
|
|
170
131
|
}
|
|
171
|
-
|
|
172
132
|
renderDialog(props) {
|
|
173
133
|
const _this$props4 = this.props,
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
134
|
+
onDismiss = _this$props4.onDismiss,
|
|
135
|
+
label = _this$props4.label,
|
|
136
|
+
shouldCloseOnDocumentClick = _this$props4.shouldCloseOnDocumentClick,
|
|
137
|
+
shouldReturnFocus = _this$props4.shouldReturnFocus,
|
|
138
|
+
liveRegion = _this$props4.liveRegion,
|
|
139
|
+
size = _this$props4.size,
|
|
140
|
+
constrain = _this$props4.constrain,
|
|
141
|
+
as = _this$props4.as,
|
|
142
|
+
styles = _this$props4.styles;
|
|
183
143
|
const isFullScreen = size === 'fullscreen';
|
|
184
144
|
const dialog = (0, _emotion.jsx)(_Dialog.Dialog, Object.assign({}, (0, _passthroughProps.passthroughProps)(props), {
|
|
185
145
|
as: as,
|
|
@@ -193,8 +153,8 @@ let Modal = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _d
|
|
|
193
153
|
liveRegion: liveRegion,
|
|
194
154
|
onDismiss: onDismiss,
|
|
195
155
|
css: styles === null || styles === void 0 ? void 0 : styles.modal,
|
|
196
|
-
ref: this.contentRef
|
|
197
|
-
|
|
156
|
+
ref: this.contentRef
|
|
157
|
+
// aria-modal="true" see VO bug https://bugs.webkit.org/show_bug.cgi?id=174667
|
|
198
158
|
}), this.renderChildren());
|
|
199
159
|
return (0, _emotion.jsx)(_Mask.Mask, {
|
|
200
160
|
placement: this.maskPlacement,
|
|
@@ -205,26 +165,24 @@ let Modal = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _d
|
|
|
205
165
|
} : {}
|
|
206
166
|
}, dialog);
|
|
207
167
|
}
|
|
208
|
-
|
|
209
168
|
render() {
|
|
210
169
|
var _this$props$styles;
|
|
211
|
-
|
|
212
170
|
const _this$props5 = this.props,
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
171
|
+
open = _this$props5.open,
|
|
172
|
+
onOpen = _this$props5.onOpen,
|
|
173
|
+
onClose = _this$props5.onClose,
|
|
174
|
+
mountNode = _this$props5.mountNode,
|
|
175
|
+
insertAt = _this$props5.insertAt,
|
|
176
|
+
transition = _this$props5.transition,
|
|
177
|
+
onEnter = _this$props5.onEnter,
|
|
178
|
+
onEntering = _this$props5.onEntering,
|
|
179
|
+
onEntered = _this$props5.onEntered,
|
|
180
|
+
onExit = _this$props5.onExit,
|
|
181
|
+
onExiting = _this$props5.onExiting,
|
|
182
|
+
onExited = _this$props5.onExited,
|
|
183
|
+
constrain = _this$props5.constrain,
|
|
184
|
+
overflow = _this$props5.overflow,
|
|
185
|
+
passthroughProps = (0, _objectWithoutProperties2.default)(_this$props5, _excluded);
|
|
228
186
|
const portalIsOpen = open || this.state.transitioning;
|
|
229
187
|
return (0, _emotion.jsx)(_Portal.Portal, {
|
|
230
188
|
mountNode: mountNode,
|
|
@@ -248,7 +206,6 @@ let Modal = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _d
|
|
|
248
206
|
css: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.constrainContext
|
|
249
207
|
}, this.renderDialog(passthroughProps)) : this.renderDialog(passthroughProps)));
|
|
250
208
|
}
|
|
251
|
-
|
|
252
209
|
}, _class2.displayName = "Modal", _class2.componentId = 'Modal', _class2.propTypes = _props.propTypes, _class2.allowedProps = _props.allowedProps, _class2.defaultProps = {
|
|
253
210
|
open: false,
|
|
254
211
|
size: 'auto',
|
package/lib/Modal/locator.js
CHANGED
package/lib/Modal/props.js
CHANGED
|
@@ -1,26 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.propTypes = exports.allowedProps = void 0;
|
|
9
|
-
|
|
10
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
-
|
|
12
9
|
var _element = require("@instructure/ui-prop-types/lib/element.js");
|
|
13
|
-
|
|
14
10
|
var _Children = require("@instructure/ui-prop-types/lib/Children.js");
|
|
15
|
-
|
|
16
11
|
var _uiMotion = require("@instructure/ui-motion");
|
|
17
|
-
|
|
18
12
|
var _ModalHeader = require("./ModalHeader");
|
|
19
|
-
|
|
20
13
|
var _ModalBody = require("./ModalBody");
|
|
21
|
-
|
|
22
14
|
var _ModalFooter = require("./ModalFooter");
|
|
23
|
-
|
|
24
15
|
/*
|
|
25
16
|
* The MIT License (MIT)
|
|
26
17
|
*
|
|
@@ -44,6 +35,7 @@ var _ModalFooter = require("./ModalFooter");
|
|
|
44
35
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
45
36
|
* SOFTWARE.
|
|
46
37
|
*/
|
|
38
|
+
|
|
47
39
|
const propTypes = {
|
|
48
40
|
label: _propTypes.default.string.isRequired,
|
|
49
41
|
children: _Children.Children.enforceOrder([_ModalHeader.ModalHeader, _ModalBody.ModalBody, _ModalFooter.ModalFooter], [_ModalHeader.ModalHeader, _ModalBody.ModalBody], [_ModalBody.ModalBody, _ModalFooter.ModalFooter], [_ModalBody.ModalBody]),
|
package/lib/Modal/styles.js
CHANGED
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
/*
|
|
9
8
|
* The MIT License (MIT)
|
|
10
9
|
*
|
|
@@ -41,8 +40,8 @@ exports.default = void 0;
|
|
|
41
40
|
*/
|
|
42
41
|
const generateStyle = (componentTheme, props) => {
|
|
43
42
|
const size = props.size,
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
variant = props.variant,
|
|
44
|
+
overflow = props.overflow;
|
|
46
45
|
const commonSizeStyleExceptForFullscreen = {
|
|
47
46
|
maxWidth: '95%',
|
|
48
47
|
maxHeight: '95%',
|
|
@@ -108,6 +107,5 @@ const generateStyle = (componentTheme, props) => {
|
|
|
108
107
|
}
|
|
109
108
|
};
|
|
110
109
|
};
|
|
111
|
-
|
|
112
110
|
var _default = generateStyle;
|
|
113
111
|
exports.default = _default;
|
package/lib/Modal/theme.js
CHANGED
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
/*
|
|
9
8
|
* The MIT License (MIT)
|
|
10
9
|
*
|
|
@@ -36,11 +35,11 @@ exports.default = void 0;
|
|
|
36
35
|
*/
|
|
37
36
|
const generateComponentTheme = theme => {
|
|
38
37
|
const colors = theme.colors,
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
38
|
+
typography = theme.typography,
|
|
39
|
+
borders = theme.borders,
|
|
40
|
+
breakpoints = theme.breakpoints,
|
|
41
|
+
shadows = theme.shadows,
|
|
42
|
+
stacking = theme.stacking;
|
|
44
43
|
const componentVariables = {
|
|
45
44
|
fontFamily: typography === null || typography === void 0 ? void 0 : typography.fontFamily,
|
|
46
45
|
textColor: colors === null || colors === void 0 ? void 0 : colors.textDarkest,
|
|
@@ -56,9 +55,9 @@ const generateComponentTheme = theme => {
|
|
|
56
55
|
boxShadow: shadows === null || shadows === void 0 ? void 0 : shadows.depth3,
|
|
57
56
|
zIndex: stacking === null || stacking === void 0 ? void 0 : stacking.topmost
|
|
58
57
|
};
|
|
59
|
-
return {
|
|
58
|
+
return {
|
|
59
|
+
...componentVariables
|
|
60
60
|
};
|
|
61
61
|
};
|
|
62
|
-
|
|
63
62
|
var _default = generateComponentTheme;
|
|
64
63
|
exports.default = _default;
|
package/lib/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-modal",
|
|
3
|
-
"version": "8.33.
|
|
3
|
+
"version": "8.33.2",
|
|
4
4
|
"description": "A component for displaying content in a dialog overlay",
|
|
5
5
|
"author": "Instructure, Inc. Engineering and Product Design",
|
|
6
6
|
"module": "./es/index.js",
|
|
@@ -24,31 +24,32 @@
|
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@babel/runtime": "^7.13.10",
|
|
27
|
-
"@instructure/console": "8.33.
|
|
28
|
-
"@instructure/emotion": "8.33.
|
|
29
|
-
"@instructure/shared-types": "8.33.
|
|
30
|
-
"@instructure/ui-buttons": "8.33.
|
|
31
|
-
"@instructure/ui-dialog": "8.33.
|
|
32
|
-
"@instructure/ui-
|
|
33
|
-
"@instructure/ui-
|
|
34
|
-
"@instructure/ui-
|
|
35
|
-
"@instructure/ui-
|
|
36
|
-
"@instructure/ui-
|
|
37
|
-
"@instructure/ui-
|
|
38
|
-
"@instructure/ui-
|
|
39
|
-
"@instructure/ui-
|
|
27
|
+
"@instructure/console": "8.33.2",
|
|
28
|
+
"@instructure/emotion": "8.33.2",
|
|
29
|
+
"@instructure/shared-types": "8.33.2",
|
|
30
|
+
"@instructure/ui-buttons": "8.33.2",
|
|
31
|
+
"@instructure/ui-dialog": "8.33.2",
|
|
32
|
+
"@instructure/ui-dom-utils": "8.33.2",
|
|
33
|
+
"@instructure/ui-motion": "8.33.2",
|
|
34
|
+
"@instructure/ui-overlays": "8.33.2",
|
|
35
|
+
"@instructure/ui-portal": "8.33.2",
|
|
36
|
+
"@instructure/ui-prop-types": "8.33.2",
|
|
37
|
+
"@instructure/ui-react-utils": "8.33.2",
|
|
38
|
+
"@instructure/ui-testable": "8.33.2",
|
|
39
|
+
"@instructure/ui-utils": "8.33.2",
|
|
40
|
+
"@instructure/ui-view": "8.33.2",
|
|
40
41
|
"prop-types": "^15"
|
|
41
42
|
},
|
|
42
43
|
"peerDependencies": {
|
|
43
44
|
"react": ">=16.8 <=18"
|
|
44
45
|
},
|
|
45
46
|
"devDependencies": {
|
|
46
|
-
"@instructure/ui-babel-preset": "8.33.
|
|
47
|
-
"@instructure/ui-color-utils": "8.33.
|
|
48
|
-
"@instructure/ui-position": "8.33.
|
|
49
|
-
"@instructure/ui-test-locator": "8.33.
|
|
50
|
-
"@instructure/ui-test-utils": "8.33.
|
|
51
|
-
"@instructure/ui-themes": "8.33.
|
|
47
|
+
"@instructure/ui-babel-preset": "8.33.2",
|
|
48
|
+
"@instructure/ui-color-utils": "8.33.2",
|
|
49
|
+
"@instructure/ui-position": "8.33.2",
|
|
50
|
+
"@instructure/ui-test-locator": "8.33.2",
|
|
51
|
+
"@instructure/ui-test-utils": "8.33.2",
|
|
52
|
+
"@instructure/ui-themes": "8.33.2"
|
|
52
53
|
},
|
|
53
54
|
"publishConfig": {
|
|
54
55
|
"access": "public"
|
|
@@ -28,13 +28,14 @@ import { Component } from 'react'
|
|
|
28
28
|
import { View } from '@instructure/ui-view'
|
|
29
29
|
import { testable } from '@instructure/ui-testable'
|
|
30
30
|
import { omitProps } from '@instructure/ui-react-utils'
|
|
31
|
+
import { getComputedStyle } from '@instructure/ui-dom-utils'
|
|
31
32
|
|
|
32
33
|
import { withStyle, jsx } from '@instructure/emotion'
|
|
33
34
|
import generateStyle from './styles'
|
|
34
35
|
import generateComponentTheme from './theme'
|
|
35
36
|
|
|
36
37
|
import { propTypes, allowedProps } from './props'
|
|
37
|
-
import type { ModalBodyProps } from './props'
|
|
38
|
+
import type { ModalBodyProps, ModalBodyState } from './props'
|
|
38
39
|
|
|
39
40
|
/**
|
|
40
41
|
---
|
|
@@ -45,7 +46,7 @@ id: Modal.Body
|
|
|
45
46
|
**/
|
|
46
47
|
@withStyle(generateStyle, generateComponentTheme)
|
|
47
48
|
@testable()
|
|
48
|
-
class ModalBody extends Component<ModalBodyProps> {
|
|
49
|
+
class ModalBody extends Component<ModalBodyProps, ModalBodyState> {
|
|
49
50
|
static readonly componentId = 'Modal.Body'
|
|
50
51
|
|
|
51
52
|
static propTypes = propTypes
|
|
@@ -68,8 +69,30 @@ class ModalBody extends Component<ModalBodyProps> {
|
|
|
68
69
|
}
|
|
69
70
|
}
|
|
70
71
|
|
|
72
|
+
constructor(props: ModalBodyProps) {
|
|
73
|
+
super(props)
|
|
74
|
+
|
|
75
|
+
this.state = {
|
|
76
|
+
isFirefox: false
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
71
80
|
componentDidMount() {
|
|
72
81
|
this.props.makeStyles?.()
|
|
82
|
+
|
|
83
|
+
// We detect if -moz- prefixed style is present to identify whether we are in Firefox browser
|
|
84
|
+
const style = this.ref && getComputedStyle(this.ref)
|
|
85
|
+
const isFirefox = !!(
|
|
86
|
+
style &&
|
|
87
|
+
Array.prototype.slice
|
|
88
|
+
.call(style)
|
|
89
|
+
.join('')
|
|
90
|
+
.match(/(?:-moz-)/)
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
if (isFirefox) {
|
|
94
|
+
this.setState({ isFirefox })
|
|
95
|
+
}
|
|
73
96
|
}
|
|
74
97
|
|
|
75
98
|
componentDidUpdate() {
|
|
@@ -96,7 +119,11 @@ class ModalBody extends Component<ModalBodyProps> {
|
|
|
96
119
|
as={as}
|
|
97
120
|
css={this.props.styles?.modalBody}
|
|
98
121
|
padding={padding}
|
|
99
|
-
|
|
122
|
+
// We have to make an exception in Firefox, because it makes
|
|
123
|
+
// the container focusable when it is scrollable.
|
|
124
|
+
// This is a feature, not a bug, but it prevents VoiceOver
|
|
125
|
+
// to correctly focus inside the body in other browsers.
|
|
126
|
+
{...(this.state.isFirefox && { tabIndex: -1 })}
|
|
100
127
|
>
|
|
101
128
|
{children}
|
|
102
129
|
</View>
|
|
@@ -58,6 +58,10 @@ type ModalBodyProps = ModalBodyOwnProps &
|
|
|
58
58
|
|
|
59
59
|
type ModalBodyStyle = ComponentStyle<'modalBody'>
|
|
60
60
|
|
|
61
|
+
type ModalBodyState = {
|
|
62
|
+
isFirefox: boolean
|
|
63
|
+
}
|
|
64
|
+
|
|
61
65
|
const propTypes: PropValidators<PropKeys> = {
|
|
62
66
|
children: PropTypes.node,
|
|
63
67
|
padding: ThemeablePropTypes.spacing,
|
|
@@ -79,5 +83,5 @@ const allowedProps: AllowedPropKeys = [
|
|
|
79
83
|
'overflow'
|
|
80
84
|
]
|
|
81
85
|
|
|
82
|
-
export type { ModalBodyProps, ModalBodyStyle }
|
|
86
|
+
export type { ModalBodyProps, ModalBodyState, ModalBodyStyle }
|
|
83
87
|
export { propTypes, allowedProps }
|
package/tsconfig.build.json
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
{ "path": "../shared-types/tsconfig.build.json" },
|
|
13
13
|
{ "path": "../ui-buttons/tsconfig.build.json" },
|
|
14
14
|
{ "path": "../ui-dialog/tsconfig.build.json" },
|
|
15
|
+
{ "path": "../ui-dom-utils/tsconfig.build.json" },
|
|
15
16
|
{ "path": "../ui-motion/tsconfig.build.json" },
|
|
16
17
|
{ "path": "../ui-overlays/tsconfig.build.json" },
|
|
17
18
|
{ "path": "../ui-portal/tsconfig.build.json" },
|