@khanacademy/wonder-blocks-link 7.1.0 → 7.1.1
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 +11 -0
- package/dist/index.js +27 -20
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @khanacademy/wonder-blocks-link
|
|
2
2
|
|
|
3
|
+
## 7.1.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- ee8d95a: Rollback rollup version from v4 to v2 to prevent an issue with CJS builds in unit tests
|
|
8
|
+
- Updated dependencies [ee8d95a]
|
|
9
|
+
- @khanacademy/wonder-blocks-clickable@6.1.1
|
|
10
|
+
- @khanacademy/wonder-blocks-core@12.1.1
|
|
11
|
+
- @khanacademy/wonder-blocks-icon@5.1.1
|
|
12
|
+
- @khanacademy/wonder-blocks-tokens@4.2.1
|
|
13
|
+
|
|
3
14
|
## 7.1.0
|
|
4
15
|
|
|
5
16
|
### Minor Changes
|
package/dist/index.js
CHANGED
|
@@ -13,7 +13,10 @@ var wonderBlocksTokens = require('@khanacademy/wonder-blocks-tokens');
|
|
|
13
13
|
var wonderBlocksIcon = require('@khanacademy/wonder-blocks-icon');
|
|
14
14
|
var externalLinkIcon = require('@phosphor-icons/core/bold/arrow-square-out-bold.svg');
|
|
15
15
|
|
|
16
|
-
function
|
|
16
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
17
|
+
|
|
18
|
+
function _interopNamespace(e) {
|
|
19
|
+
if (e && e.__esModule) return e;
|
|
17
20
|
var n = Object.create(null);
|
|
18
21
|
if (e) {
|
|
19
22
|
Object.keys(e).forEach(function (k) {
|
|
@@ -26,11 +29,15 @@ function _interopNamespaceDefault(e) {
|
|
|
26
29
|
}
|
|
27
30
|
});
|
|
28
31
|
}
|
|
29
|
-
n
|
|
32
|
+
n["default"] = e;
|
|
30
33
|
return Object.freeze(n);
|
|
31
34
|
}
|
|
32
35
|
|
|
33
|
-
var
|
|
36
|
+
var _objectDestructuringEmpty__default = /*#__PURE__*/_interopDefaultLegacy(_objectDestructuringEmpty);
|
|
37
|
+
var _extends__default = /*#__PURE__*/_interopDefaultLegacy(_extends);
|
|
38
|
+
var _objectWithoutPropertiesLoose__default = /*#__PURE__*/_interopDefaultLegacy(_objectWithoutPropertiesLoose);
|
|
39
|
+
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
40
|
+
var externalLinkIcon__default = /*#__PURE__*/_interopDefaultLegacy(externalLinkIcon);
|
|
34
41
|
|
|
35
42
|
const _excluded$1 = ["children", "skipClientNav", "focused", "hovered", "href", "inline", "kind", "light", "visitable", "pressed", "style", "testId", "waiting", "target", "startIcon", "endIcon"];
|
|
36
43
|
const StyledA = wonderBlocksCore.addStyle("a");
|
|
@@ -54,11 +61,11 @@ const LinkCore = React__namespace.forwardRef(function LinkCore(props, ref) {
|
|
|
54
61
|
startIcon,
|
|
55
62
|
endIcon
|
|
56
63
|
} = props,
|
|
57
|
-
restProps =
|
|
64
|
+
restProps = _objectWithoutPropertiesLoose__default["default"](props, _excluded$1);
|
|
58
65
|
const linkStyles = _generateStyles(inline, kind, light, visitable);
|
|
59
66
|
const restingStyles = inline ? linkStyles.restingInline : linkStyles.resting;
|
|
60
67
|
const defaultStyles = [sharedStyles.shared, restingStyles, pressed && linkStyles.active, !pressed && hovered && linkStyles.hover, !pressed && focused && linkStyles.focus];
|
|
61
|
-
const commonProps =
|
|
68
|
+
const commonProps = _extends__default["default"]({
|
|
62
69
|
"data-testid": testId,
|
|
63
70
|
style: [defaultStyles, style],
|
|
64
71
|
target
|
|
@@ -66,7 +73,7 @@ const LinkCore = React__namespace.forwardRef(function LinkCore(props, ref) {
|
|
|
66
73
|
const linkUrl = new URL(href, window.location.origin);
|
|
67
74
|
const isExternalLink = linkUrl.origin !== window.location.origin;
|
|
68
75
|
const externalIcon = React__namespace.createElement(wonderBlocksIcon.PhosphorIcon, {
|
|
69
|
-
icon:
|
|
76
|
+
icon: externalLinkIcon__default["default"],
|
|
70
77
|
size: "small",
|
|
71
78
|
style: [linkContentStyles.endIcon, linkContentStyles.centered],
|
|
72
79
|
testId: "external-icon"
|
|
@@ -74,24 +81,24 @@ const LinkCore = React__namespace.forwardRef(function LinkCore(props, ref) {
|
|
|
74
81
|
let startIconElement;
|
|
75
82
|
let endIconElement;
|
|
76
83
|
if (startIcon) {
|
|
77
|
-
startIconElement = React__namespace.cloneElement(startIcon,
|
|
84
|
+
startIconElement = React__namespace.cloneElement(startIcon, _extends__default["default"]({
|
|
78
85
|
style: [linkContentStyles.startIcon, linkContentStyles.centered],
|
|
79
86
|
testId: "start-icon",
|
|
80
87
|
"aria-hidden": "true"
|
|
81
88
|
}, startIcon.props));
|
|
82
89
|
}
|
|
83
90
|
if (endIcon) {
|
|
84
|
-
endIconElement = React__namespace.cloneElement(endIcon,
|
|
91
|
+
endIconElement = React__namespace.cloneElement(endIcon, _extends__default["default"]({
|
|
85
92
|
style: [linkContentStyles.endIcon, linkContentStyles.centered],
|
|
86
93
|
testId: "end-icon",
|
|
87
94
|
"aria-hidden": "true"
|
|
88
95
|
}, endIcon.props));
|
|
89
96
|
}
|
|
90
97
|
const linkContent = React__namespace.createElement(React__namespace.Fragment, null, startIcon && startIconElement, children, endIcon ? endIconElement : isExternalLink && target === "_blank" && externalIcon);
|
|
91
|
-
return router && !skipClientNav && wonderBlocksClickable.isClientSideUrl(href) ? React__namespace.createElement(StyledLink,
|
|
98
|
+
return router && !skipClientNav && wonderBlocksClickable.isClientSideUrl(href) ? React__namespace.createElement(StyledLink, _extends__default["default"]({}, commonProps, {
|
|
92
99
|
to: href,
|
|
93
100
|
ref: ref
|
|
94
|
-
}), linkContent) : React__namespace.createElement(StyledA,
|
|
101
|
+
}), linkContent) : React__namespace.createElement(StyledA, _extends__default["default"]({}, commonProps, {
|
|
95
102
|
href: href,
|
|
96
103
|
ref: ref
|
|
97
104
|
}), linkContent);
|
|
@@ -159,26 +166,26 @@ const _generateStyles = (inline, kind, light, visitable) => {
|
|
|
159
166
|
}
|
|
160
167
|
} : Object.freeze({});
|
|
161
168
|
const newStyles = {
|
|
162
|
-
resting:
|
|
169
|
+
resting: _extends__default["default"]({
|
|
163
170
|
color: defaultTextColor
|
|
164
171
|
}, defaultVisited),
|
|
165
|
-
restingInline:
|
|
172
|
+
restingInline: _extends__default["default"]({
|
|
166
173
|
color: defaultTextColor,
|
|
167
174
|
textDecoration: "underline currentcolor solid",
|
|
168
175
|
textUnderlineOffset: 2
|
|
169
176
|
}, defaultVisited),
|
|
170
|
-
hover:
|
|
177
|
+
hover: _extends__default["default"]({
|
|
171
178
|
textDecoration: "underline currentcolor solid",
|
|
172
179
|
color: defaultTextColor
|
|
173
180
|
}, defaultVisited),
|
|
174
181
|
focus: {
|
|
175
|
-
":focus-visible":
|
|
182
|
+
":focus-visible": _extends__default["default"]({
|
|
176
183
|
color: defaultTextColor,
|
|
177
184
|
outline: `1px solid ${light ? white : blue}`,
|
|
178
185
|
borderRadius: 3
|
|
179
186
|
}, defaultVisited)
|
|
180
187
|
},
|
|
181
|
-
active:
|
|
188
|
+
active: _extends__default["default"]({
|
|
182
189
|
color: activeColor,
|
|
183
190
|
textDecoration: "underline currentcolor solid"
|
|
184
191
|
}, activeVisited)
|
|
@@ -205,7 +212,7 @@ const Link = React__namespace.forwardRef(function Link(props, ref) {
|
|
|
205
212
|
light = false,
|
|
206
213
|
visitable = false
|
|
207
214
|
} = props,
|
|
208
|
-
sharedProps =
|
|
215
|
+
sharedProps = _objectWithoutPropertiesLoose__default["default"](props, _excluded);
|
|
209
216
|
const renderClickableBehavior = router => {
|
|
210
217
|
const ClickableBehavior = wonderBlocksClickable.getClickableBehavior(href, skipClientNav, router);
|
|
211
218
|
if (beforeNav) {
|
|
@@ -219,8 +226,8 @@ const Link = React__namespace.forwardRef(function Link(props, ref) {
|
|
|
219
226
|
onKeyDown: onKeyDown,
|
|
220
227
|
onKeyUp: onKeyUp
|
|
221
228
|
}, (state, _ref) => {
|
|
222
|
-
let childrenProps =
|
|
223
|
-
return React__namespace.createElement(LinkCore,
|
|
229
|
+
let childrenProps = _extends__default["default"]({}, (_objectDestructuringEmpty__default["default"](_ref), _ref));
|
|
230
|
+
return React__namespace.createElement(LinkCore, _extends__default["default"]({}, sharedProps, state, childrenProps, {
|
|
224
231
|
skipClientNav: skipClientNav,
|
|
225
232
|
href: href,
|
|
226
233
|
target: target,
|
|
@@ -243,8 +250,8 @@ const Link = React__namespace.forwardRef(function Link(props, ref) {
|
|
|
243
250
|
onKeyDown: onKeyDown,
|
|
244
251
|
onKeyUp: onKeyUp
|
|
245
252
|
}, (state, _ref2) => {
|
|
246
|
-
let childrenProps =
|
|
247
|
-
return React__namespace.createElement(LinkCore,
|
|
253
|
+
let childrenProps = _extends__default["default"]({}, (_objectDestructuringEmpty__default["default"](_ref2), _ref2));
|
|
254
|
+
return React__namespace.createElement(LinkCore, _extends__default["default"]({}, sharedProps, state, childrenProps, {
|
|
248
255
|
skipClientNav: skipClientNav,
|
|
249
256
|
href: href,
|
|
250
257
|
target: target,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@khanacademy/wonder-blocks-link",
|
|
3
|
-
"version": "7.1.
|
|
3
|
+
"version": "7.1.1",
|
|
4
4
|
"design": "v1",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -13,10 +13,10 @@
|
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"@babel/runtime": "^7.24.5",
|
|
16
|
-
"@khanacademy/wonder-blocks-clickable": "6.1.
|
|
17
|
-
"@khanacademy/wonder-blocks-core": "12.1.
|
|
18
|
-
"@khanacademy/wonder-blocks-icon": "5.1.
|
|
19
|
-
"@khanacademy/wonder-blocks-tokens": "4.2.
|
|
16
|
+
"@khanacademy/wonder-blocks-clickable": "6.1.1",
|
|
17
|
+
"@khanacademy/wonder-blocks-core": "12.1.1",
|
|
18
|
+
"@khanacademy/wonder-blocks-icon": "5.1.1",
|
|
19
|
+
"@khanacademy/wonder-blocks-tokens": "4.2.1"
|
|
20
20
|
},
|
|
21
21
|
"peerDependencies": {
|
|
22
22
|
"@phosphor-icons/core": "^2.0.2",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"react-router-dom": "5.3.4"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@khanacademy/wb-dev-build-settings": "2.1.
|
|
29
|
+
"@khanacademy/wb-dev-build-settings": "2.1.1"
|
|
30
30
|
},
|
|
31
31
|
"scripts": {
|
|
32
32
|
"test": "echo \"Error: no test specified\" && exit 1"
|