@khanacademy/wonder-blocks-link 4.2.8 → 4.3.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.
- package/CHANGELOG.md +14 -0
- package/dist/components/link-core.d.ts +850 -9
- package/dist/components/link-core.js.flow +2798 -14
- package/dist/components/link.d.ts +137 -16
- package/dist/components/link.js.flow +164 -15
- package/dist/es/index.js +51 -47
- package/dist/index.js +51 -47
- package/package.json +4 -4
- package/src/components/link-core.tsx +117 -101
- package/src/components/link.tsx +96 -90
- package/tsconfig-build.tsbuildinfo +1 -1
package/dist/index.js
CHANGED
|
@@ -70,27 +70,26 @@ function _objectWithoutPropertiesLoose(source, excluded) {
|
|
|
70
70
|
const _excluded$1 = ["children", "skipClientNav", "focused", "hovered", "href", "inline", "kind", "light", "visitable", "pressed", "style", "testId", "waiting", "target", "startIcon", "endIcon"];
|
|
71
71
|
const StyledAnchor = wonderBlocksCore.addStyle("a");
|
|
72
72
|
const StyledLink = wonderBlocksCore.addStyle(reactRouterDom.Link);
|
|
73
|
-
|
|
74
|
-
renderInner
|
|
75
|
-
const
|
|
76
|
-
{
|
|
73
|
+
const LinkCore = React__namespace.forwardRef((props, ref) => {
|
|
74
|
+
const renderInner = router => {
|
|
75
|
+
const {
|
|
77
76
|
children,
|
|
78
77
|
skipClientNav,
|
|
79
78
|
focused,
|
|
80
79
|
hovered,
|
|
81
80
|
href,
|
|
82
|
-
inline,
|
|
83
|
-
kind,
|
|
84
|
-
light,
|
|
85
|
-
visitable,
|
|
81
|
+
inline = false,
|
|
82
|
+
kind = "primary",
|
|
83
|
+
light = false,
|
|
84
|
+
visitable = false,
|
|
86
85
|
pressed,
|
|
87
86
|
style,
|
|
88
87
|
testId,
|
|
89
88
|
target,
|
|
90
89
|
startIcon,
|
|
91
90
|
endIcon
|
|
92
|
-
} =
|
|
93
|
-
restProps = _objectWithoutPropertiesLoose(
|
|
91
|
+
} = props,
|
|
92
|
+
restProps = _objectWithoutPropertiesLoose(props, _excluded$1);
|
|
94
93
|
const linkStyles = _generateStyles(inline, kind, light, visitable);
|
|
95
94
|
const restingStyles = inline ? linkStyles.restingInline : linkStyles.resting;
|
|
96
95
|
const defaultStyles = [sharedStyles.shared, restingStyles, pressed && linkStyles.active, !pressed && hovered && linkStyles.hover, !pressed && focused && linkStyles.focus];
|
|
@@ -124,15 +123,15 @@ class LinkCore extends React__namespace.Component {
|
|
|
124
123
|
"aria-hidden": "true"
|
|
125
124
|
}) : isExternalLink && target === "_blank" && externalIcon);
|
|
126
125
|
return router && !skipClientNav && wonderBlocksClickable.isClientSideUrl(href) ? React__namespace.createElement(StyledLink, _extends({}, commonProps, {
|
|
127
|
-
to: href
|
|
126
|
+
to: href,
|
|
127
|
+
ref: ref
|
|
128
128
|
}), linkContent) : React__namespace.createElement(StyledAnchor, _extends({}, commonProps, {
|
|
129
|
-
href: href
|
|
129
|
+
href: href,
|
|
130
|
+
ref: ref
|
|
130
131
|
}), linkContent);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
}
|
|
135
|
-
}
|
|
132
|
+
};
|
|
133
|
+
return React__namespace.createElement(reactRouter.__RouterContext.Consumer, null, router => renderInner(router));
|
|
134
|
+
});
|
|
136
135
|
const styles = {};
|
|
137
136
|
const linkContentStyles = aphrodite.StyleSheet.create({
|
|
138
137
|
startIcon: {
|
|
@@ -222,23 +221,26 @@ const _generateStyles = (inline, kind, light, visitable) => {
|
|
|
222
221
|
return styles[buttonType];
|
|
223
222
|
};
|
|
224
223
|
|
|
225
|
-
const _excluded = ["onClick", "beforeNav", "safeWithNav", "href", "skipClientNav", "children", "tabIndex", "onKeyDown", "onKeyUp", "target"];
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
224
|
+
const _excluded = ["onClick", "beforeNav", "safeWithNav", "href", "skipClientNav", "children", "tabIndex", "onKeyDown", "onKeyUp", "target", "inline", "kind", "light", "visitable"];
|
|
225
|
+
const Link = React__namespace.forwardRef((props, ref) => {
|
|
226
|
+
const {
|
|
227
|
+
onClick,
|
|
228
|
+
beforeNav = undefined,
|
|
229
|
+
safeWithNav,
|
|
230
|
+
href,
|
|
231
|
+
skipClientNav,
|
|
232
|
+
children,
|
|
233
|
+
tabIndex,
|
|
234
|
+
onKeyDown,
|
|
235
|
+
onKeyUp,
|
|
236
|
+
target = undefined,
|
|
237
|
+
inline = false,
|
|
238
|
+
kind = "primary",
|
|
239
|
+
light = false,
|
|
240
|
+
visitable = false
|
|
241
|
+
} = props,
|
|
242
|
+
sharedProps = _objectWithoutPropertiesLoose(props, _excluded);
|
|
243
|
+
const renderClickableBehavior = router => {
|
|
242
244
|
const ClickableBehavior = wonderBlocksClickable.getClickableBehavior(href, skipClientNav, router);
|
|
243
245
|
if (beforeNav) {
|
|
244
246
|
return React__namespace.createElement(ClickableBehavior, {
|
|
@@ -256,7 +258,12 @@ class Link extends React__namespace.Component {
|
|
|
256
258
|
skipClientNav: skipClientNav,
|
|
257
259
|
href: href,
|
|
258
260
|
target: target,
|
|
259
|
-
tabIndex: tabIndex
|
|
261
|
+
tabIndex: tabIndex,
|
|
262
|
+
inline: inline,
|
|
263
|
+
kind: kind,
|
|
264
|
+
light: light,
|
|
265
|
+
visitable: visitable,
|
|
266
|
+
ref: ref
|
|
260
267
|
}), children);
|
|
261
268
|
});
|
|
262
269
|
} else {
|
|
@@ -275,20 +282,17 @@ class Link extends React__namespace.Component {
|
|
|
275
282
|
skipClientNav: skipClientNav,
|
|
276
283
|
href: href,
|
|
277
284
|
target: target,
|
|
278
|
-
tabIndex: tabIndex
|
|
285
|
+
tabIndex: tabIndex,
|
|
286
|
+
inline: inline,
|
|
287
|
+
kind: kind,
|
|
288
|
+
light: light,
|
|
289
|
+
visitable: visitable,
|
|
290
|
+
ref: ref
|
|
279
291
|
}), children);
|
|
280
292
|
});
|
|
281
293
|
}
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
Link.defaultProps = {
|
|
288
|
-
inline: false,
|
|
289
|
-
kind: "primary",
|
|
290
|
-
light: false,
|
|
291
|
-
visitable: false
|
|
292
|
-
};
|
|
294
|
+
};
|
|
295
|
+
return React__namespace.createElement(reactRouter.__RouterContext.Consumer, null, router => renderClickableBehavior(router));
|
|
296
|
+
});
|
|
293
297
|
|
|
294
298
|
module.exports = Link;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@khanacademy/wonder-blocks-link",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.3.0",
|
|
4
4
|
"design": "v1",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -16,10 +16,10 @@
|
|
|
16
16
|
"license": "MIT",
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@babel/runtime": "^7.18.6",
|
|
19
|
-
"@khanacademy/wonder-blocks-clickable": "^3.1.
|
|
19
|
+
"@khanacademy/wonder-blocks-clickable": "^3.1.1",
|
|
20
20
|
"@khanacademy/wonder-blocks-color": "^2.0.1",
|
|
21
|
-
"@khanacademy/wonder-blocks-core": "^5.
|
|
22
|
-
"@khanacademy/wonder-blocks-icon": "^2.0.
|
|
21
|
+
"@khanacademy/wonder-blocks-core": "^5.3.0",
|
|
22
|
+
"@khanacademy/wonder-blocks-icon": "^2.0.14",
|
|
23
23
|
"@khanacademy/wonder-blocks-spacing": "^4.0.1"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
@@ -26,121 +26,135 @@ type Props = SharedProps &
|
|
|
26
26
|
const StyledAnchor = addStyle("a");
|
|
27
27
|
const StyledLink = addStyle(Link);
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
29
|
+
const LinkCore = React.forwardRef(
|
|
30
|
+
(
|
|
31
|
+
props: Props,
|
|
32
|
+
ref: React.ForwardedRef<typeof Link | HTMLAnchorElement>,
|
|
33
|
+
) => {
|
|
34
|
+
const renderInner = (router: any): React.ReactNode => {
|
|
35
|
+
const {
|
|
36
|
+
children,
|
|
37
|
+
skipClientNav,
|
|
38
|
+
focused,
|
|
39
|
+
hovered,
|
|
40
|
+
href,
|
|
41
|
+
inline = false,
|
|
42
|
+
kind = "primary",
|
|
43
|
+
light = false,
|
|
44
|
+
visitable = false,
|
|
45
|
+
pressed,
|
|
46
|
+
style,
|
|
47
|
+
testId,
|
|
48
|
+
waiting: _,
|
|
49
|
+
target,
|
|
50
|
+
startIcon,
|
|
51
|
+
endIcon,
|
|
52
|
+
...restProps
|
|
53
|
+
} = props;
|
|
50
54
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
+
const linkStyles = _generateStyles(inline, kind, light, visitable);
|
|
56
|
+
const restingStyles = inline
|
|
57
|
+
? linkStyles.restingInline
|
|
58
|
+
: linkStyles.resting;
|
|
55
59
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
60
|
+
const defaultStyles = [
|
|
61
|
+
sharedStyles.shared,
|
|
62
|
+
restingStyles,
|
|
63
|
+
pressed && linkStyles.active,
|
|
64
|
+
// A11y: The focus ring should always be present when the
|
|
65
|
+
// the link has focus, even the link is being hovered over.
|
|
66
|
+
// TODO(WB-1498): Udpate ClickableBehavior so that focus doesn't
|
|
67
|
+
// stop on mouseleave. We want the focus ring to remain on a
|
|
68
|
+
// focused link even after hovering and un-hovering on it.
|
|
69
|
+
!pressed && hovered && linkStyles.hover,
|
|
70
|
+
!pressed && focused && linkStyles.focus,
|
|
71
|
+
];
|
|
68
72
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
const commonProps = {
|
|
74
|
+
"data-test-id": testId,
|
|
75
|
+
style: [defaultStyles, style],
|
|
76
|
+
target,
|
|
77
|
+
...restProps,
|
|
78
|
+
} as const;
|
|
75
79
|
|
|
76
|
-
|
|
80
|
+
const linkUrl = new URL(href, window.location.origin);
|
|
77
81
|
|
|
78
|
-
|
|
82
|
+
const isExternalLink = linkUrl.origin !== window.location.origin;
|
|
79
83
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
84
|
+
const externalIconPath: IconAsset = {
|
|
85
|
+
small: "M14 6.5C14 6.63261 13.9473 6.75979 13.8536 6.85355C13.7598 6.94732 13.6326 7 13.5 7C13.3674 7 13.2402 6.94732 13.1464 6.85355C13.0527 6.75979 13 6.63261 13 6.5V3.7075L8.85437 7.85375C8.76055 7.94757 8.63331 8.00028 8.50062 8.00028C8.36794 8.00028 8.2407 7.94757 8.14688 7.85375C8.05306 7.75993 8.00035 7.63268 8.00035 7.5C8.00035 7.36732 8.05306 7.24007 8.14688 7.14625L12.2925 3H9.5C9.36739 3 9.24021 2.94732 9.14645 2.85355C9.05268 2.75979 9 2.63261 9 2.5C9 2.36739 9.05268 2.24021 9.14645 2.14645C9.24021 2.05268 9.36739 2 9.5 2H13.5C13.6326 2 13.7598 2.05268 13.8536 2.14645C13.9473 2.24021 14 2.36739 14 2.5V6.5ZM11.5 8C11.3674 8 11.2402 8.05268 11.1464 8.14645C11.0527 8.24021 11 8.36739 11 8.5V13H3V5H7.5C7.63261 5 7.75979 4.94732 7.85355 4.85355C7.94732 4.75979 8 4.63261 8 4.5C8 4.36739 7.94732 4.24021 7.85355 4.14645C7.75979 4.05268 7.63261 4 7.5 4H3C2.73478 4 2.48043 4.10536 2.29289 4.29289C2.10536 4.48043 2 4.73478 2 5V13C2 13.2652 2.10536 13.5196 2.29289 13.7071C2.48043 13.8946 2.73478 14 3 14H11C11.2652 14 11.5196 13.8946 11.7071 13.7071C11.8946 13.5196 12 13.2652 12 13V8.5C12 8.36739 11.9473 8.24021 11.8536 8.14645C11.7598 8.05268 11.6326 8 11.5 8Z",
|
|
86
|
+
};
|
|
83
87
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
88
|
+
const externalIcon = (
|
|
89
|
+
<Icon
|
|
90
|
+
icon={externalIconPath}
|
|
91
|
+
size="small"
|
|
92
|
+
style={[
|
|
93
|
+
linkContentStyles.endIcon,
|
|
94
|
+
linkContentStyles.centered,
|
|
95
|
+
]}
|
|
96
|
+
testId="external-icon"
|
|
97
|
+
/>
|
|
98
|
+
);
|
|
92
99
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
100
|
+
const linkContent = (
|
|
101
|
+
<>
|
|
102
|
+
{startIcon && (
|
|
103
|
+
<Icon
|
|
104
|
+
icon={startIcon}
|
|
105
|
+
size="small"
|
|
106
|
+
style={[
|
|
107
|
+
linkContentStyles.startIcon,
|
|
108
|
+
linkContentStyles.centered,
|
|
109
|
+
]}
|
|
110
|
+
testId="start-icon"
|
|
111
|
+
aria-hidden="true"
|
|
112
|
+
/>
|
|
113
|
+
)}
|
|
114
|
+
{children}
|
|
115
|
+
{endIcon ? (
|
|
116
|
+
<Icon
|
|
117
|
+
icon={endIcon}
|
|
118
|
+
size="small"
|
|
119
|
+
style={[
|
|
120
|
+
linkContentStyles.endIcon,
|
|
121
|
+
linkContentStyles.centered,
|
|
122
|
+
]}
|
|
123
|
+
testId="end-icon"
|
|
124
|
+
aria-hidden="true"
|
|
125
|
+
/>
|
|
126
|
+
) : (
|
|
127
|
+
isExternalLink && target === "_blank" && externalIcon
|
|
128
|
+
)}
|
|
129
|
+
</>
|
|
130
|
+
);
|
|
124
131
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
132
|
+
return router && !skipClientNav && isClientSideUrl(href) ? (
|
|
133
|
+
<StyledLink
|
|
134
|
+
{...commonProps}
|
|
135
|
+
to={href}
|
|
136
|
+
ref={ref as React.ForwardedRef<typeof Link>}
|
|
137
|
+
>
|
|
138
|
+
{linkContent}
|
|
139
|
+
</StyledLink>
|
|
140
|
+
) : (
|
|
141
|
+
<StyledAnchor
|
|
142
|
+
{...commonProps}
|
|
143
|
+
href={href}
|
|
144
|
+
ref={ref as React.ForwardedRef<HTMLAnchorElement>}
|
|
145
|
+
>
|
|
146
|
+
{linkContent}
|
|
147
|
+
</StyledAnchor>
|
|
148
|
+
);
|
|
149
|
+
};
|
|
135
150
|
|
|
136
|
-
render(): React.ReactNode {
|
|
137
151
|
return (
|
|
138
152
|
<__RouterContext.Consumer>
|
|
139
|
-
{(router) =>
|
|
153
|
+
{(router) => renderInner(router)}
|
|
140
154
|
</__RouterContext.Consumer>
|
|
141
155
|
);
|
|
142
|
-
}
|
|
143
|
-
|
|
156
|
+
},
|
|
157
|
+
);
|
|
144
158
|
|
|
145
159
|
const styles: Record<string, any> = {};
|
|
146
160
|
|
|
@@ -276,3 +290,5 @@ const _generateStyles = (
|
|
|
276
290
|
styles[buttonType] = StyleSheet.create(newStyles);
|
|
277
291
|
return styles[buttonType];
|
|
278
292
|
};
|
|
293
|
+
|
|
294
|
+
export default LinkCore;
|
package/src/components/link.tsx
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import {__RouterContext} from "react-router";
|
|
3
|
+
import {Link as ReactRouterLink} from "react-router-dom";
|
|
3
4
|
import {getClickableBehavior} from "@khanacademy/wonder-blocks-clickable";
|
|
4
5
|
|
|
5
6
|
import type {AriaProps, StyleType} from "@khanacademy/wonder-blocks-core";
|
|
@@ -26,20 +27,20 @@ export type SharedProps = AriaProps & {
|
|
|
26
27
|
* This styles the link with an underline to distinguish it
|
|
27
28
|
* from surrounding text.
|
|
28
29
|
*/
|
|
29
|
-
inline
|
|
30
|
+
inline?: boolean;
|
|
30
31
|
/**
|
|
31
32
|
* Kind of Link. Note: Secondary light Links are not supported.
|
|
32
33
|
*/
|
|
33
|
-
kind
|
|
34
|
+
kind?: "primary" | "secondary";
|
|
34
35
|
/**
|
|
35
36
|
* Whether the button is on a dark/colored background.
|
|
36
37
|
*/
|
|
37
|
-
light
|
|
38
|
+
light?: boolean;
|
|
38
39
|
/**
|
|
39
40
|
* Whether the link should change color once it's visited.
|
|
40
41
|
* secondary or primary (light) links are not allowed to be visitable.
|
|
41
42
|
*/
|
|
42
|
-
visitable
|
|
43
|
+
visitable?: boolean;
|
|
43
44
|
/**
|
|
44
45
|
* Specifies the type of relationship between the current document and the
|
|
45
46
|
* linked document. Should only be used when `href` is specified. This
|
|
@@ -153,13 +154,6 @@ export type SharedProps = AriaProps & {
|
|
|
153
154
|
endIcon?: IconAsset;
|
|
154
155
|
};
|
|
155
156
|
|
|
156
|
-
type DefaultProps = {
|
|
157
|
-
inline: SharedProps["inline"];
|
|
158
|
-
kind: SharedProps["kind"];
|
|
159
|
-
light: SharedProps["light"];
|
|
160
|
-
visitable: SharedProps["visitable"];
|
|
161
|
-
};
|
|
162
|
-
|
|
163
157
|
/**
|
|
164
158
|
* Reusable link component.
|
|
165
159
|
*
|
|
@@ -178,15 +172,11 @@ type DefaultProps = {
|
|
|
178
172
|
* </Link>
|
|
179
173
|
* ```
|
|
180
174
|
*/
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
visitable: false,
|
|
187
|
-
};
|
|
188
|
-
|
|
189
|
-
renderClickableBehavior(router: any): React.ReactNode {
|
|
175
|
+
const Link = React.forwardRef(
|
|
176
|
+
(
|
|
177
|
+
props: SharedProps,
|
|
178
|
+
ref: React.ForwardedRef<typeof ReactRouterLink | HTMLAnchorElement>,
|
|
179
|
+
) => {
|
|
190
180
|
const {
|
|
191
181
|
onClick,
|
|
192
182
|
beforeNav = undefined,
|
|
@@ -198,81 +188,97 @@ export default class Link extends React.Component<SharedProps> {
|
|
|
198
188
|
onKeyDown,
|
|
199
189
|
onKeyUp,
|
|
200
190
|
target = undefined,
|
|
191
|
+
inline = false,
|
|
192
|
+
kind = "primary",
|
|
193
|
+
light = false,
|
|
194
|
+
visitable = false,
|
|
201
195
|
...sharedProps
|
|
202
|
-
} =
|
|
203
|
-
|
|
204
|
-
const ClickableBehavior = getClickableBehavior(
|
|
205
|
-
href,
|
|
206
|
-
skipClientNav,
|
|
207
|
-
router,
|
|
208
|
-
);
|
|
196
|
+
} = props;
|
|
209
197
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
role="link"
|
|
216
|
-
onClick={onClick}
|
|
217
|
-
beforeNav={beforeNav}
|
|
218
|
-
safeWithNav={safeWithNav}
|
|
219
|
-
onKeyDown={onKeyDown}
|
|
220
|
-
onKeyUp={onKeyUp}
|
|
221
|
-
>
|
|
222
|
-
{(state, {...childrenProps}) => {
|
|
223
|
-
return (
|
|
224
|
-
<LinkCore
|
|
225
|
-
{...sharedProps}
|
|
226
|
-
{...state}
|
|
227
|
-
{...childrenProps}
|
|
228
|
-
skipClientNav={skipClientNav}
|
|
229
|
-
href={href}
|
|
230
|
-
target={target}
|
|
231
|
-
tabIndex={tabIndex}
|
|
232
|
-
>
|
|
233
|
-
{children}
|
|
234
|
-
</LinkCore>
|
|
235
|
-
);
|
|
236
|
-
}}
|
|
237
|
-
</ClickableBehavior>
|
|
238
|
-
);
|
|
239
|
-
} else {
|
|
240
|
-
return (
|
|
241
|
-
<ClickableBehavior
|
|
242
|
-
disabled={false}
|
|
243
|
-
href={href}
|
|
244
|
-
role="link"
|
|
245
|
-
onClick={onClick}
|
|
246
|
-
safeWithNav={safeWithNav}
|
|
247
|
-
target={target}
|
|
248
|
-
onKeyDown={onKeyDown}
|
|
249
|
-
onKeyUp={onKeyUp}
|
|
250
|
-
>
|
|
251
|
-
{(state, {...childrenProps}) => {
|
|
252
|
-
return (
|
|
253
|
-
<LinkCore
|
|
254
|
-
{...sharedProps}
|
|
255
|
-
{...state}
|
|
256
|
-
{...childrenProps}
|
|
257
|
-
skipClientNav={skipClientNav}
|
|
258
|
-
href={href}
|
|
259
|
-
target={target}
|
|
260
|
-
tabIndex={tabIndex}
|
|
261
|
-
>
|
|
262
|
-
{children}
|
|
263
|
-
</LinkCore>
|
|
264
|
-
);
|
|
265
|
-
}}
|
|
266
|
-
</ClickableBehavior>
|
|
198
|
+
const renderClickableBehavior = (router: any): React.ReactNode => {
|
|
199
|
+
const ClickableBehavior = getClickableBehavior(
|
|
200
|
+
href,
|
|
201
|
+
skipClientNav,
|
|
202
|
+
router,
|
|
267
203
|
);
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
204
|
|
|
271
|
-
|
|
205
|
+
if (beforeNav) {
|
|
206
|
+
return (
|
|
207
|
+
<ClickableBehavior
|
|
208
|
+
disabled={false}
|
|
209
|
+
href={href}
|
|
210
|
+
role="link"
|
|
211
|
+
onClick={onClick}
|
|
212
|
+
beforeNav={beforeNav}
|
|
213
|
+
safeWithNav={safeWithNav}
|
|
214
|
+
onKeyDown={onKeyDown}
|
|
215
|
+
onKeyUp={onKeyUp}
|
|
216
|
+
>
|
|
217
|
+
{(state, {...childrenProps}) => {
|
|
218
|
+
return (
|
|
219
|
+
<LinkCore
|
|
220
|
+
{...sharedProps}
|
|
221
|
+
{...state}
|
|
222
|
+
{...childrenProps}
|
|
223
|
+
skipClientNav={skipClientNav}
|
|
224
|
+
href={href}
|
|
225
|
+
target={target}
|
|
226
|
+
tabIndex={tabIndex}
|
|
227
|
+
inline={inline}
|
|
228
|
+
kind={kind}
|
|
229
|
+
light={light}
|
|
230
|
+
visitable={visitable}
|
|
231
|
+
ref={ref}
|
|
232
|
+
>
|
|
233
|
+
{children}
|
|
234
|
+
</LinkCore>
|
|
235
|
+
);
|
|
236
|
+
}}
|
|
237
|
+
</ClickableBehavior>
|
|
238
|
+
);
|
|
239
|
+
} else {
|
|
240
|
+
return (
|
|
241
|
+
<ClickableBehavior
|
|
242
|
+
disabled={false}
|
|
243
|
+
href={href}
|
|
244
|
+
role="link"
|
|
245
|
+
onClick={onClick}
|
|
246
|
+
safeWithNav={safeWithNav}
|
|
247
|
+
target={target}
|
|
248
|
+
onKeyDown={onKeyDown}
|
|
249
|
+
onKeyUp={onKeyUp}
|
|
250
|
+
>
|
|
251
|
+
{(state, {...childrenProps}) => {
|
|
252
|
+
return (
|
|
253
|
+
<LinkCore
|
|
254
|
+
{...sharedProps}
|
|
255
|
+
{...state}
|
|
256
|
+
{...childrenProps}
|
|
257
|
+
skipClientNav={skipClientNav}
|
|
258
|
+
href={href}
|
|
259
|
+
target={target}
|
|
260
|
+
tabIndex={tabIndex}
|
|
261
|
+
inline={inline}
|
|
262
|
+
kind={kind}
|
|
263
|
+
light={light}
|
|
264
|
+
visitable={visitable}
|
|
265
|
+
ref={ref}
|
|
266
|
+
>
|
|
267
|
+
{children}
|
|
268
|
+
</LinkCore>
|
|
269
|
+
);
|
|
270
|
+
}}
|
|
271
|
+
</ClickableBehavior>
|
|
272
|
+
);
|
|
273
|
+
}
|
|
274
|
+
};
|
|
275
|
+
|
|
272
276
|
return (
|
|
273
277
|
<__RouterContext.Consumer>
|
|
274
|
-
{(router) =>
|
|
278
|
+
{(router) => renderClickableBehavior(router)}
|
|
275
279
|
</__RouterContext.Consumer>
|
|
276
280
|
);
|
|
277
|
-
}
|
|
278
|
-
|
|
281
|
+
},
|
|
282
|
+
);
|
|
283
|
+
|
|
284
|
+
export default Link;
|