@ndla/safelink 5.1.0 → 5.1.2
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/es/SafeLink.js
CHANGED
|
@@ -12,8 +12,7 @@ import { forwardRef, useContext } from "react";
|
|
|
12
12
|
import { Link } from "react-router-dom";
|
|
13
13
|
import { Launch } from "@ndla/icons/common";
|
|
14
14
|
import MissingRouterContext from "./MissingRouterContext";
|
|
15
|
-
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
16
|
-
import { jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
15
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
17
16
|
const oldNdlaRegex = /(.*)\/?node\/(\d+).*/;
|
|
18
17
|
const isExternalLink = to => typeof to === "string" && (to.startsWith("https://") || to.startsWith("http://") || to.startsWith("mailto:") || to.endsWith(".xml"));
|
|
19
18
|
export const isOldNdlaLink = to => typeof to === "string" && to.match(oldNdlaRegex) !== null;
|
|
@@ -61,8 +60,8 @@ const SafeLink = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
61
60
|
// RR6 link immediately fails if to is somehow undefined, so we provide an empty fallback to recover.
|
|
62
61
|
_jsxs(Link, {
|
|
63
62
|
ref: ref,
|
|
64
|
-
tabIndex: tabIndex
|
|
65
|
-
to: to
|
|
63
|
+
tabIndex: tabIndex !== null && tabIndex !== void 0 ? tabIndex : 0,
|
|
64
|
+
to: to !== null && to !== void 0 ? to : "",
|
|
66
65
|
replace: replace,
|
|
67
66
|
...rest,
|
|
68
67
|
children: [children, showNewWindowIcon && _jsx(LaunchIcon, {})]
|
package/es/SafeLinkIconButton.js
CHANGED
|
@@ -12,9 +12,7 @@ import SafeLink from "./SafeLink";
|
|
|
12
12
|
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
13
13
|
const SafeLinkIconButton = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
14
14
|
let {
|
|
15
|
-
children,
|
|
16
15
|
inverted,
|
|
17
|
-
to,
|
|
18
16
|
size,
|
|
19
17
|
colorTheme,
|
|
20
18
|
variant,
|
|
@@ -22,8 +20,6 @@ const SafeLinkIconButton = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
22
20
|
...rest
|
|
23
21
|
} = _ref;
|
|
24
22
|
return _jsx(SafeLink, {
|
|
25
|
-
to: to,
|
|
26
|
-
ref: ref,
|
|
27
23
|
css: iconButtonStyle({
|
|
28
24
|
colorTheme,
|
|
29
25
|
size,
|
|
@@ -32,7 +28,7 @@ const SafeLinkIconButton = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
32
28
|
fontWeight
|
|
33
29
|
}),
|
|
34
30
|
...rest,
|
|
35
|
-
|
|
31
|
+
ref: ref
|
|
36
32
|
});
|
|
37
33
|
});
|
|
38
34
|
export default SafeLinkIconButton;
|
package/lib/SafeLink.js
CHANGED
|
@@ -66,8 +66,8 @@ const SafeLink = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
|
66
66
|
// RR6 link immediately fails if to is somehow undefined, so we provide an empty fallback to recover.
|
|
67
67
|
(0, _jsxRuntime.jsxs)(_reactRouterDom.Link, {
|
|
68
68
|
ref: ref,
|
|
69
|
-
tabIndex: tabIndex
|
|
70
|
-
to: to
|
|
69
|
+
tabIndex: tabIndex !== null && tabIndex !== void 0 ? tabIndex : 0,
|
|
70
|
+
to: to !== null && to !== void 0 ? to : "",
|
|
71
71
|
replace: replace,
|
|
72
72
|
...rest,
|
|
73
73
|
children: [children, showNewWindowIcon && (0, _jsxRuntime.jsx)(LaunchIcon, {})]
|
|
@@ -10,8 +10,6 @@ import { ButtonStyleProps } from "@ndla/button";
|
|
|
10
10
|
import { SafeLinkProps } from "./SafeLink";
|
|
11
11
|
interface Props extends SafeLinkProps, ButtonStyleProps {
|
|
12
12
|
children: ReactNode;
|
|
13
|
-
to: string;
|
|
14
|
-
className?: string;
|
|
15
13
|
}
|
|
16
14
|
declare const SafeLinkIconButton: import("react").ForwardRefExoticComponent<Omit<Props, "ref"> & import("react").RefAttributes<HTMLAnchorElement>>;
|
|
17
15
|
export default SafeLinkIconButton;
|
|
@@ -19,9 +19,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
19
19
|
|
|
20
20
|
const SafeLinkIconButton = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
21
21
|
let {
|
|
22
|
-
children,
|
|
23
22
|
inverted,
|
|
24
|
-
to,
|
|
25
23
|
size,
|
|
26
24
|
colorTheme,
|
|
27
25
|
variant,
|
|
@@ -29,8 +27,6 @@ const SafeLinkIconButton = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
|
29
27
|
...rest
|
|
30
28
|
} = _ref;
|
|
31
29
|
return (0, _jsxRuntime.jsx)(_SafeLink.default, {
|
|
32
|
-
to: to,
|
|
33
|
-
ref: ref,
|
|
34
30
|
css: (0, _button.iconButtonStyle)({
|
|
35
31
|
colorTheme,
|
|
36
32
|
size,
|
|
@@ -39,7 +35,7 @@ const SafeLinkIconButton = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
|
39
35
|
fontWeight
|
|
40
36
|
}),
|
|
41
37
|
...rest,
|
|
42
|
-
|
|
38
|
+
ref: ref
|
|
43
39
|
});
|
|
44
40
|
});
|
|
45
41
|
var _default = exports.default = SafeLinkIconButton;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ndla/safelink",
|
|
3
|
-
"version": "5.1.
|
|
3
|
+
"version": "5.1.2",
|
|
4
4
|
"description": "SafeLink component for NDLA",
|
|
5
5
|
"license": "GPL-3.0",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
"es"
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@ndla/button": "^12.0.
|
|
30
|
-
"@ndla/icons": "^6.1.
|
|
29
|
+
"@ndla/button": "^12.0.45",
|
|
30
|
+
"@ndla/icons": "^6.1.3"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"@emotion/react": "^11.10.4",
|
|
@@ -38,5 +38,5 @@
|
|
|
38
38
|
"publishConfig": {
|
|
39
39
|
"access": "public"
|
|
40
40
|
},
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "18d8228e549466cbe95555b84e66960ad4c2e590"
|
|
42
42
|
}
|