@khanacademy/wonder-blocks-modal 2.1.41 → 2.1.45
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/dist/es/index.js +601 -945
- package/dist/index.js +1089 -1422
- package/package.json +15 -14
- package/src/components/__tests__/modal-backdrop.test.js +35 -51
- package/src/components/__tests__/modal-launcher.test.js +36 -6
- package/src/components/modal-backdrop.js +3 -8
- package/src/components/one-pane-dialog.stories.js +8 -10
- package/src/util/find-focusable-nodes.js +14 -0
- package/src/util/maybe-get-portal-mounted-modal-host-element.test.js +2 -3
- package/src/__tests__/index.test.js +0 -23
package/dist/index.js
CHANGED
|
@@ -82,7 +82,7 @@ module.exports =
|
|
|
82
82
|
/******/
|
|
83
83
|
/******/
|
|
84
84
|
/******/ // Load entry module and return exports
|
|
85
|
-
/******/ return __webpack_require__(__webpack_require__.s =
|
|
85
|
+
/******/ return __webpack_require__(__webpack_require__.s = 25);
|
|
86
86
|
/******/ })
|
|
87
87
|
/************************************************************************/
|
|
88
88
|
/******/ ([
|
|
@@ -129,80 +129,232 @@ module.exports = require("react-dom");
|
|
|
129
129
|
|
|
130
130
|
/***/ }),
|
|
131
131
|
/* 7 */
|
|
132
|
-
/***/ (function(module,
|
|
133
|
-
|
|
134
|
-
module.exports = require("@khanacademy/wonder-blocks-typography");
|
|
135
|
-
|
|
136
|
-
/***/ }),
|
|
137
|
-
/* 8 */
|
|
138
|
-
/***/ (function(module, exports) {
|
|
139
|
-
|
|
140
|
-
module.exports = require("@khanacademy/wonder-blocks-icon");
|
|
132
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
141
133
|
|
|
142
|
-
|
|
143
|
-
/*
|
|
144
|
-
|
|
134
|
+
"use strict";
|
|
135
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return ModalHeader; });
|
|
136
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
|
|
137
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
138
|
+
/* harmony import */ var aphrodite__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3);
|
|
139
|
+
/* harmony import */ var aphrodite__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(aphrodite__WEBPACK_IMPORTED_MODULE_1__);
|
|
140
|
+
/* harmony import */ var _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(4);
|
|
141
|
+
/* harmony import */ var _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2__);
|
|
142
|
+
/* harmony import */ var _khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(2);
|
|
143
|
+
/* harmony import */ var _khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_3__);
|
|
144
|
+
/* harmony import */ var _khanacademy_wonder_blocks_layout__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(5);
|
|
145
|
+
/* harmony import */ var _khanacademy_wonder_blocks_layout__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_layout__WEBPACK_IMPORTED_MODULE_4__);
|
|
146
|
+
/* harmony import */ var _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(1);
|
|
147
|
+
/* harmony import */ var _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_5__);
|
|
148
|
+
/* harmony import */ var _khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(13);
|
|
149
|
+
/* harmony import */ var _khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_6__);
|
|
145
150
|
|
|
146
|
-
module.exports = require("@khanacademy/wonder-blocks-icon-button");
|
|
147
151
|
|
|
148
|
-
/***/ }),
|
|
149
|
-
/* 10 */
|
|
150
|
-
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
151
152
|
|
|
152
|
-
"use strict";
|
|
153
|
-
// ESM COMPAT FLAG
|
|
154
|
-
__webpack_require__.r(__webpack_exports__);
|
|
155
153
|
|
|
156
|
-
// EXPORTS
|
|
157
|
-
__webpack_require__.d(__webpack_exports__, "ModalHeader", function() { return /* reexport */ modal_header_ModalHeader; });
|
|
158
|
-
__webpack_require__.d(__webpack_exports__, "ModalFooter", function() { return /* reexport */ modal_footer_ModalFooter; });
|
|
159
|
-
__webpack_require__.d(__webpack_exports__, "ModalDialog", function() { return /* reexport */ modal_dialog_ModalDialog; });
|
|
160
|
-
__webpack_require__.d(__webpack_exports__, "ModalPanel", function() { return /* reexport */ modal_panel_ModalPanel; });
|
|
161
|
-
__webpack_require__.d(__webpack_exports__, "ModalLauncher", function() { return /* reexport */ modal_launcher_ModalLauncher; });
|
|
162
|
-
__webpack_require__.d(__webpack_exports__, "OnePaneDialog", function() { return /* reexport */ one_pane_dialog_OnePaneDialog; });
|
|
163
|
-
__webpack_require__.d(__webpack_exports__, "maybeGetPortalMountedModalHostElement", function() { return /* reexport */ maybeGetPortalMountedModalHostElement; });
|
|
164
154
|
|
|
165
|
-
// EXTERNAL MODULE: external "react"
|
|
166
|
-
var external_react_ = __webpack_require__(0);
|
|
167
155
|
|
|
168
|
-
// EXTERNAL MODULE: external "aphrodite"
|
|
169
|
-
var external_aphrodite_ = __webpack_require__(3);
|
|
170
156
|
|
|
171
|
-
// EXTERNAL MODULE: external "@khanacademy/wonder-blocks-layout"
|
|
172
|
-
var wonder_blocks_layout_ = __webpack_require__(5);
|
|
173
157
|
|
|
174
|
-
|
|
175
|
-
|
|
158
|
+
/**
|
|
159
|
+
* This is a helper component that is never rendered by itself. It is always
|
|
160
|
+
* pinned to the top of the dialog, is responsive using the same behavior as its
|
|
161
|
+
* parent dialog, and has the following properties:
|
|
162
|
+
* - title
|
|
163
|
+
* - breadcrumb OR subtitle, but not both.
|
|
164
|
+
*
|
|
165
|
+
* **Accessibility notes:**
|
|
166
|
+
*
|
|
167
|
+
* - By default (e.g. using [OnePaneDialog](/#onepanedialog)), `titleId` is
|
|
168
|
+
* populated automatically by the parent container.
|
|
169
|
+
* - If there is a custom Dialog implementation (e.g. `TwoPaneDialog`), the
|
|
170
|
+
* ModalHeader doesn’t have to have the `titleId` prop however this is
|
|
171
|
+
* recommended. It should match the `aria-labelledby` prop of the
|
|
172
|
+
* [ModalDialog](/#modaldialog) component. If you want to see an example of
|
|
173
|
+
* how to generate this ID, check [IDProvider](/#idprovider).
|
|
174
|
+
*
|
|
175
|
+
* **Implementation notes:**
|
|
176
|
+
*
|
|
177
|
+
* If you are creating a custom Dialog, make sure to follow these guidelines:
|
|
178
|
+
* - Make sure to include it as part of [ModalPanel](/#modalpanel) by using the
|
|
179
|
+
* `header` prop.
|
|
180
|
+
* - Add a title (required).
|
|
181
|
+
* - Optionally add a subtitle or breadcrumbs.
|
|
182
|
+
* - We encourage you to add `titleId` (see Accessibility notes).
|
|
183
|
+
* - If the `ModalPanel` has a dark background, make sure to set `light` to
|
|
184
|
+
* `false`.
|
|
185
|
+
* - If you need to create e2e tests, make sure to pass a `testId` prop and
|
|
186
|
+
* add a sufix to scope the testId to this component: e.g.
|
|
187
|
+
* `some-random-id-ModalHeader`. This scope will also be passed to the title
|
|
188
|
+
* and subtitle elements: e.g. `some-random-id-ModalHeader-title`.
|
|
189
|
+
*
|
|
190
|
+
* Example:
|
|
191
|
+
*
|
|
192
|
+
* ```js
|
|
193
|
+
* <ModalHeader
|
|
194
|
+
* title="Sidebar using ModalHeader"
|
|
195
|
+
* subtitle="subtitle"
|
|
196
|
+
* titleId="uniqueTitleId"
|
|
197
|
+
* light={false}
|
|
198
|
+
* />
|
|
199
|
+
* ```
|
|
200
|
+
*/
|
|
201
|
+
class ModalHeader extends react__WEBPACK_IMPORTED_MODULE_0__["Component"] {
|
|
202
|
+
render() {
|
|
203
|
+
const {
|
|
204
|
+
breadcrumbs = undefined,
|
|
205
|
+
light,
|
|
206
|
+
subtitle = undefined,
|
|
207
|
+
testId,
|
|
208
|
+
title,
|
|
209
|
+
titleId
|
|
210
|
+
} = this.props;
|
|
211
|
+
|
|
212
|
+
if (subtitle && breadcrumbs) {
|
|
213
|
+
throw new Error("'subtitle' and 'breadcrumbs' can't be used together");
|
|
214
|
+
}
|
|
176
215
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
216
|
+
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_layout__WEBPACK_IMPORTED_MODULE_4__["MediaLayout"], {
|
|
217
|
+
styleSheets: styleSheets
|
|
218
|
+
}, ({
|
|
219
|
+
styles
|
|
220
|
+
}) => /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_3__["View"], {
|
|
221
|
+
style: [styles.header, !light && styles.dark],
|
|
222
|
+
testId: testId
|
|
223
|
+
}, breadcrumbs && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_3__["View"], {
|
|
224
|
+
style: styles.breadcrumbs
|
|
225
|
+
}, breadcrumbs), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_6__["HeadingMedium"], {
|
|
226
|
+
style: styles.title,
|
|
227
|
+
id: titleId,
|
|
228
|
+
testId: testId && `${testId}-title`
|
|
229
|
+
}, title), subtitle && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_6__["LabelSmall"], {
|
|
230
|
+
style: light && styles.subtitle,
|
|
231
|
+
testId: testId && `${testId}-subtitle`
|
|
232
|
+
}, subtitle)));
|
|
233
|
+
}
|
|
180
234
|
|
|
181
|
-
|
|
182
|
-
|
|
235
|
+
}
|
|
236
|
+
ModalHeader.defaultProps = {
|
|
237
|
+
light: true
|
|
238
|
+
};
|
|
239
|
+
const styleSheets = {
|
|
240
|
+
all: aphrodite__WEBPACK_IMPORTED_MODULE_1__["StyleSheet"].create({
|
|
241
|
+
header: {
|
|
242
|
+
boxShadow: `0px 1px 0px ${_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2___default.a.offBlack16}`,
|
|
243
|
+
display: "flex",
|
|
244
|
+
flexDirection: "column",
|
|
245
|
+
minHeight: 66,
|
|
246
|
+
padding: `${_khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_5___default.a.large_24}px ${_khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_5___default.a.xLarge_32}px`,
|
|
247
|
+
position: "relative",
|
|
248
|
+
width: "100%"
|
|
249
|
+
},
|
|
250
|
+
dark: {
|
|
251
|
+
background: _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2___default.a.darkBlue,
|
|
252
|
+
color: _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2___default.a.white
|
|
253
|
+
},
|
|
254
|
+
breadcrumbs: {
|
|
255
|
+
color: _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2___default.a.offBlack64,
|
|
256
|
+
marginBottom: _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_5___default.a.xSmall_8
|
|
257
|
+
},
|
|
258
|
+
title: {
|
|
259
|
+
// Prevent title from overlapping the close button
|
|
260
|
+
paddingRight: _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_5___default.a.medium_16
|
|
261
|
+
},
|
|
262
|
+
subtitle: {
|
|
263
|
+
color: _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2___default.a.offBlack64,
|
|
264
|
+
marginTop: _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_5___default.a.xSmall_8
|
|
265
|
+
}
|
|
266
|
+
}),
|
|
267
|
+
small: aphrodite__WEBPACK_IMPORTED_MODULE_1__["StyleSheet"].create({
|
|
268
|
+
header: {
|
|
269
|
+
paddingLeft: _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_5___default.a.medium_16,
|
|
270
|
+
paddingRight: _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_5___default.a.medium_16
|
|
271
|
+
},
|
|
272
|
+
title: {
|
|
273
|
+
paddingRight: _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_5___default.a.xLarge_32
|
|
274
|
+
}
|
|
275
|
+
})
|
|
276
|
+
};
|
|
183
277
|
|
|
184
|
-
|
|
278
|
+
/***/ }),
|
|
279
|
+
/* 8 */
|
|
280
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
185
281
|
|
|
186
|
-
|
|
282
|
+
"use strict";
|
|
283
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return ModalFooter; });
|
|
284
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
|
|
285
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
286
|
+
/* harmony import */ var aphrodite__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3);
|
|
287
|
+
/* harmony import */ var aphrodite__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(aphrodite__WEBPACK_IMPORTED_MODULE_1__);
|
|
288
|
+
/* harmony import */ var _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(4);
|
|
289
|
+
/* harmony import */ var _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2__);
|
|
290
|
+
/* harmony import */ var _khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(2);
|
|
291
|
+
/* harmony import */ var _khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_3__);
|
|
292
|
+
/* harmony import */ var _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(1);
|
|
293
|
+
/* harmony import */ var _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_4__);
|
|
187
294
|
|
|
188
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
189
295
|
|
|
190
|
-
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); }
|
|
191
296
|
|
|
192
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
193
297
|
|
|
194
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
195
298
|
|
|
196
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
197
299
|
|
|
198
|
-
|
|
300
|
+
/**
|
|
301
|
+
* Modal footer included after the content.
|
|
302
|
+
*
|
|
303
|
+
* **Implementation notes**:
|
|
304
|
+
*
|
|
305
|
+
* If you are creating a custom Dialog, make sure to follow these guidelines:
|
|
306
|
+
* - Make sure to include it as part of [ModalPanel](/#modalpanel) by using the `footer` prop.
|
|
307
|
+
* - The footer is completely flexible. Meaning the developer needs to add its own custom layout to match design specs.
|
|
308
|
+
*/
|
|
309
|
+
class ModalFooter extends react__WEBPACK_IMPORTED_MODULE_0__["Component"] {
|
|
310
|
+
static isClassOf(instance) {
|
|
311
|
+
return instance && instance.type && instance.type.__IS_MODAL_FOOTER__;
|
|
312
|
+
}
|
|
199
313
|
|
|
200
|
-
|
|
314
|
+
render() {
|
|
315
|
+
const {
|
|
316
|
+
children
|
|
317
|
+
} = this.props;
|
|
318
|
+
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_3__["View"], {
|
|
319
|
+
style: styles.footer
|
|
320
|
+
}, children);
|
|
321
|
+
}
|
|
201
322
|
|
|
202
|
-
|
|
323
|
+
}
|
|
324
|
+
ModalFooter.__IS_MODAL_FOOTER__ = true;
|
|
325
|
+
const styles = aphrodite__WEBPACK_IMPORTED_MODULE_1__["StyleSheet"].create({
|
|
326
|
+
footer: {
|
|
327
|
+
flex: "0 0 auto",
|
|
328
|
+
boxSizing: "border-box",
|
|
329
|
+
minHeight: _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_4___default.a.xxxLarge_64,
|
|
330
|
+
paddingLeft: _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_4___default.a.medium_16,
|
|
331
|
+
paddingRight: _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_4___default.a.medium_16,
|
|
332
|
+
paddingTop: _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_4___default.a.xSmall_8,
|
|
333
|
+
paddingBottom: _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_4___default.a.xSmall_8,
|
|
334
|
+
display: "flex",
|
|
335
|
+
flexDirection: "row",
|
|
336
|
+
alignItems: "center",
|
|
337
|
+
justifyContent: "flex-end",
|
|
338
|
+
boxShadow: `0px -1px 0px ${_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2___default.a.offBlack16}`
|
|
339
|
+
}
|
|
340
|
+
});
|
|
203
341
|
|
|
204
|
-
|
|
342
|
+
/***/ }),
|
|
343
|
+
/* 9 */
|
|
344
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
205
345
|
|
|
346
|
+
"use strict";
|
|
347
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return ModalDialog; });
|
|
348
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
|
|
349
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
350
|
+
/* harmony import */ var aphrodite__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3);
|
|
351
|
+
/* harmony import */ var aphrodite__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(aphrodite__WEBPACK_IMPORTED_MODULE_1__);
|
|
352
|
+
/* harmony import */ var _khanacademy_wonder_blocks_layout__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(5);
|
|
353
|
+
/* harmony import */ var _khanacademy_wonder_blocks_layout__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_layout__WEBPACK_IMPORTED_MODULE_2__);
|
|
354
|
+
/* harmony import */ var _khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(2);
|
|
355
|
+
/* harmony import */ var _khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_3__);
|
|
356
|
+
/* harmony import */ var _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(1);
|
|
357
|
+
/* harmony import */ var _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_4__);
|
|
206
358
|
|
|
207
359
|
|
|
208
360
|
|
|
@@ -219,65 +371,48 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
|
219
371
|
* - If there is a custom Dialog implementation (e.g. `TwoPaneDialog`), the dialog element doesn’t have to have
|
|
220
372
|
* the `aria-labelledby` attribute however this is recommended. It should match the `id` of the dialog title.
|
|
221
373
|
*/
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
374
|
+
class ModalDialog extends react__WEBPACK_IMPORTED_MODULE_0__["Component"] {
|
|
375
|
+
render() {
|
|
376
|
+
const {
|
|
377
|
+
above,
|
|
378
|
+
below,
|
|
379
|
+
role,
|
|
380
|
+
style,
|
|
381
|
+
children,
|
|
382
|
+
testId,
|
|
383
|
+
"aria-labelledby": ariaLabelledBy
|
|
384
|
+
} = this.props;
|
|
385
|
+
const contextValue = {
|
|
386
|
+
ssrSize: "large",
|
|
387
|
+
mediaSpec: _khanacademy_wonder_blocks_layout__WEBPACK_IMPORTED_MODULE_2__["MEDIA_MODAL_SPEC"]
|
|
388
|
+
};
|
|
389
|
+
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_layout__WEBPACK_IMPORTED_MODULE_2__["MediaLayoutContext"].Provider, {
|
|
390
|
+
value: contextValue
|
|
391
|
+
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_layout__WEBPACK_IMPORTED_MODULE_2__["MediaLayout"], {
|
|
392
|
+
styleSheets: styleSheets
|
|
393
|
+
}, ({
|
|
394
|
+
styles
|
|
395
|
+
}) => /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_3__["View"], {
|
|
396
|
+
style: [styles.wrapper, style]
|
|
397
|
+
}, below && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_3__["View"], {
|
|
398
|
+
style: styles.below
|
|
399
|
+
}, below), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_3__["View"], {
|
|
400
|
+
role: role,
|
|
401
|
+
"aria-modal": "true",
|
|
402
|
+
"aria-labelledby": ariaLabelledBy,
|
|
403
|
+
style: styles.dialog,
|
|
404
|
+
testId: testId
|
|
405
|
+
}, children), above && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_3__["View"], {
|
|
406
|
+
style: styles.above
|
|
407
|
+
}, above))));
|
|
231
408
|
}
|
|
232
409
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
value: function render() {
|
|
236
|
-
var _this$props = this.props,
|
|
237
|
-
above = _this$props.above,
|
|
238
|
-
below = _this$props.below,
|
|
239
|
-
role = _this$props.role,
|
|
240
|
-
style = _this$props.style,
|
|
241
|
-
children = _this$props.children,
|
|
242
|
-
testId = _this$props.testId,
|
|
243
|
-
ariaLabelledBy = _this$props["aria-labelledby"];
|
|
244
|
-
var contextValue = {
|
|
245
|
-
ssrSize: "large",
|
|
246
|
-
mediaSpec: wonder_blocks_layout_["MEDIA_MODAL_SPEC"]
|
|
247
|
-
};
|
|
248
|
-
return /*#__PURE__*/external_react_["createElement"](wonder_blocks_layout_["MediaLayoutContext"].Provider, {
|
|
249
|
-
value: contextValue
|
|
250
|
-
}, /*#__PURE__*/external_react_["createElement"](wonder_blocks_layout_["MediaLayout"], {
|
|
251
|
-
styleSheets: styleSheets
|
|
252
|
-
}, function (_ref) {
|
|
253
|
-
var styles = _ref.styles;
|
|
254
|
-
return /*#__PURE__*/external_react_["createElement"](wonder_blocks_core_["View"], {
|
|
255
|
-
style: [styles.wrapper, style]
|
|
256
|
-
}, below && /*#__PURE__*/external_react_["createElement"](wonder_blocks_core_["View"], {
|
|
257
|
-
style: styles.below
|
|
258
|
-
}, below), /*#__PURE__*/external_react_["createElement"](wonder_blocks_core_["View"], {
|
|
259
|
-
role: role,
|
|
260
|
-
"aria-modal": "true",
|
|
261
|
-
"aria-labelledby": ariaLabelledBy,
|
|
262
|
-
style: styles.dialog,
|
|
263
|
-
testId: testId
|
|
264
|
-
}, children), above && /*#__PURE__*/external_react_["createElement"](wonder_blocks_core_["View"], {
|
|
265
|
-
style: styles.above
|
|
266
|
-
}, above));
|
|
267
|
-
}));
|
|
268
|
-
}
|
|
269
|
-
}]);
|
|
270
|
-
|
|
271
|
-
return ModalDialog;
|
|
272
|
-
}(external_react_["Component"]);
|
|
273
|
-
|
|
274
|
-
_defineProperty(modal_dialog_ModalDialog, "defaultProps", {
|
|
410
|
+
}
|
|
411
|
+
ModalDialog.defaultProps = {
|
|
275
412
|
role: "dialog"
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
var styleSheets = {
|
|
280
|
-
all: external_aphrodite_["StyleSheet"].create({
|
|
413
|
+
};
|
|
414
|
+
const styleSheets = {
|
|
415
|
+
all: aphrodite__WEBPACK_IMPORTED_MODULE_1__["StyleSheet"].create({
|
|
281
416
|
wrapper: {
|
|
282
417
|
display: "flex",
|
|
283
418
|
flexDirection: "row",
|
|
@@ -315,41 +450,37 @@ var styleSheets = {
|
|
|
315
450
|
zIndex: -1
|
|
316
451
|
}
|
|
317
452
|
}),
|
|
318
|
-
small:
|
|
453
|
+
small: aphrodite__WEBPACK_IMPORTED_MODULE_1__["StyleSheet"].create({
|
|
319
454
|
wrapper: {
|
|
320
|
-
padding:
|
|
455
|
+
padding: _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_4___default.a.medium_16,
|
|
321
456
|
flexDirection: "column"
|
|
322
457
|
}
|
|
323
458
|
})
|
|
324
459
|
};
|
|
325
|
-
// EXTERNAL MODULE: external "@khanacademy/wonder-blocks-color"
|
|
326
|
-
var wonder_blocks_color_ = __webpack_require__(4);
|
|
327
|
-
var wonder_blocks_color_default = /*#__PURE__*/__webpack_require__.n(wonder_blocks_color_);
|
|
328
|
-
|
|
329
|
-
// CONCATENATED MODULE: ./packages/wonder-blocks-modal/src/components/modal-footer.js
|
|
330
|
-
function modal_footer_typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { modal_footer_typeof = function _typeof(obj) { return typeof obj; }; } else { modal_footer_typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return modal_footer_typeof(obj); }
|
|
331
|
-
|
|
332
|
-
function modal_footer_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
333
|
-
|
|
334
|
-
function modal_footer_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); } }
|
|
335
|
-
|
|
336
|
-
function modal_footer_createClass(Constructor, protoProps, staticProps) { if (protoProps) modal_footer_defineProperties(Constructor.prototype, protoProps); if (staticProps) modal_footer_defineProperties(Constructor, staticProps); return Constructor; }
|
|
337
|
-
|
|
338
|
-
function modal_footer_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) modal_footer_setPrototypeOf(subClass, superClass); }
|
|
339
460
|
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
function modal_footer_possibleConstructorReturn(self, call) { if (call && (modal_footer_typeof(call) === "object" || typeof call === "function")) { return call; } return modal_footer_assertThisInitialized(self); }
|
|
461
|
+
/***/ }),
|
|
462
|
+
/* 10 */
|
|
463
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
345
464
|
|
|
346
|
-
|
|
465
|
+
"use strict";
|
|
466
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return ModalPanel; });
|
|
467
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
|
|
468
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
469
|
+
/* harmony import */ var aphrodite__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3);
|
|
470
|
+
/* harmony import */ var aphrodite__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(aphrodite__WEBPACK_IMPORTED_MODULE_1__);
|
|
471
|
+
/* harmony import */ var _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(4);
|
|
472
|
+
/* harmony import */ var _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2__);
|
|
473
|
+
/* harmony import */ var _khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(2);
|
|
474
|
+
/* harmony import */ var _khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_3__);
|
|
475
|
+
/* harmony import */ var _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(1);
|
|
476
|
+
/* harmony import */ var _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_4__);
|
|
477
|
+
/* harmony import */ var _modal_content_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(14);
|
|
478
|
+
/* harmony import */ var _modal_header_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(7);
|
|
479
|
+
/* harmony import */ var _modal_footer_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(8);
|
|
480
|
+
/* harmony import */ var _close_button_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(22);
|
|
347
481
|
|
|
348
|
-
function modal_footer_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; } }
|
|
349
482
|
|
|
350
|
-
function modal_footer_getPrototypeOf(o) { modal_footer_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return modal_footer_getPrototypeOf(o); }
|
|
351
483
|
|
|
352
|
-
function modal_footer_defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
353
484
|
|
|
354
485
|
|
|
355
486
|
|
|
@@ -358,90 +489,230 @@ function modal_footer_defineProperty(obj, key, value) { if (key in obj) { Object
|
|
|
358
489
|
|
|
359
490
|
|
|
360
491
|
/**
|
|
361
|
-
*
|
|
492
|
+
* ModalPanel is the content container.
|
|
362
493
|
*
|
|
363
|
-
* **Implementation notes
|
|
494
|
+
* **Implementation notes:**
|
|
364
495
|
*
|
|
365
496
|
* If you are creating a custom Dialog, make sure to follow these guidelines:
|
|
366
|
-
* - Make sure to
|
|
367
|
-
* -
|
|
497
|
+
* - Make sure to add this component inside the [ModalDialog](/#modaldialog).
|
|
498
|
+
* - If needed, you can also add a [ModalHeader](/#modalheader) using the
|
|
499
|
+
* `header` prop. Same goes for [ModalFooter](/#modalfooter).
|
|
500
|
+
* - If you need to create e2e tests, make sure to pass a `testId` prop. This
|
|
501
|
+
* will be passed down to this component using a sufix: e.g.
|
|
502
|
+
* `some-random-id-ModalPanel`. This scope will be propagated to the
|
|
503
|
+
* CloseButton element as well: e.g. `some-random-id-CloseButton`.
|
|
504
|
+
*
|
|
505
|
+
* ```js
|
|
506
|
+
* <ModalDialog>
|
|
507
|
+
* <ModalPanel content={"custom content goes here"} />
|
|
508
|
+
* </ModalDialog>
|
|
509
|
+
* ```
|
|
368
510
|
*/
|
|
369
|
-
|
|
370
|
-
|
|
511
|
+
class ModalPanel extends react__WEBPACK_IMPORTED_MODULE_0__["Component"] {
|
|
512
|
+
renderMainContent() {
|
|
513
|
+
const {
|
|
514
|
+
content,
|
|
515
|
+
footer,
|
|
516
|
+
scrollOverflow
|
|
517
|
+
} = this.props;
|
|
518
|
+
const mainContent = _modal_content_js__WEBPACK_IMPORTED_MODULE_5__[/* default */ "a"].isClassOf(content) ? content : /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_modal_content_js__WEBPACK_IMPORTED_MODULE_5__[/* default */ "a"], null, content);
|
|
519
|
+
|
|
520
|
+
if (!mainContent) {
|
|
521
|
+
return mainContent;
|
|
522
|
+
}
|
|
371
523
|
|
|
372
|
-
|
|
524
|
+
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["cloneElement"](mainContent, {
|
|
525
|
+
// Pass the scrollOverflow and header in to the main content
|
|
526
|
+
scrollOverflow,
|
|
527
|
+
// We override the styling of the main content to help position
|
|
528
|
+
// it if there is a footer or close button being
|
|
529
|
+
// shown. We have to do this here as the ModalContent doesn't
|
|
530
|
+
// know about things being positioned around it.
|
|
531
|
+
style: [!!footer && styles.hasFooter, mainContent.props.style]
|
|
532
|
+
});
|
|
533
|
+
}
|
|
373
534
|
|
|
374
|
-
|
|
375
|
-
|
|
535
|
+
render() {
|
|
536
|
+
const {
|
|
537
|
+
closeButtonVisible,
|
|
538
|
+
footer,
|
|
539
|
+
header,
|
|
540
|
+
light,
|
|
541
|
+
onClose,
|
|
542
|
+
style,
|
|
543
|
+
testId
|
|
544
|
+
} = this.props;
|
|
545
|
+
const mainContent = this.renderMainContent();
|
|
546
|
+
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_3__["View"], {
|
|
547
|
+
style: [styles.wrapper, !light && styles.dark, style],
|
|
548
|
+
testId: testId && `${testId}-panel`
|
|
549
|
+
}, closeButtonVisible && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_close_button_js__WEBPACK_IMPORTED_MODULE_8__[/* default */ "a"], {
|
|
550
|
+
light: !light,
|
|
551
|
+
onClick: onClose,
|
|
552
|
+
style: styles.closeButton,
|
|
553
|
+
testId: testId && `${testId}-close`
|
|
554
|
+
}), header, mainContent, !footer || _modal_footer_js__WEBPACK_IMPORTED_MODULE_7__[/* default */ "a"].isClassOf(footer) ? footer : /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_modal_footer_js__WEBPACK_IMPORTED_MODULE_7__[/* default */ "a"], null, footer));
|
|
555
|
+
}
|
|
376
556
|
|
|
377
|
-
|
|
557
|
+
}
|
|
558
|
+
ModalPanel.defaultProps = {
|
|
559
|
+
closeButtonVisible: true,
|
|
560
|
+
scrollOverflow: true,
|
|
561
|
+
light: true
|
|
562
|
+
};
|
|
563
|
+
const styles = aphrodite__WEBPACK_IMPORTED_MODULE_1__["StyleSheet"].create({
|
|
564
|
+
wrapper: {
|
|
565
|
+
flex: "1 1 auto",
|
|
566
|
+
position: "relative",
|
|
567
|
+
display: "flex",
|
|
568
|
+
flexDirection: "column",
|
|
569
|
+
background: "white",
|
|
570
|
+
boxSizing: "border-box",
|
|
571
|
+
overflow: "hidden",
|
|
572
|
+
height: "100%",
|
|
573
|
+
width: "100%"
|
|
574
|
+
},
|
|
575
|
+
closeButton: {
|
|
576
|
+
position: "absolute",
|
|
577
|
+
right: _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_4___default.a.medium_16,
|
|
578
|
+
top: _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_4___default.a.medium_16,
|
|
579
|
+
// This is to allow the button to be tab-ordered before the modal
|
|
580
|
+
// content but still be above the header and content.
|
|
581
|
+
zIndex: 1
|
|
582
|
+
},
|
|
583
|
+
dark: {
|
|
584
|
+
background: _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2___default.a.darkBlue,
|
|
585
|
+
color: _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2___default.a.white
|
|
586
|
+
},
|
|
587
|
+
hasFooter: {
|
|
588
|
+
paddingBottom: _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_4___default.a.xLarge_32
|
|
378
589
|
}
|
|
590
|
+
});
|
|
379
591
|
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
var children = this.props.children;
|
|
384
|
-
return /*#__PURE__*/external_react_["createElement"](wonder_blocks_core_["View"], {
|
|
385
|
-
style: modal_footer_styles.footer
|
|
386
|
-
}, children);
|
|
387
|
-
}
|
|
388
|
-
}], [{
|
|
389
|
-
key: "isClassOf",
|
|
390
|
-
value: function isClassOf(instance) {
|
|
391
|
-
return instance && instance.type && instance.type.__IS_MODAL_FOOTER__;
|
|
392
|
-
}
|
|
393
|
-
}]);
|
|
592
|
+
/***/ }),
|
|
593
|
+
/* 11 */
|
|
594
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
394
595
|
|
|
395
|
-
|
|
396
|
-
|
|
596
|
+
"use strict";
|
|
597
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return ModalLauncherPortalAttributeName; });
|
|
598
|
+
/**
|
|
599
|
+
* The attribute used to identify a modal launcher portal.
|
|
600
|
+
*/
|
|
601
|
+
const ModalLauncherPortalAttributeName = "data-modal-launcher-portal";
|
|
397
602
|
|
|
398
|
-
modal_footer_defineProperty(modal_footer_ModalFooter, "__IS_MODAL_FOOTER__", true);
|
|
399
603
|
|
|
604
|
+
/***/ }),
|
|
605
|
+
/* 12 */
|
|
606
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
400
607
|
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
justifyContent: "flex-end",
|
|
414
|
-
boxShadow: "0px -1px 0px ".concat(wonder_blocks_color_default.a.offBlack16)
|
|
415
|
-
}
|
|
416
|
-
});
|
|
417
|
-
// EXTERNAL MODULE: external "@khanacademy/wonder-blocks-typography"
|
|
418
|
-
var wonder_blocks_typography_ = __webpack_require__(7);
|
|
608
|
+
"use strict";
|
|
609
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
|
|
610
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
611
|
+
|
|
612
|
+
const defaultContext = {
|
|
613
|
+
closeModal: undefined
|
|
614
|
+
};
|
|
615
|
+
/* harmony default export */ __webpack_exports__["a"] = (/*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createContext"](defaultContext));
|
|
616
|
+
|
|
617
|
+
/***/ }),
|
|
618
|
+
/* 13 */
|
|
619
|
+
/***/ (function(module, exports) {
|
|
419
620
|
|
|
420
|
-
|
|
421
|
-
function modal_header_typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { modal_header_typeof = function _typeof(obj) { return typeof obj; }; } else { modal_header_typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return modal_header_typeof(obj); }
|
|
621
|
+
module.exports = require("@khanacademy/wonder-blocks-typography");
|
|
422
622
|
|
|
423
|
-
|
|
623
|
+
/***/ }),
|
|
624
|
+
/* 14 */
|
|
625
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
424
626
|
|
|
425
|
-
|
|
627
|
+
"use strict";
|
|
628
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return ModalContent; });
|
|
629
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
|
|
630
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
631
|
+
/* harmony import */ var aphrodite__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3);
|
|
632
|
+
/* harmony import */ var aphrodite__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(aphrodite__WEBPACK_IMPORTED_MODULE_1__);
|
|
633
|
+
/* harmony import */ var _khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(2);
|
|
634
|
+
/* harmony import */ var _khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_2__);
|
|
635
|
+
/* harmony import */ var _khanacademy_wonder_blocks_layout__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(5);
|
|
636
|
+
/* harmony import */ var _khanacademy_wonder_blocks_layout__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_layout__WEBPACK_IMPORTED_MODULE_3__);
|
|
637
|
+
/* harmony import */ var _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(1);
|
|
638
|
+
/* harmony import */ var _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_4__);
|
|
426
639
|
|
|
427
|
-
function modal_header_createClass(Constructor, protoProps, staticProps) { if (protoProps) modal_header_defineProperties(Constructor.prototype, protoProps); if (staticProps) modal_header_defineProperties(Constructor, staticProps); return Constructor; }
|
|
428
640
|
|
|
429
|
-
function modal_header_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) modal_header_setPrototypeOf(subClass, superClass); }
|
|
430
641
|
|
|
431
|
-
function modal_header_setPrototypeOf(o, p) { modal_header_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return modal_header_setPrototypeOf(o, p); }
|
|
432
642
|
|
|
433
|
-
function modal_header_createSuper(Derived) { var hasNativeReflectConstruct = modal_header_isNativeReflectConstruct(); return function _createSuperInternal() { var Super = modal_header_getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = modal_header_getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return modal_header_possibleConstructorReturn(this, result); }; }
|
|
434
643
|
|
|
435
|
-
function modal_header_possibleConstructorReturn(self, call) { if (call && (modal_header_typeof(call) === "object" || typeof call === "function")) { return call; } return modal_header_assertThisInitialized(self); }
|
|
436
644
|
|
|
437
|
-
|
|
645
|
+
/**
|
|
646
|
+
* The Modal content included after the header
|
|
647
|
+
*/
|
|
648
|
+
class ModalContent extends react__WEBPACK_IMPORTED_MODULE_0__["Component"] {
|
|
649
|
+
static isClassOf(instance) {
|
|
650
|
+
return instance && instance.type && instance.type.__IS_MODAL_CONTENT__;
|
|
651
|
+
}
|
|
438
652
|
|
|
439
|
-
|
|
653
|
+
render() {
|
|
654
|
+
const {
|
|
655
|
+
scrollOverflow,
|
|
656
|
+
style,
|
|
657
|
+
children
|
|
658
|
+
} = this.props;
|
|
659
|
+
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_layout__WEBPACK_IMPORTED_MODULE_3__["MediaLayout"], {
|
|
660
|
+
styleSheets: styleSheets
|
|
661
|
+
}, ({
|
|
662
|
+
styles
|
|
663
|
+
}) => /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_2__["View"], {
|
|
664
|
+
style: [styles.wrapper, scrollOverflow && styles.scrollOverflow]
|
|
665
|
+
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_2__["View"], {
|
|
666
|
+
style: [styles.content, style]
|
|
667
|
+
}, children)));
|
|
668
|
+
}
|
|
440
669
|
|
|
441
|
-
|
|
670
|
+
}
|
|
671
|
+
ModalContent.defaultProps = {
|
|
672
|
+
scrollOverflow: true
|
|
673
|
+
};
|
|
674
|
+
ModalContent.__IS_MODAL_CONTENT__ = true;
|
|
675
|
+
const styleSheets = {
|
|
676
|
+
all: aphrodite__WEBPACK_IMPORTED_MODULE_1__["StyleSheet"].create({
|
|
677
|
+
wrapper: {
|
|
678
|
+
flex: 1,
|
|
679
|
+
// This helps to ensure that the paddingBottom is preserved when
|
|
680
|
+
// the contents start to overflow, this goes away on display: flex
|
|
681
|
+
display: "block"
|
|
682
|
+
},
|
|
683
|
+
scrollOverflow: {
|
|
684
|
+
overflow: "auto"
|
|
685
|
+
},
|
|
686
|
+
content: {
|
|
687
|
+
flex: 1,
|
|
688
|
+
minHeight: "100%",
|
|
689
|
+
padding: _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_4___default.a.xLarge_32,
|
|
690
|
+
boxSizing: "border-box"
|
|
691
|
+
}
|
|
692
|
+
}),
|
|
693
|
+
small: aphrodite__WEBPACK_IMPORTED_MODULE_1__["StyleSheet"].create({
|
|
694
|
+
content: {
|
|
695
|
+
padding: `${_khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_4___default.a.xLarge_32}px ${_khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_4___default.a.medium_16}px`
|
|
696
|
+
}
|
|
697
|
+
})
|
|
698
|
+
};
|
|
442
699
|
|
|
443
|
-
|
|
700
|
+
/***/ }),
|
|
701
|
+
/* 15 */
|
|
702
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
444
703
|
|
|
704
|
+
"use strict";
|
|
705
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return ModalLauncher; });
|
|
706
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
|
|
707
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
708
|
+
/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(6);
|
|
709
|
+
/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react_dom__WEBPACK_IMPORTED_MODULE_1__);
|
|
710
|
+
/* harmony import */ var aphrodite__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(3);
|
|
711
|
+
/* harmony import */ var aphrodite__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(aphrodite__WEBPACK_IMPORTED_MODULE_2__);
|
|
712
|
+
/* harmony import */ var _focus_trap_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(18);
|
|
713
|
+
/* harmony import */ var _modal_backdrop_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(19);
|
|
714
|
+
/* harmony import */ var _scroll_disabler_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(21);
|
|
715
|
+
/* harmony import */ var _modal_context_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(12);
|
|
445
716
|
|
|
446
717
|
|
|
447
718
|
|
|
@@ -451,180 +722,362 @@ function modal_header_defineProperty(obj, key, value) { if (key in obj) { Object
|
|
|
451
722
|
|
|
452
723
|
|
|
453
724
|
/**
|
|
454
|
-
* This
|
|
455
|
-
* pinned to the top of the dialog, is responsive using the same behavior as its
|
|
456
|
-
* parent dialog, and has the following properties:
|
|
457
|
-
* - title
|
|
458
|
-
* - breadcrumb OR subtitle, but not both.
|
|
459
|
-
*
|
|
460
|
-
* **Accessibility notes:**
|
|
461
|
-
*
|
|
462
|
-
* - By default (e.g. using [OnePaneDialog](/#onepanedialog)), `titleId` is
|
|
463
|
-
* populated automatically by the parent container.
|
|
464
|
-
* - If there is a custom Dialog implementation (e.g. `TwoPaneDialog`), the
|
|
465
|
-
* ModalHeader doesn’t have to have the `titleId` prop however this is
|
|
466
|
-
* recommended. It should match the `aria-labelledby` prop of the
|
|
467
|
-
* [ModalDialog](/#modaldialog) component. If you want to see an example of
|
|
468
|
-
* how to generate this ID, check [IDProvider](/#idprovider).
|
|
469
|
-
*
|
|
470
|
-
* **Implementation notes:**
|
|
471
|
-
*
|
|
472
|
-
* If you are creating a custom Dialog, make sure to follow these guidelines:
|
|
473
|
-
* - Make sure to include it as part of [ModalPanel](/#modalpanel) by using the
|
|
474
|
-
* `header` prop.
|
|
475
|
-
* - Add a title (required).
|
|
476
|
-
* - Optionally add a subtitle or breadcrumbs.
|
|
477
|
-
* - We encourage you to add `titleId` (see Accessibility notes).
|
|
478
|
-
* - If the `ModalPanel` has a dark background, make sure to set `light` to
|
|
479
|
-
* `false`.
|
|
480
|
-
* - If you need to create e2e tests, make sure to pass a `testId` prop and
|
|
481
|
-
* add a sufix to scope the testId to this component: e.g.
|
|
482
|
-
* `some-random-id-ModalHeader`. This scope will also be passed to the title
|
|
483
|
-
* and subtitle elements: e.g. `some-random-id-ModalHeader-title`.
|
|
725
|
+
* This component enables you to launch a modal, covering the screen.
|
|
484
726
|
*
|
|
485
|
-
*
|
|
727
|
+
* Children have access to `openModal` function via the function-as-children
|
|
728
|
+
* pattern, so one common use case is for this component to wrap a button:
|
|
486
729
|
*
|
|
487
730
|
* ```js
|
|
488
|
-
* <
|
|
489
|
-
*
|
|
490
|
-
*
|
|
491
|
-
* titleId="uniqueTitleId"
|
|
492
|
-
* light={false}
|
|
493
|
-
* />
|
|
731
|
+
* <ModalLauncher modal={<TwoColumnModal ... />}>
|
|
732
|
+
* {({openModal}) => <button onClick={openModal}>Learn more</button>}
|
|
733
|
+
* </ModalLauncher>
|
|
494
734
|
* ```
|
|
735
|
+
*
|
|
736
|
+
* The actual modal itself is constructed separately, using a layout component
|
|
737
|
+
* like OnePaneDialog and is provided via
|
|
738
|
+
* the `modal` prop.
|
|
495
739
|
*/
|
|
496
|
-
|
|
497
|
-
|
|
740
|
+
class ModalLauncher extends react__WEBPACK_IMPORTED_MODULE_0__["Component"] {
|
|
741
|
+
constructor(...args) {
|
|
742
|
+
super(...args);
|
|
743
|
+
this.state = {
|
|
744
|
+
opened: false
|
|
745
|
+
};
|
|
498
746
|
|
|
499
|
-
|
|
747
|
+
this._saveLastElementFocused = () => {
|
|
748
|
+
// keep a reference of the element that triggers the modal
|
|
749
|
+
this.lastElementFocusedOutsideModal = document.activeElement;
|
|
750
|
+
};
|
|
500
751
|
|
|
501
|
-
|
|
502
|
-
|
|
752
|
+
this._openModal = () => {
|
|
753
|
+
this._saveLastElementFocused();
|
|
503
754
|
|
|
504
|
-
|
|
505
|
-
|
|
755
|
+
this.setState({
|
|
756
|
+
opened: true
|
|
757
|
+
});
|
|
758
|
+
};
|
|
506
759
|
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
breadcrumbs = _this$props$breadcrum === void 0 ? undefined : _this$props$breadcrum,
|
|
513
|
-
light = _this$props.light,
|
|
514
|
-
_this$props$subtitle = _this$props.subtitle,
|
|
515
|
-
subtitle = _this$props$subtitle === void 0 ? undefined : _this$props$subtitle,
|
|
516
|
-
testId = _this$props.testId,
|
|
517
|
-
title = _this$props.title,
|
|
518
|
-
titleId = _this$props.titleId;
|
|
519
|
-
|
|
520
|
-
if (subtitle && breadcrumbs) {
|
|
521
|
-
throw new Error("'subtitle' and 'breadcrumbs' can't be used together");
|
|
522
|
-
}
|
|
760
|
+
this.handleCloseModal = () => {
|
|
761
|
+
this.setState({
|
|
762
|
+
opened: false
|
|
763
|
+
}, () => {
|
|
764
|
+
this.props.onClose && this.props.onClose();
|
|
523
765
|
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
return /*#__PURE__*/external_react_["createElement"](wonder_blocks_core_["View"], {
|
|
529
|
-
style: [styles.header, !light && styles.dark],
|
|
530
|
-
testId: testId
|
|
531
|
-
}, breadcrumbs && /*#__PURE__*/external_react_["createElement"](wonder_blocks_core_["View"], {
|
|
532
|
-
style: styles.breadcrumbs
|
|
533
|
-
}, breadcrumbs), /*#__PURE__*/external_react_["createElement"](wonder_blocks_typography_["HeadingMedium"], {
|
|
534
|
-
style: styles.title,
|
|
535
|
-
id: titleId,
|
|
536
|
-
testId: testId && "".concat(testId, "-title")
|
|
537
|
-
}, title), subtitle && /*#__PURE__*/external_react_["createElement"](wonder_blocks_typography_["LabelSmall"], {
|
|
538
|
-
style: light && styles.subtitle,
|
|
539
|
-
testId: testId && "".concat(testId, "-subtitle")
|
|
540
|
-
}, subtitle));
|
|
766
|
+
if (this.lastElementFocusedOutsideModal != null) {
|
|
767
|
+
// return focus to the element that triggered the modal
|
|
768
|
+
this.lastElementFocusedOutsideModal.focus();
|
|
769
|
+
}
|
|
541
770
|
});
|
|
771
|
+
};
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
static getDerivedStateFromProps(props, state) {
|
|
775
|
+
if (typeof props.opened === "boolean" && props.children) {
|
|
776
|
+
// eslint-disable-next-line no-console
|
|
777
|
+
console.warn("'children' and 'opened' can't be used together");
|
|
542
778
|
}
|
|
543
|
-
}]);
|
|
544
779
|
|
|
545
|
-
|
|
546
|
-
|
|
780
|
+
if (typeof props.opened === "boolean" && !props.onClose) {
|
|
781
|
+
// eslint-disable-next-line no-console
|
|
782
|
+
console.warn("'onClose' should be used with 'opened'");
|
|
783
|
+
}
|
|
547
784
|
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
785
|
+
if (typeof props.opened !== "boolean" && !props.children) {
|
|
786
|
+
// eslint-disable-next-line no-console
|
|
787
|
+
console.warn("either 'children' or 'opened' must be set");
|
|
788
|
+
}
|
|
551
789
|
|
|
790
|
+
return {
|
|
791
|
+
opened: typeof props.opened === "boolean" ? props.opened : state.opened
|
|
792
|
+
};
|
|
793
|
+
}
|
|
552
794
|
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
display: "flex",
|
|
558
|
-
flexDirection: "column",
|
|
559
|
-
minHeight: 66,
|
|
560
|
-
padding: "".concat(wonder_blocks_spacing_default.a.large_24, "px ").concat(wonder_blocks_spacing_default.a.xLarge_32, "px"),
|
|
561
|
-
position: "relative",
|
|
562
|
-
width: "100%"
|
|
563
|
-
},
|
|
564
|
-
dark: {
|
|
565
|
-
background: wonder_blocks_color_default.a.darkBlue,
|
|
566
|
-
color: wonder_blocks_color_default.a.white
|
|
567
|
-
},
|
|
568
|
-
breadcrumbs: {
|
|
569
|
-
color: wonder_blocks_color_default.a.offBlack64,
|
|
570
|
-
marginBottom: wonder_blocks_spacing_default.a.xSmall_8
|
|
571
|
-
},
|
|
572
|
-
title: {
|
|
573
|
-
// Prevent title from overlapping the close button
|
|
574
|
-
paddingRight: wonder_blocks_spacing_default.a.medium_16
|
|
575
|
-
},
|
|
576
|
-
subtitle: {
|
|
577
|
-
color: wonder_blocks_color_default.a.offBlack64,
|
|
578
|
-
marginTop: wonder_blocks_spacing_default.a.xSmall_8
|
|
795
|
+
componentDidUpdate(prevProps) {
|
|
796
|
+
// ensures the element is stored only when the modal is opened
|
|
797
|
+
if (!prevProps.opened && this.props.opened) {
|
|
798
|
+
this._saveLastElementFocused();
|
|
579
799
|
}
|
|
580
|
-
}
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
_renderModal() {
|
|
803
|
+
if (typeof this.props.modal === "function") {
|
|
804
|
+
return this.props.modal({
|
|
805
|
+
closeModal: this.handleCloseModal
|
|
806
|
+
});
|
|
807
|
+
} else {
|
|
808
|
+
return this.props.modal;
|
|
588
809
|
}
|
|
589
|
-
}
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
render() {
|
|
813
|
+
const renderedChildren = this.props.children ? this.props.children({
|
|
814
|
+
openModal: this._openModal
|
|
815
|
+
}) : null;
|
|
816
|
+
const {
|
|
817
|
+
body
|
|
818
|
+
} = document;
|
|
819
|
+
|
|
820
|
+
if (!body) {
|
|
821
|
+
return null;
|
|
822
|
+
}
|
|
823
|
+
|
|
824
|
+
return (
|
|
825
|
+
/*#__PURE__*/
|
|
826
|
+
// This flow check is valid, it's the babel plugin which is broken,
|
|
827
|
+
// see modal-context.js for details.
|
|
828
|
+
// $FlowFixMe
|
|
829
|
+
react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_modal_context_js__WEBPACK_IMPORTED_MODULE_6__[/* default */ "a"].Provider, {
|
|
830
|
+
value: {
|
|
831
|
+
closeModal: this.handleCloseModal
|
|
832
|
+
}
|
|
833
|
+
}, renderedChildren, this.state.opened && /*#__PURE__*/react_dom__WEBPACK_IMPORTED_MODULE_1__["createPortal"](
|
|
834
|
+
/*#__PURE__*/
|
|
835
|
+
|
|
836
|
+
/* We need the container View that FocusTrap creates to be at the
|
|
837
|
+
correct z-index so that it'll be above the global nav in webapp. */
|
|
838
|
+
react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_focus_trap_js__WEBPACK_IMPORTED_MODULE_3__[/* default */ "a"], {
|
|
839
|
+
style: styles.container
|
|
840
|
+
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_modal_backdrop_js__WEBPACK_IMPORTED_MODULE_4__[/* default */ "a"], {
|
|
841
|
+
initialFocusId: this.props.initialFocusId,
|
|
842
|
+
testId: this.props.testId,
|
|
843
|
+
onCloseModal: this.props.backdropDismissEnabled ? this.handleCloseModal : () => {}
|
|
844
|
+
}, this._renderModal())), body), this.state.opened && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](ModalLauncherKeypressListener, {
|
|
845
|
+
onClose: this.handleCloseModal
|
|
846
|
+
}), this.state.opened && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_scroll_disabler_js__WEBPACK_IMPORTED_MODULE_5__[/* default */ "a"], null))
|
|
847
|
+
);
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
}
|
|
851
|
+
/** A component that, when mounted, calls `onClose` when Escape is pressed. */
|
|
852
|
+
|
|
853
|
+
ModalLauncher.defaultProps = {
|
|
854
|
+
backdropDismissEnabled: true
|
|
590
855
|
};
|
|
591
|
-
// EXTERNAL MODULE: external "react-dom"
|
|
592
|
-
var external_react_dom_ = __webpack_require__(6);
|
|
593
856
|
|
|
594
|
-
|
|
595
|
-
|
|
857
|
+
class ModalLauncherKeypressListener extends react__WEBPACK_IMPORTED_MODULE_0__["Component"] {
|
|
858
|
+
constructor(...args) {
|
|
859
|
+
super(...args);
|
|
860
|
+
|
|
861
|
+
this._handleKeyup = e => {
|
|
862
|
+
// We check the key as that's keyboard layout agnostic and also avoids
|
|
863
|
+
// the minefield of deprecated number type properties like keyCode and
|
|
864
|
+
// which, with the replacement code, which uses a string instead.
|
|
865
|
+
if (e.key === "Escape") {
|
|
866
|
+
// Stop the event going any further.
|
|
867
|
+
// For cancellation events, like the Escape key, we generally should
|
|
868
|
+
// air on the side of caution and only allow it to cancel one thing.
|
|
869
|
+
// So, it's polite for us to stop propagation of the event.
|
|
870
|
+
// Otherwise, we end up with UX where one Escape key press
|
|
871
|
+
// unexpectedly cancels multiple things.
|
|
872
|
+
e.preventDefault();
|
|
873
|
+
e.stopPropagation();
|
|
874
|
+
this.props.onClose();
|
|
875
|
+
}
|
|
876
|
+
};
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
componentDidMount() {
|
|
880
|
+
window.addEventListener("keyup", this._handleKeyup);
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
componentWillUnmount() {
|
|
884
|
+
window.removeEventListener("keyup", this._handleKeyup);
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
render() {
|
|
888
|
+
return null;
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
const styles = aphrodite__WEBPACK_IMPORTED_MODULE_2__["StyleSheet"].create({
|
|
894
|
+
container: {
|
|
895
|
+
// This z-index is copied from the Khan Academy webapp.
|
|
896
|
+
//
|
|
897
|
+
// TODO(mdr): Should we keep this in a constants file somewhere? Or
|
|
898
|
+
// not hardcode it at all, and provide it to Wonder Blocks via
|
|
899
|
+
// configuration?
|
|
900
|
+
zIndex: 1080
|
|
901
|
+
}
|
|
902
|
+
});
|
|
903
|
+
|
|
904
|
+
/***/ }),
|
|
905
|
+
/* 16 */
|
|
906
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
907
|
+
|
|
908
|
+
"use strict";
|
|
909
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return OnePaneDialog; });
|
|
910
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
|
|
911
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
912
|
+
/* harmony import */ var aphrodite__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3);
|
|
913
|
+
/* harmony import */ var aphrodite__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(aphrodite__WEBPACK_IMPORTED_MODULE_1__);
|
|
914
|
+
/* harmony import */ var _khanacademy_wonder_blocks_layout__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(5);
|
|
915
|
+
/* harmony import */ var _khanacademy_wonder_blocks_layout__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_layout__WEBPACK_IMPORTED_MODULE_2__);
|
|
916
|
+
/* harmony import */ var _khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(2);
|
|
917
|
+
/* harmony import */ var _khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_3__);
|
|
918
|
+
/* harmony import */ var _modal_dialog_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(9);
|
|
919
|
+
/* harmony import */ var _modal_panel_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(10);
|
|
920
|
+
/* harmony import */ var _modal_header_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(7);
|
|
921
|
+
|
|
922
|
+
|
|
923
|
+
|
|
596
924
|
|
|
597
|
-
function focus_trap_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
598
925
|
|
|
599
|
-
function focus_trap_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); } }
|
|
600
926
|
|
|
601
|
-
function focus_trap_createClass(Constructor, protoProps, staticProps) { if (protoProps) focus_trap_defineProperties(Constructor.prototype, protoProps); if (staticProps) focus_trap_defineProperties(Constructor, staticProps); return Constructor; }
|
|
602
927
|
|
|
603
|
-
function focus_trap_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) focus_trap_setPrototypeOf(subClass, superClass); }
|
|
604
928
|
|
|
605
|
-
|
|
929
|
+
/**
|
|
930
|
+
* This is the standard layout for most straightforward modal experiences.
|
|
931
|
+
*
|
|
932
|
+
* The ModalHeader is required, but the ModalFooter is optional.
|
|
933
|
+
* The content of the dialog itself is fully customizable, but the left/right/top/bottom padding is fixed.
|
|
934
|
+
*/
|
|
935
|
+
class OnePaneDialog extends react__WEBPACK_IMPORTED_MODULE_0__["Component"] {
|
|
936
|
+
renderHeader(uniqueId) {
|
|
937
|
+
const {
|
|
938
|
+
title,
|
|
939
|
+
breadcrumbs = undefined,
|
|
940
|
+
subtitle = undefined,
|
|
941
|
+
testId
|
|
942
|
+
} = this.props;
|
|
943
|
+
|
|
944
|
+
if (breadcrumbs) {
|
|
945
|
+
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_modal_header_js__WEBPACK_IMPORTED_MODULE_6__[/* default */ "a"], {
|
|
946
|
+
title: title,
|
|
947
|
+
breadcrumbs: breadcrumbs,
|
|
948
|
+
titleId: uniqueId,
|
|
949
|
+
testId: testId && `${testId}-header`
|
|
950
|
+
});
|
|
951
|
+
} else if (subtitle) {
|
|
952
|
+
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_modal_header_js__WEBPACK_IMPORTED_MODULE_6__[/* default */ "a"], {
|
|
953
|
+
title: title,
|
|
954
|
+
subtitle: subtitle,
|
|
955
|
+
titleId: uniqueId,
|
|
956
|
+
testId: testId && `${testId}-header`
|
|
957
|
+
});
|
|
958
|
+
} else {
|
|
959
|
+
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_modal_header_js__WEBPACK_IMPORTED_MODULE_6__[/* default */ "a"], {
|
|
960
|
+
title: title,
|
|
961
|
+
titleId: uniqueId,
|
|
962
|
+
testId: testId && `${testId}-header`
|
|
963
|
+
});
|
|
964
|
+
}
|
|
965
|
+
}
|
|
966
|
+
|
|
967
|
+
render() {
|
|
968
|
+
const {
|
|
969
|
+
onClose,
|
|
970
|
+
footer,
|
|
971
|
+
content,
|
|
972
|
+
above,
|
|
973
|
+
below,
|
|
974
|
+
style,
|
|
975
|
+
closeButtonVisible,
|
|
976
|
+
testId,
|
|
977
|
+
titleId,
|
|
978
|
+
role
|
|
979
|
+
} = this.props;
|
|
980
|
+
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_layout__WEBPACK_IMPORTED_MODULE_2__["MediaLayout"], {
|
|
981
|
+
styleSheets: styleSheets
|
|
982
|
+
}, ({
|
|
983
|
+
styles
|
|
984
|
+
}) => /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_3__["IDProvider"], {
|
|
985
|
+
id: titleId,
|
|
986
|
+
scope: "modal"
|
|
987
|
+
}, uniqueId => /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_modal_dialog_js__WEBPACK_IMPORTED_MODULE_4__[/* default */ "a"], {
|
|
988
|
+
style: [styles.dialog, style],
|
|
989
|
+
above: above,
|
|
990
|
+
below: below,
|
|
991
|
+
testId: testId,
|
|
992
|
+
"aria-labelledby": uniqueId,
|
|
993
|
+
role: role
|
|
994
|
+
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_modal_panel_js__WEBPACK_IMPORTED_MODULE_5__[/* default */ "a"], {
|
|
995
|
+
onClose: onClose,
|
|
996
|
+
header: this.renderHeader(uniqueId),
|
|
997
|
+
content: content,
|
|
998
|
+
footer: footer,
|
|
999
|
+
closeButtonVisible: closeButtonVisible,
|
|
1000
|
+
testId: testId
|
|
1001
|
+
}))));
|
|
1002
|
+
}
|
|
1003
|
+
|
|
1004
|
+
}
|
|
1005
|
+
OnePaneDialog.defaultProps = {
|
|
1006
|
+
closeButtonVisible: true
|
|
1007
|
+
};
|
|
1008
|
+
const styleSheets = {
|
|
1009
|
+
small: aphrodite__WEBPACK_IMPORTED_MODULE_1__["StyleSheet"].create({
|
|
1010
|
+
dialog: {
|
|
1011
|
+
width: "100%",
|
|
1012
|
+
height: "100%",
|
|
1013
|
+
overflow: "hidden"
|
|
1014
|
+
}
|
|
1015
|
+
}),
|
|
1016
|
+
mdOrLarger: aphrodite__WEBPACK_IMPORTED_MODULE_1__["StyleSheet"].create({
|
|
1017
|
+
dialog: {
|
|
1018
|
+
width: "93.75%",
|
|
1019
|
+
maxWidth: 576,
|
|
1020
|
+
height: "81.25%",
|
|
1021
|
+
maxHeight: 624
|
|
1022
|
+
}
|
|
1023
|
+
})
|
|
1024
|
+
};
|
|
606
1025
|
|
|
607
|
-
|
|
1026
|
+
/***/ }),
|
|
1027
|
+
/* 17 */
|
|
1028
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
608
1029
|
|
|
609
|
-
|
|
1030
|
+
"use strict";
|
|
1031
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return maybeGetPortalMountedModalHostElement; });
|
|
1032
|
+
/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(11);
|
|
610
1033
|
|
|
611
|
-
|
|
1034
|
+
/**
|
|
1035
|
+
* From a given element, finds its next ancestor that is a modal launcher portal
|
|
1036
|
+
* element.
|
|
1037
|
+
* @param {?(Element | Text)} element The element whose ancestors are to be
|
|
1038
|
+
* walked.
|
|
1039
|
+
* @returns {?Element} The nearest parent modal launcher portal.
|
|
1040
|
+
*/
|
|
612
1041
|
|
|
613
|
-
function
|
|
1042
|
+
function maybeGetNextAncestorModalLauncherPortal(element) {
|
|
1043
|
+
let candidateElement = element && element.parentElement;
|
|
614
1044
|
|
|
615
|
-
|
|
1045
|
+
while (candidateElement && !candidateElement.hasAttribute(_constants_js__WEBPACK_IMPORTED_MODULE_0__[/* ModalLauncherPortalAttributeName */ "a"])) {
|
|
1046
|
+
candidateElement = candidateElement.parentElement;
|
|
1047
|
+
}
|
|
616
1048
|
|
|
617
|
-
|
|
1049
|
+
return candidateElement;
|
|
1050
|
+
}
|
|
1051
|
+
/**
|
|
1052
|
+
* From a given element, finds the next modal host that has been mounted in
|
|
1053
|
+
* a modal portal.
|
|
1054
|
+
* @param {?(Element | Text)} element The element whose ancestors are to be
|
|
1055
|
+
* walked.
|
|
1056
|
+
* @returns {?Element} The next portal-mounted modal host element.
|
|
1057
|
+
* TODO(kevinb): look into getting rid of this
|
|
1058
|
+
*/
|
|
618
1059
|
|
|
619
1060
|
|
|
1061
|
+
function maybeGetPortalMountedModalHostElement(element) {
|
|
1062
|
+
return maybeGetNextAncestorModalLauncherPortal(element);
|
|
1063
|
+
}
|
|
620
1064
|
|
|
1065
|
+
/***/ }),
|
|
1066
|
+
/* 18 */
|
|
1067
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
621
1068
|
|
|
1069
|
+
"use strict";
|
|
1070
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return FocusTrap; });
|
|
1071
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
|
|
1072
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
1073
|
+
/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(6);
|
|
1074
|
+
/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react_dom__WEBPACK_IMPORTED_MODULE_1__);
|
|
1075
|
+
/* harmony import */ var _khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(2);
|
|
1076
|
+
/* harmony import */ var _khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_2__);
|
|
622
1077
|
|
|
623
|
-
var focus_trap_FocusTrap = /*#__PURE__*/function (_React$Component) {
|
|
624
|
-
focus_trap_inherits(FocusTrap, _React$Component);
|
|
625
1078
|
|
|
626
|
-
var _super = focus_trap_createSuper(FocusTrap);
|
|
627
1079
|
|
|
1080
|
+
class FocusTrap extends react__WEBPACK_IMPORTED_MODULE_0__["Component"] {
|
|
628
1081
|
/** The most recent node _inside this component_ to receive focus. */
|
|
629
1082
|
|
|
630
1083
|
/**
|
|
@@ -635,49 +1088,39 @@ var focus_trap_FocusTrap = /*#__PURE__*/function (_React$Component) {
|
|
|
635
1088
|
/**
|
|
636
1089
|
* Tabbing is restricted to descendents of this element.
|
|
637
1090
|
*/
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
focus_trap_classCallCheck(this, FocusTrap);
|
|
642
|
-
|
|
643
|
-
_this = _super.call(this, props);
|
|
644
|
-
|
|
645
|
-
focus_trap_defineProperty(focus_trap_assertThisInitialized(_this), "lastNodeFocusedInModal", void 0);
|
|
646
|
-
|
|
647
|
-
focus_trap_defineProperty(focus_trap_assertThisInitialized(_this), "ignoreFocusChanges", void 0);
|
|
1091
|
+
constructor(props) {
|
|
1092
|
+
super(props);
|
|
648
1093
|
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
focus_trap_defineProperty(focus_trap_assertThisInitialized(_this), "getModalRoot", function (node) {
|
|
1094
|
+
this.getModalRoot = node => {
|
|
652
1095
|
if (!node) {
|
|
653
1096
|
// The component is being umounted
|
|
654
1097
|
return;
|
|
655
1098
|
}
|
|
656
1099
|
|
|
657
|
-
|
|
1100
|
+
const modalRoot = react_dom__WEBPACK_IMPORTED_MODULE_1__["findDOMNode"](node);
|
|
658
1101
|
|
|
659
1102
|
if (!modalRoot) {
|
|
660
1103
|
throw new Error("Assertion error: modal root should exist after mount");
|
|
661
1104
|
}
|
|
662
1105
|
|
|
663
|
-
|
|
664
|
-
}
|
|
1106
|
+
this.modalRoot = modalRoot;
|
|
1107
|
+
};
|
|
665
1108
|
|
|
666
|
-
|
|
1109
|
+
this.handleGlobalFocus = e => {
|
|
667
1110
|
// If we're busy applying our own programmatic focus, we ignore focus
|
|
668
1111
|
// changes, to avoid an infinite loop.
|
|
669
|
-
if (
|
|
1112
|
+
if (this.ignoreFocusChanges) {
|
|
670
1113
|
return;
|
|
671
1114
|
}
|
|
672
1115
|
|
|
673
|
-
|
|
1116
|
+
const target = e.target;
|
|
674
1117
|
|
|
675
1118
|
if (!(target instanceof Node)) {
|
|
676
1119
|
// Sometimes focus events trigger on the document itself. Ignore!
|
|
677
1120
|
return;
|
|
678
1121
|
}
|
|
679
1122
|
|
|
680
|
-
|
|
1123
|
+
const modalRoot = this.modalRoot;
|
|
681
1124
|
|
|
682
1125
|
if (!modalRoot) {
|
|
683
1126
|
return;
|
|
@@ -686,164 +1129,141 @@ var focus_trap_FocusTrap = /*#__PURE__*/function (_React$Component) {
|
|
|
686
1129
|
if (modalRoot.contains(target)) {
|
|
687
1130
|
// If the newly focused node is inside the modal, we just keep track
|
|
688
1131
|
// of that.
|
|
689
|
-
|
|
1132
|
+
this.lastNodeFocusedInModal = target;
|
|
690
1133
|
} else {
|
|
691
1134
|
// If the newly focused node is outside the modal, we try refocusing
|
|
692
1135
|
// the first focusable node of the modal. (This could be the user
|
|
693
1136
|
// pressing Tab on the last node of the modal, or focus escaping in
|
|
694
1137
|
// some other way.)
|
|
695
|
-
|
|
1138
|
+
this.focusFirstElementIn(modalRoot); // But, if it turns out that the first focusable node of the modal
|
|
696
1139
|
// was what we were previously focusing, then this is probably the
|
|
697
1140
|
// user pressing Shift-Tab on the first node, wanting to go to the
|
|
698
1141
|
// end. So, we instead try focusing the last focusable node of the
|
|
699
1142
|
// modal.
|
|
700
1143
|
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
_this.focusLastElementIn(modalRoot);
|
|
1144
|
+
if (document.activeElement === this.lastNodeFocusedInModal) {
|
|
1145
|
+
this.focusLastElementIn(modalRoot);
|
|
704
1146
|
} // Focus should now be inside the modal, so record the newly-focused
|
|
705
1147
|
// node as the last node focused in the modal.
|
|
706
1148
|
|
|
707
1149
|
|
|
708
|
-
|
|
1150
|
+
this.lastNodeFocusedInModal = document.activeElement;
|
|
709
1151
|
}
|
|
710
|
-
}
|
|
1152
|
+
};
|
|
711
1153
|
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
return _this;
|
|
1154
|
+
this.lastNodeFocusedInModal = null;
|
|
1155
|
+
this.ignoreFocusChanges = false;
|
|
715
1156
|
}
|
|
716
1157
|
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
window.addEventListener("focus", this.handleGlobalFocus, true);
|
|
721
|
-
}
|
|
722
|
-
}, {
|
|
723
|
-
key: "componentWillUnmount",
|
|
724
|
-
value: function componentWillUnmount() {
|
|
725
|
-
window.removeEventListener("focus", this.handleGlobalFocus, true);
|
|
726
|
-
}
|
|
727
|
-
}, {
|
|
728
|
-
key: "tryToFocus",
|
|
729
|
-
|
|
730
|
-
/** Try to focus the given node. Return true iff successful. */
|
|
731
|
-
value: function tryToFocus(node) {
|
|
732
|
-
if (node instanceof HTMLElement) {
|
|
733
|
-
this.ignoreFocusChanges = true;
|
|
734
|
-
|
|
735
|
-
try {
|
|
736
|
-
node.focus();
|
|
737
|
-
} catch (e) {// ignore error
|
|
738
|
-
}
|
|
739
|
-
|
|
740
|
-
this.ignoreFocusChanges = false;
|
|
741
|
-
return document.activeElement === node;
|
|
742
|
-
}
|
|
743
|
-
}
|
|
744
|
-
/**
|
|
745
|
-
* Focus the first focusable descendant of the given node.
|
|
746
|
-
*
|
|
747
|
-
* Return true if we succeed. Or, if the given node has no focusable
|
|
748
|
-
* descendants, return false.
|
|
749
|
-
*/
|
|
1158
|
+
componentDidMount() {
|
|
1159
|
+
window.addEventListener("focus", this.handleGlobalFocus, true);
|
|
1160
|
+
}
|
|
750
1161
|
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
var children = currentParent.childNodes;
|
|
1162
|
+
componentWillUnmount() {
|
|
1163
|
+
window.removeEventListener("focus", this.handleGlobalFocus, true);
|
|
1164
|
+
}
|
|
755
1165
|
|
|
756
|
-
|
|
757
|
-
|
|
1166
|
+
/** Try to focus the given node. Return true iff successful. */
|
|
1167
|
+
tryToFocus(node) {
|
|
1168
|
+
if (node instanceof HTMLElement) {
|
|
1169
|
+
this.ignoreFocusChanges = true;
|
|
758
1170
|
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
1171
|
+
try {
|
|
1172
|
+
node.focus();
|
|
1173
|
+
} catch (e) {// ignore error
|
|
762
1174
|
}
|
|
763
1175
|
|
|
764
|
-
|
|
1176
|
+
this.ignoreFocusChanges = false;
|
|
1177
|
+
return document.activeElement === node;
|
|
765
1178
|
}
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
1179
|
+
}
|
|
1180
|
+
/**
|
|
1181
|
+
* Focus the first focusable descendant of the given node.
|
|
1182
|
+
*
|
|
1183
|
+
* Return true if we succeed. Or, if the given node has no focusable
|
|
1184
|
+
* descendants, return false.
|
|
1185
|
+
*/
|
|
772
1186
|
|
|
773
|
-
}, {
|
|
774
|
-
key: "focusLastElementIn",
|
|
775
|
-
value: function focusLastElementIn(currentParent) {
|
|
776
|
-
var children = currentParent.childNodes;
|
|
777
1187
|
|
|
778
|
-
|
|
779
|
-
|
|
1188
|
+
focusFirstElementIn(currentParent) {
|
|
1189
|
+
const children = currentParent.childNodes;
|
|
780
1190
|
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
}
|
|
784
|
-
}
|
|
1191
|
+
for (let i = 0; i < children.length; i++) {
|
|
1192
|
+
const child = children[i];
|
|
785
1193
|
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
}, {
|
|
791
|
-
key: "render",
|
|
792
|
-
value: function render() {
|
|
793
|
-
var style = this.props.style;
|
|
794
|
-
return /*#__PURE__*/external_react_["createElement"](external_react_["Fragment"], null, /*#__PURE__*/external_react_["createElement"]("div", {
|
|
795
|
-
tabIndex: "0",
|
|
796
|
-
style: {
|
|
797
|
-
position: "fixed"
|
|
798
|
-
}
|
|
799
|
-
}), /*#__PURE__*/external_react_["createElement"](wonder_blocks_core_["View"], {
|
|
800
|
-
style: style,
|
|
801
|
-
ref: this.getModalRoot
|
|
802
|
-
}, this.props.children), /*#__PURE__*/external_react_["createElement"]("div", {
|
|
803
|
-
tabIndex: "0",
|
|
804
|
-
style: {
|
|
805
|
-
position: "fixed"
|
|
806
|
-
}
|
|
807
|
-
}));
|
|
1194
|
+
if (this.tryToFocus(child) || this.focusFirstElementIn(child)) {
|
|
1195
|
+
return true;
|
|
1196
|
+
}
|
|
808
1197
|
}
|
|
809
|
-
}]);
|
|
810
|
-
|
|
811
|
-
return FocusTrap;
|
|
812
|
-
}(external_react_["Component"]);
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
// CONCATENATED MODULE: ./packages/wonder-blocks-modal/src/util/constants.js
|
|
816
|
-
/**
|
|
817
|
-
* The attribute used to identify a modal launcher portal.
|
|
818
|
-
*/
|
|
819
|
-
var ModalLauncherPortalAttributeName = "data-modal-launcher-portal";
|
|
820
|
-
|
|
821
|
-
// CONCATENATED MODULE: ./packages/wonder-blocks-modal/src/components/modal-backdrop.js
|
|
822
|
-
function modal_backdrop_typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { modal_backdrop_typeof = function _typeof(obj) { return typeof obj; }; } else { modal_backdrop_typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return modal_backdrop_typeof(obj); }
|
|
823
1198
|
|
|
824
|
-
|
|
1199
|
+
return false;
|
|
1200
|
+
}
|
|
1201
|
+
/**
|
|
1202
|
+
* Focus the last focusable descendant of the given node.
|
|
1203
|
+
*
|
|
1204
|
+
* Return true if we succeed. Or, if the given node has no focusable
|
|
1205
|
+
* descendants, return false.
|
|
1206
|
+
*/
|
|
825
1207
|
|
|
826
|
-
function modal_backdrop_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
827
1208
|
|
|
828
|
-
|
|
1209
|
+
focusLastElementIn(currentParent) {
|
|
1210
|
+
const children = currentParent.childNodes;
|
|
829
1211
|
|
|
830
|
-
|
|
1212
|
+
for (let i = children.length - 1; i >= 0; i--) {
|
|
1213
|
+
const child = children[i];
|
|
831
1214
|
|
|
832
|
-
|
|
1215
|
+
if (this.tryToFocus(child) || this.focusLastElementIn(child)) {
|
|
1216
|
+
return true;
|
|
1217
|
+
}
|
|
1218
|
+
}
|
|
833
1219
|
|
|
834
|
-
|
|
1220
|
+
return false;
|
|
1221
|
+
}
|
|
1222
|
+
/** This method is called when any node on the page is focused. */
|
|
835
1223
|
|
|
836
|
-
function modal_backdrop_createSuper(Derived) { var hasNativeReflectConstruct = modal_backdrop_isNativeReflectConstruct(); return function _createSuperInternal() { var Super = modal_backdrop_getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = modal_backdrop_getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return modal_backdrop_possibleConstructorReturn(this, result); }; }
|
|
837
1224
|
|
|
838
|
-
|
|
1225
|
+
render() {
|
|
1226
|
+
const {
|
|
1227
|
+
style
|
|
1228
|
+
} = this.props;
|
|
1229
|
+
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](react__WEBPACK_IMPORTED_MODULE_0__["Fragment"], null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"]("div", {
|
|
1230
|
+
tabIndex: "0",
|
|
1231
|
+
style: {
|
|
1232
|
+
position: "fixed"
|
|
1233
|
+
}
|
|
1234
|
+
}), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_2__["View"], {
|
|
1235
|
+
style: style,
|
|
1236
|
+
ref: this.getModalRoot
|
|
1237
|
+
}, this.props.children), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"]("div", {
|
|
1238
|
+
tabIndex: "0",
|
|
1239
|
+
style: {
|
|
1240
|
+
position: "fixed"
|
|
1241
|
+
}
|
|
1242
|
+
}));
|
|
1243
|
+
}
|
|
839
1244
|
|
|
840
|
-
|
|
1245
|
+
}
|
|
841
1246
|
|
|
842
|
-
|
|
1247
|
+
/***/ }),
|
|
1248
|
+
/* 19 */
|
|
1249
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
843
1250
|
|
|
844
|
-
|
|
1251
|
+
"use strict";
|
|
1252
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return ModalBackdrop; });
|
|
1253
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
|
|
1254
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
1255
|
+
/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(6);
|
|
1256
|
+
/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react_dom__WEBPACK_IMPORTED_MODULE_1__);
|
|
1257
|
+
/* harmony import */ var aphrodite__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(3);
|
|
1258
|
+
/* harmony import */ var aphrodite__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(aphrodite__WEBPACK_IMPORTED_MODULE_2__);
|
|
1259
|
+
/* harmony import */ var _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(4);
|
|
1260
|
+
/* harmony import */ var _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_3__);
|
|
1261
|
+
/* harmony import */ var _khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(2);
|
|
1262
|
+
/* harmony import */ var _khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_4__);
|
|
1263
|
+
/* harmony import */ var _util_constants_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(11);
|
|
1264
|
+
/* harmony import */ var _util_find_focusable_nodes_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(20);
|
|
1265
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
845
1266
|
|
|
846
|
-
function modal_backdrop_defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
847
1267
|
|
|
848
1268
|
|
|
849
1269
|
|
|
@@ -852,11 +1272,6 @@ function modal_backdrop_defineProperty(obj, key, value) { if (key in obj) { Obje
|
|
|
852
1272
|
|
|
853
1273
|
|
|
854
1274
|
|
|
855
|
-
/**
|
|
856
|
-
* List of elements that can be focused
|
|
857
|
-
* @see https://www.w3.org/TR/html5/editing.html#can-be-focused
|
|
858
|
-
*/
|
|
859
|
-
var FOCUSABLE_ELEMENTS = 'a[href], details, input, textarea, select, button:not([aria-label^="Close"])';
|
|
860
1275
|
/**
|
|
861
1276
|
* A private component used by ModalLauncher. This is the fixed-position
|
|
862
1277
|
* container element that gets mounted outside the DOM. It overlays the modal
|
|
@@ -867,127 +1282,105 @@ var FOCUSABLE_ELEMENTS = 'a[href], details, input, textarea, select, button:not(
|
|
|
867
1282
|
* and adding an `onClose` prop that will call `onCloseModal`. If an
|
|
868
1283
|
* `onClose` prop is already provided, the two are merged.
|
|
869
1284
|
*/
|
|
1285
|
+
class ModalBackdrop extends react__WEBPACK_IMPORTED_MODULE_0__["Component"] {
|
|
1286
|
+
constructor(...args) {
|
|
1287
|
+
super(...args);
|
|
870
1288
|
|
|
871
|
-
|
|
872
|
-
modal_backdrop_inherits(ModalBackdrop, _React$Component);
|
|
873
|
-
|
|
874
|
-
var _super = modal_backdrop_createSuper(ModalBackdrop);
|
|
875
|
-
|
|
876
|
-
function ModalBackdrop() {
|
|
877
|
-
var _this;
|
|
878
|
-
|
|
879
|
-
modal_backdrop_classCallCheck(this, ModalBackdrop);
|
|
880
|
-
|
|
881
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
882
|
-
args[_key] = arguments[_key];
|
|
883
|
-
}
|
|
884
|
-
|
|
885
|
-
_this = _super.call.apply(_super, [this].concat(args));
|
|
886
|
-
|
|
887
|
-
modal_backdrop_defineProperty(modal_backdrop_assertThisInitialized(_this), "handleClick", function (e) {
|
|
1289
|
+
this.handleClick = e => {
|
|
888
1290
|
// Was the lowest-level click target (`e.target`) the positioner element
|
|
889
1291
|
// (`e.currentTarget`)?
|
|
890
1292
|
if (e.target === e.currentTarget) {
|
|
891
|
-
|
|
1293
|
+
this.props.onCloseModal();
|
|
892
1294
|
}
|
|
893
|
-
}
|
|
894
|
-
|
|
895
|
-
return _this;
|
|
1295
|
+
};
|
|
896
1296
|
}
|
|
897
1297
|
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
value: function componentDidMount() {
|
|
901
|
-
var node = external_react_dom_["findDOMNode"](this);
|
|
1298
|
+
componentDidMount() {
|
|
1299
|
+
const node = react_dom__WEBPACK_IMPORTED_MODULE_1__["findDOMNode"](this);
|
|
902
1300
|
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
1301
|
+
if (!node) {
|
|
1302
|
+
return;
|
|
1303
|
+
}
|
|
906
1304
|
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
1305
|
+
const firstFocusableElement = // 1. try to get element specified by the user
|
|
1306
|
+
this._getInitialFocusElement(node) || // 2. get first occurence from list of focusable elements
|
|
1307
|
+
this._getFirstFocusableElement(node) || // 3. get the dialog itself
|
|
1308
|
+
this._getDialogElement(node); // wait for styles to applied
|
|
911
1309
|
|
|
912
1310
|
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
1311
|
+
setTimeout(() => {
|
|
1312
|
+
firstFocusableElement.focus();
|
|
1313
|
+
}, 0);
|
|
1314
|
+
}
|
|
1315
|
+
/**
|
|
1316
|
+
* Returns an element specified by the user
|
|
1317
|
+
*/
|
|
920
1318
|
|
|
921
|
-
}, {
|
|
922
|
-
key: "_getInitialFocusElement",
|
|
923
|
-
value: function _getInitialFocusElement(node) {
|
|
924
|
-
var initialFocusId = this.props.initialFocusId;
|
|
925
1319
|
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
1320
|
+
_getInitialFocusElement(node) {
|
|
1321
|
+
const {
|
|
1322
|
+
initialFocusId
|
|
1323
|
+
} = this.props;
|
|
929
1324
|
|
|
930
|
-
|
|
1325
|
+
if (!initialFocusId) {
|
|
1326
|
+
return null;
|
|
931
1327
|
}
|
|
932
|
-
/**
|
|
933
|
-
* Returns the first focusable element found inside the Dialog
|
|
934
|
-
*/
|
|
935
1328
|
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
1329
|
+
return react_dom__WEBPACK_IMPORTED_MODULE_1__["findDOMNode"](node.querySelector(`#${initialFocusId}`));
|
|
1330
|
+
}
|
|
1331
|
+
/**
|
|
1332
|
+
* Returns the first focusable element found inside the Dialog
|
|
1333
|
+
*/
|
|
941
1334
|
|
|
942
|
-
if (!focusableElements) {
|
|
943
|
-
return null;
|
|
944
|
-
} // if found, return the first focusable element
|
|
945
1335
|
|
|
1336
|
+
_getFirstFocusableElement(node) {
|
|
1337
|
+
// get a collection of elements that can be focused
|
|
1338
|
+
const focusableElements = Object(_util_find_focusable_nodes_js__WEBPACK_IMPORTED_MODULE_6__[/* findFocusableNodes */ "a"])(node);
|
|
946
1339
|
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
* Returns the dialog element
|
|
951
|
-
*/
|
|
1340
|
+
if (!focusableElements) {
|
|
1341
|
+
return null;
|
|
1342
|
+
} // if found, return the first focusable element
|
|
952
1343
|
|
|
953
|
-
}, {
|
|
954
|
-
key: "_getDialogElement",
|
|
955
|
-
value: function _getDialogElement(node) {
|
|
956
|
-
// If no focusable elements are found,
|
|
957
|
-
// the dialog content element itself will receive focus.
|
|
958
|
-
var dialogElement = external_react_dom_["findDOMNode"](node.querySelector('[role="dialog"]')); // add tabIndex to make the Dialog focusable
|
|
959
1344
|
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
* _directly_ from the positioner, not bubbled up from its children), close
|
|
966
|
-
* the modal.
|
|
967
|
-
*/
|
|
1345
|
+
return focusableElements[0];
|
|
1346
|
+
}
|
|
1347
|
+
/**
|
|
1348
|
+
* Returns the dialog element
|
|
1349
|
+
*/
|
|
968
1350
|
|
|
969
|
-
}, {
|
|
970
|
-
key: "render",
|
|
971
|
-
value: function render() {
|
|
972
|
-
var _this$props = this.props,
|
|
973
|
-
children = _this$props.children,
|
|
974
|
-
testId = _this$props.testId;
|
|
975
1351
|
|
|
976
|
-
|
|
1352
|
+
_getDialogElement(node) {
|
|
1353
|
+
// If no focusable elements are found,
|
|
1354
|
+
// the dialog content element itself will receive focus.
|
|
1355
|
+
const dialogElement = react_dom__WEBPACK_IMPORTED_MODULE_1__["findDOMNode"](node.querySelector('[role="dialog"]')); // add tabIndex to make the Dialog focusable
|
|
977
1356
|
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
1357
|
+
dialogElement.tabIndex = -1;
|
|
1358
|
+
return dialogElement;
|
|
1359
|
+
}
|
|
1360
|
+
/**
|
|
1361
|
+
* When the user clicks on the gray backdrop area (i.e., the click came
|
|
1362
|
+
* _directly_ from the positioner, not bubbled up from its children), close
|
|
1363
|
+
* the modal.
|
|
1364
|
+
*/
|
|
985
1365
|
|
|
986
|
-
return ModalBackdrop;
|
|
987
|
-
}(external_react_["Component"]);
|
|
988
1366
|
|
|
1367
|
+
render() {
|
|
1368
|
+
const {
|
|
1369
|
+
children,
|
|
1370
|
+
testId
|
|
1371
|
+
} = this.props;
|
|
1372
|
+
const backdropProps = {
|
|
1373
|
+
[_util_constants_js__WEBPACK_IMPORTED_MODULE_5__[/* ModalLauncherPortalAttributeName */ "a"]]: true
|
|
1374
|
+
};
|
|
1375
|
+
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_4__["View"], _extends({
|
|
1376
|
+
style: styles.modalPositioner,
|
|
1377
|
+
onClick: this.handleClick,
|
|
1378
|
+
testId: testId
|
|
1379
|
+
}, backdropProps), children);
|
|
1380
|
+
}
|
|
989
1381
|
|
|
990
|
-
|
|
1382
|
+
}
|
|
1383
|
+
const styles = aphrodite__WEBPACK_IMPORTED_MODULE_2__["StyleSheet"].create({
|
|
991
1384
|
modalPositioner: {
|
|
992
1385
|
position: "fixed",
|
|
993
1386
|
left: 0,
|
|
@@ -1005,34 +1398,32 @@ var modal_backdrop_styles = external_aphrodite_["StyleSheet"].create({
|
|
|
1005
1398
|
// turns out to be necessary. That sounds hard to do; punting for
|
|
1006
1399
|
// now!
|
|
1007
1400
|
overflow: "auto",
|
|
1008
|
-
background:
|
|
1401
|
+
background: _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_3___default.a.offBlack64
|
|
1009
1402
|
}
|
|
1010
1403
|
});
|
|
1011
|
-
// CONCATENATED MODULE: ./packages/wonder-blocks-modal/src/components/scroll-disabler.js
|
|
1012
|
-
function scroll_disabler_typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { scroll_disabler_typeof = function _typeof(obj) { return typeof obj; }; } else { scroll_disabler_typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return scroll_disabler_typeof(obj); }
|
|
1013
1404
|
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
function scroll_disabler_createClass(Constructor, protoProps, staticProps) { if (protoProps) scroll_disabler_defineProperties(Constructor.prototype, protoProps); if (staticProps) scroll_disabler_defineProperties(Constructor, staticProps); return Constructor; }
|
|
1019
|
-
|
|
1020
|
-
function scroll_disabler_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) scroll_disabler_setPrototypeOf(subClass, superClass); }
|
|
1021
|
-
|
|
1022
|
-
function scroll_disabler_setPrototypeOf(o, p) { scroll_disabler_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return scroll_disabler_setPrototypeOf(o, p); }
|
|
1023
|
-
|
|
1024
|
-
function scroll_disabler_createSuper(Derived) { var hasNativeReflectConstruct = scroll_disabler_isNativeReflectConstruct(); return function _createSuperInternal() { var Super = scroll_disabler_getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = scroll_disabler_getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return scroll_disabler_possibleConstructorReturn(this, result); }; }
|
|
1025
|
-
|
|
1026
|
-
function scroll_disabler_possibleConstructorReturn(self, call) { if (call && (scroll_disabler_typeof(call) === "object" || typeof call === "function")) { return call; } return scroll_disabler_assertThisInitialized(self); }
|
|
1027
|
-
|
|
1028
|
-
function scroll_disabler_assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
1029
|
-
|
|
1030
|
-
function scroll_disabler_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; } }
|
|
1405
|
+
/***/ }),
|
|
1406
|
+
/* 20 */
|
|
1407
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
1031
1408
|
|
|
1032
|
-
|
|
1409
|
+
"use strict";
|
|
1410
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return findFocusableNodes; });
|
|
1411
|
+
/**
|
|
1412
|
+
* List of elements that can be focused
|
|
1413
|
+
* @see https://www.w3.org/TR/html5/editing.html#can-be-focused
|
|
1414
|
+
*/
|
|
1415
|
+
const FOCUSABLE_ELEMENTS = 'a[href], details, input, textarea, select, button:not([aria-label^="Close"])';
|
|
1416
|
+
function findFocusableNodes(root) {
|
|
1417
|
+
return Array.from(root.querySelectorAll(FOCUSABLE_ELEMENTS));
|
|
1418
|
+
}
|
|
1033
1419
|
|
|
1034
|
-
|
|
1420
|
+
/***/ }),
|
|
1421
|
+
/* 21 */
|
|
1422
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
1035
1423
|
|
|
1424
|
+
"use strict";
|
|
1425
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
|
|
1426
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
1036
1427
|
/**
|
|
1037
1428
|
* A UI-less component that lets `ModalLauncher` disable page scroll.
|
|
1038
1429
|
*
|
|
@@ -1045,895 +1436,171 @@ function scroll_disabler_defineProperty(obj, key, value) { if (key in obj) { Obj
|
|
|
1045
1436
|
*/
|
|
1046
1437
|
|
|
1047
1438
|
|
|
1048
|
-
|
|
1439
|
+
const needsHackyMobileSafariScrollDisabler = (() => {
|
|
1049
1440
|
if (typeof window === "undefined") {
|
|
1050
1441
|
return false;
|
|
1051
1442
|
}
|
|
1052
1443
|
|
|
1053
|
-
|
|
1444
|
+
const userAgent = window.navigator.userAgent;
|
|
1054
1445
|
return userAgent.indexOf("iPad") > -1 || userAgent.indexOf("iPhone") > -1;
|
|
1055
|
-
}();
|
|
1056
|
-
|
|
1057
|
-
var ScrollDisabler = /*#__PURE__*/function (_React$Component) {
|
|
1058
|
-
scroll_disabler_inherits(ScrollDisabler, _React$Component);
|
|
1446
|
+
})();
|
|
1059
1447
|
|
|
1060
|
-
|
|
1448
|
+
class ScrollDisabler extends react__WEBPACK_IMPORTED_MODULE_0__["Component"] {
|
|
1449
|
+
componentDidMount() {
|
|
1450
|
+
if (ScrollDisabler.numModalsOpened === 0) {
|
|
1451
|
+
const body = document.body;
|
|
1061
1452
|
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
}
|
|
1067
|
-
|
|
1068
|
-
scroll_disabler_createClass(ScrollDisabler, [{
|
|
1069
|
-
key: "componentDidMount",
|
|
1070
|
-
value: function componentDidMount() {
|
|
1071
|
-
if (ScrollDisabler.numModalsOpened === 0) {
|
|
1072
|
-
var body = document.body;
|
|
1073
|
-
|
|
1074
|
-
if (!body) {
|
|
1075
|
-
throw new Error("couldn't find document.body");
|
|
1076
|
-
} // Prevent scrolling of the background, the first time a modal is
|
|
1077
|
-
// opened.
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
ScrollDisabler.oldOverflow = body.style.overflow;
|
|
1081
|
-
ScrollDisabler.oldScrollY = window.scrollY; // We need to grab all of the original style properties before we
|
|
1082
|
-
// modified any of them.
|
|
1453
|
+
if (!body) {
|
|
1454
|
+
throw new Error("couldn't find document.body");
|
|
1455
|
+
} // Prevent scrolling of the background, the first time a modal is
|
|
1456
|
+
// opened.
|
|
1083
1457
|
|
|
1084
|
-
if (needsHackyMobileSafariScrollDisabler) {
|
|
1085
|
-
ScrollDisabler.oldPosition = body.style.position;
|
|
1086
|
-
ScrollDisabler.oldWidth = body.style.width;
|
|
1087
|
-
ScrollDisabler.oldTop = body.style.top;
|
|
1088
|
-
}
|
|
1089
1458
|
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1459
|
+
ScrollDisabler.oldOverflow = body.style.overflow;
|
|
1460
|
+
ScrollDisabler.oldScrollY = window.scrollY; // We need to grab all of the original style properties before we
|
|
1461
|
+
// modified any of them.
|
|
1093
1462
|
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
}
|
|
1463
|
+
if (needsHackyMobileSafariScrollDisabler) {
|
|
1464
|
+
ScrollDisabler.oldPosition = body.style.position;
|
|
1465
|
+
ScrollDisabler.oldWidth = body.style.width;
|
|
1466
|
+
ScrollDisabler.oldTop = body.style.top;
|
|
1099
1467
|
}
|
|
1100
1468
|
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
key: "componentWillUnmount",
|
|
1105
|
-
value: function componentWillUnmount() {
|
|
1106
|
-
ScrollDisabler.numModalsOpened--;
|
|
1107
|
-
|
|
1108
|
-
if (ScrollDisabler.numModalsOpened === 0) {
|
|
1109
|
-
var body = document.body;
|
|
1110
|
-
|
|
1111
|
-
if (!body) {
|
|
1112
|
-
throw new Error("couldn't find document.body");
|
|
1113
|
-
} // Reset all values on the closing of the final modal.
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
body.style.overflow = ScrollDisabler.oldOverflow;
|
|
1117
|
-
|
|
1118
|
-
if (needsHackyMobileSafariScrollDisabler) {
|
|
1119
|
-
body.style.position = ScrollDisabler.oldPosition;
|
|
1120
|
-
body.style.width = ScrollDisabler.oldWidth;
|
|
1121
|
-
body.style.top = ScrollDisabler.oldTop;
|
|
1122
|
-
}
|
|
1469
|
+
body.style.overflow = "hidden"; // On mobile Safari, overflow: hidden is not enough, position:
|
|
1470
|
+
// fixed is also required. Setting style.top = -scollTop maintains
|
|
1471
|
+
// the scroll position (without which we'd scroll to the top).
|
|
1123
1472
|
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1473
|
+
if (needsHackyMobileSafariScrollDisabler) {
|
|
1474
|
+
body.style.position = "fixed";
|
|
1475
|
+
body.style.width = "100%";
|
|
1476
|
+
body.style.top = `${-ScrollDisabler.oldScrollY}px`;
|
|
1127
1477
|
}
|
|
1128
1478
|
}
|
|
1129
|
-
}, {
|
|
1130
|
-
key: "render",
|
|
1131
|
-
value: function render() {
|
|
1132
|
-
return null;
|
|
1133
|
-
}
|
|
1134
|
-
}]);
|
|
1135
|
-
|
|
1136
|
-
return ScrollDisabler;
|
|
1137
|
-
}(external_react_["Component"]);
|
|
1138
|
-
|
|
1139
|
-
scroll_disabler_defineProperty(ScrollDisabler, "oldOverflow", void 0);
|
|
1140
|
-
|
|
1141
|
-
scroll_disabler_defineProperty(ScrollDisabler, "oldPosition", void 0);
|
|
1142
|
-
|
|
1143
|
-
scroll_disabler_defineProperty(ScrollDisabler, "oldScrollY", void 0);
|
|
1144
|
-
|
|
1145
|
-
scroll_disabler_defineProperty(ScrollDisabler, "oldWidth", void 0);
|
|
1146
|
-
|
|
1147
|
-
scroll_disabler_defineProperty(ScrollDisabler, "oldTop", void 0);
|
|
1148
|
-
|
|
1149
|
-
scroll_disabler_defineProperty(ScrollDisabler, "numModalsOpened", 0);
|
|
1150
|
-
|
|
1151
|
-
/* harmony default export */ var scroll_disabler = (ScrollDisabler);
|
|
1152
|
-
// CONCATENATED MODULE: ./packages/wonder-blocks-modal/src/components/modal-context.js
|
|
1153
|
-
|
|
1154
|
-
var defaultContext = {
|
|
1155
|
-
closeModal: undefined
|
|
1156
|
-
};
|
|
1157
|
-
/* harmony default export */ var modal_context = (external_react_["createContext"](defaultContext));
|
|
1158
|
-
// CONCATENATED MODULE: ./packages/wonder-blocks-modal/src/components/modal-launcher.js
|
|
1159
|
-
function modal_launcher_typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { modal_launcher_typeof = function _typeof(obj) { return typeof obj; }; } else { modal_launcher_typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return modal_launcher_typeof(obj); }
|
|
1160
|
-
|
|
1161
|
-
function modal_launcher_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
1162
|
-
|
|
1163
|
-
function modal_launcher_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); } }
|
|
1164
|
-
|
|
1165
|
-
function modal_launcher_createClass(Constructor, protoProps, staticProps) { if (protoProps) modal_launcher_defineProperties(Constructor.prototype, protoProps); if (staticProps) modal_launcher_defineProperties(Constructor, staticProps); return Constructor; }
|
|
1166
|
-
|
|
1167
|
-
function modal_launcher_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) modal_launcher_setPrototypeOf(subClass, superClass); }
|
|
1168
|
-
|
|
1169
|
-
function modal_launcher_setPrototypeOf(o, p) { modal_launcher_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return modal_launcher_setPrototypeOf(o, p); }
|
|
1170
|
-
|
|
1171
|
-
function modal_launcher_createSuper(Derived) { var hasNativeReflectConstruct = modal_launcher_isNativeReflectConstruct(); return function _createSuperInternal() { var Super = modal_launcher_getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = modal_launcher_getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return modal_launcher_possibleConstructorReturn(this, result); }; }
|
|
1172
|
-
|
|
1173
|
-
function modal_launcher_possibleConstructorReturn(self, call) { if (call && (modal_launcher_typeof(call) === "object" || typeof call === "function")) { return call; } return modal_launcher_assertThisInitialized(self); }
|
|
1174
|
-
|
|
1175
|
-
function modal_launcher_assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
1176
|
-
|
|
1177
|
-
function modal_launcher_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; } }
|
|
1178
|
-
|
|
1179
|
-
function modal_launcher_getPrototypeOf(o) { modal_launcher_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return modal_launcher_getPrototypeOf(o); }
|
|
1180
|
-
|
|
1181
|
-
function modal_launcher_defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
/**
|
|
1192
|
-
* This component enables you to launch a modal, covering the screen.
|
|
1193
|
-
*
|
|
1194
|
-
* Children have access to `openModal` function via the function-as-children
|
|
1195
|
-
* pattern, so one common use case is for this component to wrap a button:
|
|
1196
|
-
*
|
|
1197
|
-
* ```js
|
|
1198
|
-
* <ModalLauncher modal={<TwoColumnModal ... />}>
|
|
1199
|
-
* {({openModal}) => <button onClick={openModal}>Learn more</button>}
|
|
1200
|
-
* </ModalLauncher>
|
|
1201
|
-
* ```
|
|
1202
|
-
*
|
|
1203
|
-
* The actual modal itself is constructed separately, using a layout component
|
|
1204
|
-
* like OnePaneDialog and is provided via
|
|
1205
|
-
* the `modal` prop.
|
|
1206
|
-
*/
|
|
1207
|
-
var modal_launcher_ModalLauncher = /*#__PURE__*/function (_React$Component) {
|
|
1208
|
-
modal_launcher_inherits(ModalLauncher, _React$Component);
|
|
1209
|
-
|
|
1210
|
-
var _super = modal_launcher_createSuper(ModalLauncher);
|
|
1211
|
-
|
|
1212
|
-
function ModalLauncher() {
|
|
1213
|
-
var _this;
|
|
1214
|
-
|
|
1215
|
-
modal_launcher_classCallCheck(this, ModalLauncher);
|
|
1216
|
-
|
|
1217
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
1218
|
-
args[_key] = arguments[_key];
|
|
1219
|
-
}
|
|
1220
|
-
|
|
1221
|
-
_this = _super.call.apply(_super, [this].concat(args));
|
|
1222
|
-
|
|
1223
|
-
modal_launcher_defineProperty(modal_launcher_assertThisInitialized(_this), "lastElementFocusedOutsideModal", void 0);
|
|
1224
|
-
|
|
1225
|
-
modal_launcher_defineProperty(modal_launcher_assertThisInitialized(_this), "state", {
|
|
1226
|
-
opened: false
|
|
1227
|
-
});
|
|
1228
|
-
|
|
1229
|
-
modal_launcher_defineProperty(modal_launcher_assertThisInitialized(_this), "_saveLastElementFocused", function () {
|
|
1230
|
-
// keep a reference of the element that triggers the modal
|
|
1231
|
-
_this.lastElementFocusedOutsideModal = document.activeElement;
|
|
1232
|
-
});
|
|
1233
|
-
|
|
1234
|
-
modal_launcher_defineProperty(modal_launcher_assertThisInitialized(_this), "_openModal", function () {
|
|
1235
|
-
_this._saveLastElementFocused();
|
|
1236
1479
|
|
|
1237
|
-
|
|
1238
|
-
opened: true
|
|
1239
|
-
});
|
|
1240
|
-
});
|
|
1241
|
-
|
|
1242
|
-
modal_launcher_defineProperty(modal_launcher_assertThisInitialized(_this), "handleCloseModal", function () {
|
|
1243
|
-
_this.setState({
|
|
1244
|
-
opened: false
|
|
1245
|
-
}, function () {
|
|
1246
|
-
_this.props.onClose && _this.props.onClose();
|
|
1247
|
-
|
|
1248
|
-
if (_this.lastElementFocusedOutsideModal != null) {
|
|
1249
|
-
// return focus to the element that triggered the modal
|
|
1250
|
-
_this.lastElementFocusedOutsideModal.focus();
|
|
1251
|
-
}
|
|
1252
|
-
});
|
|
1253
|
-
});
|
|
1254
|
-
|
|
1255
|
-
return _this;
|
|
1480
|
+
ScrollDisabler.numModalsOpened++;
|
|
1256
1481
|
}
|
|
1257
1482
|
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
this._saveLastElementFocused();
|
|
1264
|
-
}
|
|
1265
|
-
}
|
|
1266
|
-
}, {
|
|
1267
|
-
key: "_renderModal",
|
|
1268
|
-
value: function _renderModal() {
|
|
1269
|
-
if (typeof this.props.modal === "function") {
|
|
1270
|
-
return this.props.modal({
|
|
1271
|
-
closeModal: this.handleCloseModal
|
|
1272
|
-
});
|
|
1273
|
-
} else {
|
|
1274
|
-
return this.props.modal;
|
|
1275
|
-
}
|
|
1276
|
-
}
|
|
1277
|
-
}, {
|
|
1278
|
-
key: "render",
|
|
1279
|
-
value: function render() {
|
|
1280
|
-
var renderedChildren = this.props.children ? this.props.children({
|
|
1281
|
-
openModal: this._openModal
|
|
1282
|
-
}) : null;
|
|
1283
|
-
var _document = document,
|
|
1284
|
-
body = _document.body;
|
|
1483
|
+
componentWillUnmount() {
|
|
1484
|
+
ScrollDisabler.numModalsOpened--;
|
|
1485
|
+
|
|
1486
|
+
if (ScrollDisabler.numModalsOpened === 0) {
|
|
1487
|
+
const body = document.body;
|
|
1285
1488
|
|
|
1286
1489
|
if (!body) {
|
|
1287
|
-
|
|
1288
|
-
}
|
|
1490
|
+
throw new Error("couldn't find document.body");
|
|
1491
|
+
} // Reset all values on the closing of the final modal.
|
|
1289
1492
|
|
|
1290
|
-
return (
|
|
1291
|
-
/*#__PURE__*/
|
|
1292
|
-
// This flow check is valid, it's the babel plugin which is broken,
|
|
1293
|
-
// see modal-context.js for details.
|
|
1294
|
-
// $FlowFixMe
|
|
1295
|
-
external_react_["createElement"](modal_context.Provider, {
|
|
1296
|
-
value: {
|
|
1297
|
-
closeModal: this.handleCloseModal
|
|
1298
|
-
}
|
|
1299
|
-
}, renderedChildren, this.state.opened && external_react_dom_["createPortal"](
|
|
1300
|
-
/*#__PURE__*/
|
|
1301
|
-
|
|
1302
|
-
/* We need the container View that FocusTrap creates to be at the
|
|
1303
|
-
correct z-index so that it'll be above the global nav in webapp. */
|
|
1304
|
-
external_react_["createElement"](focus_trap_FocusTrap, {
|
|
1305
|
-
style: modal_launcher_styles.container
|
|
1306
|
-
}, /*#__PURE__*/external_react_["createElement"](modal_backdrop_ModalBackdrop, {
|
|
1307
|
-
initialFocusId: this.props.initialFocusId,
|
|
1308
|
-
testId: this.props.testId,
|
|
1309
|
-
onCloseModal: this.props.backdropDismissEnabled ? this.handleCloseModal : function () {}
|
|
1310
|
-
}, this._renderModal())), body), this.state.opened && /*#__PURE__*/external_react_["createElement"](ModalLauncherKeypressListener, {
|
|
1311
|
-
onClose: this.handleCloseModal
|
|
1312
|
-
}), this.state.opened && /*#__PURE__*/external_react_["createElement"](scroll_disabler, null))
|
|
1313
|
-
);
|
|
1314
|
-
}
|
|
1315
|
-
}], [{
|
|
1316
|
-
key: "getDerivedStateFromProps",
|
|
1317
|
-
value: function getDerivedStateFromProps(props, state) {
|
|
1318
|
-
if (typeof props.opened === "boolean" && props.children) {
|
|
1319
|
-
// eslint-disable-next-line no-console
|
|
1320
|
-
console.warn("'children' and 'opened' can't be used together");
|
|
1321
|
-
}
|
|
1322
1493
|
|
|
1323
|
-
|
|
1324
|
-
// eslint-disable-next-line no-console
|
|
1325
|
-
console.warn("'onClose' should be used with 'opened'");
|
|
1326
|
-
}
|
|
1494
|
+
body.style.overflow = ScrollDisabler.oldOverflow;
|
|
1327
1495
|
|
|
1328
|
-
if (
|
|
1329
|
-
|
|
1330
|
-
|
|
1496
|
+
if (needsHackyMobileSafariScrollDisabler) {
|
|
1497
|
+
body.style.position = ScrollDisabler.oldPosition;
|
|
1498
|
+
body.style.width = ScrollDisabler.oldWidth;
|
|
1499
|
+
body.style.top = ScrollDisabler.oldTop;
|
|
1331
1500
|
}
|
|
1332
1501
|
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
};
|
|
1336
|
-
}
|
|
1337
|
-
}]);
|
|
1338
|
-
|
|
1339
|
-
return ModalLauncher;
|
|
1340
|
-
}(external_react_["Component"]);
|
|
1341
|
-
/** A component that, when mounted, calls `onClose` when Escape is pressed. */
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
modal_launcher_defineProperty(modal_launcher_ModalLauncher, "defaultProps", {
|
|
1345
|
-
backdropDismissEnabled: true
|
|
1346
|
-
});
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
var ModalLauncherKeypressListener = /*#__PURE__*/function (_React$Component2) {
|
|
1351
|
-
modal_launcher_inherits(ModalLauncherKeypressListener, _React$Component2);
|
|
1352
|
-
|
|
1353
|
-
var _super2 = modal_launcher_createSuper(ModalLauncherKeypressListener);
|
|
1354
|
-
|
|
1355
|
-
function ModalLauncherKeypressListener() {
|
|
1356
|
-
var _this2;
|
|
1357
|
-
|
|
1358
|
-
modal_launcher_classCallCheck(this, ModalLauncherKeypressListener);
|
|
1359
|
-
|
|
1360
|
-
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
1361
|
-
args[_key2] = arguments[_key2];
|
|
1362
|
-
}
|
|
1363
|
-
|
|
1364
|
-
_this2 = _super2.call.apply(_super2, [this].concat(args));
|
|
1365
|
-
|
|
1366
|
-
modal_launcher_defineProperty(modal_launcher_assertThisInitialized(_this2), "_handleKeyup", function (e) {
|
|
1367
|
-
// We check the key as that's keyboard layout agnostic and also avoids
|
|
1368
|
-
// the minefield of deprecated number type properties like keyCode and
|
|
1369
|
-
// which, with the replacement code, which uses a string instead.
|
|
1370
|
-
if (e.key === "Escape") {
|
|
1371
|
-
// Stop the event going any further.
|
|
1372
|
-
// For cancellation events, like the Escape key, we generally should
|
|
1373
|
-
// air on the side of caution and only allow it to cancel one thing.
|
|
1374
|
-
// So, it's polite for us to stop propagation of the event.
|
|
1375
|
-
// Otherwise, we end up with UX where one Escape key press
|
|
1376
|
-
// unexpectedly cancels multiple things.
|
|
1377
|
-
e.preventDefault();
|
|
1378
|
-
e.stopPropagation();
|
|
1379
|
-
|
|
1380
|
-
_this2.props.onClose();
|
|
1502
|
+
if (typeof window !== "undefined" && window.scrollTo) {
|
|
1503
|
+
window.scrollTo(0, ScrollDisabler.oldScrollY);
|
|
1381
1504
|
}
|
|
1382
|
-
});
|
|
1383
|
-
|
|
1384
|
-
return _this2;
|
|
1385
|
-
}
|
|
1386
|
-
|
|
1387
|
-
modal_launcher_createClass(ModalLauncherKeypressListener, [{
|
|
1388
|
-
key: "componentDidMount",
|
|
1389
|
-
value: function componentDidMount() {
|
|
1390
|
-
window.addEventListener("keyup", this._handleKeyup);
|
|
1391
|
-
}
|
|
1392
|
-
}, {
|
|
1393
|
-
key: "componentWillUnmount",
|
|
1394
|
-
value: function componentWillUnmount() {
|
|
1395
|
-
window.removeEventListener("keyup", this._handleKeyup);
|
|
1396
1505
|
}
|
|
1397
|
-
}, {
|
|
1398
|
-
key: "render",
|
|
1399
|
-
value: function render() {
|
|
1400
|
-
return null;
|
|
1401
|
-
}
|
|
1402
|
-
}]);
|
|
1403
|
-
|
|
1404
|
-
return ModalLauncherKeypressListener;
|
|
1405
|
-
}(external_react_["Component"]);
|
|
1406
|
-
|
|
1407
|
-
var modal_launcher_styles = external_aphrodite_["StyleSheet"].create({
|
|
1408
|
-
container: {
|
|
1409
|
-
// This z-index is copied from the Khan Academy webapp.
|
|
1410
|
-
//
|
|
1411
|
-
// TODO(mdr): Should we keep this in a constants file somewhere? Or
|
|
1412
|
-
// not hardcode it at all, and provide it to Wonder Blocks via
|
|
1413
|
-
// configuration?
|
|
1414
|
-
zIndex: 1080
|
|
1415
1506
|
}
|
|
1416
|
-
});
|
|
1417
|
-
// CONCATENATED MODULE: ./packages/wonder-blocks-modal/src/components/modal-content.js
|
|
1418
|
-
function modal_content_typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { modal_content_typeof = function _typeof(obj) { return typeof obj; }; } else { modal_content_typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return modal_content_typeof(obj); }
|
|
1419
|
-
|
|
1420
|
-
function modal_content_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
1421
|
-
|
|
1422
|
-
function modal_content_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); } }
|
|
1423
|
-
|
|
1424
|
-
function modal_content_createClass(Constructor, protoProps, staticProps) { if (protoProps) modal_content_defineProperties(Constructor.prototype, protoProps); if (staticProps) modal_content_defineProperties(Constructor, staticProps); return Constructor; }
|
|
1425
|
-
|
|
1426
|
-
function modal_content_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) modal_content_setPrototypeOf(subClass, superClass); }
|
|
1427
|
-
|
|
1428
|
-
function modal_content_setPrototypeOf(o, p) { modal_content_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return modal_content_setPrototypeOf(o, p); }
|
|
1429
|
-
|
|
1430
|
-
function modal_content_createSuper(Derived) { var hasNativeReflectConstruct = modal_content_isNativeReflectConstruct(); return function _createSuperInternal() { var Super = modal_content_getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = modal_content_getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return modal_content_possibleConstructorReturn(this, result); }; }
|
|
1431
|
-
|
|
1432
|
-
function modal_content_possibleConstructorReturn(self, call) { if (call && (modal_content_typeof(call) === "object" || typeof call === "function")) { return call; } return modal_content_assertThisInitialized(self); }
|
|
1433
|
-
|
|
1434
|
-
function modal_content_assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
1435
|
-
|
|
1436
|
-
function modal_content_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; } }
|
|
1437
|
-
|
|
1438
|
-
function modal_content_getPrototypeOf(o) { modal_content_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return modal_content_getPrototypeOf(o); }
|
|
1439
|
-
|
|
1440
|
-
function modal_content_defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
1507
|
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
*/
|
|
1451
|
-
var modal_content_ModalContent = /*#__PURE__*/function (_React$Component) {
|
|
1452
|
-
modal_content_inherits(ModalContent, _React$Component);
|
|
1453
|
-
|
|
1454
|
-
var _super = modal_content_createSuper(ModalContent);
|
|
1455
|
-
|
|
1456
|
-
function ModalContent() {
|
|
1457
|
-
modal_content_classCallCheck(this, ModalContent);
|
|
1458
|
-
|
|
1459
|
-
return _super.apply(this, arguments);
|
|
1460
|
-
}
|
|
1461
|
-
|
|
1462
|
-
modal_content_createClass(ModalContent, [{
|
|
1463
|
-
key: "render",
|
|
1464
|
-
value: function render() {
|
|
1465
|
-
var _this$props = this.props,
|
|
1466
|
-
scrollOverflow = _this$props.scrollOverflow,
|
|
1467
|
-
style = _this$props.style,
|
|
1468
|
-
children = _this$props.children;
|
|
1469
|
-
return /*#__PURE__*/external_react_["createElement"](wonder_blocks_layout_["MediaLayout"], {
|
|
1470
|
-
styleSheets: modal_content_styleSheets
|
|
1471
|
-
}, function (_ref) {
|
|
1472
|
-
var styles = _ref.styles;
|
|
1473
|
-
return /*#__PURE__*/external_react_["createElement"](wonder_blocks_core_["View"], {
|
|
1474
|
-
style: [styles.wrapper, scrollOverflow && styles.scrollOverflow]
|
|
1475
|
-
}, /*#__PURE__*/external_react_["createElement"](wonder_blocks_core_["View"], {
|
|
1476
|
-
style: [styles.content, style]
|
|
1477
|
-
}, children));
|
|
1478
|
-
});
|
|
1479
|
-
}
|
|
1480
|
-
}], [{
|
|
1481
|
-
key: "isClassOf",
|
|
1482
|
-
value: function isClassOf(instance) {
|
|
1483
|
-
return instance && instance.type && instance.type.__IS_MODAL_CONTENT__;
|
|
1484
|
-
}
|
|
1485
|
-
}]);
|
|
1486
|
-
|
|
1487
|
-
return ModalContent;
|
|
1488
|
-
}(external_react_["Component"]);
|
|
1489
|
-
|
|
1490
|
-
modal_content_defineProperty(modal_content_ModalContent, "defaultProps", {
|
|
1491
|
-
scrollOverflow: true
|
|
1492
|
-
});
|
|
1493
|
-
|
|
1494
|
-
modal_content_defineProperty(modal_content_ModalContent, "__IS_MODAL_CONTENT__", true);
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
var modal_content_styleSheets = {
|
|
1498
|
-
all: external_aphrodite_["StyleSheet"].create({
|
|
1499
|
-
wrapper: {
|
|
1500
|
-
flex: 1,
|
|
1501
|
-
// This helps to ensure that the paddingBottom is preserved when
|
|
1502
|
-
// the contents start to overflow, this goes away on display: flex
|
|
1503
|
-
display: "block"
|
|
1504
|
-
},
|
|
1505
|
-
scrollOverflow: {
|
|
1506
|
-
overflow: "auto"
|
|
1507
|
-
},
|
|
1508
|
-
content: {
|
|
1509
|
-
flex: 1,
|
|
1510
|
-
minHeight: "100%",
|
|
1511
|
-
padding: wonder_blocks_spacing_default.a.xLarge_32,
|
|
1512
|
-
boxSizing: "border-box"
|
|
1513
|
-
}
|
|
1514
|
-
}),
|
|
1515
|
-
small: external_aphrodite_["StyleSheet"].create({
|
|
1516
|
-
content: {
|
|
1517
|
-
padding: "".concat(wonder_blocks_spacing_default.a.xLarge_32, "px ").concat(wonder_blocks_spacing_default.a.medium_16, "px")
|
|
1518
|
-
}
|
|
1519
|
-
})
|
|
1520
|
-
};
|
|
1521
|
-
// EXTERNAL MODULE: external "@khanacademy/wonder-blocks-icon"
|
|
1522
|
-
var wonder_blocks_icon_ = __webpack_require__(8);
|
|
1523
|
-
|
|
1524
|
-
// EXTERNAL MODULE: external "@khanacademy/wonder-blocks-icon-button"
|
|
1525
|
-
var wonder_blocks_icon_button_ = __webpack_require__(9);
|
|
1526
|
-
var wonder_blocks_icon_button_default = /*#__PURE__*/__webpack_require__.n(wonder_blocks_icon_button_);
|
|
1527
|
-
|
|
1528
|
-
// CONCATENATED MODULE: ./packages/wonder-blocks-modal/src/components/close-button.js
|
|
1529
|
-
function close_button_typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { close_button_typeof = function _typeof(obj) { return typeof obj; }; } else { close_button_typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return close_button_typeof(obj); }
|
|
1530
|
-
|
|
1531
|
-
function close_button_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
1532
|
-
|
|
1533
|
-
function close_button_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); } }
|
|
1534
|
-
|
|
1535
|
-
function close_button_createClass(Constructor, protoProps, staticProps) { if (protoProps) close_button_defineProperties(Constructor.prototype, protoProps); if (staticProps) close_button_defineProperties(Constructor, staticProps); return Constructor; }
|
|
1536
|
-
|
|
1537
|
-
function close_button_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) close_button_setPrototypeOf(subClass, superClass); }
|
|
1538
|
-
|
|
1539
|
-
function close_button_setPrototypeOf(o, p) { close_button_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return close_button_setPrototypeOf(o, p); }
|
|
1540
|
-
|
|
1541
|
-
function close_button_createSuper(Derived) { var hasNativeReflectConstruct = close_button_isNativeReflectConstruct(); return function _createSuperInternal() { var Super = close_button_getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = close_button_getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return close_button_possibleConstructorReturn(this, result); }; }
|
|
1542
|
-
|
|
1543
|
-
function close_button_possibleConstructorReturn(self, call) { if (call && (close_button_typeof(call) === "object" || typeof call === "function")) { return call; } return close_button_assertThisInitialized(self); }
|
|
1544
|
-
|
|
1545
|
-
function close_button_assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
1546
|
-
|
|
1547
|
-
function close_button_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; } }
|
|
1548
|
-
|
|
1549
|
-
function close_button_getPrototypeOf(o) { close_button_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return close_button_getPrototypeOf(o); }
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
var close_button_CloseButton = /*#__PURE__*/function (_React$Component) {
|
|
1557
|
-
close_button_inherits(CloseButton, _React$Component);
|
|
1558
|
-
|
|
1559
|
-
var _super = close_button_createSuper(CloseButton);
|
|
1560
|
-
|
|
1561
|
-
function CloseButton() {
|
|
1562
|
-
close_button_classCallCheck(this, CloseButton);
|
|
1563
|
-
|
|
1564
|
-
return _super.apply(this, arguments);
|
|
1508
|
+
render() {
|
|
1509
|
+
return null;
|
|
1565
1510
|
}
|
|
1566
1511
|
|
|
1567
|
-
|
|
1568
|
-
key: "render",
|
|
1569
|
-
value: function render() {
|
|
1570
|
-
var _this$props = this.props,
|
|
1571
|
-
light = _this$props.light,
|
|
1572
|
-
onClick = _this$props.onClick,
|
|
1573
|
-
style = _this$props.style,
|
|
1574
|
-
testId = _this$props.testId;
|
|
1575
|
-
return /*#__PURE__*/external_react_["createElement"](modal_context.Consumer, null, function (_ref) {
|
|
1576
|
-
var closeModal = _ref.closeModal;
|
|
1577
|
-
|
|
1578
|
-
if (closeModal && onClick) {
|
|
1579
|
-
throw new Error("You've specified 'onClose' on a modal when using ModalLauncher. Please specify 'onClose' on the ModalLauncher instead");
|
|
1580
|
-
}
|
|
1581
|
-
|
|
1582
|
-
return /*#__PURE__*/external_react_["createElement"](wonder_blocks_icon_button_default.a, {
|
|
1583
|
-
icon: wonder_blocks_icon_["icons"].dismiss // TODO(mdr): Translate this string for i18n.
|
|
1584
|
-
// TODO(kevinb): provide a way to set this label
|
|
1585
|
-
,
|
|
1586
|
-
"aria-label": "Close modal",
|
|
1587
|
-
onClick: onClick || closeModal,
|
|
1588
|
-
kind: light ? "primary" : "tertiary",
|
|
1589
|
-
light: light,
|
|
1590
|
-
style: style,
|
|
1591
|
-
testId: testId
|
|
1592
|
-
});
|
|
1593
|
-
});
|
|
1594
|
-
}
|
|
1595
|
-
}]);
|
|
1596
|
-
|
|
1597
|
-
return CloseButton;
|
|
1598
|
-
}(external_react_["Component"]);
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
// CONCATENATED MODULE: ./packages/wonder-blocks-modal/src/components/modal-panel.js
|
|
1602
|
-
function modal_panel_typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { modal_panel_typeof = function _typeof(obj) { return typeof obj; }; } else { modal_panel_typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return modal_panel_typeof(obj); }
|
|
1603
|
-
|
|
1604
|
-
function modal_panel_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
1605
|
-
|
|
1606
|
-
function modal_panel_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); } }
|
|
1607
|
-
|
|
1608
|
-
function modal_panel_createClass(Constructor, protoProps, staticProps) { if (protoProps) modal_panel_defineProperties(Constructor.prototype, protoProps); if (staticProps) modal_panel_defineProperties(Constructor, staticProps); return Constructor; }
|
|
1609
|
-
|
|
1610
|
-
function modal_panel_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) modal_panel_setPrototypeOf(subClass, superClass); }
|
|
1611
|
-
|
|
1612
|
-
function modal_panel_setPrototypeOf(o, p) { modal_panel_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return modal_panel_setPrototypeOf(o, p); }
|
|
1613
|
-
|
|
1614
|
-
function modal_panel_createSuper(Derived) { var hasNativeReflectConstruct = modal_panel_isNativeReflectConstruct(); return function _createSuperInternal() { var Super = modal_panel_getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = modal_panel_getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return modal_panel_possibleConstructorReturn(this, result); }; }
|
|
1615
|
-
|
|
1616
|
-
function modal_panel_possibleConstructorReturn(self, call) { if (call && (modal_panel_typeof(call) === "object" || typeof call === "function")) { return call; } return modal_panel_assertThisInitialized(self); }
|
|
1617
|
-
|
|
1618
|
-
function modal_panel_assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
1619
|
-
|
|
1620
|
-
function modal_panel_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; } }
|
|
1621
|
-
|
|
1622
|
-
function modal_panel_getPrototypeOf(o) { modal_panel_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return modal_panel_getPrototypeOf(o); }
|
|
1623
|
-
|
|
1624
|
-
function modal_panel_defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
/**
|
|
1637
|
-
* ModalPanel is the content container.
|
|
1638
|
-
*
|
|
1639
|
-
* **Implementation notes:**
|
|
1640
|
-
*
|
|
1641
|
-
* If you are creating a custom Dialog, make sure to follow these guidelines:
|
|
1642
|
-
* - Make sure to add this component inside the [ModalDialog](/#modaldialog).
|
|
1643
|
-
* - If needed, you can also add a [ModalHeader](/#modalheader) using the
|
|
1644
|
-
* `header` prop. Same goes for [ModalFooter](/#modalfooter).
|
|
1645
|
-
* - If you need to create e2e tests, make sure to pass a `testId` prop. This
|
|
1646
|
-
* will be passed down to this component using a sufix: e.g.
|
|
1647
|
-
* `some-random-id-ModalPanel`. This scope will be propagated to the
|
|
1648
|
-
* CloseButton element as well: e.g. `some-random-id-CloseButton`.
|
|
1649
|
-
*
|
|
1650
|
-
* ```js
|
|
1651
|
-
* <ModalDialog>
|
|
1652
|
-
* <ModalPanel content={"custom content goes here"} />
|
|
1653
|
-
* </ModalDialog>
|
|
1654
|
-
* ```
|
|
1655
|
-
*/
|
|
1656
|
-
var modal_panel_ModalPanel = /*#__PURE__*/function (_React$Component) {
|
|
1657
|
-
modal_panel_inherits(ModalPanel, _React$Component);
|
|
1658
|
-
|
|
1659
|
-
var _super = modal_panel_createSuper(ModalPanel);
|
|
1512
|
+
}
|
|
1660
1513
|
|
|
1661
|
-
|
|
1662
|
-
|
|
1514
|
+
ScrollDisabler.numModalsOpened = 0;
|
|
1515
|
+
/* harmony default export */ __webpack_exports__["a"] = (ScrollDisabler);
|
|
1663
1516
|
|
|
1664
|
-
|
|
1665
|
-
|
|
1517
|
+
/***/ }),
|
|
1518
|
+
/* 22 */
|
|
1519
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
1666
1520
|
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1521
|
+
"use strict";
|
|
1522
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return CloseButton; });
|
|
1523
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
|
|
1524
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
1525
|
+
/* harmony import */ var _khanacademy_wonder_blocks_icon__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(23);
|
|
1526
|
+
/* harmony import */ var _khanacademy_wonder_blocks_icon__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_icon__WEBPACK_IMPORTED_MODULE_1__);
|
|
1527
|
+
/* harmony import */ var _khanacademy_wonder_blocks_icon_button__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(24);
|
|
1528
|
+
/* harmony import */ var _khanacademy_wonder_blocks_icon_button__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_icon_button__WEBPACK_IMPORTED_MODULE_2__);
|
|
1529
|
+
/* harmony import */ var _modal_context_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(12);
|
|
1530
|
+
|
|
1531
|
+
|
|
1532
|
+
|
|
1533
|
+
|
|
1534
|
+
class CloseButton extends react__WEBPACK_IMPORTED_MODULE_0__["Component"] {
|
|
1535
|
+
render() {
|
|
1536
|
+
const {
|
|
1537
|
+
light,
|
|
1538
|
+
onClick,
|
|
1539
|
+
style,
|
|
1540
|
+
testId
|
|
1541
|
+
} = this.props;
|
|
1542
|
+
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_modal_context_js__WEBPACK_IMPORTED_MODULE_3__[/* default */ "a"].Consumer, null, ({
|
|
1543
|
+
closeModal
|
|
1544
|
+
}) => {
|
|
1545
|
+
if (closeModal && onClick) {
|
|
1546
|
+
throw new Error("You've specified 'onClose' on a modal when using ModalLauncher. Please specify 'onClose' on the ModalLauncher instead");
|
|
1678
1547
|
}
|
|
1679
1548
|
|
|
1680
|
-
return
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1549
|
+
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_icon_button__WEBPACK_IMPORTED_MODULE_2___default.a, {
|
|
1550
|
+
icon: _khanacademy_wonder_blocks_icon__WEBPACK_IMPORTED_MODULE_1__["icons"].dismiss // TODO(mdr): Translate this string for i18n.
|
|
1551
|
+
// TODO(kevinb): provide a way to set this label
|
|
1552
|
+
,
|
|
1553
|
+
"aria-label": "Close modal",
|
|
1554
|
+
onClick: onClick || closeModal,
|
|
1555
|
+
kind: light ? "primary" : "tertiary",
|
|
1556
|
+
light: light,
|
|
1557
|
+
style: style,
|
|
1558
|
+
testId: testId
|
|
1688
1559
|
});
|
|
1689
|
-
}
|
|
1690
|
-
}, {
|
|
1691
|
-
key: "render",
|
|
1692
|
-
value: function render() {
|
|
1693
|
-
var _this$props2 = this.props,
|
|
1694
|
-
closeButtonVisible = _this$props2.closeButtonVisible,
|
|
1695
|
-
footer = _this$props2.footer,
|
|
1696
|
-
header = _this$props2.header,
|
|
1697
|
-
light = _this$props2.light,
|
|
1698
|
-
onClose = _this$props2.onClose,
|
|
1699
|
-
style = _this$props2.style,
|
|
1700
|
-
testId = _this$props2.testId;
|
|
1701
|
-
var mainContent = this.renderMainContent();
|
|
1702
|
-
return /*#__PURE__*/external_react_["createElement"](wonder_blocks_core_["View"], {
|
|
1703
|
-
style: [modal_panel_styles.wrapper, !light && modal_panel_styles.dark, style],
|
|
1704
|
-
testId: testId && "".concat(testId, "-panel")
|
|
1705
|
-
}, closeButtonVisible && /*#__PURE__*/external_react_["createElement"](close_button_CloseButton, {
|
|
1706
|
-
light: !light,
|
|
1707
|
-
onClick: onClose,
|
|
1708
|
-
style: modal_panel_styles.closeButton,
|
|
1709
|
-
testId: testId && "".concat(testId, "-close")
|
|
1710
|
-
}), header, mainContent, !footer || modal_footer_ModalFooter.isClassOf(footer) ? footer : /*#__PURE__*/external_react_["createElement"](modal_footer_ModalFooter, null, footer));
|
|
1711
|
-
}
|
|
1712
|
-
}]);
|
|
1713
|
-
|
|
1714
|
-
return ModalPanel;
|
|
1715
|
-
}(external_react_["Component"]);
|
|
1716
|
-
|
|
1717
|
-
modal_panel_defineProperty(modal_panel_ModalPanel, "defaultProps", {
|
|
1718
|
-
closeButtonVisible: true,
|
|
1719
|
-
scrollOverflow: true,
|
|
1720
|
-
light: true
|
|
1721
|
-
});
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
var modal_panel_styles = external_aphrodite_["StyleSheet"].create({
|
|
1725
|
-
wrapper: {
|
|
1726
|
-
flex: "1 1 auto",
|
|
1727
|
-
position: "relative",
|
|
1728
|
-
display: "flex",
|
|
1729
|
-
flexDirection: "column",
|
|
1730
|
-
background: "white",
|
|
1731
|
-
boxSizing: "border-box",
|
|
1732
|
-
overflow: "hidden",
|
|
1733
|
-
height: "100%",
|
|
1734
|
-
width: "100%"
|
|
1735
|
-
},
|
|
1736
|
-
closeButton: {
|
|
1737
|
-
position: "absolute",
|
|
1738
|
-
right: wonder_blocks_spacing_default.a.medium_16,
|
|
1739
|
-
top: wonder_blocks_spacing_default.a.medium_16,
|
|
1740
|
-
// This is to allow the button to be tab-ordered before the modal
|
|
1741
|
-
// content but still be above the header and content.
|
|
1742
|
-
zIndex: 1
|
|
1743
|
-
},
|
|
1744
|
-
dark: {
|
|
1745
|
-
background: wonder_blocks_color_default.a.darkBlue,
|
|
1746
|
-
color: wonder_blocks_color_default.a.white
|
|
1747
|
-
},
|
|
1748
|
-
hasFooter: {
|
|
1749
|
-
paddingBottom: wonder_blocks_spacing_default.a.xLarge_32
|
|
1560
|
+
});
|
|
1750
1561
|
}
|
|
1751
|
-
});
|
|
1752
|
-
// CONCATENATED MODULE: ./packages/wonder-blocks-modal/src/components/one-pane-dialog.js
|
|
1753
|
-
function one_pane_dialog_typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { one_pane_dialog_typeof = function _typeof(obj) { return typeof obj; }; } else { one_pane_dialog_typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return one_pane_dialog_typeof(obj); }
|
|
1754
|
-
|
|
1755
|
-
function one_pane_dialog_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
1756
|
-
|
|
1757
|
-
function one_pane_dialog_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); } }
|
|
1758
|
-
|
|
1759
|
-
function one_pane_dialog_createClass(Constructor, protoProps, staticProps) { if (protoProps) one_pane_dialog_defineProperties(Constructor.prototype, protoProps); if (staticProps) one_pane_dialog_defineProperties(Constructor, staticProps); return Constructor; }
|
|
1760
|
-
|
|
1761
|
-
function one_pane_dialog_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) one_pane_dialog_setPrototypeOf(subClass, superClass); }
|
|
1762
|
-
|
|
1763
|
-
function one_pane_dialog_setPrototypeOf(o, p) { one_pane_dialog_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return one_pane_dialog_setPrototypeOf(o, p); }
|
|
1764
|
-
|
|
1765
|
-
function one_pane_dialog_createSuper(Derived) { var hasNativeReflectConstruct = one_pane_dialog_isNativeReflectConstruct(); return function _createSuperInternal() { var Super = one_pane_dialog_getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = one_pane_dialog_getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return one_pane_dialog_possibleConstructorReturn(this, result); }; }
|
|
1766
|
-
|
|
1767
|
-
function one_pane_dialog_possibleConstructorReturn(self, call) { if (call && (one_pane_dialog_typeof(call) === "object" || typeof call === "function")) { return call; } return one_pane_dialog_assertThisInitialized(self); }
|
|
1768
|
-
|
|
1769
|
-
function one_pane_dialog_assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
1770
|
-
|
|
1771
|
-
function one_pane_dialog_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; } }
|
|
1772
|
-
|
|
1773
|
-
function one_pane_dialog_getPrototypeOf(o) { one_pane_dialog_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return one_pane_dialog_getPrototypeOf(o); }
|
|
1774
|
-
|
|
1775
|
-
function one_pane_dialog_defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
/**
|
|
1786
|
-
* This is the standard layout for most straightforward modal experiences.
|
|
1787
|
-
*
|
|
1788
|
-
* The ModalHeader is required, but the ModalFooter is optional.
|
|
1789
|
-
* The content of the dialog itself is fully customizable, but the left/right/top/bottom padding is fixed.
|
|
1790
|
-
*/
|
|
1791
|
-
var one_pane_dialog_OnePaneDialog = /*#__PURE__*/function (_React$Component) {
|
|
1792
|
-
one_pane_dialog_inherits(OnePaneDialog, _React$Component);
|
|
1793
1562
|
|
|
1794
|
-
|
|
1563
|
+
}
|
|
1795
1564
|
|
|
1796
|
-
|
|
1797
|
-
|
|
1565
|
+
/***/ }),
|
|
1566
|
+
/* 23 */
|
|
1567
|
+
/***/ (function(module, exports) {
|
|
1798
1568
|
|
|
1799
|
-
|
|
1800
|
-
}
|
|
1569
|
+
module.exports = require("@khanacademy/wonder-blocks-icon");
|
|
1801
1570
|
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
var _this$props = this.props,
|
|
1806
|
-
title = _this$props.title,
|
|
1807
|
-
_this$props$breadcrum = _this$props.breadcrumbs,
|
|
1808
|
-
breadcrumbs = _this$props$breadcrum === void 0 ? undefined : _this$props$breadcrum,
|
|
1809
|
-
_this$props$subtitle = _this$props.subtitle,
|
|
1810
|
-
subtitle = _this$props$subtitle === void 0 ? undefined : _this$props$subtitle,
|
|
1811
|
-
testId = _this$props.testId;
|
|
1812
|
-
|
|
1813
|
-
if (breadcrumbs) {
|
|
1814
|
-
return /*#__PURE__*/external_react_["createElement"](modal_header_ModalHeader, {
|
|
1815
|
-
title: title,
|
|
1816
|
-
breadcrumbs: breadcrumbs,
|
|
1817
|
-
titleId: uniqueId,
|
|
1818
|
-
testId: testId && "".concat(testId, "-header")
|
|
1819
|
-
});
|
|
1820
|
-
} else if (subtitle) {
|
|
1821
|
-
return /*#__PURE__*/external_react_["createElement"](modal_header_ModalHeader, {
|
|
1822
|
-
title: title,
|
|
1823
|
-
subtitle: subtitle,
|
|
1824
|
-
titleId: uniqueId,
|
|
1825
|
-
testId: testId && "".concat(testId, "-header")
|
|
1826
|
-
});
|
|
1827
|
-
} else {
|
|
1828
|
-
return /*#__PURE__*/external_react_["createElement"](modal_header_ModalHeader, {
|
|
1829
|
-
title: title,
|
|
1830
|
-
titleId: uniqueId,
|
|
1831
|
-
testId: testId && "".concat(testId, "-header")
|
|
1832
|
-
});
|
|
1833
|
-
}
|
|
1834
|
-
}
|
|
1835
|
-
}, {
|
|
1836
|
-
key: "render",
|
|
1837
|
-
value: function render() {
|
|
1838
|
-
var _this = this;
|
|
1839
|
-
|
|
1840
|
-
var _this$props2 = this.props,
|
|
1841
|
-
onClose = _this$props2.onClose,
|
|
1842
|
-
footer = _this$props2.footer,
|
|
1843
|
-
content = _this$props2.content,
|
|
1844
|
-
above = _this$props2.above,
|
|
1845
|
-
below = _this$props2.below,
|
|
1846
|
-
style = _this$props2.style,
|
|
1847
|
-
closeButtonVisible = _this$props2.closeButtonVisible,
|
|
1848
|
-
testId = _this$props2.testId,
|
|
1849
|
-
titleId = _this$props2.titleId,
|
|
1850
|
-
role = _this$props2.role;
|
|
1851
|
-
return /*#__PURE__*/external_react_["createElement"](wonder_blocks_layout_["MediaLayout"], {
|
|
1852
|
-
styleSheets: one_pane_dialog_styleSheets
|
|
1853
|
-
}, function (_ref) {
|
|
1854
|
-
var styles = _ref.styles;
|
|
1855
|
-
return /*#__PURE__*/external_react_["createElement"](wonder_blocks_core_["IDProvider"], {
|
|
1856
|
-
id: titleId,
|
|
1857
|
-
scope: "modal"
|
|
1858
|
-
}, function (uniqueId) {
|
|
1859
|
-
return /*#__PURE__*/external_react_["createElement"](modal_dialog_ModalDialog, {
|
|
1860
|
-
style: [styles.dialog, style],
|
|
1861
|
-
above: above,
|
|
1862
|
-
below: below,
|
|
1863
|
-
testId: testId,
|
|
1864
|
-
"aria-labelledby": uniqueId,
|
|
1865
|
-
role: role
|
|
1866
|
-
}, /*#__PURE__*/external_react_["createElement"](modal_panel_ModalPanel, {
|
|
1867
|
-
onClose: onClose,
|
|
1868
|
-
header: _this.renderHeader(uniqueId),
|
|
1869
|
-
content: content,
|
|
1870
|
-
footer: footer,
|
|
1871
|
-
closeButtonVisible: closeButtonVisible,
|
|
1872
|
-
testId: testId
|
|
1873
|
-
}));
|
|
1874
|
-
});
|
|
1875
|
-
});
|
|
1876
|
-
}
|
|
1877
|
-
}]);
|
|
1571
|
+
/***/ }),
|
|
1572
|
+
/* 24 */
|
|
1573
|
+
/***/ (function(module, exports) {
|
|
1878
1574
|
|
|
1879
|
-
|
|
1880
|
-
}(external_react_["Component"]);
|
|
1575
|
+
module.exports = require("@khanacademy/wonder-blocks-icon-button");
|
|
1881
1576
|
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1577
|
+
/***/ }),
|
|
1578
|
+
/* 25 */
|
|
1579
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
1885
1580
|
|
|
1581
|
+
"use strict";
|
|
1582
|
+
__webpack_require__.r(__webpack_exports__);
|
|
1583
|
+
/* harmony import */ var _components_modal_dialog_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(9);
|
|
1584
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ModalDialog", function() { return _components_modal_dialog_js__WEBPACK_IMPORTED_MODULE_0__["a"]; });
|
|
1886
1585
|
|
|
1887
|
-
var
|
|
1888
|
-
|
|
1889
|
-
dialog: {
|
|
1890
|
-
width: "100%",
|
|
1891
|
-
height: "100%",
|
|
1892
|
-
overflow: "hidden"
|
|
1893
|
-
}
|
|
1894
|
-
}),
|
|
1895
|
-
mdOrLarger: external_aphrodite_["StyleSheet"].create({
|
|
1896
|
-
dialog: {
|
|
1897
|
-
width: "93.75%",
|
|
1898
|
-
maxWidth: 576,
|
|
1899
|
-
height: "81.25%",
|
|
1900
|
-
maxHeight: 624
|
|
1901
|
-
}
|
|
1902
|
-
})
|
|
1903
|
-
};
|
|
1904
|
-
// CONCATENATED MODULE: ./packages/wonder-blocks-modal/src/util/maybe-get-portal-mounted-modal-host-element.js
|
|
1586
|
+
/* harmony import */ var _components_modal_footer_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(8);
|
|
1587
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ModalFooter", function() { return _components_modal_footer_js__WEBPACK_IMPORTED_MODULE_1__["a"]; });
|
|
1905
1588
|
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
* element.
|
|
1909
|
-
* @param {?(Element | Text)} element The element whose ancestors are to be
|
|
1910
|
-
* walked.
|
|
1911
|
-
* @returns {?Element} The nearest parent modal launcher portal.
|
|
1912
|
-
*/
|
|
1589
|
+
/* harmony import */ var _components_modal_header_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(7);
|
|
1590
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ModalHeader", function() { return _components_modal_header_js__WEBPACK_IMPORTED_MODULE_2__["a"]; });
|
|
1913
1591
|
|
|
1914
|
-
|
|
1915
|
-
|
|
1592
|
+
/* harmony import */ var _components_modal_launcher_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(15);
|
|
1593
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ModalLauncher", function() { return _components_modal_launcher_js__WEBPACK_IMPORTED_MODULE_3__["a"]; });
|
|
1916
1594
|
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
}
|
|
1595
|
+
/* harmony import */ var _components_modal_panel_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(10);
|
|
1596
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ModalPanel", function() { return _components_modal_panel_js__WEBPACK_IMPORTED_MODULE_4__["a"]; });
|
|
1920
1597
|
|
|
1921
|
-
|
|
1922
|
-
}
|
|
1923
|
-
/**
|
|
1924
|
-
* From a given element, finds the next modal host that has been mounted in
|
|
1925
|
-
* a modal portal.
|
|
1926
|
-
* @param {?(Element | Text)} element The element whose ancestors are to be
|
|
1927
|
-
* walked.
|
|
1928
|
-
* @returns {?Element} The next portal-mounted modal host element.
|
|
1929
|
-
* TODO(kevinb): look into getting rid of this
|
|
1930
|
-
*/
|
|
1598
|
+
/* harmony import */ var _components_one_pane_dialog_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(16);
|
|
1599
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OnePaneDialog", function() { return _components_one_pane_dialog_js__WEBPACK_IMPORTED_MODULE_5__["a"]; });
|
|
1931
1600
|
|
|
1601
|
+
/* harmony import */ var _util_maybe_get_portal_mounted_modal_host_element_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(17);
|
|
1602
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "maybeGetPortalMountedModalHostElement", function() { return _util_maybe_get_portal_mounted_modal_host_element_js__WEBPACK_IMPORTED_MODULE_6__["a"]; });
|
|
1932
1603
|
|
|
1933
|
-
function maybeGetPortalMountedModalHostElement(element) {
|
|
1934
|
-
return maybeGetNextAncestorModalLauncherPortal(element);
|
|
1935
|
-
}
|
|
1936
|
-
// CONCATENATED MODULE: ./packages/wonder-blocks-modal/src/index.js
|
|
1937
1604
|
|
|
1938
1605
|
|
|
1939
1606
|
|