@khanacademy/wonder-blocks-modal 2.1.44 → 2.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +29 -0
- package/dist/es/index.js +96 -85
- package/dist/index.js +42 -23
- package/package.json +13 -14
- package/src/__tests__/__snapshots__/generated-snapshot.test.js.snap +11 -11
- package/src/components/__tests__/close-button.test.js +1 -0
- package/src/components/__tests__/modal-backdrop.test.js +115 -57
- package/src/components/__tests__/modal-header.test.js +1 -0
- package/src/components/__tests__/modal-launcher.test.js +37 -6
- package/src/components/__tests__/modal-panel.test.js +1 -0
- package/src/components/__tests__/one-pane-dialog.test.js +1 -0
- package/src/components/modal-backdrop.js +17 -13
- package/src/components/one-pane-dialog.stories.js +4 -4
- package/src/util/find-focusable-nodes.js +14 -0
- package/src/util/maybe-get-portal-mounted-modal-host-element.test.js +3 -3
- package/LICENSE +0 -21
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# @khanacademy/wonder-blocks-modal
|
|
2
|
+
|
|
3
|
+
## 2.2.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- @khanacademy/wonder-blocks-icon-button@3.4.4
|
|
8
|
+
|
|
9
|
+
## 2.2.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- @khanacademy/wonder-blocks-breadcrumbs@1.0.28
|
|
14
|
+
- @khanacademy/wonder-blocks-core@4.2.1
|
|
15
|
+
- @khanacademy/wonder-blocks-icon@1.2.25
|
|
16
|
+
- @khanacademy/wonder-blocks-icon-button@3.4.3
|
|
17
|
+
- @khanacademy/wonder-blocks-layout@1.4.7
|
|
18
|
+
- @khanacademy/wonder-blocks-toolbar@2.1.29
|
|
19
|
+
- @khanacademy/wonder-blocks-typography@1.1.29
|
|
20
|
+
|
|
21
|
+
## 2.2.0
|
|
22
|
+
|
|
23
|
+
### Minor Changes
|
|
24
|
+
|
|
25
|
+
- e7bbf149: Modals will no longer close when a user presses in the panel, drags, and releases the mouse in backdrop and vice versa.
|
|
26
|
+
|
|
27
|
+
### Patch Changes
|
|
28
|
+
|
|
29
|
+
- @khanacademy/wonder-blocks-icon-button@3.4.2
|
package/dist/es/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as React from 'react';
|
|
2
2
|
import { StyleSheet } from 'aphrodite';
|
|
3
3
|
import { MediaLayoutContext, MediaLayout, MEDIA_MODAL_SPEC } from '@khanacademy/wonder-blocks-layout';
|
|
4
4
|
import { View, IDProvider } from '@khanacademy/wonder-blocks-core';
|
|
5
5
|
import Spacing from '@khanacademy/wonder-blocks-spacing';
|
|
6
6
|
import Color from '@khanacademy/wonder-blocks-color';
|
|
7
7
|
import { HeadingMedium, LabelSmall } from '@khanacademy/wonder-blocks-typography';
|
|
8
|
-
import
|
|
8
|
+
import * as ReactDOM from 'react-dom';
|
|
9
9
|
import _extends from '@babel/runtime/helpers/extends';
|
|
10
10
|
import { icons } from '@khanacademy/wonder-blocks-icon';
|
|
11
11
|
import IconButton from '@khanacademy/wonder-blocks-icon-button';
|
|
@@ -20,7 +20,7 @@ import IconButton from '@khanacademy/wonder-blocks-icon-button';
|
|
|
20
20
|
* - If there is a custom Dialog implementation (e.g. `TwoPaneDialog`), the dialog element doesn’t have to have
|
|
21
21
|
* the `aria-labelledby` attribute however this is recommended. It should match the `id` of the dialog title.
|
|
22
22
|
*/
|
|
23
|
-
class ModalDialog extends Component {
|
|
23
|
+
class ModalDialog extends React.Component {
|
|
24
24
|
render() {
|
|
25
25
|
const {
|
|
26
26
|
above,
|
|
@@ -35,23 +35,23 @@ class ModalDialog extends Component {
|
|
|
35
35
|
ssrSize: "large",
|
|
36
36
|
mediaSpec: MEDIA_MODAL_SPEC
|
|
37
37
|
};
|
|
38
|
-
return /*#__PURE__*/createElement(MediaLayoutContext.Provider, {
|
|
38
|
+
return /*#__PURE__*/React.createElement(MediaLayoutContext.Provider, {
|
|
39
39
|
value: contextValue
|
|
40
|
-
}, /*#__PURE__*/createElement(MediaLayout, {
|
|
41
|
-
styleSheets: styleSheets
|
|
40
|
+
}, /*#__PURE__*/React.createElement(MediaLayout, {
|
|
41
|
+
styleSheets: styleSheets$3
|
|
42
42
|
}, ({
|
|
43
43
|
styles
|
|
44
|
-
}) => /*#__PURE__*/createElement(View, {
|
|
44
|
+
}) => /*#__PURE__*/React.createElement(View, {
|
|
45
45
|
style: [styles.wrapper, style]
|
|
46
|
-
}, below && /*#__PURE__*/createElement(View, {
|
|
46
|
+
}, below && /*#__PURE__*/React.createElement(View, {
|
|
47
47
|
style: styles.below
|
|
48
|
-
}, below), /*#__PURE__*/createElement(View, {
|
|
48
|
+
}, below), /*#__PURE__*/React.createElement(View, {
|
|
49
49
|
role: role,
|
|
50
50
|
"aria-modal": "true",
|
|
51
51
|
"aria-labelledby": ariaLabelledBy,
|
|
52
52
|
style: styles.dialog,
|
|
53
53
|
testId: testId
|
|
54
|
-
}, children), above && /*#__PURE__*/createElement(View, {
|
|
54
|
+
}, children), above && /*#__PURE__*/React.createElement(View, {
|
|
55
55
|
style: styles.above
|
|
56
56
|
}, above))));
|
|
57
57
|
}
|
|
@@ -60,7 +60,7 @@ class ModalDialog extends Component {
|
|
|
60
60
|
ModalDialog.defaultProps = {
|
|
61
61
|
role: "dialog"
|
|
62
62
|
};
|
|
63
|
-
const styleSheets = {
|
|
63
|
+
const styleSheets$3 = {
|
|
64
64
|
all: StyleSheet.create({
|
|
65
65
|
wrapper: {
|
|
66
66
|
display: "flex",
|
|
@@ -116,7 +116,7 @@ const styleSheets = {
|
|
|
116
116
|
* - Make sure to include it as part of [ModalPanel](/#modalpanel) by using the `footer` prop.
|
|
117
117
|
* - The footer is completely flexible. Meaning the developer needs to add its own custom layout to match design specs.
|
|
118
118
|
*/
|
|
119
|
-
class ModalFooter extends Component {
|
|
119
|
+
class ModalFooter extends React.Component {
|
|
120
120
|
static isClassOf(instance) {
|
|
121
121
|
return instance && instance.type && instance.type.__IS_MODAL_FOOTER__;
|
|
122
122
|
}
|
|
@@ -125,14 +125,14 @@ class ModalFooter extends Component {
|
|
|
125
125
|
const {
|
|
126
126
|
children
|
|
127
127
|
} = this.props;
|
|
128
|
-
return /*#__PURE__*/createElement(View, {
|
|
129
|
-
style: styles.footer
|
|
128
|
+
return /*#__PURE__*/React.createElement(View, {
|
|
129
|
+
style: styles$3.footer
|
|
130
130
|
}, children);
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
}
|
|
134
134
|
ModalFooter.__IS_MODAL_FOOTER__ = true;
|
|
135
|
-
const styles = StyleSheet.create({
|
|
135
|
+
const styles$3 = StyleSheet.create({
|
|
136
136
|
footer: {
|
|
137
137
|
flex: "0 0 auto",
|
|
138
138
|
boxSizing: "border-box",
|
|
@@ -192,7 +192,7 @@ const styles = StyleSheet.create({
|
|
|
192
192
|
* />
|
|
193
193
|
* ```
|
|
194
194
|
*/
|
|
195
|
-
class ModalHeader extends Component {
|
|
195
|
+
class ModalHeader extends React.Component {
|
|
196
196
|
render() {
|
|
197
197
|
const {
|
|
198
198
|
breadcrumbs = undefined,
|
|
@@ -207,20 +207,20 @@ class ModalHeader extends Component {
|
|
|
207
207
|
throw new Error("'subtitle' and 'breadcrumbs' can't be used together");
|
|
208
208
|
}
|
|
209
209
|
|
|
210
|
-
return /*#__PURE__*/createElement(MediaLayout, {
|
|
211
|
-
styleSheets: styleSheets$
|
|
210
|
+
return /*#__PURE__*/React.createElement(MediaLayout, {
|
|
211
|
+
styleSheets: styleSheets$2
|
|
212
212
|
}, ({
|
|
213
213
|
styles
|
|
214
|
-
}) => /*#__PURE__*/createElement(View, {
|
|
214
|
+
}) => /*#__PURE__*/React.createElement(View, {
|
|
215
215
|
style: [styles.header, !light && styles.dark],
|
|
216
216
|
testId: testId
|
|
217
|
-
}, breadcrumbs && /*#__PURE__*/createElement(View, {
|
|
217
|
+
}, breadcrumbs && /*#__PURE__*/React.createElement(View, {
|
|
218
218
|
style: styles.breadcrumbs
|
|
219
|
-
}, breadcrumbs), /*#__PURE__*/createElement(HeadingMedium, {
|
|
219
|
+
}, breadcrumbs), /*#__PURE__*/React.createElement(HeadingMedium, {
|
|
220
220
|
style: styles.title,
|
|
221
221
|
id: titleId,
|
|
222
222
|
testId: testId && `${testId}-title`
|
|
223
|
-
}, title), subtitle && /*#__PURE__*/createElement(LabelSmall, {
|
|
223
|
+
}, title), subtitle && /*#__PURE__*/React.createElement(LabelSmall, {
|
|
224
224
|
style: light && styles.subtitle,
|
|
225
225
|
testId: testId && `${testId}-subtitle`
|
|
226
226
|
}, subtitle)));
|
|
@@ -230,7 +230,7 @@ class ModalHeader extends Component {
|
|
|
230
230
|
ModalHeader.defaultProps = {
|
|
231
231
|
light: true
|
|
232
232
|
};
|
|
233
|
-
const styleSheets$
|
|
233
|
+
const styleSheets$2 = {
|
|
234
234
|
all: StyleSheet.create({
|
|
235
235
|
header: {
|
|
236
236
|
boxShadow: `0px 1px 0px ${Color.offBlack16}`,
|
|
@@ -269,7 +269,7 @@ const styleSheets$1 = {
|
|
|
269
269
|
})
|
|
270
270
|
};
|
|
271
271
|
|
|
272
|
-
class FocusTrap extends Component {
|
|
272
|
+
class FocusTrap extends React.Component {
|
|
273
273
|
/** The most recent node _inside this component_ to receive focus. */
|
|
274
274
|
|
|
275
275
|
/**
|
|
@@ -289,7 +289,7 @@ class FocusTrap extends Component {
|
|
|
289
289
|
return;
|
|
290
290
|
}
|
|
291
291
|
|
|
292
|
-
const modalRoot = findDOMNode(node);
|
|
292
|
+
const modalRoot = ReactDOM.findDOMNode(node);
|
|
293
293
|
|
|
294
294
|
if (!modalRoot) {
|
|
295
295
|
throw new Error("Assertion error: modal root should exist after mount");
|
|
@@ -418,15 +418,15 @@ class FocusTrap extends Component {
|
|
|
418
418
|
const {
|
|
419
419
|
style
|
|
420
420
|
} = this.props;
|
|
421
|
-
return /*#__PURE__*/createElement(Fragment, null, /*#__PURE__*/createElement("div", {
|
|
421
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
422
422
|
tabIndex: "0",
|
|
423
423
|
style: {
|
|
424
424
|
position: "fixed"
|
|
425
425
|
}
|
|
426
|
-
}), /*#__PURE__*/createElement(View, {
|
|
426
|
+
}), /*#__PURE__*/React.createElement(View, {
|
|
427
427
|
style: style,
|
|
428
428
|
ref: this.getModalRoot
|
|
429
|
-
}, this.props.children), /*#__PURE__*/createElement("div", {
|
|
429
|
+
}, this.props.children), /*#__PURE__*/React.createElement("div", {
|
|
430
430
|
tabIndex: "0",
|
|
431
431
|
style: {
|
|
432
432
|
position: "fixed"
|
|
@@ -446,6 +446,10 @@ const ModalLauncherPortalAttributeName = "data-modal-launcher-portal";
|
|
|
446
446
|
* @see https://www.w3.org/TR/html5/editing.html#can-be-focused
|
|
447
447
|
*/
|
|
448
448
|
const FOCUSABLE_ELEMENTS = 'a[href], details, input, textarea, select, button:not([aria-label^="Close"])';
|
|
449
|
+
function findFocusableNodes(root) {
|
|
450
|
+
return Array.from(root.querySelectorAll(FOCUSABLE_ELEMENTS));
|
|
451
|
+
}
|
|
452
|
+
|
|
449
453
|
/**
|
|
450
454
|
* A private component used by ModalLauncher. This is the fixed-position
|
|
451
455
|
* container element that gets mounted outside the DOM. It overlays the modal
|
|
@@ -456,22 +460,29 @@ const FOCUSABLE_ELEMENTS = 'a[href], details, input, textarea, select, button:no
|
|
|
456
460
|
* and adding an `onClose` prop that will call `onCloseModal`. If an
|
|
457
461
|
* `onClose` prop is already provided, the two are merged.
|
|
458
462
|
*/
|
|
459
|
-
|
|
460
|
-
class ModalBackdrop extends Component {
|
|
463
|
+
class ModalBackdrop extends React.Component {
|
|
461
464
|
constructor(...args) {
|
|
462
465
|
super(...args);
|
|
466
|
+
this._mousePressedOutside = false;
|
|
463
467
|
|
|
464
|
-
this.
|
|
465
|
-
//
|
|
466
|
-
|
|
467
|
-
|
|
468
|
+
this.handleMouseDown = e => {
|
|
469
|
+
// Confirm that it is the backdrop that is being clicked, not the child
|
|
470
|
+
this._mousePressedOutside = e.target === e.currentTarget;
|
|
471
|
+
};
|
|
472
|
+
|
|
473
|
+
this.handleMouseUp = e => {
|
|
474
|
+
// Confirm that it is the backdrop that is being clicked, not the child
|
|
475
|
+
// and that the mouse was pressed in the backdrop first.
|
|
476
|
+
if (e.target === e.currentTarget && this._mousePressedOutside) {
|
|
468
477
|
this.props.onCloseModal();
|
|
469
478
|
}
|
|
479
|
+
|
|
480
|
+
this._mousePressedOutside = false;
|
|
470
481
|
};
|
|
471
482
|
}
|
|
472
483
|
|
|
473
484
|
componentDidMount() {
|
|
474
|
-
const node = findDOMNode(this);
|
|
485
|
+
const node = ReactDOM.findDOMNode(this);
|
|
475
486
|
|
|
476
487
|
if (!node) {
|
|
477
488
|
return;
|
|
@@ -487,11 +498,10 @@ class ModalBackdrop extends Component {
|
|
|
487
498
|
firstFocusableElement.focus();
|
|
488
499
|
}, 0);
|
|
489
500
|
}
|
|
501
|
+
|
|
490
502
|
/**
|
|
491
503
|
* Returns an element specified by the user
|
|
492
504
|
*/
|
|
493
|
-
|
|
494
|
-
|
|
495
505
|
_getInitialFocusElement(node) {
|
|
496
506
|
const {
|
|
497
507
|
initialFocusId
|
|
@@ -501,7 +511,7 @@ class ModalBackdrop extends Component {
|
|
|
501
511
|
return null;
|
|
502
512
|
}
|
|
503
513
|
|
|
504
|
-
return findDOMNode(node.querySelector(`#${initialFocusId}`));
|
|
514
|
+
return ReactDOM.findDOMNode(node.querySelector(`#${initialFocusId}`));
|
|
505
515
|
}
|
|
506
516
|
/**
|
|
507
517
|
* Returns the first focusable element found inside the Dialog
|
|
@@ -510,7 +520,7 @@ class ModalBackdrop extends Component {
|
|
|
510
520
|
|
|
511
521
|
_getFirstFocusableElement(node) {
|
|
512
522
|
// get a collection of elements that can be focused
|
|
513
|
-
const focusableElements = node
|
|
523
|
+
const focusableElements = findFocusableNodes(node);
|
|
514
524
|
|
|
515
525
|
if (!focusableElements) {
|
|
516
526
|
return null;
|
|
@@ -527,7 +537,7 @@ class ModalBackdrop extends Component {
|
|
|
527
537
|
_getDialogElement(node) {
|
|
528
538
|
// If no focusable elements are found,
|
|
529
539
|
// the dialog content element itself will receive focus.
|
|
530
|
-
const dialogElement = findDOMNode(node.querySelector('[role="dialog"]')); // add tabIndex to make the Dialog focusable
|
|
540
|
+
const dialogElement = ReactDOM.findDOMNode(node.querySelector('[role="dialog"]')); // add tabIndex to make the Dialog focusable
|
|
531
541
|
|
|
532
542
|
dialogElement.tabIndex = -1;
|
|
533
543
|
return dialogElement;
|
|
@@ -547,15 +557,16 @@ class ModalBackdrop extends Component {
|
|
|
547
557
|
const backdropProps = {
|
|
548
558
|
[ModalLauncherPortalAttributeName]: true
|
|
549
559
|
};
|
|
550
|
-
return /*#__PURE__*/createElement(View, _extends({
|
|
551
|
-
style: styles$
|
|
552
|
-
|
|
560
|
+
return /*#__PURE__*/React.createElement(View, _extends({
|
|
561
|
+
style: styles$2.modalPositioner,
|
|
562
|
+
onMouseDown: this.handleMouseDown,
|
|
563
|
+
onMouseUp: this.handleMouseUp,
|
|
553
564
|
testId: testId
|
|
554
565
|
}, backdropProps), children);
|
|
555
566
|
}
|
|
556
567
|
|
|
557
568
|
}
|
|
558
|
-
const styles$
|
|
569
|
+
const styles$2 = StyleSheet.create({
|
|
559
570
|
modalPositioner: {
|
|
560
571
|
position: "fixed",
|
|
561
572
|
left: 0,
|
|
@@ -597,7 +608,7 @@ const needsHackyMobileSafariScrollDisabler = (() => {
|
|
|
597
608
|
return userAgent.indexOf("iPad") > -1 || userAgent.indexOf("iPhone") > -1;
|
|
598
609
|
})();
|
|
599
610
|
|
|
600
|
-
class ScrollDisabler extends Component {
|
|
611
|
+
class ScrollDisabler extends React.Component {
|
|
601
612
|
componentDidMount() {
|
|
602
613
|
if (ScrollDisabler.numModalsOpened === 0) {
|
|
603
614
|
const body = document.body;
|
|
@@ -668,7 +679,7 @@ ScrollDisabler.numModalsOpened = 0;
|
|
|
668
679
|
const defaultContext = {
|
|
669
680
|
closeModal: undefined
|
|
670
681
|
};
|
|
671
|
-
var ModalContext = /*#__PURE__*/createContext(defaultContext);
|
|
682
|
+
var ModalContext = /*#__PURE__*/React.createContext(defaultContext);
|
|
672
683
|
|
|
673
684
|
/**
|
|
674
685
|
* This component enables you to launch a modal, covering the screen.
|
|
@@ -686,7 +697,7 @@ var ModalContext = /*#__PURE__*/createContext(defaultContext);
|
|
|
686
697
|
* like OnePaneDialog and is provided via
|
|
687
698
|
* the `modal` prop.
|
|
688
699
|
*/
|
|
689
|
-
class ModalLauncher extends Component {
|
|
700
|
+
class ModalLauncher extends React.Component {
|
|
690
701
|
constructor(...args) {
|
|
691
702
|
super(...args);
|
|
692
703
|
this.state = {
|
|
@@ -775,24 +786,24 @@ class ModalLauncher extends Component {
|
|
|
775
786
|
// This flow check is valid, it's the babel plugin which is broken,
|
|
776
787
|
// see modal-context.js for details.
|
|
777
788
|
// $FlowFixMe
|
|
778
|
-
createElement(ModalContext.Provider, {
|
|
789
|
+
React.createElement(ModalContext.Provider, {
|
|
779
790
|
value: {
|
|
780
791
|
closeModal: this.handleCloseModal
|
|
781
792
|
}
|
|
782
|
-
}, renderedChildren, this.state.opened && /*#__PURE__*/createPortal(
|
|
793
|
+
}, renderedChildren, this.state.opened && /*#__PURE__*/ReactDOM.createPortal(
|
|
783
794
|
/*#__PURE__*/
|
|
784
795
|
|
|
785
796
|
/* We need the container View that FocusTrap creates to be at the
|
|
786
797
|
correct z-index so that it'll be above the global nav in webapp. */
|
|
787
|
-
createElement(FocusTrap, {
|
|
788
|
-
style: styles$
|
|
789
|
-
}, /*#__PURE__*/createElement(ModalBackdrop, {
|
|
798
|
+
React.createElement(FocusTrap, {
|
|
799
|
+
style: styles$1.container
|
|
800
|
+
}, /*#__PURE__*/React.createElement(ModalBackdrop, {
|
|
790
801
|
initialFocusId: this.props.initialFocusId,
|
|
791
802
|
testId: this.props.testId,
|
|
792
803
|
onCloseModal: this.props.backdropDismissEnabled ? this.handleCloseModal : () => {}
|
|
793
|
-
}, this._renderModal())), body), this.state.opened && /*#__PURE__*/createElement(ModalLauncherKeypressListener, {
|
|
804
|
+
}, this._renderModal())), body), this.state.opened && /*#__PURE__*/React.createElement(ModalLauncherKeypressListener, {
|
|
794
805
|
onClose: this.handleCloseModal
|
|
795
|
-
}), this.state.opened && /*#__PURE__*/createElement(ScrollDisabler, null))
|
|
806
|
+
}), this.state.opened && /*#__PURE__*/React.createElement(ScrollDisabler, null))
|
|
796
807
|
);
|
|
797
808
|
}
|
|
798
809
|
|
|
@@ -803,7 +814,7 @@ ModalLauncher.defaultProps = {
|
|
|
803
814
|
backdropDismissEnabled: true
|
|
804
815
|
};
|
|
805
816
|
|
|
806
|
-
class ModalLauncherKeypressListener extends Component {
|
|
817
|
+
class ModalLauncherKeypressListener extends React.Component {
|
|
807
818
|
constructor(...args) {
|
|
808
819
|
super(...args);
|
|
809
820
|
|
|
@@ -839,7 +850,7 @@ class ModalLauncherKeypressListener extends Component {
|
|
|
839
850
|
|
|
840
851
|
}
|
|
841
852
|
|
|
842
|
-
const styles$
|
|
853
|
+
const styles$1 = StyleSheet.create({
|
|
843
854
|
container: {
|
|
844
855
|
// This z-index is copied from the Khan Academy webapp.
|
|
845
856
|
//
|
|
@@ -853,7 +864,7 @@ const styles$2 = StyleSheet.create({
|
|
|
853
864
|
/**
|
|
854
865
|
* The Modal content included after the header
|
|
855
866
|
*/
|
|
856
|
-
class ModalContent extends Component {
|
|
867
|
+
class ModalContent extends React.Component {
|
|
857
868
|
static isClassOf(instance) {
|
|
858
869
|
return instance && instance.type && instance.type.__IS_MODAL_CONTENT__;
|
|
859
870
|
}
|
|
@@ -864,13 +875,13 @@ class ModalContent extends Component {
|
|
|
864
875
|
style,
|
|
865
876
|
children
|
|
866
877
|
} = this.props;
|
|
867
|
-
return /*#__PURE__*/createElement(MediaLayout, {
|
|
868
|
-
styleSheets: styleSheets$
|
|
878
|
+
return /*#__PURE__*/React.createElement(MediaLayout, {
|
|
879
|
+
styleSheets: styleSheets$1
|
|
869
880
|
}, ({
|
|
870
881
|
styles
|
|
871
|
-
}) => /*#__PURE__*/createElement(View, {
|
|
882
|
+
}) => /*#__PURE__*/React.createElement(View, {
|
|
872
883
|
style: [styles.wrapper, scrollOverflow && styles.scrollOverflow]
|
|
873
|
-
}, /*#__PURE__*/createElement(View, {
|
|
884
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
874
885
|
style: [styles.content, style]
|
|
875
886
|
}, children)));
|
|
876
887
|
}
|
|
@@ -880,7 +891,7 @@ ModalContent.defaultProps = {
|
|
|
880
891
|
scrollOverflow: true
|
|
881
892
|
};
|
|
882
893
|
ModalContent.__IS_MODAL_CONTENT__ = true;
|
|
883
|
-
const styleSheets$
|
|
894
|
+
const styleSheets$1 = {
|
|
884
895
|
all: StyleSheet.create({
|
|
885
896
|
wrapper: {
|
|
886
897
|
flex: 1,
|
|
@@ -905,7 +916,7 @@ const styleSheets$2 = {
|
|
|
905
916
|
})
|
|
906
917
|
};
|
|
907
918
|
|
|
908
|
-
class CloseButton extends Component {
|
|
919
|
+
class CloseButton extends React.Component {
|
|
909
920
|
render() {
|
|
910
921
|
const {
|
|
911
922
|
light,
|
|
@@ -913,14 +924,14 @@ class CloseButton extends Component {
|
|
|
913
924
|
style,
|
|
914
925
|
testId
|
|
915
926
|
} = this.props;
|
|
916
|
-
return /*#__PURE__*/createElement(ModalContext.Consumer, null, ({
|
|
927
|
+
return /*#__PURE__*/React.createElement(ModalContext.Consumer, null, ({
|
|
917
928
|
closeModal
|
|
918
929
|
}) => {
|
|
919
930
|
if (closeModal && onClick) {
|
|
920
931
|
throw new Error("You've specified 'onClose' on a modal when using ModalLauncher. Please specify 'onClose' on the ModalLauncher instead");
|
|
921
932
|
}
|
|
922
933
|
|
|
923
|
-
return /*#__PURE__*/createElement(IconButton, {
|
|
934
|
+
return /*#__PURE__*/React.createElement(IconButton, {
|
|
924
935
|
icon: icons.dismiss // TODO(mdr): Translate this string for i18n.
|
|
925
936
|
// TODO(kevinb): provide a way to set this label
|
|
926
937
|
,
|
|
@@ -956,27 +967,27 @@ class CloseButton extends Component {
|
|
|
956
967
|
* </ModalDialog>
|
|
957
968
|
* ```
|
|
958
969
|
*/
|
|
959
|
-
class ModalPanel extends Component {
|
|
970
|
+
class ModalPanel extends React.Component {
|
|
960
971
|
renderMainContent() {
|
|
961
972
|
const {
|
|
962
973
|
content,
|
|
963
974
|
footer,
|
|
964
975
|
scrollOverflow
|
|
965
976
|
} = this.props;
|
|
966
|
-
const mainContent = ModalContent.isClassOf(content) ? content : /*#__PURE__*/createElement(ModalContent, null, content);
|
|
977
|
+
const mainContent = ModalContent.isClassOf(content) ? content : /*#__PURE__*/React.createElement(ModalContent, null, content);
|
|
967
978
|
|
|
968
979
|
if (!mainContent) {
|
|
969
980
|
return mainContent;
|
|
970
981
|
}
|
|
971
982
|
|
|
972
|
-
return /*#__PURE__*/cloneElement(mainContent, {
|
|
983
|
+
return /*#__PURE__*/React.cloneElement(mainContent, {
|
|
973
984
|
// Pass the scrollOverflow and header in to the main content
|
|
974
985
|
scrollOverflow,
|
|
975
986
|
// We override the styling of the main content to help position
|
|
976
987
|
// it if there is a footer or close button being
|
|
977
988
|
// shown. We have to do this here as the ModalContent doesn't
|
|
978
989
|
// know about things being positioned around it.
|
|
979
|
-
style: [!!footer && styles
|
|
990
|
+
style: [!!footer && styles.hasFooter, mainContent.props.style]
|
|
980
991
|
});
|
|
981
992
|
}
|
|
982
993
|
|
|
@@ -991,15 +1002,15 @@ class ModalPanel extends Component {
|
|
|
991
1002
|
testId
|
|
992
1003
|
} = this.props;
|
|
993
1004
|
const mainContent = this.renderMainContent();
|
|
994
|
-
return /*#__PURE__*/createElement(View, {
|
|
995
|
-
style: [styles
|
|
1005
|
+
return /*#__PURE__*/React.createElement(View, {
|
|
1006
|
+
style: [styles.wrapper, !light && styles.dark, style],
|
|
996
1007
|
testId: testId && `${testId}-panel`
|
|
997
|
-
}, closeButtonVisible && /*#__PURE__*/createElement(CloseButton, {
|
|
1008
|
+
}, closeButtonVisible && /*#__PURE__*/React.createElement(CloseButton, {
|
|
998
1009
|
light: !light,
|
|
999
1010
|
onClick: onClose,
|
|
1000
|
-
style: styles
|
|
1011
|
+
style: styles.closeButton,
|
|
1001
1012
|
testId: testId && `${testId}-close`
|
|
1002
|
-
}), header, mainContent, !footer || ModalFooter.isClassOf(footer) ? footer : /*#__PURE__*/createElement(ModalFooter, null, footer));
|
|
1013
|
+
}), header, mainContent, !footer || ModalFooter.isClassOf(footer) ? footer : /*#__PURE__*/React.createElement(ModalFooter, null, footer));
|
|
1003
1014
|
}
|
|
1004
1015
|
|
|
1005
1016
|
}
|
|
@@ -1008,7 +1019,7 @@ ModalPanel.defaultProps = {
|
|
|
1008
1019
|
scrollOverflow: true,
|
|
1009
1020
|
light: true
|
|
1010
1021
|
};
|
|
1011
|
-
const styles
|
|
1022
|
+
const styles = StyleSheet.create({
|
|
1012
1023
|
wrapper: {
|
|
1013
1024
|
flex: "1 1 auto",
|
|
1014
1025
|
position: "relative",
|
|
@@ -1043,7 +1054,7 @@ const styles$3 = StyleSheet.create({
|
|
|
1043
1054
|
* The ModalHeader is required, but the ModalFooter is optional.
|
|
1044
1055
|
* The content of the dialog itself is fully customizable, but the left/right/top/bottom padding is fixed.
|
|
1045
1056
|
*/
|
|
1046
|
-
class OnePaneDialog extends Component {
|
|
1057
|
+
class OnePaneDialog extends React.Component {
|
|
1047
1058
|
renderHeader(uniqueId) {
|
|
1048
1059
|
const {
|
|
1049
1060
|
title,
|
|
@@ -1053,21 +1064,21 @@ class OnePaneDialog extends Component {
|
|
|
1053
1064
|
} = this.props;
|
|
1054
1065
|
|
|
1055
1066
|
if (breadcrumbs) {
|
|
1056
|
-
return /*#__PURE__*/createElement(ModalHeader, {
|
|
1067
|
+
return /*#__PURE__*/React.createElement(ModalHeader, {
|
|
1057
1068
|
title: title,
|
|
1058
1069
|
breadcrumbs: breadcrumbs,
|
|
1059
1070
|
titleId: uniqueId,
|
|
1060
1071
|
testId: testId && `${testId}-header`
|
|
1061
1072
|
});
|
|
1062
1073
|
} else if (subtitle) {
|
|
1063
|
-
return /*#__PURE__*/createElement(ModalHeader, {
|
|
1074
|
+
return /*#__PURE__*/React.createElement(ModalHeader, {
|
|
1064
1075
|
title: title,
|
|
1065
1076
|
subtitle: subtitle,
|
|
1066
1077
|
titleId: uniqueId,
|
|
1067
1078
|
testId: testId && `${testId}-header`
|
|
1068
1079
|
});
|
|
1069
1080
|
} else {
|
|
1070
|
-
return /*#__PURE__*/createElement(ModalHeader, {
|
|
1081
|
+
return /*#__PURE__*/React.createElement(ModalHeader, {
|
|
1071
1082
|
title: title,
|
|
1072
1083
|
titleId: uniqueId,
|
|
1073
1084
|
testId: testId && `${testId}-header`
|
|
@@ -1088,21 +1099,21 @@ class OnePaneDialog extends Component {
|
|
|
1088
1099
|
titleId,
|
|
1089
1100
|
role
|
|
1090
1101
|
} = this.props;
|
|
1091
|
-
return /*#__PURE__*/createElement(MediaLayout, {
|
|
1092
|
-
styleSheets: styleSheets
|
|
1102
|
+
return /*#__PURE__*/React.createElement(MediaLayout, {
|
|
1103
|
+
styleSheets: styleSheets
|
|
1093
1104
|
}, ({
|
|
1094
1105
|
styles
|
|
1095
|
-
}) => /*#__PURE__*/createElement(IDProvider, {
|
|
1106
|
+
}) => /*#__PURE__*/React.createElement(IDProvider, {
|
|
1096
1107
|
id: titleId,
|
|
1097
1108
|
scope: "modal"
|
|
1098
|
-
}, uniqueId => /*#__PURE__*/createElement(ModalDialog, {
|
|
1109
|
+
}, uniqueId => /*#__PURE__*/React.createElement(ModalDialog, {
|
|
1099
1110
|
style: [styles.dialog, style],
|
|
1100
1111
|
above: above,
|
|
1101
1112
|
below: below,
|
|
1102
1113
|
testId: testId,
|
|
1103
1114
|
"aria-labelledby": uniqueId,
|
|
1104
1115
|
role: role
|
|
1105
|
-
}, /*#__PURE__*/createElement(ModalPanel, {
|
|
1116
|
+
}, /*#__PURE__*/React.createElement(ModalPanel, {
|
|
1106
1117
|
onClose: onClose,
|
|
1107
1118
|
header: this.renderHeader(uniqueId),
|
|
1108
1119
|
content: content,
|
|
@@ -1116,7 +1127,7 @@ class OnePaneDialog extends Component {
|
|
|
1116
1127
|
OnePaneDialog.defaultProps = {
|
|
1117
1128
|
closeButtonVisible: true
|
|
1118
1129
|
};
|
|
1119
|
-
const styleSheets
|
|
1130
|
+
const styleSheets = {
|
|
1120
1131
|
small: StyleSheet.create({
|
|
1121
1132
|
dialog: {
|
|
1122
1133
|
width: "100%",
|