@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
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,37 @@
|
|
|
1
1
|
# @khanacademy/wonder-blocks-modal
|
|
2
2
|
|
|
3
|
+
## 3.0.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- d816af08: Update build and test configs use TypeScript
|
|
8
|
+
- 3891f544: Update babel config to include plugins that Storybook needed
|
|
9
|
+
- 0d28bb1c: Configured TypeScript
|
|
10
|
+
- 3d05f764: Fix HOCs and other type errors
|
|
11
|
+
- c2ec4902: Update eslint configuration, fix lint
|
|
12
|
+
- 2983c05b: Include 'types' field in package.json
|
|
13
|
+
- 77ff6a66: Generate Flow types from TypeScript types
|
|
14
|
+
- ec8d4b7f: Fix miscellaneous TypeScript errors
|
|
15
|
+
- Updated dependencies [d816af08]
|
|
16
|
+
- Updated dependencies [3891f544]
|
|
17
|
+
- Updated dependencies [3813715d]
|
|
18
|
+
- Updated dependencies [0d28bb1c]
|
|
19
|
+
- Updated dependencies [873f4a14]
|
|
20
|
+
- Updated dependencies [3d05f764]
|
|
21
|
+
- Updated dependencies [c2ec4902]
|
|
22
|
+
- Updated dependencies [2983c05b]
|
|
23
|
+
- Updated dependencies [77ff6a66]
|
|
24
|
+
- Updated dependencies [ec8d4b7f]
|
|
25
|
+
- @khanacademy/wonder-blocks-breadcrumbs@1.0.39
|
|
26
|
+
- @khanacademy/wonder-blocks-color@1.2.2
|
|
27
|
+
- @khanacademy/wonder-blocks-core@4.8.0
|
|
28
|
+
- @khanacademy/wonder-blocks-icon@1.2.38
|
|
29
|
+
- @khanacademy/wonder-blocks-icon-button@3.4.22
|
|
30
|
+
- @khanacademy/wonder-blocks-layout@1.4.17
|
|
31
|
+
- @khanacademy/wonder-blocks-spacing@3.0.6
|
|
32
|
+
- @khanacademy/wonder-blocks-timing@2.1.2
|
|
33
|
+
- @khanacademy/wonder-blocks-typography@1.1.39
|
|
34
|
+
|
|
3
35
|
## 3.0.7
|
|
4
36
|
|
|
5
37
|
### Patch Changes
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { StyleType } from "@khanacademy/wonder-blocks-core";
|
|
3
|
+
type Props = {
|
|
4
|
+
/**
|
|
5
|
+
* Whether the button is on a dark/colored background.
|
|
6
|
+
*
|
|
7
|
+
* Sets primary button background color to white, and secondary and
|
|
8
|
+
* tertiary button title to color.
|
|
9
|
+
*/
|
|
10
|
+
light?: boolean;
|
|
11
|
+
/** Optional click handler */
|
|
12
|
+
onClick?: () => unknown;
|
|
13
|
+
/** Optional custom styles. */
|
|
14
|
+
style?: StyleType;
|
|
15
|
+
/**
|
|
16
|
+
* Test ID used for e2e testing.
|
|
17
|
+
*
|
|
18
|
+
* In this case, this component is internal, so `testId` is composed with
|
|
19
|
+
* the `testId` passed down from the Dialog variant + a suffix to scope it
|
|
20
|
+
* to this component.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* For testId="some-random-id"
|
|
24
|
+
* The result will be: `some-random-id-modal-panel`
|
|
25
|
+
*/
|
|
26
|
+
testId?: string;
|
|
27
|
+
};
|
|
28
|
+
export default class CloseButton extends React.Component<Props> {
|
|
29
|
+
render(): React.ReactElement;
|
|
30
|
+
}
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flowtype definitions for close-button
|
|
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 type { StyleType } from "@khanacademy/wonder-blocks-core";
|
|
10
|
+
declare type Props = {
|
|
11
|
+
/**
|
|
12
|
+
* Whether the button is on a dark/colored background.
|
|
13
|
+
*
|
|
14
|
+
* Sets primary button background color to white, and secondary and
|
|
15
|
+
* tertiary button title to color.
|
|
16
|
+
*/
|
|
17
|
+
light?: boolean,
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Optional click handler
|
|
21
|
+
*/
|
|
22
|
+
onClick?: () => mixed,
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Optional custom styles.
|
|
26
|
+
*/
|
|
27
|
+
style?: StyleType,
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Test ID used for e2e testing.
|
|
31
|
+
*
|
|
32
|
+
* In this case, this component is internal, so `testId` is composed with
|
|
33
|
+
* the `testId` passed down from the Dialog variant + a suffix to scope it
|
|
34
|
+
* to this component.
|
|
35
|
+
* @example For testId="some-random-id"
|
|
36
|
+
* The result will be: `some-random-id-modal-panel`
|
|
37
|
+
*/
|
|
38
|
+
testId?: string,
|
|
39
|
+
...
|
|
40
|
+
};
|
|
41
|
+
declare export default class CloseButton mixins React.Component<Props> {
|
|
42
|
+
render(): React.Element<>;
|
|
43
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { StyleType } from "@khanacademy/wonder-blocks-core";
|
|
3
|
+
/**
|
|
4
|
+
* This component ensures that focus stays within itself. If the user uses Tab
|
|
5
|
+
* at the end of the modal, or Shift-Tab at the start of the modal, then this
|
|
6
|
+
* component wraps focus to the start/end respectively.
|
|
7
|
+
*
|
|
8
|
+
* We use this in `ModalBackdrop` to ensure that focus stays within the launched
|
|
9
|
+
* modal.
|
|
10
|
+
*
|
|
11
|
+
* Adapted from the WAI-ARIA dialog behavior example.
|
|
12
|
+
* https://www.w3.org/TR/2017/NOTE-wai-aria-practices-1.1-20171214/examples/dialog-modal/dialog.html
|
|
13
|
+
*
|
|
14
|
+
* NOTE(mdr): This component frequently references the "modal" and the "modal
|
|
15
|
+
* root", to aid readability in this package. But this component isn't
|
|
16
|
+
* actually coupled to the modal, and these could be renamed "children"
|
|
17
|
+
* instead if we were to generalize!
|
|
18
|
+
*/
|
|
19
|
+
type Props = {
|
|
20
|
+
children: React.ReactNode;
|
|
21
|
+
/**
|
|
22
|
+
* Style applied to the View containing children.
|
|
23
|
+
* TODO(kevinb): only allow z-index to be specified. We'll be able to remove
|
|
24
|
+
* this prop once we remove all uses of z-indexes from webapp.
|
|
25
|
+
*/
|
|
26
|
+
style?: StyleType;
|
|
27
|
+
};
|
|
28
|
+
export default class FocusTrap extends React.Component<Props> {
|
|
29
|
+
/**
|
|
30
|
+
* Tabbing is restricted to descendents of this element.
|
|
31
|
+
*/
|
|
32
|
+
modalRoot: Node | null | undefined;
|
|
33
|
+
getModalRoot: (node?: any) => void;
|
|
34
|
+
/**
|
|
35
|
+
* Try to focus the given node. Return true if successful.
|
|
36
|
+
*/
|
|
37
|
+
tryToFocus(node: Node): boolean | null | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Focus the next available focusable element within the modal root.
|
|
40
|
+
*
|
|
41
|
+
* @param {boolean} isLast Used to determine the next available item. true =
|
|
42
|
+
* First element within the modal, false = Last element within the modal.
|
|
43
|
+
*/
|
|
44
|
+
focusElementIn(isLast: boolean): void;
|
|
45
|
+
/**
|
|
46
|
+
* Triggered when the focus is set to the first sentinel. This way, the
|
|
47
|
+
* focus will be redirected to the last element inside the modal dialog.
|
|
48
|
+
*/
|
|
49
|
+
handleFocusMoveToLast: () => void;
|
|
50
|
+
/**
|
|
51
|
+
* Triggered when the focus is set to the last sentinel. This way, the focus
|
|
52
|
+
* will be redirected to the first element inside the modal dialog.
|
|
53
|
+
*/
|
|
54
|
+
handleFocusMoveToFirst: () => void;
|
|
55
|
+
render(): React.ReactElement;
|
|
56
|
+
}
|
|
57
|
+
export {};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flowtype definitions for focus-trap
|
|
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 type { StyleType } from "@khanacademy/wonder-blocks-core";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* This component ensures that focus stays within itself. If the user uses Tab
|
|
13
|
+
* at the end of the modal, or Shift-Tab at the start of the modal, then this
|
|
14
|
+
* component wraps focus to the start/end respectively.
|
|
15
|
+
*
|
|
16
|
+
* We use this in `ModalBackdrop` to ensure that focus stays within the launched
|
|
17
|
+
* modal.
|
|
18
|
+
*
|
|
19
|
+
* Adapted from the WAI-ARIA dialog behavior example.
|
|
20
|
+
* https://www.w3.org/TR/2017/NOTE-wai-aria-practices-1.1-20171214/examples/dialog-modal/dialog.html
|
|
21
|
+
*
|
|
22
|
+
* NOTE(mdr): This component frequently references the "modal" and the "modal
|
|
23
|
+
* root", to aid readability in this package. But this component isn't
|
|
24
|
+
* actually coupled to the modal, and these could be renamed "children"
|
|
25
|
+
* instead if we were to generalize!
|
|
26
|
+
*/
|
|
27
|
+
declare type Props = {
|
|
28
|
+
children: React.Node,
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Style applied to the View containing children.
|
|
32
|
+
* TODO(kevinb): only allow z-index to be specified. We'll be able to remove
|
|
33
|
+
* this prop once we remove all uses of z-indexes from webapp.
|
|
34
|
+
*/
|
|
35
|
+
style?: StyleType,
|
|
36
|
+
...
|
|
37
|
+
};
|
|
38
|
+
declare export default class FocusTrap mixins React.Component<Props> {
|
|
39
|
+
/**
|
|
40
|
+
* Tabbing is restricted to descendents of this element.
|
|
41
|
+
*/
|
|
42
|
+
modalRoot: Node | null | void;
|
|
43
|
+
getModalRoot: (node?: any) => void;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Try to focus the given node. Return true if successful.
|
|
47
|
+
*/
|
|
48
|
+
tryToFocus(node: Node): boolean | null | void;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Focus the next available focusable element within the modal root.
|
|
52
|
+
* @param {boolean} isLast Used to determine the next available item. true =
|
|
53
|
+
* First element within the modal, false = Last element within the modal.
|
|
54
|
+
*/
|
|
55
|
+
focusElementIn(isLast: boolean): void;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Triggered when the focus is set to the first sentinel. This way, the
|
|
59
|
+
* focus will be redirected to the last element inside the modal dialog.
|
|
60
|
+
*/
|
|
61
|
+
handleFocusMoveToLast: () => void;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Triggered when the focus is set to the last sentinel. This way, the focus
|
|
65
|
+
* will be redirected to the first element inside the modal dialog.
|
|
66
|
+
*/
|
|
67
|
+
handleFocusMoveToFirst: () => void;
|
|
68
|
+
render(): React.Element<>;
|
|
69
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { ModalElement } from "../util/types";
|
|
3
|
+
type Props = {
|
|
4
|
+
children: ModalElement;
|
|
5
|
+
onCloseModal: () => unknown;
|
|
6
|
+
/**
|
|
7
|
+
* The selector for the element that will be focused when the dialog shows.
|
|
8
|
+
* When not set, the first tabbable element within the dialog will be used.
|
|
9
|
+
*/
|
|
10
|
+
initialFocusId?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Test ID used for e2e testing.
|
|
13
|
+
*/
|
|
14
|
+
testId?: string;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* A private component used by ModalLauncher. This is the fixed-position
|
|
18
|
+
* container element that gets mounted outside the DOM. It overlays the modal
|
|
19
|
+
* content (provided as `children`) over the content, with a gray backdrop
|
|
20
|
+
* behind it.
|
|
21
|
+
*
|
|
22
|
+
* This component is also responsible for cloning the provided modal `children`,
|
|
23
|
+
* and adding an `onClose` prop that will call `onCloseModal`. If an
|
|
24
|
+
* `onClose` prop is already provided, the two are merged.
|
|
25
|
+
*/
|
|
26
|
+
export default class ModalBackdrop extends React.Component<Props> {
|
|
27
|
+
componentDidMount(): void;
|
|
28
|
+
_mousePressedOutside: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Returns an element specified by the user
|
|
31
|
+
*/
|
|
32
|
+
_getInitialFocusElement(node: HTMLElement): HTMLElement | null;
|
|
33
|
+
/**
|
|
34
|
+
* Returns the first focusable element found inside the Dialog
|
|
35
|
+
*/
|
|
36
|
+
_getFirstFocusableElement(node: HTMLElement): HTMLElement | null;
|
|
37
|
+
/**
|
|
38
|
+
* Returns the dialog element
|
|
39
|
+
*/
|
|
40
|
+
_getDialogElement(node: HTMLElement): HTMLElement;
|
|
41
|
+
/**
|
|
42
|
+
* When the user clicks on the gray backdrop area (i.e., the click came
|
|
43
|
+
* _directly_ from the positioner, not bubbled up from its children), close
|
|
44
|
+
* the modal.
|
|
45
|
+
*/
|
|
46
|
+
handleMouseDown: (e: React.SyntheticEvent) => void;
|
|
47
|
+
handleMouseUp: (e: React.SyntheticEvent) => void;
|
|
48
|
+
render(): React.ReactElement;
|
|
49
|
+
}
|
|
50
|
+
export {};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flowtype definitions for modal-backdrop
|
|
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 type { ModalElement } from "../util/types";
|
|
10
|
+
declare type Props = {
|
|
11
|
+
children: ModalElement,
|
|
12
|
+
onCloseModal: () => mixed,
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* The selector for the element that will be focused when the dialog shows.
|
|
16
|
+
* When not set, the first tabbable element within the dialog will be used.
|
|
17
|
+
*/
|
|
18
|
+
initialFocusId?: string,
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Test ID used for e2e testing.
|
|
22
|
+
*/
|
|
23
|
+
testId?: string,
|
|
24
|
+
...
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* A private component used by ModalLauncher. This is the fixed-position
|
|
28
|
+
* container element that gets mounted outside the DOM. It overlays the modal
|
|
29
|
+
* content (provided as `children`) over the content, with a gray backdrop
|
|
30
|
+
* behind it.
|
|
31
|
+
*
|
|
32
|
+
* This component is also responsible for cloning the provided modal `children`,
|
|
33
|
+
* and adding an `onClose` prop that will call `onCloseModal`. If an
|
|
34
|
+
* `onClose` prop is already provided, the two are merged.
|
|
35
|
+
*/
|
|
36
|
+
declare export default class ModalBackdrop mixins React.Component<Props> {
|
|
37
|
+
componentDidMount(): void;
|
|
38
|
+
_mousePressedOutside: boolean;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Returns an element specified by the user
|
|
42
|
+
*/
|
|
43
|
+
_getInitialFocusElement(node: HTMLElement): HTMLElement | null;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Returns the first focusable element found inside the Dialog
|
|
47
|
+
*/
|
|
48
|
+
_getFirstFocusableElement(node: HTMLElement): HTMLElement | null;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Returns the dialog element
|
|
52
|
+
*/
|
|
53
|
+
_getDialogElement(node: HTMLElement): HTMLElement;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* When the user clicks on the gray backdrop area (i.e., the click came
|
|
57
|
+
* _directly_ from the positioner, not bubbled up from its children), close
|
|
58
|
+
* the modal.
|
|
59
|
+
*/
|
|
60
|
+
handleMouseDown: (e: React.SyntheticEvent<>) => void;
|
|
61
|
+
handleMouseUp: (e: React.SyntheticEvent<>) => void;
|
|
62
|
+
render(): React.Element<>;
|
|
63
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { StyleType } from "@khanacademy/wonder-blocks-core";
|
|
3
|
+
type Props = {
|
|
4
|
+
/** Should the content scroll on overflow, or just expand. */
|
|
5
|
+
scrollOverflow: boolean;
|
|
6
|
+
/** The contents of the ModalContent */
|
|
7
|
+
children: React.ReactNode;
|
|
8
|
+
/** Optional styling to apply to the contents. */
|
|
9
|
+
style?: StyleType;
|
|
10
|
+
};
|
|
11
|
+
type DefaultProps = {
|
|
12
|
+
scrollOverflow: Props["scrollOverflow"];
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* The Modal content included after the header
|
|
16
|
+
*/
|
|
17
|
+
export default class ModalContent extends React.Component<Props> {
|
|
18
|
+
static isClassOf(instance: any): boolean;
|
|
19
|
+
static defaultProps: DefaultProps;
|
|
20
|
+
static __IS_MODAL_CONTENT__: boolean;
|
|
21
|
+
render(): React.ReactElement;
|
|
22
|
+
}
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flowtype definitions for modal-content
|
|
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 type { StyleType } from "@khanacademy/wonder-blocks-core";
|
|
10
|
+
declare type Props = {
|
|
11
|
+
/**
|
|
12
|
+
* Should the content scroll on overflow, or just expand.
|
|
13
|
+
*/
|
|
14
|
+
scrollOverflow: boolean,
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* The contents of the ModalContent
|
|
18
|
+
*/
|
|
19
|
+
children: React.Node,
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Optional styling to apply to the contents.
|
|
23
|
+
*/
|
|
24
|
+
style?: StyleType,
|
|
25
|
+
...
|
|
26
|
+
};
|
|
27
|
+
declare type DefaultProps = {
|
|
28
|
+
scrollOverflow: $PropertyType<Props, "scrollOverflow">,
|
|
29
|
+
...
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* The Modal content included after the header
|
|
33
|
+
*/
|
|
34
|
+
declare export default class ModalContent mixins React.Component<Props> {
|
|
35
|
+
static isClassOf(instance: any): boolean;
|
|
36
|
+
static defaultProps: DefaultProps;
|
|
37
|
+
static __IS_MODAL_CONTENT__: boolean;
|
|
38
|
+
render(): React.Element<>;
|
|
39
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flowtype definitions for modal-context
|
|
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 ContextType = {
|
|
10
|
+
closeModal?: () => mixed,
|
|
11
|
+
...
|
|
12
|
+
};
|
|
13
|
+
declare var _default: React.Context<ContextType>;
|
|
14
|
+
declare export default typeof _default;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { StyleType } from "@khanacademy/wonder-blocks-core";
|
|
3
|
+
type Props = {
|
|
4
|
+
/**
|
|
5
|
+
* The dialog content
|
|
6
|
+
*/
|
|
7
|
+
children: React.ReactNode;
|
|
8
|
+
/**
|
|
9
|
+
* When set, provides a component that can render content above the top of the modal;
|
|
10
|
+
* when not set, no additional content is shown above the modal.
|
|
11
|
+
* This prop is passed down to the ModalDialog.
|
|
12
|
+
*/
|
|
13
|
+
above?: React.ReactNode;
|
|
14
|
+
/**
|
|
15
|
+
* When set, provides a component that will render content below the bottom of the modal;
|
|
16
|
+
* when not set, no additional content is shown below the modal.
|
|
17
|
+
* This prop is passed down to the ModalDialog.
|
|
18
|
+
*/
|
|
19
|
+
below?: React.ReactNode;
|
|
20
|
+
/**
|
|
21
|
+
* When set, overrides the default role value. Default role is "dialog"
|
|
22
|
+
* Roles other than dialog and alertdialog aren't appropriate for this
|
|
23
|
+
* component
|
|
24
|
+
*/
|
|
25
|
+
role?: "dialog" | "alertdialog";
|
|
26
|
+
/**
|
|
27
|
+
* Custom styles
|
|
28
|
+
*/
|
|
29
|
+
style?: StyleType;
|
|
30
|
+
/**
|
|
31
|
+
* Test ID used for e2e testing.
|
|
32
|
+
*/
|
|
33
|
+
testId?: string;
|
|
34
|
+
/**
|
|
35
|
+
* The ID of the content labelling this dialog, if applicable.
|
|
36
|
+
*/
|
|
37
|
+
["aria-labelledby"]?: string;
|
|
38
|
+
/**
|
|
39
|
+
* The ID of the content describing this dialog, if applicable.
|
|
40
|
+
*/
|
|
41
|
+
["aria-describedby"]?: string;
|
|
42
|
+
};
|
|
43
|
+
type DefaultProps = {
|
|
44
|
+
role: Props["role"];
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* `ModalDialog` is a component that contains these elements:
|
|
48
|
+
* - The visual dialog element itself (`<div role="dialog"/>`)
|
|
49
|
+
* - The custom contents below and/or above the Dialog itself (e.g. decorative graphics).
|
|
50
|
+
*
|
|
51
|
+
* **Accessibility notes:**
|
|
52
|
+
* - By default (e.g. using `OnePaneDialog`), `aria-labelledby` is populated automatically using the dialog title `id`.
|
|
53
|
+
* - If there is a custom Dialog implementation (e.g. `TwoPaneDialog`), the dialog element doesn’t have to have
|
|
54
|
+
* the `aria-labelledby` attribute however this is recommended. It should match the `id` of the dialog title.
|
|
55
|
+
*/
|
|
56
|
+
export default class ModalDialog extends React.Component<Props> {
|
|
57
|
+
static defaultProps: DefaultProps;
|
|
58
|
+
render(): React.ReactElement;
|
|
59
|
+
}
|
|
60
|
+
export {};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flowtype definitions for modal-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 type { StyleType } from "@khanacademy/wonder-blocks-core";
|
|
10
|
+
declare type Props = {
|
|
11
|
+
/**
|
|
12
|
+
* The dialog content
|
|
13
|
+
*/
|
|
14
|
+
children: React.Node,
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* When set, provides a component that can render content above the top of the modal;
|
|
18
|
+
* when not set, no additional content is shown above the modal.
|
|
19
|
+
* This prop is passed down to the ModalDialog.
|
|
20
|
+
*/
|
|
21
|
+
above?: React.Node,
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* When set, provides a component that will render content below the bottom of the modal;
|
|
25
|
+
* when not set, no additional content is shown below the modal.
|
|
26
|
+
* This prop is passed down to the ModalDialog.
|
|
27
|
+
*/
|
|
28
|
+
below?: React.Node,
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* When set, overrides the default role value. Default role is "dialog"
|
|
32
|
+
* Roles other than dialog and alertdialog aren't appropriate for this
|
|
33
|
+
* component
|
|
34
|
+
*/
|
|
35
|
+
role?: "dialog" | "alertdialog",
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Custom styles
|
|
39
|
+
*/
|
|
40
|
+
style?: StyleType,
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Test ID used for e2e testing.
|
|
44
|
+
*/
|
|
45
|
+
testId?: string,
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* The ID of the content labelling this dialog, if applicable.
|
|
49
|
+
*/
|
|
50
|
+
"aria-labelledby": string | void,
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* The ID of the content describing this dialog, if applicable.
|
|
54
|
+
*/
|
|
55
|
+
"aria-describedby": string | void,
|
|
56
|
+
...
|
|
57
|
+
};
|
|
58
|
+
declare type DefaultProps = {
|
|
59
|
+
role: $PropertyType<Props, "role">,
|
|
60
|
+
...
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* `ModalDialog` is a component that contains these elements:
|
|
64
|
+
* - The visual dialog element itself (`<div role="dialog"/>`)
|
|
65
|
+
* - The custom contents below and/or above the Dialog itself (e.g. decorative graphics).
|
|
66
|
+
*
|
|
67
|
+
* **Accessibility notes:**
|
|
68
|
+
* - By default (e.g. using `OnePaneDialog`), `aria-labelledby` is populated automatically using the dialog title `id`.
|
|
69
|
+
* - If there is a custom Dialog implementation (e.g. `TwoPaneDialog`), the dialog element doesn’t have to have
|
|
70
|
+
* the `aria-labelledby` attribute however this is recommended. It should match the `id` of the dialog title.
|
|
71
|
+
*/
|
|
72
|
+
declare export default class ModalDialog mixins React.Component<Props> {
|
|
73
|
+
static defaultProps: DefaultProps;
|
|
74
|
+
render(): React.Element<>;
|
|
75
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
type Props = {
|
|
3
|
+
children: React.ReactNode;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* Modal footer included after the content.
|
|
7
|
+
*
|
|
8
|
+
* **Implementation notes**:
|
|
9
|
+
*
|
|
10
|
+
* If you are creating a custom Dialog, make sure to follow these guidelines:
|
|
11
|
+
* - Make sure to include it as part of [ModalPanel](/#modalpanel) by using the `footer` prop.
|
|
12
|
+
* - The footer is completely flexible. Meaning the developer needs to add its own custom layout to match design specs.
|
|
13
|
+
*
|
|
14
|
+
* **Usage**
|
|
15
|
+
*
|
|
16
|
+
* ```js
|
|
17
|
+
* <ModalFooter>
|
|
18
|
+
* <Button onClick={() => {}}>Submit</Button>
|
|
19
|
+
* </ModalFooter>
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export default class ModalFooter extends React.Component<Props> {
|
|
23
|
+
static isClassOf(instance: any): boolean;
|
|
24
|
+
static __IS_MODAL_FOOTER__: boolean;
|
|
25
|
+
render(): React.ReactElement;
|
|
26
|
+
}
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flowtype definitions for modal-footer
|
|
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 = {
|
|
10
|
+
children: React.Node,
|
|
11
|
+
...
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Modal footer included after the content.
|
|
15
|
+
*
|
|
16
|
+
* **Implementation notes**:
|
|
17
|
+
*
|
|
18
|
+
* If you are creating a custom Dialog, make sure to follow these guidelines:
|
|
19
|
+
* - Make sure to include it as part of [ModalPanel](/#modalpanel) by using the `footer` prop.
|
|
20
|
+
* - The footer is completely flexible. Meaning the developer needs to add its own custom layout to match design specs.
|
|
21
|
+
*
|
|
22
|
+
* **Usage**
|
|
23
|
+
*
|
|
24
|
+
* ```js
|
|
25
|
+
* <ModalFooter>
|
|
26
|
+
* <Button onClick={() => {}}>Submit</Button>
|
|
27
|
+
* </ModalFooter>
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
declare export default class ModalFooter mixins React.Component<Props> {
|
|
31
|
+
static isClassOf(instance: any): boolean;
|
|
32
|
+
static __IS_MODAL_FOOTER__: boolean;
|
|
33
|
+
render(): React.Element<>;
|
|
34
|
+
}
|