@khanacademy/wonder-blocks-modal 4.0.39 → 4.2.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 +13 -0
- package/dist/components/modal-content.d.ts +8 -9
- package/dist/components/modal-dialog.d.ts +3 -19
- package/dist/components/modal-footer.d.ts +5 -5
- package/dist/components/modal-header.d.ts +6 -7
- package/dist/components/modal-panel.d.ts +13 -14
- package/dist/es/index.js +287 -254
- package/dist/index.js +302 -269
- package/dist/themes/default.d.ts +33 -0
- package/dist/themes/khanmigo.d.ts +36 -0
- package/dist/themes/themed-modal-dialog.d.ts +48 -0
- package/package.json +2 -1
- package/src/components/__tests__/modal-dialog.test.tsx +78 -0
- package/src/components/modal-content.tsx +53 -54
- package/src/components/modal-dialog.tsx +103 -103
- package/src/components/modal-footer.tsx +8 -10
- package/src/components/modal-header.tsx +95 -102
- package/src/components/modal-panel.tsx +66 -73
- package/src/themes/default.ts +36 -0
- package/src/themes/khanmigo.ts +15 -0
- package/src/themes/themed-modal-dialog.tsx +44 -0
- package/tsconfig-build.json +1 -0
- package/tsconfig-build.tsbuildinfo +1 -1
package/dist/index.js
CHANGED
|
@@ -3,143 +3,203 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var React = require('react');
|
|
6
|
-
var aphrodite = require('aphrodite');
|
|
7
|
-
var wonderBlocksLayout = require('@khanacademy/wonder-blocks-layout');
|
|
8
6
|
var wonderBlocksCore = require('@khanacademy/wonder-blocks-core');
|
|
9
|
-
var
|
|
7
|
+
var wonderBlocksTheming = require('@khanacademy/wonder-blocks-theming');
|
|
8
|
+
var aphrodite = require('aphrodite');
|
|
10
9
|
var Color = require('@khanacademy/wonder-blocks-color');
|
|
10
|
+
var Spacing = require('@khanacademy/wonder-blocks-spacing');
|
|
11
11
|
var wonderBlocksTypography = require('@khanacademy/wonder-blocks-typography');
|
|
12
12
|
var ReactDOM = require('react-dom');
|
|
13
13
|
var wonderBlocksTiming = require('@khanacademy/wonder-blocks-timing');
|
|
14
14
|
var xIcon = require('@phosphor-icons/core/regular/x.svg');
|
|
15
15
|
var IconButton = require('@khanacademy/wonder-blocks-icon-button');
|
|
16
|
+
var wonderBlocksLayout = require('@khanacademy/wonder-blocks-layout');
|
|
16
17
|
|
|
17
18
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
18
19
|
|
|
19
20
|
function _interopNamespace(e) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
});
|
|
30
|
-
}
|
|
21
|
+
if (e && e.__esModule) return e;
|
|
22
|
+
var n = Object.create(null);
|
|
23
|
+
if (e) {
|
|
24
|
+
Object.keys(e).forEach(function (k) {
|
|
25
|
+
if (k !== 'default') {
|
|
26
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
27
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
28
|
+
enumerable: true,
|
|
29
|
+
get: function () { return e[k]; }
|
|
31
30
|
});
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
n["default"] = e;
|
|
35
|
+
return Object.freeze(n);
|
|
35
36
|
}
|
|
36
37
|
|
|
37
38
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
38
|
-
var Spacing__default = /*#__PURE__*/_interopDefaultLegacy(Spacing);
|
|
39
39
|
var Color__default = /*#__PURE__*/_interopDefaultLegacy(Color);
|
|
40
|
+
var Spacing__default = /*#__PURE__*/_interopDefaultLegacy(Spacing);
|
|
40
41
|
var ReactDOM__namespace = /*#__PURE__*/_interopNamespace(ReactDOM);
|
|
41
42
|
var xIcon__default = /*#__PURE__*/_interopDefaultLegacy(xIcon);
|
|
42
43
|
var IconButton__default = /*#__PURE__*/_interopDefaultLegacy(IconButton);
|
|
43
44
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
ssrSize: "large",
|
|
58
|
-
mediaSpec: wonderBlocksLayout.MEDIA_MODAL_SPEC
|
|
59
|
-
};
|
|
60
|
-
return React__namespace.createElement(wonderBlocksLayout.MediaLayoutContext.Provider, {
|
|
61
|
-
value: contextValue
|
|
62
|
-
}, React__namespace.createElement(wonderBlocksLayout.MediaLayout, {
|
|
63
|
-
styleSheets: styleSheets$3
|
|
64
|
-
}, ({
|
|
65
|
-
styles
|
|
66
|
-
}) => React__namespace.createElement(wonderBlocksCore.View, {
|
|
67
|
-
style: [styles.wrapper, style]
|
|
68
|
-
}, below && React__namespace.createElement(wonderBlocksCore.View, {
|
|
69
|
-
style: styles.below
|
|
70
|
-
}, below), React__namespace.createElement(wonderBlocksCore.View, {
|
|
71
|
-
role: role,
|
|
72
|
-
"aria-modal": "true",
|
|
73
|
-
"aria-labelledby": ariaLabelledBy,
|
|
74
|
-
"aria-describedby": ariaDescribedBy,
|
|
75
|
-
style: styles.dialog,
|
|
76
|
-
testId: testId
|
|
77
|
-
}, children), above && React__namespace.createElement(wonderBlocksCore.View, {
|
|
78
|
-
style: styles.above
|
|
79
|
-
}, above))));
|
|
80
|
-
}
|
|
45
|
+
function _extends() {
|
|
46
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
47
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
48
|
+
var source = arguments[i];
|
|
49
|
+
for (var key in source) {
|
|
50
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
51
|
+
target[key] = source[key];
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return target;
|
|
56
|
+
};
|
|
57
|
+
return _extends.apply(this, arguments);
|
|
81
58
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
width: "100%",
|
|
92
|
-
height: "100%",
|
|
93
|
-
position: "relative"
|
|
59
|
+
|
|
60
|
+
const theme$1 = {
|
|
61
|
+
color: {
|
|
62
|
+
bg: {
|
|
63
|
+
inverse: wonderBlocksTheming.tokens.color.darkBlue
|
|
64
|
+
},
|
|
65
|
+
text: {
|
|
66
|
+
inverse: wonderBlocksTheming.tokens.color.white,
|
|
67
|
+
secondary: wonderBlocksTheming.tokens.color.offBlack64
|
|
94
68
|
},
|
|
69
|
+
shadow: {
|
|
70
|
+
default: wonderBlocksTheming.tokens.color.offBlack16
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
border: {
|
|
74
|
+
radius: wonderBlocksTheming.tokens.border.radius.medium_4
|
|
75
|
+
},
|
|
76
|
+
spacing: {
|
|
95
77
|
dialog: {
|
|
96
|
-
|
|
97
|
-
height: "100%",
|
|
98
|
-
borderRadius: 4,
|
|
99
|
-
overflow: "hidden"
|
|
78
|
+
small: wonderBlocksTheming.tokens.spacing.medium_16
|
|
100
79
|
},
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
top: 0,
|
|
105
|
-
left: 0,
|
|
106
|
-
bottom: 0,
|
|
107
|
-
right: 0,
|
|
108
|
-
zIndex: 1
|
|
80
|
+
panel: {
|
|
81
|
+
closeButton: wonderBlocksTheming.tokens.spacing.medium_16,
|
|
82
|
+
footer: wonderBlocksTheming.tokens.spacing.xLarge_32
|
|
109
83
|
},
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
bottom: 0,
|
|
116
|
-
right: 0,
|
|
117
|
-
zIndex: -1
|
|
118
|
-
}
|
|
119
|
-
}),
|
|
120
|
-
small: aphrodite.StyleSheet.create({
|
|
121
|
-
wrapper: {
|
|
122
|
-
padding: Spacing__default["default"].medium_16,
|
|
123
|
-
flexDirection: "column"
|
|
84
|
+
header: {
|
|
85
|
+
xsmall: wonderBlocksTheming.tokens.spacing.xSmall_8,
|
|
86
|
+
small: wonderBlocksTheming.tokens.spacing.medium_16,
|
|
87
|
+
medium: wonderBlocksTheming.tokens.spacing.large_24,
|
|
88
|
+
large: wonderBlocksTheming.tokens.spacing.xLarge_32
|
|
124
89
|
}
|
|
125
|
-
}
|
|
90
|
+
}
|
|
126
91
|
};
|
|
127
92
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
93
|
+
const theme = wonderBlocksTheming.mergeTheme(theme$1, {
|
|
94
|
+
color: {
|
|
95
|
+
bg: {
|
|
96
|
+
inverse: wonderBlocksTheming.tokens.color.eggplant
|
|
97
|
+
}
|
|
131
98
|
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
const themes = {
|
|
102
|
+
default: theme$1,
|
|
103
|
+
khanmigo: theme
|
|
104
|
+
};
|
|
105
|
+
const ModalDialogThemeContext = wonderBlocksTheming.createThemeContext(theme$1);
|
|
106
|
+
function ThemeModalDialog(props) {
|
|
107
|
+
const currentTheme = React__namespace.useContext(wonderBlocksTheming.ThemeSwitcherContext);
|
|
108
|
+
const theme = themes[currentTheme] || theme$1;
|
|
109
|
+
return React__namespace.createElement(ModalDialogThemeContext.Provider, {
|
|
110
|
+
value: theme
|
|
111
|
+
}, props.children);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const ModalDialogCore = React__namespace.forwardRef(function ModalDialogCore(props, ref) {
|
|
115
|
+
const {
|
|
116
|
+
above,
|
|
117
|
+
below,
|
|
118
|
+
role = "dialog",
|
|
119
|
+
style,
|
|
120
|
+
children,
|
|
121
|
+
testId,
|
|
122
|
+
"aria-labelledby": ariaLabelledBy,
|
|
123
|
+
"aria-describedby": ariaDescribedBy
|
|
124
|
+
} = props;
|
|
125
|
+
const {
|
|
126
|
+
theme
|
|
127
|
+
} = wonderBlocksTheming.useScopedTheme(ModalDialogThemeContext);
|
|
128
|
+
const styles = wonderBlocksTheming.useStyles(themedStylesFn$3, theme);
|
|
129
|
+
return React__namespace.createElement(wonderBlocksCore.View, {
|
|
130
|
+
style: [styles.wrapper, style]
|
|
131
|
+
}, below && React__namespace.createElement(wonderBlocksCore.View, {
|
|
132
|
+
style: styles.below
|
|
133
|
+
}, below), React__namespace.createElement(wonderBlocksCore.View, {
|
|
134
|
+
role: role,
|
|
135
|
+
"aria-modal": "true",
|
|
136
|
+
"aria-labelledby": ariaLabelledBy,
|
|
137
|
+
"aria-describedby": ariaDescribedBy,
|
|
138
|
+
ref: ref,
|
|
139
|
+
style: styles.dialog,
|
|
140
|
+
testId: testId
|
|
141
|
+
}, children), above && React__namespace.createElement(wonderBlocksCore.View, {
|
|
142
|
+
style: styles.above
|
|
143
|
+
}, above));
|
|
144
|
+
});
|
|
145
|
+
const ModalDialog = React__namespace.forwardRef(function ModalDialog(props, ref) {
|
|
146
|
+
return React__namespace.createElement(ThemeModalDialog, null, React__namespace.createElement(ModalDialogCore, _extends({}, props, {
|
|
147
|
+
ref: ref
|
|
148
|
+
})));
|
|
149
|
+
});
|
|
150
|
+
const small$2 = "@media (max-width: 767px)";
|
|
151
|
+
const themedStylesFn$3 = theme => ({
|
|
152
|
+
wrapper: {
|
|
153
|
+
display: "flex",
|
|
154
|
+
flexDirection: "row",
|
|
155
|
+
alignItems: "stretch",
|
|
156
|
+
width: "100%",
|
|
157
|
+
height: "100%",
|
|
158
|
+
position: "relative",
|
|
159
|
+
[small$2]: {
|
|
160
|
+
padding: theme.spacing.dialog.small,
|
|
161
|
+
flexDirection: "column"
|
|
162
|
+
}
|
|
163
|
+
},
|
|
164
|
+
dialog: {
|
|
165
|
+
width: "100%",
|
|
166
|
+
height: "100%",
|
|
167
|
+
borderRadius: theme.border.radius,
|
|
168
|
+
overflow: "hidden"
|
|
169
|
+
},
|
|
170
|
+
above: {
|
|
171
|
+
pointerEvents: "none",
|
|
172
|
+
position: "absolute",
|
|
173
|
+
top: 0,
|
|
174
|
+
left: 0,
|
|
175
|
+
bottom: 0,
|
|
176
|
+
right: 0,
|
|
177
|
+
zIndex: 1
|
|
178
|
+
},
|
|
179
|
+
below: {
|
|
180
|
+
pointerEvents: "none",
|
|
181
|
+
position: "absolute",
|
|
182
|
+
top: 0,
|
|
183
|
+
left: 0,
|
|
184
|
+
bottom: 0,
|
|
185
|
+
right: 0,
|
|
186
|
+
zIndex: -1
|
|
139
187
|
}
|
|
188
|
+
});
|
|
189
|
+
ModalDialog.displayName = "ModalDialog";
|
|
190
|
+
|
|
191
|
+
function ModalFooter({
|
|
192
|
+
children
|
|
193
|
+
}) {
|
|
194
|
+
return React__namespace.createElement(wonderBlocksCore.View, {
|
|
195
|
+
style: styles$2.footer
|
|
196
|
+
}, children);
|
|
140
197
|
}
|
|
141
198
|
ModalFooter.__IS_MODAL_FOOTER__ = true;
|
|
142
|
-
|
|
199
|
+
ModalFooter.isComponentOf = instance => {
|
|
200
|
+
return instance && instance.type && instance.type.__IS_MODAL_FOOTER__;
|
|
201
|
+
};
|
|
202
|
+
const styles$2 = aphrodite.StyleSheet.create({
|
|
143
203
|
footer: {
|
|
144
204
|
flex: "0 0 auto",
|
|
145
205
|
boxSizing: "border-box",
|
|
@@ -156,78 +216,73 @@ const styles$3 = aphrodite.StyleSheet.create({
|
|
|
156
216
|
}
|
|
157
217
|
});
|
|
158
218
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
219
|
+
function ModalHeader(props) {
|
|
220
|
+
const {
|
|
221
|
+
breadcrumbs = undefined,
|
|
222
|
+
light,
|
|
223
|
+
subtitle = undefined,
|
|
224
|
+
testId,
|
|
225
|
+
title,
|
|
226
|
+
titleId
|
|
227
|
+
} = props;
|
|
228
|
+
if (subtitle && breadcrumbs) {
|
|
229
|
+
throw new Error("'subtitle' and 'breadcrumbs' can't be used together");
|
|
230
|
+
}
|
|
231
|
+
const {
|
|
232
|
+
theme
|
|
233
|
+
} = wonderBlocksTheming.useScopedTheme(ModalDialogThemeContext);
|
|
234
|
+
const styles = wonderBlocksTheming.useStyles(themedStylesFn$2, theme);
|
|
235
|
+
return React__namespace.createElement(wonderBlocksCore.View, {
|
|
236
|
+
style: [styles.header, !light && styles.dark],
|
|
237
|
+
testId: testId
|
|
238
|
+
}, breadcrumbs && React__namespace.createElement(wonderBlocksCore.View, {
|
|
239
|
+
style: styles.breadcrumbs
|
|
240
|
+
}, breadcrumbs), React__namespace.createElement(wonderBlocksTypography.HeadingMedium, {
|
|
241
|
+
style: styles.title,
|
|
242
|
+
id: titleId,
|
|
243
|
+
testId: testId && `${testId}-title`
|
|
244
|
+
}, title), subtitle && React__namespace.createElement(wonderBlocksTypography.LabelSmall, {
|
|
245
|
+
style: light && styles.subtitle,
|
|
246
|
+
testId: testId && `${testId}-subtitle`
|
|
247
|
+
}, subtitle));
|
|
248
|
+
}
|
|
249
|
+
const small$1 = "@media (max-width: 767px)";
|
|
250
|
+
const themedStylesFn$2 = theme => ({
|
|
251
|
+
header: {
|
|
252
|
+
boxShadow: `0px 1px 0px ${theme.color.shadow.default}`,
|
|
253
|
+
display: "flex",
|
|
254
|
+
flexDirection: "column",
|
|
255
|
+
minHeight: 66,
|
|
256
|
+
padding: `${theme.spacing.header.medium}px ${theme.spacing.header.large}px`,
|
|
257
|
+
position: "relative",
|
|
258
|
+
width: "100%",
|
|
259
|
+
[small$1]: {
|
|
260
|
+
paddingLeft: theme.spacing.header.small,
|
|
261
|
+
paddingRight: theme.spacing.header.small
|
|
171
262
|
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
263
|
+
},
|
|
264
|
+
dark: {
|
|
265
|
+
background: theme.color.bg.inverse,
|
|
266
|
+
color: theme.color.text.inverse
|
|
267
|
+
},
|
|
268
|
+
breadcrumbs: {
|
|
269
|
+
color: theme.color.text.secondary,
|
|
270
|
+
marginBottom: theme.spacing.header.xsmall
|
|
271
|
+
},
|
|
272
|
+
title: {
|
|
273
|
+
paddingRight: theme.spacing.header.small,
|
|
274
|
+
[small$1]: {
|
|
275
|
+
paddingRight: theme.spacing.header.large
|
|
276
|
+
}
|
|
277
|
+
},
|
|
278
|
+
subtitle: {
|
|
279
|
+
color: theme.color.text.secondary,
|
|
280
|
+
marginTop: theme.spacing.header.xsmall
|
|
189
281
|
}
|
|
190
|
-
}
|
|
282
|
+
});
|
|
191
283
|
ModalHeader.defaultProps = {
|
|
192
284
|
light: true
|
|
193
285
|
};
|
|
194
|
-
const styleSheets$2 = {
|
|
195
|
-
all: aphrodite.StyleSheet.create({
|
|
196
|
-
header: {
|
|
197
|
-
boxShadow: `0px 1px 0px ${Color__default["default"].offBlack16}`,
|
|
198
|
-
display: "flex",
|
|
199
|
-
flexDirection: "column",
|
|
200
|
-
minHeight: 66,
|
|
201
|
-
padding: `${Spacing__default["default"].large_24}px ${Spacing__default["default"].xLarge_32}px`,
|
|
202
|
-
position: "relative",
|
|
203
|
-
width: "100%"
|
|
204
|
-
},
|
|
205
|
-
dark: {
|
|
206
|
-
background: Color__default["default"].darkBlue,
|
|
207
|
-
color: Color__default["default"].white
|
|
208
|
-
},
|
|
209
|
-
breadcrumbs: {
|
|
210
|
-
color: Color__default["default"].offBlack64,
|
|
211
|
-
marginBottom: Spacing__default["default"].xSmall_8
|
|
212
|
-
},
|
|
213
|
-
title: {
|
|
214
|
-
paddingRight: Spacing__default["default"].medium_16
|
|
215
|
-
},
|
|
216
|
-
subtitle: {
|
|
217
|
-
color: Color__default["default"].offBlack64,
|
|
218
|
-
marginTop: Spacing__default["default"].xSmall_8
|
|
219
|
-
}
|
|
220
|
-
}),
|
|
221
|
-
small: aphrodite.StyleSheet.create({
|
|
222
|
-
header: {
|
|
223
|
-
paddingLeft: Spacing__default["default"].medium_16,
|
|
224
|
-
paddingRight: Spacing__default["default"].medium_16
|
|
225
|
-
},
|
|
226
|
-
title: {
|
|
227
|
-
paddingRight: Spacing__default["default"].xLarge_32
|
|
228
|
-
}
|
|
229
|
-
})
|
|
230
|
-
};
|
|
231
286
|
|
|
232
287
|
const FOCUSABLE_ELEMENTS$1 = 'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';
|
|
233
288
|
class FocusTrap extends React__namespace.Component {
|
|
@@ -291,21 +346,6 @@ class FocusTrap extends React__namespace.Component {
|
|
|
291
346
|
}
|
|
292
347
|
}
|
|
293
348
|
|
|
294
|
-
function _extends() {
|
|
295
|
-
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
296
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
297
|
-
var source = arguments[i];
|
|
298
|
-
for (var key in source) {
|
|
299
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
300
|
-
target[key] = source[key];
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
return target;
|
|
305
|
-
};
|
|
306
|
-
return _extends.apply(this, arguments);
|
|
307
|
-
}
|
|
308
|
-
|
|
309
349
|
const ModalLauncherPortalAttributeName = "data-modal-launcher-portal";
|
|
310
350
|
|
|
311
351
|
const FOCUSABLE_ELEMENTS = 'a[href], details, input, textarea, select, button:not([aria-label^="Close"])';
|
|
@@ -367,14 +407,14 @@ class ModalBackdrop extends React__namespace.Component {
|
|
|
367
407
|
[ModalLauncherPortalAttributeName]: true
|
|
368
408
|
};
|
|
369
409
|
return React__namespace.createElement(wonderBlocksCore.View, _extends({
|
|
370
|
-
style: styles$
|
|
410
|
+
style: styles$1.modalPositioner,
|
|
371
411
|
onMouseDown: this.handleMouseDown,
|
|
372
412
|
onMouseUp: this.handleMouseUp,
|
|
373
413
|
testId: testId
|
|
374
414
|
}, backdropProps), children);
|
|
375
415
|
}
|
|
376
416
|
}
|
|
377
|
-
const styles$
|
|
417
|
+
const styles$1 = aphrodite.StyleSheet.create({
|
|
378
418
|
modalPositioner: {
|
|
379
419
|
position: "fixed",
|
|
380
420
|
left: 0,
|
|
@@ -545,7 +585,7 @@ class ModalLauncher extends React__namespace.Component {
|
|
|
545
585
|
closeModal: this.handleCloseModal
|
|
546
586
|
}
|
|
547
587
|
}, renderedChildren, this.state.opened && ReactDOM__namespace.createPortal(React__namespace.createElement(FocusTrap, {
|
|
548
|
-
style: styles
|
|
588
|
+
style: styles.container
|
|
549
589
|
}, React__namespace.createElement(ModalBackdrop, {
|
|
550
590
|
initialFocusId: this.props.initialFocusId,
|
|
551
591
|
testId: this.props.testId,
|
|
@@ -579,59 +619,54 @@ class ModalLauncherKeypressListener extends React__namespace.Component {
|
|
|
579
619
|
return null;
|
|
580
620
|
}
|
|
581
621
|
}
|
|
582
|
-
const styles
|
|
622
|
+
const styles = aphrodite.StyleSheet.create({
|
|
583
623
|
container: {
|
|
584
624
|
zIndex: 1080
|
|
585
625
|
}
|
|
586
626
|
});
|
|
587
627
|
var modalLauncher = wonderBlocksTiming.withActionScheduler(ModalLauncher);
|
|
588
628
|
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
style: [styles.wrapper, scrollOverflow && styles.scrollOverflow]
|
|
605
|
-
}, React__namespace.createElement(wonderBlocksCore.View, {
|
|
606
|
-
style: [styles.content, style]
|
|
607
|
-
}, children)));
|
|
608
|
-
}
|
|
629
|
+
function ModalContent(props) {
|
|
630
|
+
const {
|
|
631
|
+
scrollOverflow,
|
|
632
|
+
style,
|
|
633
|
+
children
|
|
634
|
+
} = props;
|
|
635
|
+
const {
|
|
636
|
+
theme
|
|
637
|
+
} = wonderBlocksTheming.useScopedTheme(ModalDialogThemeContext);
|
|
638
|
+
const styles = wonderBlocksTheming.useStyles(themedStylesFn$1, theme);
|
|
639
|
+
return React__namespace.createElement(wonderBlocksCore.View, {
|
|
640
|
+
style: [styles.wrapper, scrollOverflow && styles.scrollOverflow]
|
|
641
|
+
}, React__namespace.createElement(wonderBlocksCore.View, {
|
|
642
|
+
style: [styles.content, style]
|
|
643
|
+
}, children));
|
|
609
644
|
}
|
|
610
|
-
ModalContent.defaultProps = {
|
|
611
|
-
scrollOverflow: true
|
|
612
|
-
};
|
|
613
645
|
ModalContent.__IS_MODAL_CONTENT__ = true;
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
646
|
+
ModalContent.isComponentOf = instance => {
|
|
647
|
+
return instance && instance.type && instance.type.__IS_MODAL_CONTENT__;
|
|
648
|
+
};
|
|
649
|
+
const small = "@media (max-width: 767px)";
|
|
650
|
+
const themedStylesFn$1 = theme => ({
|
|
651
|
+
wrapper: {
|
|
652
|
+
flex: 1,
|
|
653
|
+
display: "block"
|
|
654
|
+
},
|
|
655
|
+
scrollOverflow: {
|
|
656
|
+
overflow: "auto"
|
|
657
|
+
},
|
|
658
|
+
content: {
|
|
659
|
+
flex: 1,
|
|
660
|
+
minHeight: "100%",
|
|
661
|
+
padding: Spacing__default["default"].xLarge_32,
|
|
662
|
+
boxSizing: "border-box",
|
|
663
|
+
[small]: {
|
|
632
664
|
padding: `${Spacing__default["default"].xLarge_32}px ${Spacing__default["default"].medium_16}px`
|
|
633
665
|
}
|
|
634
|
-
}
|
|
666
|
+
}
|
|
667
|
+
});
|
|
668
|
+
ModalContent.defaultProps = {
|
|
669
|
+
scrollOverflow: true
|
|
635
670
|
};
|
|
636
671
|
|
|
637
672
|
class CloseButton extends React__namespace.Component {
|
|
@@ -661,14 +696,23 @@ class CloseButton extends React__namespace.Component {
|
|
|
661
696
|
}
|
|
662
697
|
}
|
|
663
698
|
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
699
|
+
function ModalPanel({
|
|
700
|
+
closeButtonVisible = true,
|
|
701
|
+
scrollOverflow = true,
|
|
702
|
+
light = true,
|
|
703
|
+
content,
|
|
704
|
+
footer,
|
|
705
|
+
header,
|
|
706
|
+
onClose,
|
|
707
|
+
style,
|
|
708
|
+
testId
|
|
709
|
+
}) {
|
|
710
|
+
const {
|
|
711
|
+
theme
|
|
712
|
+
} = wonderBlocksTheming.useScopedTheme(ModalDialogThemeContext);
|
|
713
|
+
const styles = wonderBlocksTheming.useStyles(themedStylesFn, theme);
|
|
714
|
+
const renderMainContent = React__namespace.useCallback(() => {
|
|
715
|
+
const mainContent = ModalContent.isComponentOf(content) ? content : React__namespace.createElement(ModalContent, null, content);
|
|
672
716
|
if (!mainContent) {
|
|
673
717
|
return mainContent;
|
|
674
718
|
}
|
|
@@ -676,35 +720,24 @@ class ModalPanel extends React__namespace.Component {
|
|
|
676
720
|
scrollOverflow,
|
|
677
721
|
style: [!!footer && styles.hasFooter, mainContent.props.style]
|
|
678
722
|
});
|
|
679
|
-
}
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
const mainContent = this.renderMainContent();
|
|
691
|
-
return React__namespace.createElement(wonderBlocksCore.View, {
|
|
692
|
-
style: [styles.wrapper, !light && styles.dark, style],
|
|
693
|
-
testId: testId && `${testId}-panel`
|
|
694
|
-
}, closeButtonVisible && React__namespace.createElement(CloseButton, {
|
|
695
|
-
light: !light,
|
|
696
|
-
onClick: onClose,
|
|
697
|
-
style: styles.closeButton,
|
|
698
|
-
testId: testId && `${testId}-close`
|
|
699
|
-
}), header, mainContent, !footer || ModalFooter.isClassOf(footer) ? footer : React__namespace.createElement(ModalFooter, null, footer));
|
|
700
|
-
}
|
|
723
|
+
}, [content, footer, scrollOverflow, styles.hasFooter]);
|
|
724
|
+
const mainContent = renderMainContent();
|
|
725
|
+
return React__namespace.createElement(wonderBlocksCore.View, {
|
|
726
|
+
style: [styles.wrapper, !light && styles.dark, style],
|
|
727
|
+
testId: testId && `${testId}-panel`
|
|
728
|
+
}, closeButtonVisible && React__namespace.createElement(CloseButton, {
|
|
729
|
+
light: !light,
|
|
730
|
+
onClick: onClose,
|
|
731
|
+
style: styles.closeButton,
|
|
732
|
+
testId: testId && `${testId}-close`
|
|
733
|
+
}), header, mainContent, !footer || ModalFooter.isComponentOf(footer) ? footer : React__namespace.createElement(ModalFooter, null, footer));
|
|
701
734
|
}
|
|
702
735
|
ModalPanel.defaultProps = {
|
|
703
736
|
closeButtonVisible: true,
|
|
704
737
|
scrollOverflow: true,
|
|
705
738
|
light: true
|
|
706
739
|
};
|
|
707
|
-
const
|
|
740
|
+
const themedStylesFn = theme => ({
|
|
708
741
|
wrapper: {
|
|
709
742
|
flex: "1 1 auto",
|
|
710
743
|
position: "relative",
|
|
@@ -718,16 +751,16 @@ const styles = aphrodite.StyleSheet.create({
|
|
|
718
751
|
},
|
|
719
752
|
closeButton: {
|
|
720
753
|
position: "absolute",
|
|
721
|
-
right:
|
|
722
|
-
top:
|
|
754
|
+
right: theme.spacing.panel.closeButton,
|
|
755
|
+
top: theme.spacing.panel.closeButton,
|
|
723
756
|
zIndex: 1
|
|
724
757
|
},
|
|
725
758
|
dark: {
|
|
726
|
-
background:
|
|
727
|
-
color:
|
|
759
|
+
background: theme.color.bg.inverse,
|
|
760
|
+
color: theme.color.text.inverse
|
|
728
761
|
},
|
|
729
762
|
hasFooter: {
|
|
730
|
-
paddingBottom:
|
|
763
|
+
paddingBottom: theme.spacing.panel.footer
|
|
731
764
|
}
|
|
732
765
|
});
|
|
733
766
|
|