@ndla/safelink 4.1.39 → 4.1.42

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.
@@ -7,5 +7,5 @@
7
7
  */
8
8
 
9
9
  import { createContext } from 'react';
10
- var MissingRouterContext = /*#__PURE__*/createContext(false);
10
+ const MissingRouterContext = /*#__PURE__*/createContext(false);
11
11
  export default MissingRouterContext;
package/es/SafeLink.js CHANGED
@@ -1,13 +1,4 @@
1
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
1
  import _styled from "@emotion/styled/base";
3
- var _excluded = ["to", "replace", "disabled", "children", "showNewWindowIcon", "tabIndex", "asAnchor"];
4
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
5
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
6
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
7
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
8
- function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
9
- function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
10
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
11
2
  function _EMOTION_STRINGIFIED_CSS_ERROR__() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
12
3
  /**
13
4
  * Copyright (c) 2019-present, NDLA.
@@ -23,14 +14,10 @@ import { Launch } from '@ndla/icons/common';
23
14
  import MissingRouterContext from './MissingRouterContext';
24
15
  import { jsx as _jsx } from "@emotion/react/jsx-runtime";
25
16
  import { jsxs as _jsxs } from "@emotion/react/jsx-runtime";
26
- var oldNdlaRegex = /(.*)\/?node\/(\d+).*/;
27
- var isExternalLink = function isExternalLink(to) {
28
- return typeof to === 'string' && (to.startsWith('https://') || to.startsWith('http://'));
29
- };
30
- export var isOldNdlaLink = function isOldNdlaLink(to) {
31
- return typeof to === 'string' && to.match(oldNdlaRegex) !== null;
32
- };
33
- var LaunchIcon = /*#__PURE__*/_styled(Launch, {
17
+ const oldNdlaRegex = /(.*)\/?node\/(\d+).*/;
18
+ const isExternalLink = to => typeof to === 'string' && (to.startsWith('https://') || to.startsWith('http://'));
19
+ export const isOldNdlaLink = to => typeof to === 'string' && to.match(oldNdlaRegex) !== null;
20
+ const LaunchIcon = /*#__PURE__*/_styled(Launch, {
34
21
  target: "e2rl38a0",
35
22
  label: "LaunchIcon"
36
23
  })(process.env.NODE_ENV === "production" ? {
@@ -44,38 +31,40 @@ var LaunchIcon = /*#__PURE__*/_styled(Launch, {
44
31
  });
45
32
  // Fallback to normal link if app is missing RouterContext, link is external or is old ndla link
46
33
 
47
- var SafeLink = /*#__PURE__*/forwardRef(function (_ref, ref) {
48
- var to = _ref.to,
49
- replace = _ref.replace,
50
- disabled = _ref.disabled,
51
- children = _ref.children,
52
- showNewWindowIcon = _ref.showNewWindowIcon,
53
- tabIndex = _ref.tabIndex,
54
- asAnchor = _ref.asAnchor,
55
- rest = _objectWithoutProperties(_ref, _excluded);
56
- var isMissingRouterContext = useContext(MissingRouterContext);
34
+ const SafeLink = /*#__PURE__*/forwardRef((_ref, ref) => {
35
+ let {
36
+ to,
37
+ replace,
38
+ disabled,
39
+ children,
40
+ showNewWindowIcon,
41
+ tabIndex,
42
+ asAnchor,
43
+ ...rest
44
+ } = _ref;
45
+ const isMissingRouterContext = useContext(MissingRouterContext);
57
46
  if (isMissingRouterContext || isExternalLink(to) || isOldNdlaLink(to) || asAnchor || disabled) {
58
- var href = typeof to === 'string' ? to : '#';
59
- return _jsxs("a", _objectSpread(_objectSpread({
47
+ const href = typeof to === 'string' ? to : '#';
48
+ return _jsxs("a", {
60
49
  href: disabled ? undefined : href,
61
50
  role: disabled ? 'link' : undefined,
62
51
  "aria-disabled": disabled,
63
52
  ref: ref,
64
- tabIndex: tabIndex
65
- }, rest), {}, {
53
+ tabIndex: tabIndex,
54
+ ...rest,
66
55
  children: [children, showNewWindowIcon && _jsx(LaunchIcon, {})]
67
- }));
56
+ });
68
57
  }
69
58
  return (
70
59
  // RR6 link immediately fails if to is somehow undefined, so we provide an empty fallback to recover.
71
- _jsxs(Link, _objectSpread(_objectSpread({
60
+ _jsxs(Link, {
72
61
  ref: ref,
73
- tabIndex: tabIndex !== null && tabIndex !== void 0 ? tabIndex : 0,
74
- to: to !== null && to !== void 0 ? to : '',
75
- replace: replace
76
- }, rest), {}, {
62
+ tabIndex: tabIndex ?? 0,
63
+ to: to ?? '',
64
+ replace: replace,
65
+ ...rest,
77
66
  children: [children, showNewWindowIcon && _jsx(LaunchIcon, {})]
78
- }))
67
+ })
79
68
  );
80
69
  });
81
70
  export default SafeLink;
@@ -1,12 +1,3 @@
1
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
- var _excluded = ["children", "inverted", "to", "size", "colorTheme", "variant", "shape", "fontWeight"];
3
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
4
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
5
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
7
- function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
8
- function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
9
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
10
1
  /**
11
2
  * Copyright (c) 2019-present, NDLA.
12
3
  *
@@ -19,29 +10,31 @@ import { forwardRef } from 'react';
19
10
  import { buttonStyleV2 } from '@ndla/button';
20
11
  import SafeLink from './SafeLink';
21
12
  import { jsx as _jsx } from "@emotion/react/jsx-runtime";
22
- var SafeLinkButton = /*#__PURE__*/forwardRef(function (_ref, ref) {
23
- var children = _ref.children,
24
- inverted = _ref.inverted,
25
- to = _ref.to,
26
- size = _ref.size,
27
- colorTheme = _ref.colorTheme,
28
- variant = _ref.variant,
29
- shape = _ref.shape,
30
- fontWeight = _ref.fontWeight,
31
- rest = _objectWithoutProperties(_ref, _excluded);
32
- return _jsx(SafeLink, _objectSpread(_objectSpread({
13
+ const SafeLinkButton = /*#__PURE__*/forwardRef((_ref, ref) => {
14
+ let {
15
+ children,
16
+ inverted,
17
+ to,
18
+ size,
19
+ colorTheme,
20
+ variant,
21
+ shape,
22
+ fontWeight,
23
+ ...rest
24
+ } = _ref;
25
+ return _jsx(SafeLink, {
33
26
  to: to,
34
27
  ref: ref,
35
28
  css: buttonStyleV2({
36
- colorTheme: colorTheme,
37
- size: size,
38
- variant: variant,
39
- inverted: inverted,
40
- shape: shape,
41
- fontWeight: fontWeight
42
- })
43
- }, rest), {}, {
29
+ colorTheme,
30
+ size,
31
+ variant,
32
+ inverted,
33
+ shape,
34
+ fontWeight
35
+ }),
36
+ ...rest,
44
37
  children: children
45
- }));
38
+ });
46
39
  });
47
40
  export default SafeLinkButton;
@@ -1,12 +1,3 @@
1
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
- var _excluded = ["children", "inverted", "to", "size", "colorTheme", "variant", "fontWeight"];
3
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
4
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
5
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
7
- function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
8
- function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
9
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
10
1
  /**
11
2
  * Copyright (c) 2022-present, NDLA.
12
3
  *
@@ -19,27 +10,29 @@ import { forwardRef } from 'react';
19
10
  import { iconButtonStyle } from '@ndla/button';
20
11
  import SafeLink from './SafeLink';
21
12
  import { jsx as _jsx } from "@emotion/react/jsx-runtime";
22
- var SafeLinkIconButton = /*#__PURE__*/forwardRef(function (_ref, ref) {
23
- var children = _ref.children,
24
- inverted = _ref.inverted,
25
- to = _ref.to,
26
- size = _ref.size,
27
- colorTheme = _ref.colorTheme,
28
- variant = _ref.variant,
29
- fontWeight = _ref.fontWeight,
30
- rest = _objectWithoutProperties(_ref, _excluded);
31
- return _jsx(SafeLink, _objectSpread(_objectSpread({
13
+ const SafeLinkIconButton = /*#__PURE__*/forwardRef((_ref, ref) => {
14
+ let {
15
+ children,
16
+ inverted,
17
+ to,
18
+ size,
19
+ colorTheme,
20
+ variant,
21
+ fontWeight,
22
+ ...rest
23
+ } = _ref;
24
+ return _jsx(SafeLink, {
32
25
  to: to,
33
26
  ref: ref,
34
27
  css: iconButtonStyle({
35
- colorTheme: colorTheme,
36
- size: size,
37
- variant: variant,
38
- inverted: inverted,
39
- fontWeight: fontWeight
40
- })
41
- }, rest), {}, {
28
+ colorTheme,
29
+ size,
30
+ variant,
31
+ inverted,
32
+ fontWeight
33
+ }),
34
+ ...rest,
42
35
  children: children
43
- }));
36
+ });
44
37
  });
45
38
  export default SafeLinkIconButton;
@@ -13,6 +13,5 @@ var _react = require("react");
13
13
  *
14
14
  */
15
15
 
16
- var MissingRouterContext = /*#__PURE__*/(0, _react.createContext)(false);
17
- var _default = MissingRouterContext;
18
- exports.default = _default;
16
+ const MissingRouterContext = /*#__PURE__*/(0, _react.createContext)(false);
17
+ var _default = exports.default = MissingRouterContext;
package/lib/SafeLink.js CHANGED
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
 
3
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
@@ -11,31 +10,19 @@ var _reactRouterDom = require("react-router-dom");
11
10
  var _common = require("@ndla/icons/common");
12
11
  var _MissingRouterContext = _interopRequireDefault(require("./MissingRouterContext"));
13
12
  var _jsxRuntime = require("@emotion/react/jsx-runtime");
14
- var _excluded = ["to", "replace", "disabled", "children", "showNewWindowIcon", "tabIndex", "asAnchor"];
15
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
17
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
18
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
19
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
20
- function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
21
- function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
22
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
23
14
  function _EMOTION_STRINGIFIED_CSS_ERROR__() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; } /**
24
- * Copyright (c) 2019-present, NDLA.
25
- *
26
- * This source code is licensed under the GPLv3 license found in the
27
- * LICENSE file in the root directory of this source tree.
28
- *
29
- */
30
- var oldNdlaRegex = /(.*)\/?node\/(\d+).*/;
31
- var isExternalLink = function isExternalLink(to) {
32
- return typeof to === 'string' && (to.startsWith('https://') || to.startsWith('http://'));
33
- };
34
- var isOldNdlaLink = function isOldNdlaLink(to) {
35
- return typeof to === 'string' && to.match(oldNdlaRegex) !== null;
36
- };
15
+ * Copyright (c) 2019-present, NDLA.
16
+ *
17
+ * This source code is licensed under the GPLv3 license found in the
18
+ * LICENSE file in the root directory of this source tree.
19
+ *
20
+ */
21
+ const oldNdlaRegex = /(.*)\/?node\/(\d+).*/;
22
+ const isExternalLink = to => typeof to === 'string' && (to.startsWith('https://') || to.startsWith('http://'));
23
+ const isOldNdlaLink = to => typeof to === 'string' && to.match(oldNdlaRegex) !== null;
37
24
  exports.isOldNdlaLink = isOldNdlaLink;
38
- var LaunchIcon = /*#__PURE__*/(0, _base.default)(_common.Launch, {
25
+ const LaunchIcon = /*#__PURE__*/(0, _base.default)(_common.Launch, {
39
26
  target: "e2rl38a0",
40
27
  label: "LaunchIcon"
41
28
  })(process.env.NODE_ENV === "production" ? {
@@ -49,39 +36,40 @@ var LaunchIcon = /*#__PURE__*/(0, _base.default)(_common.Launch, {
49
36
  });
50
37
  // Fallback to normal link if app is missing RouterContext, link is external or is old ndla link
51
38
 
52
- var SafeLink = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
53
- var to = _ref.to,
54
- replace = _ref.replace,
55
- disabled = _ref.disabled,
56
- children = _ref.children,
57
- showNewWindowIcon = _ref.showNewWindowIcon,
58
- tabIndex = _ref.tabIndex,
59
- asAnchor = _ref.asAnchor,
60
- rest = _objectWithoutProperties(_ref, _excluded);
61
- var isMissingRouterContext = (0, _react.useContext)(_MissingRouterContext.default);
39
+ const SafeLink = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
40
+ let {
41
+ to,
42
+ replace,
43
+ disabled,
44
+ children,
45
+ showNewWindowIcon,
46
+ tabIndex,
47
+ asAnchor,
48
+ ...rest
49
+ } = _ref;
50
+ const isMissingRouterContext = (0, _react.useContext)(_MissingRouterContext.default);
62
51
  if (isMissingRouterContext || isExternalLink(to) || isOldNdlaLink(to) || asAnchor || disabled) {
63
- var href = typeof to === 'string' ? to : '#';
64
- return (0, _jsxRuntime.jsxs)("a", _objectSpread(_objectSpread({
52
+ const href = typeof to === 'string' ? to : '#';
53
+ return (0, _jsxRuntime.jsxs)("a", {
65
54
  href: disabled ? undefined : href,
66
55
  role: disabled ? 'link' : undefined,
67
56
  "aria-disabled": disabled,
68
57
  ref: ref,
69
- tabIndex: tabIndex
70
- }, rest), {}, {
58
+ tabIndex: tabIndex,
59
+ ...rest,
71
60
  children: [children, showNewWindowIcon && (0, _jsxRuntime.jsx)(LaunchIcon, {})]
72
- }));
61
+ });
73
62
  }
74
63
  return (
75
64
  // RR6 link immediately fails if to is somehow undefined, so we provide an empty fallback to recover.
76
- (0, _jsxRuntime.jsxs)(_reactRouterDom.Link, _objectSpread(_objectSpread({
65
+ (0, _jsxRuntime.jsxs)(_reactRouterDom.Link, {
77
66
  ref: ref,
78
- tabIndex: tabIndex !== null && tabIndex !== void 0 ? tabIndex : 0,
79
- to: to !== null && to !== void 0 ? to : '',
80
- replace: replace
81
- }, rest), {}, {
67
+ tabIndex: tabIndex ?? 0,
68
+ to: to ?? '',
69
+ replace: replace,
70
+ ...rest,
82
71
  children: [children, showNewWindowIcon && (0, _jsxRuntime.jsx)(LaunchIcon, {})]
83
- }))
72
+ })
84
73
  );
85
74
  });
86
- var _default = SafeLink;
87
- exports.default = _default;
75
+ var _default = exports.default = SafeLink;
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
 
3
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
@@ -9,7 +8,7 @@ var _react = require("react");
9
8
  var _button = require("@ndla/button");
10
9
  var _SafeLink = _interopRequireDefault(require("./SafeLink"));
11
10
  var _jsxRuntime = require("@emotion/react/jsx-runtime");
12
- var _excluded = ["children", "inverted", "to", "size", "colorTheme", "variant", "shape", "fontWeight"];
11
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
12
  /**
14
13
  * Copyright (c) 2019-present, NDLA.
15
14
  *
@@ -17,38 +16,32 @@ var _excluded = ["children", "inverted", "to", "size", "colorTheme", "variant",
17
16
  * LICENSE file in the root directory of this source tree.
18
17
  *
19
18
  */
20
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
22
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
23
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
24
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
25
- function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
26
- function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
27
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
28
- var SafeLinkButton = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
29
- var children = _ref.children,
30
- inverted = _ref.inverted,
31
- to = _ref.to,
32
- size = _ref.size,
33
- colorTheme = _ref.colorTheme,
34
- variant = _ref.variant,
35
- shape = _ref.shape,
36
- fontWeight = _ref.fontWeight,
37
- rest = _objectWithoutProperties(_ref, _excluded);
38
- return (0, _jsxRuntime.jsx)(_SafeLink.default, _objectSpread(_objectSpread({
19
+
20
+ const SafeLinkButton = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
21
+ let {
22
+ children,
23
+ inverted,
24
+ to,
25
+ size,
26
+ colorTheme,
27
+ variant,
28
+ shape,
29
+ fontWeight,
30
+ ...rest
31
+ } = _ref;
32
+ return (0, _jsxRuntime.jsx)(_SafeLink.default, {
39
33
  to: to,
40
34
  ref: ref,
41
35
  css: (0, _button.buttonStyleV2)({
42
- colorTheme: colorTheme,
43
- size: size,
44
- variant: variant,
45
- inverted: inverted,
46
- shape: shape,
47
- fontWeight: fontWeight
48
- })
49
- }, rest), {}, {
36
+ colorTheme,
37
+ size,
38
+ variant,
39
+ inverted,
40
+ shape,
41
+ fontWeight
42
+ }),
43
+ ...rest,
50
44
  children: children
51
- }));
45
+ });
52
46
  });
53
- var _default = SafeLinkButton;
54
- exports.default = _default;
47
+ var _default = exports.default = SafeLinkButton;
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
 
3
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
@@ -9,7 +8,7 @@ var _react = require("react");
9
8
  var _button = require("@ndla/button");
10
9
  var _SafeLink = _interopRequireDefault(require("./SafeLink"));
11
10
  var _jsxRuntime = require("@emotion/react/jsx-runtime");
12
- var _excluded = ["children", "inverted", "to", "size", "colorTheme", "variant", "fontWeight"];
11
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
12
  /**
14
13
  * Copyright (c) 2022-present, NDLA.
15
14
  *
@@ -17,36 +16,30 @@ var _excluded = ["children", "inverted", "to", "size", "colorTheme", "variant",
17
16
  * LICENSE file in the root directory of this source tree.
18
17
  *
19
18
  */
20
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
22
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
23
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
24
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
25
- function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
26
- function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
27
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
28
- var SafeLinkIconButton = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
29
- var children = _ref.children,
30
- inverted = _ref.inverted,
31
- to = _ref.to,
32
- size = _ref.size,
33
- colorTheme = _ref.colorTheme,
34
- variant = _ref.variant,
35
- fontWeight = _ref.fontWeight,
36
- rest = _objectWithoutProperties(_ref, _excluded);
37
- return (0, _jsxRuntime.jsx)(_SafeLink.default, _objectSpread(_objectSpread({
19
+
20
+ const SafeLinkIconButton = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
21
+ let {
22
+ children,
23
+ inverted,
24
+ to,
25
+ size,
26
+ colorTheme,
27
+ variant,
28
+ fontWeight,
29
+ ...rest
30
+ } = _ref;
31
+ return (0, _jsxRuntime.jsx)(_SafeLink.default, {
38
32
  to: to,
39
33
  ref: ref,
40
34
  css: (0, _button.iconButtonStyle)({
41
- colorTheme: colorTheme,
42
- size: size,
43
- variant: variant,
44
- inverted: inverted,
45
- fontWeight: fontWeight
46
- })
47
- }, rest), {}, {
35
+ colorTheme,
36
+ size,
37
+ variant,
38
+ inverted,
39
+ fontWeight
40
+ }),
41
+ ...rest,
48
42
  children: children
49
- }));
43
+ });
50
44
  });
51
- var _default = SafeLinkIconButton;
52
- exports.default = _default;
45
+ var _default = exports.default = SafeLinkIconButton;
package/lib/index.js CHANGED
@@ -5,19 +5,19 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  Object.defineProperty(exports, "MissingRouterContext", {
7
7
  enumerable: true,
8
- get: function get() {
8
+ get: function () {
9
9
  return _MissingRouterContext.default;
10
10
  }
11
11
  });
12
12
  Object.defineProperty(exports, "SafeLinkButton", {
13
13
  enumerable: true,
14
- get: function get() {
14
+ get: function () {
15
15
  return _SafeLinkButton.default;
16
16
  }
17
17
  });
18
18
  Object.defineProperty(exports, "SafeLinkIconButton", {
19
19
  enumerable: true,
20
- get: function get() {
20
+ get: function () {
21
21
  return _SafeLinkIconButton.default;
22
22
  }
23
23
  });
@@ -34,5 +34,4 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
34
34
  * LICENSE file in the root directory of this source tree.
35
35
  *
36
36
  */
37
- var _default = _SafeLink.default;
38
- exports.default = _default;
37
+ var _default = exports.default = _SafeLink.default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ndla/safelink",
3
- "version": "4.1.39",
3
+ "version": "4.1.42",
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.14",
30
- "@ndla/icons": "^4.2.2"
29
+ "@ndla/button": "^12.0.17",
30
+ "@ndla/icons": "^4.2.4"
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": "252018f46b2084d45d08bf86072787257cdb0348"
41
+ "gitHead": "5c65dfc8de95fb464182f86a40b74868ca30a29e"
42
42
  }