@khanacademy/wonder-blocks-modal 4.0.18 → 4.0.20

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.
@@ -1,67 +0,0 @@
1
- /**
2
- * Flowtype definitions for data
3
- * Generated by Flowgen from a Typescript Definition
4
- * Flowgen v1.21.0
5
- * @flow
6
- */
7
- import * as React from "react";
8
- import type { StyleType } from "@khanacademy/wonder-blocks-core";
9
-
10
- /**
11
- * This component ensures that focus stays within itself. If the user uses Tab
12
- * at the end of the modal, or Shift-Tab at the start of the modal, then this
13
- * component wraps focus to the start/end respectively.
14
- *
15
- * We use this in `ModalBackdrop` to ensure that focus stays within the launched
16
- * modal.
17
- *
18
- * Adapted from the WAI-ARIA dialog behavior example.
19
- * https://www.w3.org/TR/2017/NOTE-wai-aria-practices-1.1-20171214/examples/dialog-modal/dialog.html
20
- *
21
- * NOTE(mdr): This component frequently references the "modal" and the "modal
22
- * root", to aid readability in this package. But this component isn't
23
- * actually coupled to the modal, and these could be renamed "children"
24
- * instead if we were to generalize!
25
- */
26
- declare type Props = {|
27
- children: React.Node,
28
-
29
- /**
30
- * Style applied to the View containing children.
31
- * TODO(kevinb): only allow z-index to be specified. We'll be able to remove
32
- * this prop once we remove all uses of z-indexes from webapp.
33
- */
34
- style?: StyleType,
35
- |};
36
- declare export default class FocusTrap extends React.Component<Props> {
37
- /**
38
- * Tabbing is restricted to descendents of this element.
39
- */
40
- modalRoot: Node | null | void;
41
- getModalRoot: (node?: any) => void;
42
-
43
- /**
44
- * Try to focus the given node. Return true if successful.
45
- */
46
- tryToFocus(node: Node): boolean | null | void;
47
-
48
- /**
49
- * Focus the next available focusable element within the modal root.
50
- * @param {boolean} isLast Used to determine the next available item. true =
51
- * First element within the modal, false = Last element within the modal.
52
- */
53
- focusElementIn(isLast: boolean): void;
54
-
55
- /**
56
- * Triggered when the focus is set to the first sentinel. This way, the
57
- * focus will be redirected to the last element inside the modal dialog.
58
- */
59
- handleFocusMoveToLast: () => void;
60
-
61
- /**
62
- * Triggered when the focus is set to the last sentinel. This way, the focus
63
- * will be redirected to the first element inside the modal dialog.
64
- */
65
- handleFocusMoveToFirst: () => void;
66
- render(): React.Node;
67
- }
@@ -1,61 +0,0 @@
1
- /**
2
- * Flowtype definitions for data
3
- * Generated by Flowgen from a Typescript Definition
4
- * Flowgen v1.21.0
5
- * @flow
6
- */
7
- import * as React from "react";
8
- import type { ModalElement } from "../util/types";
9
- declare type Props = {|
10
- children: ModalElement,
11
- onCloseModal: () => mixed,
12
-
13
- /**
14
- * The selector for the element that will be focused when the dialog shows.
15
- * When not set, the first tabbable element within the dialog will be used.
16
- */
17
- initialFocusId?: string,
18
-
19
- /**
20
- * Test ID used for e2e testing.
21
- */
22
- testId?: string,
23
- |};
24
- /**
25
- * A private component used by ModalLauncher. This is the fixed-position
26
- * container element that gets mounted outside the DOM. It overlays the modal
27
- * content (provided as `children`) over the content, with a gray backdrop
28
- * behind it.
29
- *
30
- * This component is also responsible for cloning the provided modal `children`,
31
- * and adding an `onClose` prop that will call `onCloseModal`. If an
32
- * `onClose` prop is already provided, the two are merged.
33
- */
34
- declare export default class ModalBackdrop extends React.Component<Props> {
35
- componentDidMount(): void;
36
- _mousePressedOutside: boolean;
37
-
38
- /**
39
- * Returns an element specified by the user
40
- */
41
- _getInitialFocusElement(node: HTMLElement): HTMLElement | null;
42
-
43
- /**
44
- * Returns the first focusable element found inside the Dialog
45
- */
46
- _getFirstFocusableElement(node: HTMLElement): HTMLElement | null;
47
-
48
- /**
49
- * Returns the dialog element
50
- */
51
- _getDialogElement(node: HTMLElement): HTMLElement;
52
-
53
- /**
54
- * When the user clicks on the gray backdrop area (i.e., the click came
55
- * _directly_ from the positioner, not bubbled up from its children), close
56
- * the modal.
57
- */
58
- handleMouseDown: (e: SyntheticEvent<>) => void;
59
- handleMouseUp: (e: SyntheticEvent<>) => void;
60
- render(): React.Node;
61
- }
@@ -1,36 +0,0 @@
1
- /**
2
- * Flowtype definitions for data
3
- * Generated by Flowgen from a Typescript Definition
4
- * Flowgen v1.21.0
5
- * @flow
6
- */
7
- import * as React from "react";
8
- import type { StyleType } from "@khanacademy/wonder-blocks-core";
9
- declare type Props = {|
10
- /**
11
- * Should the content scroll on overflow, or just expand.
12
- */
13
- scrollOverflow: boolean,
14
-
15
- /**
16
- * The contents of the ModalContent
17
- */
18
- children: React.Node,
19
-
20
- /**
21
- * Optional styling to apply to the contents.
22
- */
23
- style?: StyleType,
24
- |};
25
- declare type DefaultProps = {|
26
- scrollOverflow: $PropertyType<Props, "scrollOverflow">,
27
- |};
28
- /**
29
- * The Modal content included after the header
30
- */
31
- declare export default class ModalContent extends React.Component<Props> {
32
- static isClassOf(instance: any): boolean;
33
- static defaultProps: DefaultProps;
34
- static __IS_MODAL_CONTENT__: boolean;
35
- render(): React.Node;
36
- }
@@ -1,12 +0,0 @@
1
- /**
2
- * Flowtype definitions for data
3
- * Generated by Flowgen from a Typescript Definition
4
- * Flowgen v1.21.0
5
- * @flow
6
- */
7
- import * as React from "react";
8
- declare type ContextType = {|
9
- closeModal?: () => mixed,
10
- |};
11
- declare var ModalContext: React.Context<ContextType>;
12
- declare export default typeof ModalContext;
@@ -1,72 +0,0 @@
1
- /**
2
- * Flowtype definitions for data
3
- * Generated by Flowgen from a Typescript Definition
4
- * Flowgen v1.21.0
5
- * @flow
6
- */
7
- import * as React from "react";
8
- import type { StyleType } from "@khanacademy/wonder-blocks-core";
9
- declare type Props = {|
10
- /**
11
- * The dialog content
12
- */
13
- children: React.Node,
14
-
15
- /**
16
- * When set, provides a component that can render content above the top of the modal;
17
- * when not set, no additional content is shown above the modal.
18
- * This prop is passed down to the ModalDialog.
19
- */
20
- above?: React.Node,
21
-
22
- /**
23
- * When set, provides a component that will render content below the bottom of the modal;
24
- * when not set, no additional content is shown below the modal.
25
- * This prop is passed down to the ModalDialog.
26
- */
27
- below?: React.Node,
28
-
29
- /**
30
- * When set, overrides the default role value. Default role is "dialog"
31
- * Roles other than dialog and alertdialog aren't appropriate for this
32
- * component
33
- */
34
- role?: "dialog" | "alertdialog",
35
-
36
- /**
37
- * Custom styles
38
- */
39
- style?: StyleType,
40
-
41
- /**
42
- * Test ID used for e2e testing.
43
- */
44
- testId?: string,
45
-
46
- /**
47
- * The ID of the content labelling this dialog, if applicable.
48
- */
49
- "aria-labelledby"?: string,
50
-
51
- /**
52
- * The ID of the content describing this dialog, if applicable.
53
- */
54
- "aria-describedby"?: string,
55
- |};
56
- declare type DefaultProps = {|
57
- role: $PropertyType<Props, "role">,
58
- |};
59
- /**
60
- * `ModalDialog` is a component that contains these elements:
61
- * - The visual dialog element itself (`<div role="dialog"/>`)
62
- * - The custom contents below and/or above the Dialog itself (e.g. decorative graphics).
63
- *
64
- * **Accessibility notes:**
65
- * - By default (e.g. using `OnePaneDialog`), `aria-labelledby` is populated automatically using the dialog title `id`.
66
- * - If there is a custom Dialog implementation (e.g. `TwoPaneDialog`), the dialog element doesn’t have to have
67
- * the `aria-labelledby` attribute however this is recommended. It should match the `id` of the dialog title.
68
- */
69
- declare export default class ModalDialog extends React.Component<Props> {
70
- static defaultProps: DefaultProps;
71
- render(): React.Node;
72
- }
@@ -1,32 +0,0 @@
1
- /**
2
- * Flowtype definitions for data
3
- * Generated by Flowgen from a Typescript Definition
4
- * Flowgen v1.21.0
5
- * @flow
6
- */
7
- import * as React from "react";
8
- declare type Props = {|
9
- children: React.Node,
10
- |};
11
- /**
12
- * Modal footer included after the content.
13
- *
14
- * **Implementation notes**:
15
- *
16
- * If you are creating a custom Dialog, make sure to follow these guidelines:
17
- * - Make sure to include it as part of [ModalPanel](/#modalpanel) by using the `footer` prop.
18
- * - The footer is completely flexible. Meaning the developer needs to add its own custom layout to match design specs.
19
- *
20
- * **Usage**
21
- *
22
- * ```js
23
- * <ModalFooter>
24
- * <Button onClick={() => {}}>Submit</Button>
25
- * </ModalFooter>
26
- * ```
27
- */
28
- declare export default class ModalFooter extends React.Component<Props> {
29
- static isClassOf(instance: any): boolean;
30
- static __IS_MODAL_FOOTER__: boolean;
31
- render(): React.Node;
32
- }
@@ -1,105 +0,0 @@
1
- /**
2
- * Flowtype definitions for data
3
- * Generated by Flowgen from a Typescript Definition
4
- * Flowgen v1.21.0
5
- * @flow
6
- */
7
- import * as React from "react";
8
- import { Breadcrumbs } from "@khanacademy/wonder-blocks-breadcrumbs";
9
- declare type Common = {|
10
- /**
11
- * The main title rendered in larger bold text.
12
- */
13
- title: string,
14
-
15
- /**
16
- * Whether to display the "light" version of this component instead, for
17
- * use when the item is used on a dark background.
18
- */
19
- light: boolean,
20
-
21
- /**
22
- * An id to provide a selector for the title element.
23
- */
24
- titleId: string,
25
-
26
- /**
27
- * Test ID used for e2e testing.
28
- *
29
- * In this case, this component is internal, so `testId` is composed with
30
- * the `testId` passed down from the Dialog variant + a suffix to scope it
31
- * to this component.
32
- * @example For testId="some-random-id"
33
- * The result will be: `some-random-id-modal-header`
34
- */
35
- testId?: string,
36
- |};
37
- declare type WithSubtitle = {|
38
- ...Common,
39
- ...{|
40
- /**
41
- * The dialog subtitle.
42
- */
43
- subtitle: string,
44
- |},
45
- |};
46
- declare type WithBreadcrumbs = {|
47
- ...Common,
48
- ...{|
49
- /**
50
- * Adds a breadcrumb-trail, appearing in the ModalHeader, above the title.
51
- */
52
- breadcrumbs: React.Element<typeof Breadcrumbs>,
53
- |},
54
- |};
55
- declare type Props = Common | WithSubtitle | WithBreadcrumbs;
56
- declare type DefaultProps = {|
57
- light: $PropertyType<Props, "light">,
58
- |};
59
- /**
60
- * This is a helper component that is never rendered by itself. It is always
61
- * pinned to the top of the dialog, is responsive using the same behavior as its
62
- * parent dialog, and has the following properties:
63
- * - title
64
- * - breadcrumb OR subtitle, but not both.
65
- *
66
- * **Accessibility notes:**
67
- *
68
- * - By default (e.g. using [OnePaneDialog](/#onepanedialog)), `titleId` is
69
- * populated automatically by the parent container.
70
- * - If there is a custom Dialog implementation (e.g. `TwoPaneDialog`), the
71
- * ModalHeader doesn’t have to have the `titleId` prop however this is
72
- * recommended. It should match the `aria-labelledby` prop of the
73
- * [ModalDialog](/#modaldialog) component. If you want to see an example of
74
- * how to generate this ID, check [IDProvider](/#idprovider).
75
- *
76
- * **Implementation notes:**
77
- *
78
- * If you are creating a custom Dialog, make sure to follow these guidelines:
79
- * - Make sure to include it as part of [ModalPanel](/#modalpanel) by using the
80
- * `header` prop.
81
- * - Add a title (required).
82
- * - Optionally add a subtitle or breadcrumbs.
83
- * - We encourage you to add `titleId` (see Accessibility notes).
84
- * - If the `ModalPanel` has a dark background, make sure to set `light` to
85
- * `false`.
86
- * - If you need to create e2e tests, make sure to pass a `testId` prop and
87
- * add a sufix to scope the testId to this component: e.g.
88
- * `some-random-id-ModalHeader`. This scope will also be passed to the title
89
- * and subtitle elements: e.g. `some-random-id-ModalHeader-title`.
90
- *
91
- * Example:
92
- *
93
- * ```js
94
- * <ModalHeader
95
- * title="Sidebar using ModalHeader"
96
- * subtitle="subtitle"
97
- * titleId="uniqueTitleId"
98
- * light={false}
99
- * />
100
- * ```
101
- */
102
- declare export default class ModalHeader extends React.Component<Props> {
103
- static defaultProps: DefaultProps;
104
- render(): React.Node;
105
- }
@@ -1,27 +0,0 @@
1
- /**
2
- * Flowtype definitions for data
3
- * Generated by Flowgen from a Typescript Definition
4
- * Flowgen v1.21.0
5
- * @flow
6
- */
7
- import * as React from "react";
8
- import type { ModalElement } from "../util/types";
9
- declare var _default: (props: {|
10
- +children?:
11
- | ((arg1: {|
12
- openModal: () => mixed,
13
- |}) => React.Node)
14
- | void,
15
- +onClose?: (() => mixed) | void,
16
- +testId?: string | void,
17
- +initialFocusId?: string | void,
18
- +backdropDismissEnabled?: boolean | void,
19
- +modal:
20
- | ModalElement
21
- | ((props: {|
22
- closeModal: () => void,
23
- |}) => ModalElement),
24
- +closedFocusId?: string | void,
25
- +opened?: boolean | void,
26
- |}) => React$Node;
27
- declare export default typeof _default;
@@ -1,97 +0,0 @@
1
- /**
2
- * Flowtype definitions for data
3
- * Generated by Flowgen from a Typescript Definition
4
- * Flowgen v1.21.0
5
- * @flow
6
- */
7
- import * as React from "react";
8
- import type { StyleType } from "@khanacademy/wonder-blocks-core";
9
- import ModalContent from "./modal-content";
10
- import ModalHeader from "./modal-header";
11
- import ModalFooter from "./modal-footer";
12
- declare type Props = {|
13
- /**
14
- * The main contents of the ModalPanel. All other parts of the panel
15
- * are positioned around it.
16
- */
17
- content: React.Element<typeof ModalContent> | React.Node,
18
-
19
- /**
20
- * The modal header to show at the top of the panel.
21
- */
22
- header?: React.Element<typeof ModalHeader> | React.Node,
23
-
24
- /**
25
- * A footer to show beneath the contents.
26
- */
27
- footer?: React.Element<typeof ModalFooter> | React.Node,
28
-
29
- /**
30
- * When true, the close button is shown; otherwise, the close button is not shown.
31
- */
32
- closeButtonVisible: boolean,
33
-
34
- /**
35
- * Should the contents of the panel become scrollable should they
36
- * become too tall?
37
- */
38
- scrollOverflow: boolean,
39
-
40
- /**
41
- * Whether to display the "light" version of this component instead, for
42
- * use when the item is used on a dark background.
43
- */
44
- light: boolean,
45
-
46
- /**
47
- * Any optional styling to apply to the panel.
48
- */
49
- style?: StyleType,
50
-
51
- /**
52
- * Called when the close button is clicked.
53
- *
54
- * If you're using `ModalLauncher`, you should not use this prop!
55
- * Instead, to listen for when the modal closes, add an `onClose` handler
56
- * to the `ModalLauncher`. Doing so will throw an error.
57
- */
58
- onClose?: () => mixed,
59
-
60
- /**
61
- * Test ID used for e2e testing.
62
- *
63
- * In this case, this `testId` comes from the `testId` prop defined in the
64
- * Dialog variant (e.g. OnePaneDialog).
65
- */
66
- testId?: string,
67
- |};
68
- declare type DefaultProps = {|
69
- closeButtonVisible: $PropertyType<Props, "closeButtonVisible">,
70
- scrollOverflow: $PropertyType<Props, "scrollOverflow">,
71
- light: $PropertyType<Props, "light">,
72
- |};
73
- /**
74
- * ModalPanel is the content container.
75
- *
76
- * **Implementation notes:**
77
- *
78
- * If you are creating a custom Dialog, make sure to follow these guidelines:
79
- * - Make sure to add this component inside the [ModalDialog](/#modaldialog).
80
- * - If needed, you can also add a [ModalHeader](/#modalheader) using the
81
- * `header` prop. Same goes for [ModalFooter](/#modalfooter).
82
- * - If you need to create e2e tests, make sure to pass a `testId` prop. This
83
- * will be passed down to this component using a sufix: e.g.
84
- * `some-random-id-ModalPanel`. This scope will be propagated to the
85
- * CloseButton element as well: e.g. `some-random-id-CloseButton`.
86
- *
87
- * ```js
88
- * <ModalDialog>
89
- * <ModalPanel content={"custom content goes here"} />
90
- * </ModalDialog>
91
- * ```
92
- */
93
- declare export default class ModalPanel extends React.Component<Props> {
94
- static defaultProps: DefaultProps;
95
- renderMainContent(): React.Node;
96
- render(): React.Node;
97
- }
@@ -1,148 +0,0 @@
1
- /**
2
- * Flowtype definitions for data
3
- * Generated by Flowgen from a Typescript Definition
4
- * Flowgen v1.21.0
5
- * @flow
6
- */
7
- import * as React from "react";
8
- import { Breadcrumbs } from "@khanacademy/wonder-blocks-breadcrumbs";
9
- import type { StyleType } from "@khanacademy/wonder-blocks-core";
10
- import ModalHeader from "./modal-header";
11
- declare type Common = {|
12
- /**
13
- * The content of the modal, appearing between the titlebar and footer.
14
- */
15
- content: React.Node,
16
-
17
- /**
18
- * The title of the modal, appearing in the titlebar.
19
- */
20
- title: string,
21
-
22
- /**
23
- * The content of the modal's footer. A great place for buttons!
24
- *
25
- * Content is right-aligned by default. To control alignment yourself,
26
- * provide a container element with 100% width.
27
- */
28
- footer?: React.Node,
29
-
30
- /**
31
- * Called when the close button is clicked.
32
- *
33
- * If you're using `ModalLauncher`, you probably shouldn't use this prop!
34
- * Instead, to listen for when the modal closes, add an `onClose` handler
35
- * to the `ModalLauncher`. Doing so will result in a console.warn().
36
- */
37
- onClose?: () => mixed,
38
-
39
- /**
40
- * When true, the close button is shown; otherwise, the close button is not shown.
41
- */
42
- closeButtonVisible?: boolean,
43
-
44
- /**
45
- * When set, provides a component that can render content above the top of the modal;
46
- * when not set, no additional content is shown above the modal.
47
- * This prop is passed down to the ModalDialog.
48
- */
49
- above?: React.Node,
50
-
51
- /**
52
- * When set, provides a component that will render content below the bottom of the modal;
53
- * when not set, no additional content is shown below the modal.
54
- * This prop is passed down to the ModalDialog.
55
- *
56
- * NOTE: Devs can customize this content by rendering the component assigned to this prop with custom styles,
57
- * such as by wrapping it in a View.
58
- */
59
- below?: React.Node,
60
-
61
- /**
62
- * When set, overrides the default role value. Default role is "dialog"
63
- * Roles other than dialog and alertdialog aren't appropriate for this
64
- * component
65
- */
66
- role?: "dialog" | "alertdialog",
67
-
68
- /**
69
- * Optional custom styles.
70
- */
71
- style?: StyleType,
72
-
73
- /**
74
- * Test ID used for e2e testing. This ID will be passed down to the Dialog.
75
- */
76
- testId?: string,
77
-
78
- /**
79
- * An optional id parameter for the title. If one is
80
- * not provided, a unique id will be generated.
81
- */
82
- titleId?: string,
83
-
84
- /**
85
- * The ID of the content describing this dialog, if applicable.
86
- */
87
- "aria-describedby"?: string,
88
- |};
89
- declare type WithSubtitle = {|
90
- ...Common,
91
- ...{|
92
- /**
93
- * The subtitle of the modal, appearing in the titlebar, below the title.
94
- */
95
- subtitle: string,
96
- |},
97
- |};
98
- declare type WithBreadcrumbs = {|
99
- ...Common,
100
- ...{|
101
- /**
102
- * Adds a breadcrumb-trail, appearing in the ModalHeader, above the title.
103
- */
104
- breadcrumbs: React.Element<typeof Breadcrumbs>,
105
- |},
106
- |};
107
- declare type Props = Common | WithSubtitle | WithBreadcrumbs;
108
- declare type DefaultProps = {|
109
- closeButtonVisible: $PropertyType<Props, "closeButtonVisible">,
110
- |};
111
- /**
112
- * This is the standard layout for most straightforward modal experiences.
113
- *
114
- * The ModalHeader is required, but the ModalFooter is optional.
115
- * The content of the dialog itself is fully customizable, but the
116
- * left/right/top/bottom padding is fixed.
117
- *
118
- * ### Usage
119
- *
120
- * ```jsx
121
- * import {OnePaneDialog} from "@khanacademy/wonder-blocks-modal";
122
- * import {Body} from "@khanacademy/wonder-blocks-typography";
123
- *
124
- * <OnePaneDialog
125
- * title="Some title"
126
- * content={
127
- * <Body>
128
- * {`Lorem ipsum dolor sit amet, consectetur adipiscing
129
- * elit, sed do eiusmod tempor incididunt ut labore et
130
- * dolore magna aliqua. Ut enim ad minim veniam,
131
- * quis nostrud exercitation ullamco laboris nisi ut
132
- * aliquip ex ea commodo consequat. Duis aute irure
133
- * dolor in reprehenderit in voluptate velit esse
134
- * cillum dolore eu fugiat nulla pariatur. Excepteur
135
- * sint occaecat cupidatat non proident, sunt in culpa
136
- * qui officia deserunt mollit anim id est.`}
137
- * </Body>
138
- * }
139
- * />
140
- * ```
141
- */
142
- declare export default class OnePaneDialog extends React.Component<Props> {
143
- static defaultProps: DefaultProps;
144
- renderHeader(
145
- uniqueId: string
146
- ): React.Element<typeof ModalHeader>;
147
- render(): React.Node;
148
- }
@@ -1,20 +0,0 @@
1
- /**
2
- * Flowtype definitions for data
3
- * Generated by Flowgen from a Typescript Definition
4
- * Flowgen v1.21.0
5
- * @flow
6
- */
7
- import * as React from "react";
8
- declare type Props = { [key: any]: any };
9
- declare class ScrollDisabler extends React.Component<Props> {
10
- static oldOverflow: string;
11
- static oldPosition: string;
12
- static oldScrollY: number;
13
- static oldWidth: string;
14
- static oldTop: string;
15
- componentDidMount(): void;
16
- componentWillUnmount(): void;
17
- static numModalsOpened: number;
18
- render(): React.Element<any> | null;
19
- }
20
- declare export default typeof ScrollDisabler;