@khanacademy/wonder-blocks-modal 3.0.7 → 3.0.8
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 +32 -0
- package/dist/components/close-button.d.ts +31 -0
- package/dist/components/close-button.js.flow +43 -0
- package/dist/components/focus-trap.d.ts +57 -0
- package/dist/components/focus-trap.js.flow +69 -0
- package/dist/components/modal-backdrop.d.ts +50 -0
- package/dist/components/modal-backdrop.js.flow +63 -0
- package/dist/components/modal-content.d.ts +23 -0
- package/dist/components/modal-content.js.flow +39 -0
- package/dist/components/modal-context.d.ts +6 -0
- package/dist/components/modal-context.js.flow +14 -0
- package/dist/components/modal-dialog.d.ts +60 -0
- package/dist/components/modal-dialog.js.flow +75 -0
- package/dist/components/modal-footer.d.ts +27 -0
- package/dist/components/modal-footer.js.flow +34 -0
- package/dist/components/modal-header.d.ts +93 -0
- package/dist/components/modal-header.js.flow +110 -0
- package/dist/components/modal-launcher.d.ts +17 -0
- package/dist/components/modal-launcher.js.flow +34 -0
- package/dist/components/modal-panel.d.ts +84 -0
- package/dist/components/modal-panel.js.flow +102 -0
- package/dist/components/one-pane-dialog.d.ts +124 -0
- package/dist/components/one-pane-dialog.js.flow +153 -0
- package/dist/components/scroll-disabler.d.ts +24 -0
- package/dist/components/scroll-disabler.js.flow +21 -0
- package/dist/es/index.js +222 -210
- package/dist/index.d.ts +8 -0
- package/dist/index.js +237 -226
- package/dist/index.js.flow +23 -2
- package/dist/util/constants.d.ts +5 -0
- package/dist/util/constants.js.flow +12 -0
- package/dist/util/find-focusable-nodes.d.ts +1 -0
- package/dist/util/find-focusable-nodes.js.flow +10 -0
- package/dist/util/maybe-get-portal-mounted-modal-host-element.d.ts +9 -0
- package/dist/util/maybe-get-portal-mounted-modal-host-element.js.flow +18 -0
- package/dist/util/types.d.ts +12 -0
- package/dist/util/types.js.flow +20 -0
- package/package.json +13 -13
- package/src/components/__tests__/{close-button.test.js → close-button.test.tsx} +0 -1
- package/src/components/__tests__/{focus-trap.test.js → focus-trap.test.tsx} +0 -1
- package/src/components/__tests__/{modal-backdrop.test.js → modal-backdrop.test.tsx} +0 -1
- package/src/components/__tests__/{modal-header.test.js → modal-header.test.tsx} +3 -2
- package/src/components/__tests__/{modal-launcher.test.js → modal-launcher.test.tsx} +11 -15
- package/src/components/__tests__/{modal-panel.test.js → modal-panel.test.tsx} +0 -1
- package/src/components/__tests__/{one-pane-dialog.test.js → one-pane-dialog.test.tsx} +0 -1
- package/src/components/{close-button.js → close-button.tsx} +7 -11
- package/src/components/{focus-trap.js → focus-trap.tsx} +12 -12
- package/src/components/{modal-backdrop.js → modal-backdrop.tsx} +20 -18
- package/src/components/{modal-content.js → modal-content.tsx} +11 -12
- package/src/components/modal-context.ts +13 -0
- package/src/components/{modal-dialog.js → modal-dialog.tsx} +15 -23
- package/src/components/{modal-footer.js → modal-footer.tsx} +5 -6
- package/src/components/{modal-header.js → modal-header.tsx} +20 -26
- package/src/components/{modal-launcher.js → modal-launcher.tsx} +29 -50
- package/src/components/{modal-panel.js → modal-panel.tsx} +27 -28
- package/src/components/{one-pane-dialog.js → one-pane-dialog.tsx} +37 -45
- package/src/components/{scroll-disabler.js → scroll-disabler.ts} +3 -4
- package/src/{index.js → index.ts} +0 -1
- package/src/util/{constants.js → constants.ts} +0 -2
- package/src/util/{find-focusable-nodes.js → find-focusable-nodes.ts} +0 -2
- package/src/util/{maybe-get-portal-mounted-modal-host-element.test.js → maybe-get-portal-mounted-modal-host-element.test.tsx} +4 -5
- package/src/util/{maybe-get-portal-mounted-modal-host-element.js → maybe-get-portal-mounted-modal-host-element.ts} +5 -4
- package/src/util/{types.js → types.ts} +3 -2
- package/tsconfig.json +20 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/src/components/__docs__/modal-dialog.stories.js +0 -308
- package/src/components/__docs__/modal-footer.stories.js +0 -337
- package/src/components/__docs__/modal-header.argtypes.js +0 -76
- package/src/components/__docs__/modal-header.stories.js +0 -294
- package/src/components/__docs__/modal-launcher.argtypes.js +0 -78
- package/src/components/__docs__/modal-launcher.stories.js +0 -513
- package/src/components/__docs__/modal-panel.stories.js +0 -414
- package/src/components/__docs__/one-pane-dialog.argtypes.js +0 -108
- package/src/components/__docs__/one-pane-dialog.stories.js +0 -582
- package/src/components/modal-context.js +0 -14
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flowtype definitions for one-pane-dialog
|
|
3
|
+
* Generated by Flowgen from a Typescript Definition
|
|
4
|
+
* Flowgen v1.21.0
|
|
5
|
+
* @flow
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import * as React from "react";
|
|
9
|
+
import { Breadcrumbs } from "@khanacademy/wonder-blocks-breadcrumbs";
|
|
10
|
+
import type { StyleType } from "@khanacademy/wonder-blocks-core";
|
|
11
|
+
import ModalHeader from "./modal-header";
|
|
12
|
+
declare type Common = {
|
|
13
|
+
/**
|
|
14
|
+
* The content of the modal, appearing between the titlebar and footer.
|
|
15
|
+
*/
|
|
16
|
+
content: React.Node,
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* The title of the modal, appearing in the titlebar.
|
|
20
|
+
*/
|
|
21
|
+
title: string,
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The content of the modal's footer. A great place for buttons!
|
|
25
|
+
*
|
|
26
|
+
* Content is right-aligned by default. To control alignment yourself,
|
|
27
|
+
* provide a container element with 100% width.
|
|
28
|
+
*/
|
|
29
|
+
footer?: React.Node,
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Called when the close button is clicked.
|
|
33
|
+
*
|
|
34
|
+
* If you're using `ModalLauncher`, you probably shouldn't use this prop!
|
|
35
|
+
* Instead, to listen for when the modal closes, add an `onClose` handler
|
|
36
|
+
* to the `ModalLauncher`. Doing so will result in a console.warn().
|
|
37
|
+
*/
|
|
38
|
+
onClose?: () => mixed,
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* When true, the close button is shown; otherwise, the close button is not shown.
|
|
42
|
+
*/
|
|
43
|
+
closeButtonVisible?: boolean,
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* When set, provides a component that can render content above the top of the modal;
|
|
47
|
+
* when not set, no additional content is shown above the modal.
|
|
48
|
+
* This prop is passed down to the ModalDialog.
|
|
49
|
+
*/
|
|
50
|
+
above?: React.Node,
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* When set, provides a component that will render content below the bottom of the modal;
|
|
54
|
+
* when not set, no additional content is shown below the modal.
|
|
55
|
+
* This prop is passed down to the ModalDialog.
|
|
56
|
+
*
|
|
57
|
+
* NOTE: Devs can customize this content by rendering the component assigned to this prop with custom styles,
|
|
58
|
+
* such as by wrapping it in a View.
|
|
59
|
+
*/
|
|
60
|
+
below?: React.Node,
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* When set, overrides the default role value. Default role is "dialog"
|
|
64
|
+
* Roles other than dialog and alertdialog aren't appropriate for this
|
|
65
|
+
* component
|
|
66
|
+
*/
|
|
67
|
+
role?: "dialog" | "alertdialog",
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Optional custom styles.
|
|
71
|
+
*/
|
|
72
|
+
style?: StyleType,
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Test ID used for e2e testing. This ID will be passed down to the Dialog.
|
|
76
|
+
*/
|
|
77
|
+
testId?: string,
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* An optional id parameter for the title. If one is
|
|
81
|
+
* not provided, a unique id will be generated.
|
|
82
|
+
*/
|
|
83
|
+
titleId?: string,
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* The ID of the content describing this dialog, if applicable.
|
|
87
|
+
*/
|
|
88
|
+
"aria-describedby": string | void,
|
|
89
|
+
...
|
|
90
|
+
};
|
|
91
|
+
declare type WithSubtitle = {
|
|
92
|
+
...Common,
|
|
93
|
+
...{
|
|
94
|
+
/**
|
|
95
|
+
* The subtitle of the modal, appearing in the titlebar, below the title.
|
|
96
|
+
*/
|
|
97
|
+
subtitle: string,
|
|
98
|
+
...
|
|
99
|
+
},
|
|
100
|
+
};
|
|
101
|
+
declare type WithBreadcrumbs = {
|
|
102
|
+
...Common,
|
|
103
|
+
...{
|
|
104
|
+
/**
|
|
105
|
+
* Adds a breadcrumb-trail, appearing in the ModalHeader, above the title.
|
|
106
|
+
*/
|
|
107
|
+
breadcrumbs: React.Element<React.ComponentProps<typeof Breadcrumbs>>,
|
|
108
|
+
...
|
|
109
|
+
},
|
|
110
|
+
};
|
|
111
|
+
declare type Props = Common | WithSubtitle | WithBreadcrumbs;
|
|
112
|
+
declare type DefaultProps = {
|
|
113
|
+
closeButtonVisible: $PropertyType<Props, "closeButtonVisible">,
|
|
114
|
+
...
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
* This is the standard layout for most straightforward modal experiences.
|
|
118
|
+
*
|
|
119
|
+
* The ModalHeader is required, but the ModalFooter is optional.
|
|
120
|
+
* The content of the dialog itself is fully customizable, but the
|
|
121
|
+
* left/right/top/bottom padding is fixed.
|
|
122
|
+
*
|
|
123
|
+
* ### Usage
|
|
124
|
+
*
|
|
125
|
+
* ```jsx
|
|
126
|
+
* import {OnePaneDialog} from "@khanacademy/wonder-blocks-modal";
|
|
127
|
+
* import {Body} from "@khanacademy/wonder-blocks-typography";
|
|
128
|
+
*
|
|
129
|
+
* <OnePaneDialog
|
|
130
|
+
* title="Some title"
|
|
131
|
+
* content={
|
|
132
|
+
* <Body>
|
|
133
|
+
* {`Lorem ipsum dolor sit amet, consectetur adipiscing
|
|
134
|
+
* elit, sed do eiusmod tempor incididunt ut labore et
|
|
135
|
+
* dolore magna aliqua. Ut enim ad minim veniam,
|
|
136
|
+
* quis nostrud exercitation ullamco laboris nisi ut
|
|
137
|
+
* aliquip ex ea commodo consequat. Duis aute irure
|
|
138
|
+
* dolor in reprehenderit in voluptate velit esse
|
|
139
|
+
* cillum dolore eu fugiat nulla pariatur. Excepteur
|
|
140
|
+
* sint occaecat cupidatat non proident, sunt in culpa
|
|
141
|
+
* qui officia deserunt mollit anim id est.`}
|
|
142
|
+
* </Body>
|
|
143
|
+
* }
|
|
144
|
+
* />
|
|
145
|
+
* ```
|
|
146
|
+
*/
|
|
147
|
+
declare export default class OnePaneDialog mixins React.Component<Props> {
|
|
148
|
+
static defaultProps: DefaultProps;
|
|
149
|
+
renderHeader(
|
|
150
|
+
uniqueId: string
|
|
151
|
+
): React.Element<React.ComponentProps<typeof ModalHeader>>;
|
|
152
|
+
render(): React.Element<>;
|
|
153
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A UI-less component that lets `ModalLauncher` disable page scroll.
|
|
3
|
+
*
|
|
4
|
+
* The positioning of the modal requires some global page state changed
|
|
5
|
+
* unfortunately, and this handles that in an encapsulated way.
|
|
6
|
+
*
|
|
7
|
+
* NOTE(mdr): This component was copied from webapp. Be wary of sync issues. It
|
|
8
|
+
* also doesn't have unit tests, and we haven't added any, since it's a
|
|
9
|
+
* relatively stable component that has now been stress-tested lots in prod.
|
|
10
|
+
*/
|
|
11
|
+
import * as React from "react";
|
|
12
|
+
type Props = Record<any, any>;
|
|
13
|
+
declare class ScrollDisabler extends React.Component<Props> {
|
|
14
|
+
static oldOverflow: string;
|
|
15
|
+
static oldPosition: string;
|
|
16
|
+
static oldScrollY: number;
|
|
17
|
+
static oldWidth: string;
|
|
18
|
+
static oldTop: string;
|
|
19
|
+
componentDidMount(): void;
|
|
20
|
+
componentWillUnmount(): void;
|
|
21
|
+
static numModalsOpened: number;
|
|
22
|
+
render(): React.ReactElement | null;
|
|
23
|
+
}
|
|
24
|
+
export default ScrollDisabler;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flowtype definitions for scroll-disabler
|
|
3
|
+
* Generated by Flowgen from a Typescript Definition
|
|
4
|
+
* Flowgen v1.21.0
|
|
5
|
+
* @flow
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import * as React from "react";
|
|
9
|
+
declare type Props = { [key: any]: any, ... };
|
|
10
|
+
declare class ScrollDisabler mixins React.Component<Props> {
|
|
11
|
+
static oldOverflow: string;
|
|
12
|
+
static oldPosition: string;
|
|
13
|
+
static oldScrollY: number;
|
|
14
|
+
static oldWidth: string;
|
|
15
|
+
static oldTop: string;
|
|
16
|
+
componentDidMount(): void;
|
|
17
|
+
componentWillUnmount(): void;
|
|
18
|
+
static numModalsOpened: number;
|
|
19
|
+
render(): React.Element<> | null;
|
|
20
|
+
}
|
|
21
|
+
declare export default typeof ScrollDisabler;
|