@khanacademy/wonder-blocks-clickable 3.1.2 → 4.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,166 +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 { Link } from "react-router-dom";
9
- import type { AriaProps, StyleType } from "@khanacademy/wonder-blocks-core";
10
- import type { ClickableRole, ClickableState } from "./clickable-behavior";
11
-
12
- /**
13
- * A component to turn any custom component into a clickable one.
14
- *
15
- * Works by wrapping `ClickableBehavior` around the child element and styling
16
- * the child appropriately and encapsulates routing logic which can be
17
- * customized. Expects a function which returns an element as its child.
18
- *
19
- * Clickable allows your components to:
20
- *
21
- * - Handle mouse / touch / keyboard events
22
- * - Match the standard behavior of the given role
23
- * - Apply custom styles based on pressed / focused / hovered state
24
- * - Perform Client Side Navigation when href is passed and the component is a
25
- * descendent of a react-router Router.
26
- *
27
- * ### Usage
28
- *
29
- * ```jsx
30
- * <Clickable onClick={() => alert("You clicked me!")}>
31
- * {({hovered, focused, pressed}) =>
32
- * <div
33
- * style={[
34
- * hovered && styles.hovered,
35
- * focused && styles.focused,
36
- * pressed && styles.pressed,
37
- * ]}
38
- * >
39
- * Click Me!
40
- * </div>
41
- * }
42
- * </Clickable>
43
- * ```
44
- */
45
- declare var Clickable: React.ForwardRefExoticComponent<{|
46
- ...$Rest<$Diff<AriaProps, { "aria-disabled": any }>, {}>,
47
- ...{|
48
- /**
49
- * The child of Clickable must be a function which returns the component
50
- * which should be made Clickable. The function is passed an object with
51
- * three boolean properties: hovered, focused, and pressed.
52
- */
53
- children: (arg1: ClickableState) => React.Node,
54
-
55
- /**
56
- * An onClick function which Clickable can execute when clicked
57
- */
58
- onClick?: ((e: SyntheticEvent<>) => mixed) | void,
59
-
60
- /**
61
- * Optional href which Clickable should direct to, uses client-side routing
62
- * by default if react-router is present
63
- */
64
- href?: string | void,
65
-
66
- /**
67
- * Styles to apply to the Clickable component
68
- */
69
- style?: StyleType,
70
-
71
- /**
72
- * Adds CSS classes to the Clickable.
73
- */
74
- className?: string | void,
75
-
76
- /**
77
- * Whether the Clickable is on a dark colored background.
78
- * Sets the default focus ring color to white, instead of blue.
79
- * Defaults to false.
80
- */
81
- light?: boolean | void,
82
-
83
- /**
84
- * Disables or enables the child; defaults to false
85
- */
86
- disabled?: boolean | void,
87
-
88
- /**
89
- * An optional id attribute.
90
- */
91
- id?: string | void,
92
-
93
- /**
94
- * Specifies the type of relationship between the current document and the
95
- * linked document. Should only be used when `href` is specified. This
96
- * defaults to "noopener noreferrer" when `target="_blank"`, but can be
97
- * overridden by setting this prop to something else.
98
- */
99
- rel?: string | void,
100
-
101
- /**
102
- * The role of the component, can be a role of type ClickableRole
103
- */
104
- role?: ClickableRole | void,
105
-
106
- /**
107
- * Avoids client-side routing in the presence of the href prop
108
- */
109
- skipClientNav?: boolean | void,
110
-
111
- /**
112
- * Test ID used for e2e testing.
113
- */
114
- testId?: string | void,
115
-
116
- /**
117
- * Respond to raw "keydown" event.
118
- */
119
- onKeyDown?: ((e: SyntheticKeyboardEvent<>) => mixed) | void,
120
-
121
- /**
122
- * Respond to raw "keyup" event.
123
- */
124
- onKeyUp?: ((e: SyntheticKeyboardEvent<>) => mixed) | void,
125
-
126
- /**
127
- * Don't show the default focus ring. This should be used when implementing
128
- * a custom focus ring within your own component that uses Clickable.
129
- */
130
- hideDefaultFocusRing?: boolean | void,
131
-
132
- /**
133
- * A target destination window for a link to open in.
134
- *
135
- * TODO(WB-1262): only allow this prop when `href` is also set.t
136
- */
137
- target?: "_blank" | void,
138
-
139
- /**
140
- * Set the tabindex attribute on the rendered element.
141
- */
142
- tabIndex?: number | void,
143
-
144
- /**
145
- * Run async code before navigating. If the promise returned rejects then
146
- * navigation will not occur.
147
- *
148
- * If both safeWithNav and beforeNav are provided, beforeNav will be run
149
- * first and safeWithNav will only be run if beforeNav does not reject.
150
- *
151
- * WARNING: This prop must be used with `href` and should not be used with
152
- * `target="blank"`.
153
- */
154
- beforeNav?: (() => Promise<mixed>) | void,
155
-
156
- /**
157
- * Run async code in the background while client-side navigating. If the
158
- * browser does a full page load navigation, the callback promise must be
159
- * settled before the navigation will occur. Errors are ignored so that
160
- * navigation is guaranteed to succeed.
161
- */
162
- safeWithNav?: (() => Promise<mixed>) | void,
163
- |},
164
- ...React.RefAttributes<HTMLAnchorElement | HTMLButtonElement | typeof Link>,
165
- |}>;
166
- declare export default typeof Clickable;
@@ -1,17 +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 type {
8
- ChildrenProps,
9
- ClickableState,
10
- ClickableRole,
11
- } from "./components/clickable-behavior";
12
- import Clickable from "./components/clickable";
13
- declare export { default as ClickableBehavior } from "./components/clickable-behavior";
14
- declare export { default as getClickableBehavior } from "./util/get-clickable-behavior";
15
- declare export { isClientSideUrl } from "./util/is-client-side-url";
16
- declare export { Clickable as default };
17
- export type { ChildrenProps, ClickableState, ClickableRole };
@@ -1,15 +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 ClickableBehavior from "../components/clickable-behavior";
9
- declare export default function getClickableBehavior(
10
- href?: string,
11
- skipClientNav?: boolean,
12
- router?: any
13
- ): React.ComponentType<
14
- React.ElementConfig<typeof ClickableBehavior>
15
- >;
@@ -1,13 +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
- /**
8
- * Returns:
9
- * - false for hrefs staring with http://, https://, //.
10
- * - false for '#', 'javascript:...', 'mailto:...', 'tel:...', etc.
11
- * - true for all other values, e.g. /foo/bar
12
- */
13
- declare export var isClientSideUrl: (href: string) => boolean;