@khanacademy/wonder-blocks-link 3.8.4 → 3.8.7
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 +24 -0
- package/dist/es/index.js +10 -34
- package/package.json +4 -4
- package/src/components/link.js +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# @khanacademy/wonder-blocks-link
|
|
2
2
|
|
|
3
|
+
## 3.8.7
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [5f4a4297]
|
|
8
|
+
- Updated dependencies [2b96fd59]
|
|
9
|
+
- @khanacademy/wonder-blocks-core@4.3.2
|
|
10
|
+
- @khanacademy/wonder-blocks-clickable@2.2.7
|
|
11
|
+
|
|
12
|
+
## 3.8.6
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- @khanacademy/wonder-blocks-clickable@2.2.6
|
|
17
|
+
- @khanacademy/wonder-blocks-core@4.3.1
|
|
18
|
+
|
|
19
|
+
## 3.8.5
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- Updated dependencies [246a921d]
|
|
24
|
+
- @khanacademy/wonder-blocks-core@4.3.0
|
|
25
|
+
- @khanacademy/wonder-blocks-clickable@2.2.5
|
|
26
|
+
|
|
3
27
|
## 3.8.4
|
|
4
28
|
|
|
5
29
|
### Patch Changes
|
package/dist/es/index.js
CHANGED
|
@@ -38,15 +38,15 @@ class LinkCore extends React.Component {
|
|
|
38
38
|
style: [defaultStyles, style]
|
|
39
39
|
}, restProps);
|
|
40
40
|
|
|
41
|
-
return router && !skipClientNav && isClientSideUrl(href) ?
|
|
41
|
+
return router && !skipClientNav && isClientSideUrl(href) ? React.createElement(StyledLink, _extends({}, commonProps, {
|
|
42
42
|
to: href
|
|
43
|
-
}), children) :
|
|
43
|
+
}), children) : React.createElement(StyledAnchor, _extends({}, commonProps, {
|
|
44
44
|
href: href
|
|
45
45
|
}), children);
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
render() {
|
|
49
|
-
return
|
|
49
|
+
return React.createElement(__RouterContext.Consumer, null, router => this.renderInner(router));
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
}
|
|
@@ -115,24 +115,6 @@ const _generateStyles = (kind, light, visitable) => {
|
|
|
115
115
|
const _excluded = ["onClick", "beforeNav", "safeWithNav", "href", "skipClientNav", "children", "tabIndex", "onKeyDown", "onKeyUp", "target"],
|
|
116
116
|
_excluded2 = ["tabIndex"],
|
|
117
117
|
_excluded3 = ["tabIndex"];
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Reusable link component.
|
|
121
|
-
*
|
|
122
|
-
* Consisting of a [`ClickableBehavior`](#clickablebehavior) surrounding a
|
|
123
|
-
* `LinkCore`. `ClickableBehavior` handles interactions and state changes.
|
|
124
|
-
* `LinkCore` is a stateless component which displays the different states
|
|
125
|
-
* the `Link` can take.
|
|
126
|
-
*
|
|
127
|
-
* Example usage:
|
|
128
|
-
* ```jsx
|
|
129
|
-
* <Link
|
|
130
|
-
* href="https://khanacademy.org/"
|
|
131
|
-
* >
|
|
132
|
-
* Label
|
|
133
|
-
* </Link>
|
|
134
|
-
* ```
|
|
135
|
-
*/
|
|
136
118
|
class Link extends React.Component {
|
|
137
119
|
renderClickableBehavior(router) {
|
|
138
120
|
const _this$props = this.props,
|
|
@@ -153,7 +135,7 @@ class Link extends React.Component {
|
|
|
153
135
|
const ClickableBehavior = getClickableBehavior(href, skipClientNav, router);
|
|
154
136
|
|
|
155
137
|
if (beforeNav) {
|
|
156
|
-
return
|
|
138
|
+
return React.createElement(ClickableBehavior, {
|
|
157
139
|
disabled: false,
|
|
158
140
|
href: href,
|
|
159
141
|
role: "link",
|
|
@@ -168,18 +150,15 @@ class Link extends React.Component {
|
|
|
168
150
|
} = _ref,
|
|
169
151
|
childrenProps = _objectWithoutPropertiesLoose(_ref, _excluded2);
|
|
170
152
|
|
|
171
|
-
return
|
|
153
|
+
return React.createElement(LinkCore, _extends({}, sharedProps, state, childrenProps, {
|
|
172
154
|
skipClientNav: skipClientNav,
|
|
173
155
|
href: href,
|
|
174
|
-
target: target
|
|
175
|
-
// it to override the tabIndex provide to use by
|
|
176
|
-
// ClickableBehavior.
|
|
177
|
-
,
|
|
156
|
+
target: target,
|
|
178
157
|
tabIndex: tabIndex || clickableTabIndex
|
|
179
158
|
}), children);
|
|
180
159
|
});
|
|
181
160
|
} else {
|
|
182
|
-
return
|
|
161
|
+
return React.createElement(ClickableBehavior, {
|
|
183
162
|
disabled: false,
|
|
184
163
|
href: href,
|
|
185
164
|
role: "link",
|
|
@@ -194,13 +173,10 @@ class Link extends React.Component {
|
|
|
194
173
|
} = _ref2,
|
|
195
174
|
childrenProps = _objectWithoutPropertiesLoose(_ref2, _excluded3);
|
|
196
175
|
|
|
197
|
-
return
|
|
176
|
+
return React.createElement(LinkCore, _extends({}, sharedProps, state, childrenProps, {
|
|
198
177
|
skipClientNav: skipClientNav,
|
|
199
178
|
href: href,
|
|
200
|
-
target: target
|
|
201
|
-
// it to override the tabIndex provide to use by
|
|
202
|
-
// ClickableBehavior.
|
|
203
|
-
,
|
|
179
|
+
target: target,
|
|
204
180
|
tabIndex: tabIndex || clickableTabIndex
|
|
205
181
|
}), children);
|
|
206
182
|
});
|
|
@@ -208,7 +184,7 @@ class Link extends React.Component {
|
|
|
208
184
|
}
|
|
209
185
|
|
|
210
186
|
render() {
|
|
211
|
-
return
|
|
187
|
+
return React.createElement(__RouterContext.Consumer, null, router => this.renderClickableBehavior(router));
|
|
212
188
|
}
|
|
213
189
|
|
|
214
190
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@khanacademy/wonder-blocks-link",
|
|
3
|
-
"version": "3.8.
|
|
3
|
+
"version": "3.8.7",
|
|
4
4
|
"design": "v1",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -16,9 +16,9 @@
|
|
|
16
16
|
"license": "MIT",
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@babel/runtime": "^7.16.3",
|
|
19
|
-
"@khanacademy/wonder-blocks-clickable": "^2.2.
|
|
19
|
+
"@khanacademy/wonder-blocks-clickable": "^2.2.7",
|
|
20
20
|
"@khanacademy/wonder-blocks-color": "^1.1.20",
|
|
21
|
-
"@khanacademy/wonder-blocks-core": "^4.2
|
|
21
|
+
"@khanacademy/wonder-blocks-core": "^4.3.2"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
24
|
"aphrodite": "^1.2.5",
|
|
@@ -27,6 +27,6 @@
|
|
|
27
27
|
"react-router-dom": "5.3.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"wb-dev-build-settings": "^0.
|
|
30
|
+
"wb-dev-build-settings": "^0.4.0"
|
|
31
31
|
}
|
|
32
32
|
}
|
package/src/components/link.js
CHANGED
|
@@ -134,6 +134,8 @@ export type SharedProps =
|
|
|
134
134
|
/**
|
|
135
135
|
* A target destination window for a link to open in. We only support
|
|
136
136
|
* "_blank" which opens the URL in a new tab.
|
|
137
|
+
*
|
|
138
|
+
* TODO(WB-1262): only allow this prop when `href` is also set.t
|
|
137
139
|
*/
|
|
138
140
|
target?: "_blank",
|
|
139
141
|
|}
|