@ndla/safelink 6.0.0-alpha.0 → 6.0.2-alpha.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/es/SafeLink.js +6 -0
- package/lib/SafeLink.d.ts +1 -0
- package/lib/SafeLink.js +6 -0
- package/package.json +4 -4
package/es/SafeLink.js
CHANGED
|
@@ -25,6 +25,7 @@ export const SafeLink = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
25
25
|
to,
|
|
26
26
|
replace,
|
|
27
27
|
disabled,
|
|
28
|
+
unstyled,
|
|
28
29
|
children,
|
|
29
30
|
showNewWindowIcon,
|
|
30
31
|
tabIndex,
|
|
@@ -32,6 +33,9 @@ export const SafeLink = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
32
33
|
...rest
|
|
33
34
|
} = _ref;
|
|
34
35
|
const isMissingRouterContext = useContext(MissingRouterContext);
|
|
36
|
+
const unstyledProps = unstyled ? {
|
|
37
|
+
"data-unstyled": ""
|
|
38
|
+
} : {};
|
|
35
39
|
if (isMissingRouterContext || isExternalLink(to) || isOldNdlaLink(to) || asAnchor || disabled) {
|
|
36
40
|
const href = typeof to === "string" ? to : "#";
|
|
37
41
|
return /*#__PURE__*/_jsx(styled.a, {
|
|
@@ -40,6 +44,7 @@ export const SafeLink = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
40
44
|
"aria-disabled": disabled,
|
|
41
45
|
ref: ref,
|
|
42
46
|
tabIndex: tabIndex,
|
|
47
|
+
...unstyledProps,
|
|
43
48
|
...rest,
|
|
44
49
|
children: children
|
|
45
50
|
});
|
|
@@ -52,6 +57,7 @@ export const SafeLink = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
52
57
|
tabIndex: tabIndex ?? 0,
|
|
53
58
|
to: to ?? "",
|
|
54
59
|
replace: replace,
|
|
60
|
+
...unstyledProps,
|
|
55
61
|
...rest,
|
|
56
62
|
children: children
|
|
57
63
|
})
|
package/lib/SafeLink.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ type Props = {
|
|
|
15
15
|
asAnchor?: boolean;
|
|
16
16
|
children?: ReactNode;
|
|
17
17
|
disabled?: boolean;
|
|
18
|
+
unstyled?: boolean;
|
|
18
19
|
};
|
|
19
20
|
export type SafeLinkProps = Props & LinkProps & JsxStyleProps & HTMLAttributes<HTMLElement>;
|
|
20
21
|
export declare const SafeLink: import("react").ForwardRefExoticComponent<Omit<SafeLinkProps, "ref"> & import("react").RefAttributes<HTMLAnchorElement>>;
|
package/lib/SafeLink.js
CHANGED
|
@@ -32,6 +32,7 @@ const SafeLink = exports.SafeLink = /*#__PURE__*/(0, _react.forwardRef)((_ref, r
|
|
|
32
32
|
to,
|
|
33
33
|
replace,
|
|
34
34
|
disabled,
|
|
35
|
+
unstyled,
|
|
35
36
|
children,
|
|
36
37
|
showNewWindowIcon,
|
|
37
38
|
tabIndex,
|
|
@@ -39,6 +40,9 @@ const SafeLink = exports.SafeLink = /*#__PURE__*/(0, _react.forwardRef)((_ref, r
|
|
|
39
40
|
...rest
|
|
40
41
|
} = _ref;
|
|
41
42
|
const isMissingRouterContext = (0, _react.useContext)(_MissingRouterContext.MissingRouterContext);
|
|
43
|
+
const unstyledProps = unstyled ? {
|
|
44
|
+
"data-unstyled": ""
|
|
45
|
+
} : {};
|
|
42
46
|
if (isMissingRouterContext || isExternalLink(to) || isOldNdlaLink(to) || asAnchor || disabled) {
|
|
43
47
|
const href = typeof to === "string" ? to : "#";
|
|
44
48
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsx2.styled.a, {
|
|
@@ -47,6 +51,7 @@ const SafeLink = exports.SafeLink = /*#__PURE__*/(0, _react.forwardRef)((_ref, r
|
|
|
47
51
|
"aria-disabled": disabled,
|
|
48
52
|
ref: ref,
|
|
49
53
|
tabIndex: tabIndex,
|
|
54
|
+
...unstyledProps,
|
|
50
55
|
...rest,
|
|
51
56
|
children: children
|
|
52
57
|
});
|
|
@@ -59,6 +64,7 @@ const SafeLink = exports.SafeLink = /*#__PURE__*/(0, _react.forwardRef)((_ref, r
|
|
|
59
64
|
tabIndex: tabIndex ?? 0,
|
|
60
65
|
to: to ?? "",
|
|
61
66
|
replace: replace,
|
|
67
|
+
...unstyledProps,
|
|
62
68
|
...rest,
|
|
63
69
|
children: children
|
|
64
70
|
})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ndla/safelink",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.2-alpha.0",
|
|
4
4
|
"description": "SafeLink component for NDLA",
|
|
5
5
|
"license": "GPL-3.0",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -27,11 +27,11 @@
|
|
|
27
27
|
"es"
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@ndla/primitives": "^0.0.
|
|
30
|
+
"@ndla/primitives": "^0.0.19",
|
|
31
31
|
"@ndla/styled-system": "^0.0.8"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@ndla/preset-panda": "^0.0.
|
|
34
|
+
"@ndla/preset-panda": "^0.0.11",
|
|
35
35
|
"@pandacss/dev": "^0.42.0"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
"publishConfig": {
|
|
43
43
|
"access": "public"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "3675a902b9f44f5afb37c648038b8d90f1ccd7d0"
|
|
46
46
|
}
|