@khanacademy/wonder-blocks-popover 2.1.6 → 3.0.0

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,51 +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 { AriaProps } from "@khanacademy/wonder-blocks-core";
9
- declare type Props = {|
10
- ...AriaProps,
11
- ...{|
12
- /**
13
- * Callback to be invoked when the anchored content is mounted.
14
- * This provides a reference to the anchored content, which can then be
15
- * used for calculating popover content positioning.
16
- */
17
- anchorRef: (arg1?: HTMLElement) => mixed,
18
-
19
- /**
20
- * The element that triggers the popover. This element will be used to
21
- * position the popover. It can be either a Node or a function using the
22
- * children-as-function pattern to pass an open function for use anywhere
23
- * within children. The latter provides a lot of flexibility in terms of
24
- * what actions may trigger the `Popover` to launch the
25
- * [PopoverDialog](#PopoverDialog).
26
- */
27
- children:
28
- | React.Element<any>
29
- | ((arg1: {|
30
- open: () => void,
31
- |}) => React.Element<any>),
32
-
33
- /**
34
- * The unique identifier to give to the anchor.
35
- */
36
- id?: string,
37
-
38
- /**
39
- * Called when the anchor is clicked
40
- */
41
- onClick: () => void,
42
- |},
43
- |};
44
- /**
45
- * The element that triggers the popover dialog. This is also used as reference
46
- * to position the dialog itself.
47
- */
48
- declare export default class PopoverAnchor extends React.Component<Props> {
49
- componentDidMount(): void;
50
- render(): React.Node;
51
- }
@@ -1,73 +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 { AriaProps, StyleType } from "@khanacademy/wonder-blocks-core";
9
- declare type Props = {|
10
- ...AriaProps,
11
- ...{|
12
- /**
13
- * The content to render inside the popover.
14
- */
15
- children: React.Node,
16
-
17
- /**
18
- * Close button color
19
- */
20
- closeButtonLight?: boolean,
21
-
22
- /**
23
- * Close button label for use in screen readers
24
- */
25
- closeButtonLabel?: string,
26
-
27
- /**
28
- * When true, the close button is shown; otherwise, the close button is not shown.
29
- */
30
- closeButtonVisible?: boolean,
31
-
32
- /**
33
- * Whether we should use the default light color scheme or switch to a
34
- * different color scheme.
35
- */
36
- color: "blue" | "darkBlue" | "white",
37
-
38
- /**
39
- * Custom styles applied to the content container
40
- */
41
- style?: StyleType,
42
-
43
- /**
44
- * Test ID used for e2e testing.
45
- */
46
- testId?: string,
47
- |},
48
- |};
49
- declare type DefaultProps = {|
50
- color: $PropertyType<Props, "color">,
51
- closeButtonLight: $PropertyType<Props, "closeButtonLight">,
52
- closeButtonVisible: $PropertyType<Props, "closeButtonVisible">,
53
- |};
54
- /**
55
- * This is the base popover container. It’s used internally by all the variants.
56
- * Also, it can be used to create flexible popovers.
57
- *
58
- * ### Usage
59
- *
60
- * ```jsx
61
- * import {PopoverContentCore} from "@khanacademy/wonder-blocks-popover";
62
- *
63
- * <PopoverContentCore>
64
- * <>
65
- * Some custom layout
66
- * </>
67
- * </PopoverContentCore>
68
- * ```
69
- */
70
- declare export default class PopoverContentCore extends React.Component<Props> {
71
- static defaultProps: DefaultProps;
72
- render(): React.Node;
73
- }
@@ -1,113 +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 { AriaProps, StyleType } from "@khanacademy/wonder-blocks-core";
9
- import type { PopoverContextType } from "./popover-context";
10
- declare type Props = {|
11
- ...AriaProps,
12
- ...{|
13
- /**
14
- * The content to render inside the popover.
15
- */
16
- content: string,
17
-
18
- /**
19
- * The popover title
20
- */
21
- title: string,
22
-
23
- /**
24
- * User-defined actions.
25
- *
26
- * It can be either a Node or a function using the children-as-function
27
- * pattern to pass a close function for use anywhere within the actions.
28
- * This provides a lot of flexibility in terms of what actions may trigger
29
- * the Popover to close the popover dialog.
30
- */
31
- actions?:
32
- | React.Node
33
- | ((arg1: {|
34
- close: () => mixed,
35
- |}) => React.Element<any>),
36
-
37
- /**
38
- * Close button label for use in screen readers
39
- */
40
- closeButtonLabel?: string,
41
-
42
- /**
43
- * When true, the close button is shown; otherwise, the close button is not shown.
44
- */
45
- closeButtonVisible?: boolean,
46
-
47
- /**
48
- * Custom styles to be injected to the popover content container
49
- */
50
- style?: StyleType,
51
-
52
- /**
53
- * Test ID used for e2e testing.
54
- */
55
- testId?: string,
56
-
57
- /**
58
- * Decorate the popover with an illustrated icon. It cannot be used at the
59
- * same time with image.
60
- */
61
- icon?:
62
- | string
63
- | React.Element<"img">
64
- | React.Element<"svg">,
65
-
66
- /**
67
- * Decorate the popover with a full-bleed illustration. It cannot be used at
68
- * the same time with icon.
69
- */
70
- image?:
71
- | React.Element<"img">
72
- | React.Element<"svg">,
73
-
74
- /**
75
- * When true, changes the popover dialog background to blue; otherwise, the
76
- * popover dialog background is not modified. It can be used only with
77
- * Text-only popovers. It cannot be used with icon or image.
78
- */
79
- emphasized?: boolean,
80
- |},
81
- |};
82
- declare type DefaultProps = {|
83
- closeButtonVisible: $PropertyType<Props, "closeButtonVisible">,
84
- |};
85
- /**
86
- * This is the container that is consumed by all the predefined variations. Its
87
- * main responsibility is populate the contents depending on the variation used.
88
- *
89
- * ### Usage
90
- *
91
- * ```jsx
92
- * import {PopoverContent} from "@khanacademy/wonder-blocks-popover";
93
- *
94
- * <PopoverContent
95
- * closeButtonVisible
96
- * content="Some content for the popover"
97
- * title="Popover with text only"
98
- * />
99
- * ```
100
- */
101
- declare export default class PopoverContent extends React.Component<Props> {
102
- static defaultProps: DefaultProps;
103
- componentDidMount(): void;
104
-
105
- /**
106
- * Runtime validation in case we try to use an invalid shape
107
- */
108
- validateProps(x: PopoverContextType): void;
109
- maybeRenderImage: (context: PopoverContextType) => React.Element<any>;
110
- maybeRenderIcon: () => React.Element<any>;
111
- maybeRenderActions: (close: () => mixed) => React.Element<any>;
112
- render(): React.Node;
113
- }
@@ -1,35 +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 { Placement } from "@khanacademy/wonder-blocks-tooltip";
9
- export type PopoverContextType = {|
10
- /**
11
- * Facilitates passing the `onClose` handler from the Popover down to its
12
- * children.
13
- */
14
- close?: () => mixed,
15
-
16
- /**
17
- * Facilitates passing this value from Popover (via TooltipPopper) down to
18
- * PopoverContent. This is needed here to reposition the illustration to the
19
- * start or the end of the content, in case the popper changes its
20
- * placement.
21
- */
22
- placement?: Placement,
23
- |};
24
- /**
25
- * This context is being used for two reasons:
26
- *
27
- * 1. Pass down the `close` method from the `Popover` component to its children
28
- * (`PopoverContent` and `CloseButton`). This way, these components can use
29
- * this handler internally.
30
- *
31
- * 2. Keeps a reference of the TooltipPopper's `placement` value. It can be one
32
- * of the following values: "top", "bottom", "left" or "right".
33
- */
34
- declare var PopoverContext: React.Context<PopoverContextType>;
35
- declare export default typeof PopoverContext;
@@ -1,59 +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 { AriaProps } from "@khanacademy/wonder-blocks-core";
9
- import type {
10
- Placement,
11
- PopperElementProps,
12
- } from "@khanacademy/wonder-blocks-tooltip";
13
- import PopoverContent from "./popover-content";
14
- import PopoverContentCore from "./popover-content-core";
15
- declare type Props = {|
16
- ...AriaProps,
17
- ...PopperElementProps,
18
- ...{|
19
- /**
20
- * The content to render inside the dialog.
21
- */
22
- children:
23
- | React.Element<typeof PopoverContent>
24
- | React.Element<typeof PopoverContentCore>,
25
-
26
- /**
27
- * The unique identifier to give to the popover content.
28
- */
29
- id?: string,
30
-
31
- /**
32
- * Called when popper changes its placement
33
- */
34
- onUpdate: (placement: Placement) => mixed,
35
-
36
- /**
37
- * Whether to show the popover tail or not.
38
- */
39
- showTail: boolean,
40
- |},
41
- |};
42
- /**
43
- * This is an internal component that we use to render the stuff that appears
44
- * when a popover shows. It's composed by two elements: The popover content,
45
- * that can be of type [PopoverContent](#PopoverContent) or
46
- * [PopoverContentCore](#PopoverContentCore), and the
47
- * [TooltipTail](#TooltipTail).
48
- *
49
- * The main difference with [TooltipBubble](#TooltipBubble) is that bubble
50
- * handles hover states and PopoverDialog doesn't need to handle any states at
51
- * all (for now). Also, PopoverDialog needs to coordinate different background
52
- * colors for the content and tail components.
53
- *
54
- * Note that without explicit positioning, the tail will not be centered.
55
- */
56
- declare export default class PopoverDialog extends React.Component<Props> {
57
- componentDidUpdate(prevProps: Props): void;
58
- render(): React.Node;
59
- }
@@ -1,43 +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 PopoverContent from "./popover-content";
9
- import PopoverContentCore from "./popover-content-core";
10
- declare type Props = {|
11
- /**
12
- * Called when `esc` is pressed
13
- */
14
- onClose: () => mixed,
15
-
16
- /**
17
- * Popover Content ref.
18
- * Will close the popover when clicking outside this element.
19
- */
20
- contentRef?: React.RefObject<PopoverContentCore | PopoverContent>,
21
- |};
22
- declare type State = {|
23
- /**
24
- * Tracks the first click triggered by the click event listener.
25
- */
26
- isFirstClick: boolean,
27
- |};
28
- /**
29
- * A component that, when mounted, calls `onClose` when certain events occur.
30
- * This includes when pressing Escape or clicking outside the Popover.
31
- * @see
32
- * @khanacademy /wonder-blocks-modal/components/modal-launcher.js
33
- */
34
- declare export default class PopoverEventListener
35
- extends React.Component<Props, State>
36
- {
37
- state: State;
38
- componentDidMount(): void;
39
- componentWillUnmount(): void;
40
- _handleKeyup: (e: KeyboardEvent) => void;
41
- _handleClick: (e: MouseEvent) => void;
42
- render(): React.Element<any> | null;
43
- }
@@ -1,182 +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 { AriaProps } from "@khanacademy/wonder-blocks-core";
9
- import type { Placement } from "@khanacademy/wonder-blocks-tooltip";
10
- import PopoverContent from "./popover-content";
11
- import PopoverContentCore from "./popover-content-core";
12
- declare type PopoverContents =
13
- | React.Element<typeof PopoverContent>
14
- | React.Element<typeof PopoverContentCore>;
15
- declare type Props = {|
16
- ...AriaProps,
17
- ...$ReadOnly<{|
18
- /**
19
- * The element that triggers the popover. This element will be used to
20
- * position the popover. It can be either a Node or a function using the
21
- * children-as-function pattern to pass an open function for use anywhere
22
- * within children. The latter provides a lot of flexibility in terms of
23
- * what actions may trigger the `Popover` to launch the popover dialog.
24
- */
25
- children:
26
- | React.Element<any>
27
- | ((arg1: {|
28
- open: () => void,
29
- |}) => React.Element<any>),
30
-
31
- /**
32
- * The content of the popover. You can either use
33
- * [PopoverContent](#PopoverContent) with one of the pre-defined variants,
34
- * or include your own custom content using
35
- * [PopoverContentCore](#PopoverContentCore directly.
36
- *
37
- * If the popover needs to close itself, the close function provided to this
38
- * callback can be called to close the popover.
39
- */
40
- content:
41
- | PopoverContents
42
- | ((arg1: {|
43
- close: () => void,
44
- |}) => PopoverContents),
45
-
46
- /**
47
- * Where the popover should try to appear in relation to the trigger element.
48
- */
49
- placement: Placement,
50
-
51
- /**
52
- * When enabled, user can hide the popover content by pressing the `esc` key
53
- * or clicking/tapping outside of it.
54
- */
55
- dismissEnabled?: boolean,
56
-
57
- /**
58
- * The unique identifier to give to the popover. Provide this in cases where
59
- * you want to override the default accessibility solution. This identifier
60
- * will be applied to the popover content.
61
- *
62
- * By providing this identifier, the children that this popover anchors to
63
- * will not be automatically given the
64
- * [aria-describedby](https://www.w3.org/TR/wai-aria-1.1/#aria-describedby)
65
- * attribute. Instead, the accessibility solution is the responsibility of
66
- * the caller.
67
- *
68
- * If this is not provided, the
69
- * [aria-describedby](https://www.w3.org/TR/wai-aria-1.1/#aria-describedby)
70
- * attribute will be added to the children with a unique identifier pointing
71
- * to the popover dialog.
72
- */
73
- id?: string,
74
-
75
- /**
76
- * The selector for the element that will be focused when the popover
77
- * content shows. When not set, the first focusable element within the
78
- * popover content will be used.
79
- */
80
- initialFocusId?: string,
81
-
82
- /**
83
- * Renders the popover when true, renders nothing when false.
84
- *
85
- * Using this prop makes the component behave as a controlled component. The
86
- * parent is responsible for managing the opening/closing of the popover
87
- * when using this prop.
88
- */
89
- opened?: boolean,
90
-
91
- /**
92
- * Called when the popover closes
93
- */
94
- onClose?: () => mixed,
95
-
96
- /**
97
- * Test ID used for e2e testing.
98
- */
99
- testId?: string,
100
-
101
- /**
102
- * Whether to show the popover tail or not. Defaults to true.
103
- */
104
- showTail: boolean,
105
- |}>,
106
- |};
107
- declare type State = $ReadOnly<{|
108
- /**
109
- * Keeps a reference of the dialog state
110
- */
111
- opened: boolean,
112
-
113
- /**
114
- * Anchor element DOM reference
115
- */
116
- anchorElement?: HTMLElement,
117
-
118
- /**
119
- * Current popper placement
120
- */
121
- placement: Placement,
122
- |}>;
123
- declare type DefaultProps = $ReadOnly<{|
124
- placement: $PropertyType<Props, "placement">,
125
- showTail: $PropertyType<Props, "showTail">,
126
- |}>;
127
- /**
128
- * Popovers provide additional information that is related to a particular
129
- * element and/or content. They can include text, links, icons and
130
- * illustrations. The main difference with `Tooltip` is that they must be
131
- * dismissed by clicking an element.
132
- *
133
- * This component uses the `PopoverPopper` component to position the
134
- * `PopoverContentCore` component according to the children it is wrapping.
135
- *
136
- * ### Usage
137
- *
138
- * ```jsx
139
- * import {Popover, PopoverContent} from "@khanacademy/wonder-blocks-popover";
140
- *
141
- * <Popover
142
- * onClose={() => {}}
143
- * content={
144
- * <PopoverContent title="Title" content="Some content" closeButtonVisible />
145
- * }>
146
- * {({ open }) => <Button onClick={open}>Open popover</Button>}
147
- * </Popover>
148
- * ```
149
- */
150
- declare export default class Popover extends React.Component<Props, State> {
151
- static defaultProps: DefaultProps;
152
-
153
- /**
154
- * Used to sync the `opened` state when Popover acts as a controlled
155
- * component
156
- */
157
- static getDerivedStateFromProps(
158
- props: Props,
159
- state: State
160
- ): $Rest<State, {}> | null | void;
161
- state: State;
162
-
163
- /**
164
- * Popover content ref
165
- */
166
- contentRef: React.RefObject<PopoverContent | PopoverContentCore>;
167
-
168
- /**
169
- * Popover dialog closed
170
- */
171
- handleClose: () => void;
172
-
173
- /**
174
- * Popover dialog opened
175
- */
176
- handleOpen: () => void;
177
- updateRef: (actualRef?: HTMLElement) => void;
178
- renderContent(): PopoverContents;
179
- renderPopper(uniqueId: string): React.Node;
180
- getHost(): Element | null | void;
181
- render(): React.Node;
182
- }
@@ -1,10 +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 Popover from "./components/popover";
8
- import PopoverContent from "./components/popover-content";
9
- import PopoverContentCore from "./components/popover-content-core";
10
- declare export { Popover, PopoverContent, PopoverContentCore };
@@ -1,9 +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
- declare export function findFocusableNodes(
8
- root: HTMLElement | Document
9
- ): Array<HTMLElement>;