@ndla/safelink 5.1.15 → 6.0.0-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.
@@ -0,0 +1,7 @@
1
+ {
2
+ "schemaVersion": "0.42.0",
3
+ "styles": {
4
+ "atomic": [],
5
+ "recipes": {}
6
+ }
7
+ }
File without changes
@@ -7,5 +7,4 @@
7
7
  */
8
8
 
9
9
  import { createContext } from "react";
10
- const MissingRouterContext = /*#__PURE__*/createContext(false);
11
- export default MissingRouterContext;
10
+ export const MissingRouterContext = /*#__PURE__*/createContext(false);
package/es/SafeLink.js CHANGED
@@ -1,4 +1,3 @@
1
- import _styled from "@emotion/styled/base";
2
1
  /**
3
2
  * Copyright (c) 2019-present, NDLA.
4
3
  *
@@ -9,20 +8,19 @@ import _styled from "@emotion/styled/base";
9
8
 
10
9
  import { forwardRef, useContext } from "react";
11
10
  import { Link } from "react-router-dom";
12
- import { spacing } from "@ndla/core";
13
- import { Launch } from "@ndla/icons/common";
14
- import MissingRouterContext from "./MissingRouterContext";
15
- import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
11
+ import { styled } from "@ndla/styled-system/jsx";
12
+ import { MissingRouterContext } from "./MissingRouterContext";
13
+ import { jsx as _jsx } from "react/jsx-runtime";
16
14
  const oldNdlaRegex = /(.*)\/?node\/(\d+).*/;
17
15
  const isExternalLink = to => typeof to === "string" && (to.startsWith("https://") || to.startsWith("http://") || to.startsWith("mailto:") || to.endsWith(".xml"));
18
16
  export const isOldNdlaLink = to => typeof to === "string" && to.match(oldNdlaRegex) !== null;
19
- const LaunchIcon = /*#__PURE__*/_styled(Launch, {
20
- target: "e2rl38a0",
21
- label: "LaunchIcon"
22
- })("margin-left:", spacing.xsmall, ";vertical-align:text-top;" + (process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIlNhZmVMaW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ICAgICAgICB7c2hvd05ld1dpbmRvd0ljb24gJiYgPExhdW5jaEljb24gLz59XG4gICAgICA8L0xpbms+XG4gICAgKTtcbiAgfSxcbik7XG5cbmV4cG9ydCBkZWZhdWx0IFNhZmVMaW5rO1xuIl19 */"));
17
+ const StyledLink = styled(Link, {}, {
18
+ baseComponent: true
19
+ });
20
+
23
21
  // Fallback to normal link if app is missing RouterContext, link is external or is old ndla link
24
22
 
25
- const SafeLink = /*#__PURE__*/forwardRef((_ref, ref) => {
23
+ export const SafeLink = /*#__PURE__*/forwardRef((_ref, ref) => {
26
24
  let {
27
25
  to,
28
26
  replace,
@@ -36,28 +34,26 @@ const SafeLink = /*#__PURE__*/forwardRef((_ref, ref) => {
36
34
  const isMissingRouterContext = useContext(MissingRouterContext);
37
35
  if (isMissingRouterContext || isExternalLink(to) || isOldNdlaLink(to) || asAnchor || disabled) {
38
36
  const href = typeof to === "string" ? to : "#";
39
- return _jsxs("a", {
37
+ return /*#__PURE__*/_jsx(styled.a, {
40
38
  href: disabled ? undefined : href,
41
39
  role: disabled ? "link" : undefined,
42
40
  "aria-disabled": disabled,
43
41
  ref: ref,
44
42
  tabIndex: tabIndex,
45
43
  ...rest,
46
- children: [children, showNewWindowIcon && _jsx(LaunchIcon, {
47
- size: "medium"
48
- })]
44
+ children: children
49
45
  });
50
46
  }
51
47
  return (
48
+ /*#__PURE__*/
52
49
  // RR6 link immediately fails if to is somehow undefined, so we provide an empty fallback to recover.
53
- _jsxs(Link, {
50
+ _jsx(StyledLink, {
54
51
  ref: ref,
55
- tabIndex: tabIndex !== null && tabIndex !== void 0 ? tabIndex : 0,
56
- to: to !== null && to !== void 0 ? to : "",
52
+ tabIndex: tabIndex ?? 0,
53
+ to: to ?? "",
57
54
  replace: replace,
58
55
  ...rest,
59
- children: [children, showNewWindowIcon && _jsx(LaunchIcon, {})]
56
+ children: children
60
57
  })
61
58
  );
62
- });
63
- export default SafeLink;
59
+ });
@@ -6,36 +6,25 @@
6
6
  *
7
7
  */
8
8
 
9
- /** @jsxImportSource @emotion/react */
10
9
  import { forwardRef } from "react";
11
- import { buttonStyleV2 } from "@ndla/button";
12
- import SafeLink from "./SafeLink";
13
- import { jsx as _jsx } from "@emotion/react/jsx-runtime";
14
- const SafeLinkButton = /*#__PURE__*/forwardRef((_ref, ref) => {
10
+ import { buttonBaseRecipe, buttonRecipe } from "@ndla/primitives";
11
+ import { css } from "@ndla/styled-system/css";
12
+ import { SafeLink } from "./SafeLink";
13
+ import { jsx as _jsx } from "react/jsx-runtime";
14
+ export const SafeLinkButton = /*#__PURE__*/forwardRef((_ref, ref) => {
15
15
  let {
16
- children,
17
- inverted,
18
- to,
19
- size,
20
- colorTheme,
21
16
  variant,
22
- shape,
23
- fontWeight,
24
- ...rest
17
+ size,
18
+ css: cssProp,
19
+ ...props
25
20
  } = _ref;
26
- return _jsx(SafeLink, {
27
- to: to,
28
- ref: ref,
29
- css: buttonStyleV2({
30
- colorTheme,
31
- size,
32
- variant,
33
- inverted,
34
- shape,
35
- fontWeight
36
- }),
37
- ...rest,
38
- children: children
21
+ return /*#__PURE__*/_jsx(SafeLink, {
22
+ ...props,
23
+ css: css.raw(buttonBaseRecipe.raw({
24
+ variant
25
+ }), buttonRecipe.raw({
26
+ size
27
+ }), cssProp),
28
+ ref: ref
39
29
  });
40
- });
41
- export default SafeLinkButton;
30
+ });
@@ -6,30 +6,22 @@
6
6
  *
7
7
  */
8
8
 
9
- /** @jsxImportSource @emotion/react */
10
9
  import { forwardRef } from "react";
11
- import { iconButtonStyle } from "@ndla/button";
12
- import SafeLink from "./SafeLink";
13
- import { jsx as _jsx } from "@emotion/react/jsx-runtime";
14
- const SafeLinkIconButton = /*#__PURE__*/forwardRef((_ref, ref) => {
10
+ import { buttonBaseRecipe, iconButtonRecipe } from "@ndla/primitives";
11
+ import { css } from "@ndla/styled-system/css";
12
+ import { SafeLink } from "./SafeLink";
13
+ import { jsx as _jsx } from "react/jsx-runtime";
14
+ export const SafeLinkIconButton = /*#__PURE__*/forwardRef((_ref, ref) => {
15
15
  let {
16
- inverted,
17
- size,
18
- colorTheme,
19
16
  variant,
20
- fontWeight,
21
- ...rest
17
+ css: cssProp,
18
+ ...props
22
19
  } = _ref;
23
- return _jsx(SafeLink, {
24
- css: iconButtonStyle({
25
- colorTheme,
26
- size,
27
- variant,
28
- inverted,
29
- fontWeight
30
- }),
31
- ...rest,
20
+ return /*#__PURE__*/_jsx(SafeLink, {
21
+ ...props,
22
+ css: css.raw(buttonBaseRecipe.raw({
23
+ variant
24
+ }), iconButtonRecipe.raw(), cssProp),
32
25
  ref: ref
33
26
  });
34
- });
35
- export default SafeLinkIconButton;
27
+ });
package/es/index.js CHANGED
@@ -6,7 +6,7 @@
6
6
  *
7
7
  */
8
8
 
9
- export { default as MissingRouterContext } from "./MissingRouterContext";
10
- export { default as SafeLinkButton } from "./SafeLinkButton";
11
- export { default as SafeLinkIconButton } from "./SafeLinkIconButton";
12
- export { default as SafeLink } from "./SafeLink";
9
+ export { MissingRouterContext } from "./MissingRouterContext";
10
+ export { SafeLinkButton } from "./SafeLinkButton";
11
+ export { SafeLinkIconButton } from "./SafeLinkIconButton";
12
+ export { SafeLink } from "./SafeLink";
@@ -6,5 +6,4 @@
6
6
  *
7
7
  */
8
8
  /// <reference types="react" />
9
- declare const MissingRouterContext: import("react").Context<boolean>;
10
- export default MissingRouterContext;
9
+ export declare const MissingRouterContext: import("react").Context<boolean>;
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = void 0;
6
+ exports.MissingRouterContext = void 0;
7
7
  var _react = require("react");
8
8
  /**
9
9
  * Copyright (c) 2019-present, NDLA.
@@ -13,5 +13,4 @@ var _react = require("react");
13
13
  *
14
14
  */
15
15
 
16
- const MissingRouterContext = /*#__PURE__*/(0, _react.createContext)(false);
17
- var _default = exports.default = MissingRouterContext;
16
+ const MissingRouterContext = exports.MissingRouterContext = /*#__PURE__*/(0, _react.createContext)(false);
package/lib/SafeLink.d.ts CHANGED
@@ -7,6 +7,7 @@
7
7
  */
8
8
  import { HTMLAttributes, MutableRefObject, ReactNode } from "react";
9
9
  import { LinkProps } from "react-router-dom";
10
+ import { JsxStyleProps } from "@ndla/styled-system/types";
10
11
  export declare const isOldNdlaLink: (to?: LinkProps["to"]) => boolean;
11
12
  type Props = {
12
13
  showNewWindowIcon?: boolean;
@@ -15,6 +16,6 @@ type Props = {
15
16
  children?: ReactNode;
16
17
  disabled?: boolean;
17
18
  };
18
- export type SafeLinkProps = Props & LinkProps & HTMLAttributes<HTMLElement>;
19
- declare const SafeLink: import("react").ForwardRefExoticComponent<Omit<SafeLinkProps, "ref"> & import("react").RefAttributes<HTMLAnchorElement>>;
20
- export default SafeLink;
19
+ export type SafeLinkProps = Props & LinkProps & JsxStyleProps & HTMLAttributes<HTMLElement>;
20
+ export declare const SafeLink: import("react").ForwardRefExoticComponent<Omit<SafeLinkProps, "ref"> & import("react").RefAttributes<HTMLAnchorElement>>;
21
+ export {};
package/lib/SafeLink.js CHANGED
@@ -3,15 +3,12 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.isOldNdlaLink = exports.default = void 0;
7
- var _base = _interopRequireDefault(require("@emotion/styled/base"));
6
+ exports.isOldNdlaLink = exports.SafeLink = void 0;
8
7
  var _react = require("react");
9
8
  var _reactRouterDom = require("react-router-dom");
10
- var _core = require("@ndla/core");
11
- var _common = require("@ndla/icons/common");
12
- var _MissingRouterContext = _interopRequireDefault(require("./MissingRouterContext"));
13
- var _jsxRuntime = require("@emotion/react/jsx-runtime");
14
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
+ var _jsx2 = require("@ndla/styled-system/jsx");
10
+ var _MissingRouterContext = require("./MissingRouterContext");
11
+ var _jsxRuntime = require("react/jsx-runtime");
15
12
  /**
16
13
  * Copyright (c) 2019-present, NDLA.
17
14
  *
@@ -24,13 +21,13 @@ const oldNdlaRegex = /(.*)\/?node\/(\d+).*/;
24
21
  const isExternalLink = to => typeof to === "string" && (to.startsWith("https://") || to.startsWith("http://") || to.startsWith("mailto:") || to.endsWith(".xml"));
25
22
  const isOldNdlaLink = to => typeof to === "string" && to.match(oldNdlaRegex) !== null;
26
23
  exports.isOldNdlaLink = isOldNdlaLink;
27
- const LaunchIcon = /*#__PURE__*/(0, _base.default)(_common.Launch, {
28
- target: "e2rl38a0",
29
- label: "LaunchIcon"
30
- })("margin-left:", _core.spacing.xsmall, ";vertical-align:text-top;" + (process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIlNhZmVMaW5rLnRzeCJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUF1QmlDIiwiZmlsZSI6IlNhZmVMaW5rLnRzeCIsInNvdXJjZXNDb250ZW50IjpbIi8qKlxuICogQ29weXJpZ2h0IChjKSAyMDE5LXByZXNlbnQsIE5ETEEuXG4gKlxuICogVGhpcyBzb3VyY2UgY29kZSBpcyBsaWNlbnNlZCB1bmRlciB0aGUgR1BMdjMgbGljZW5zZSBmb3VuZCBpbiB0aGVcbiAqIExJQ0VOU0UgZmlsZSBpbiB0aGUgcm9vdCBkaXJlY3Rvcnkgb2YgdGhpcyBzb3VyY2UgdHJlZS5cbiAqXG4gKi9cblxuaW1wb3J0IHsgZm9yd2FyZFJlZiwgSFRNTEF0dHJpYnV0ZXMsIE11dGFibGVSZWZPYmplY3QsIFJlYWN0Tm9kZSwgdXNlQ29udGV4dCB9IGZyb20gXCJyZWFjdFwiO1xuaW1wb3J0IHsgTGluaywgTGlua1Byb3BzIH0gZnJvbSBcInJlYWN0LXJvdXRlci1kb21cIjtcbmltcG9ydCBzdHlsZWQgZnJvbSBcIkBlbW90aW9uL3N0eWxlZFwiO1xuaW1wb3J0IHsgc3BhY2luZyB9IGZyb20gXCJAbmRsYS9jb3JlXCI7XG5pbXBvcnQgeyBMY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uIHNpemU9XCJtZWRpdW1cIiAvPn1cbiAgICAgICAgPC9hPlxuICAgICAgKTtcbiAgICB9XG5cbiAgICByZXR1cm4gKFxuICAgICAgLy8gUlI2IGxpbmsgaW1tZWRpYXRlbHkgZmFpbHMgaWYgdG8gaXMgc29tZWhvdyB1bmRlZmluZWQsIHNvIHdlIHByb3ZpZGUgYW4gZW1wdHkgZmFsbGJhY2sgdG8gcmVjb3Zlci5cbiAgICAgIDxMaW5rIHJlZj17cmVmfSB0YWJJbmRleD17dGFiSW5kZXggPz8gMH0gdG89e3RvID8/IFwiXCJ9IHJlcGxhY2U9e3JlcGxhY2V9IHsuLi5yZXN0fT5cbiAgICAgICAge2NoaWxkcmVufVxuICAgICAgICB7c2hvd05ld1dpbmRvd0ljb24gJiYgPExhdW5jaEljb24gLz59XG4gICAgICA8L0xpbms+XG4gICAgKTtcbiAgfSxcbik7XG5cbmV4cG9ydCBkZWZhdWx0IFNhZmVMaW5rO1xuIl19 */"));
24
+ const StyledLink = (0, _jsx2.styled)(_reactRouterDom.Link, {}, {
25
+ baseComponent: true
26
+ });
27
+
31
28
  // Fallback to normal link if app is missing RouterContext, link is external or is old ndla link
32
29
 
33
- const SafeLink = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
30
+ const SafeLink = exports.SafeLink = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
34
31
  let {
35
32
  to,
36
33
  replace,
@@ -41,31 +38,29 @@ const SafeLink = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
41
38
  asAnchor,
42
39
  ...rest
43
40
  } = _ref;
44
- const isMissingRouterContext = (0, _react.useContext)(_MissingRouterContext.default);
41
+ const isMissingRouterContext = (0, _react.useContext)(_MissingRouterContext.MissingRouterContext);
45
42
  if (isMissingRouterContext || isExternalLink(to) || isOldNdlaLink(to) || asAnchor || disabled) {
46
43
  const href = typeof to === "string" ? to : "#";
47
- return (0, _jsxRuntime.jsxs)("a", {
44
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsx2.styled.a, {
48
45
  href: disabled ? undefined : href,
49
46
  role: disabled ? "link" : undefined,
50
47
  "aria-disabled": disabled,
51
48
  ref: ref,
52
49
  tabIndex: tabIndex,
53
50
  ...rest,
54
- children: [children, showNewWindowIcon && (0, _jsxRuntime.jsx)(LaunchIcon, {
55
- size: "medium"
56
- })]
51
+ children: children
57
52
  });
58
53
  }
59
54
  return (
55
+ /*#__PURE__*/
60
56
  // RR6 link immediately fails if to is somehow undefined, so we provide an empty fallback to recover.
61
- (0, _jsxRuntime.jsxs)(_reactRouterDom.Link, {
57
+ (0, _jsxRuntime.jsx)(StyledLink, {
62
58
  ref: ref,
63
- tabIndex: tabIndex !== null && tabIndex !== void 0 ? tabIndex : 0,
64
- to: to !== null && to !== void 0 ? to : "",
59
+ tabIndex: tabIndex ?? 0,
60
+ to: to ?? "",
65
61
  replace: replace,
66
62
  ...rest,
67
- children: [children, showNewWindowIcon && (0, _jsxRuntime.jsx)(LaunchIcon, {})]
63
+ children: children
68
64
  })
69
65
  );
70
- });
71
- var _default = exports.default = SafeLink;
66
+ });
@@ -5,14 +5,11 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  */
8
- /** @jsxImportSource @emotion/react */
9
8
  import { ReactNode } from "react";
10
- import { ButtonStyleProps } from "@ndla/button";
9
+ import { ButtonVariantProps } from "@ndla/primitives";
11
10
  import { SafeLinkProps } from "./SafeLink";
12
- interface Props extends SafeLinkProps, ButtonStyleProps {
11
+ export interface SafeLinkButtonProps extends SafeLinkProps, ButtonVariantProps {
13
12
  children: ReactNode;
14
13
  to: string;
15
- className?: string;
16
14
  }
17
- declare const SafeLinkButton: import("react").ForwardRefExoticComponent<Omit<Props, "ref"> & import("react").RefAttributes<HTMLAnchorElement>>;
18
- export default SafeLinkButton;
15
+ export declare const SafeLinkButton: import("react").ForwardRefExoticComponent<Omit<SafeLinkButtonProps, "ref"> & import("react").RefAttributes<HTMLAnchorElement>>;
@@ -3,12 +3,12 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = void 0;
6
+ exports.SafeLinkButton = void 0;
7
7
  var _react = require("react");
8
- var _button = require("@ndla/button");
9
- var _SafeLink = _interopRequireDefault(require("./SafeLink"));
10
- var _jsxRuntime = require("@emotion/react/jsx-runtime");
11
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
8
+ var _primitives = require("@ndla/primitives");
9
+ var _css = require("@ndla/styled-system/css");
10
+ var _SafeLink = require("./SafeLink");
11
+ var _jsxRuntime = require("react/jsx-runtime");
12
12
  /**
13
13
  * Copyright (c) 2019-present, NDLA.
14
14
  *
@@ -17,33 +17,20 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
17
17
  *
18
18
  */
19
19
 
20
- /** @jsxImportSource @emotion/react */
21
-
22
- const SafeLinkButton = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
20
+ const SafeLinkButton = exports.SafeLinkButton = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
23
21
  let {
24
- children,
25
- inverted,
26
- to,
27
- size,
28
- colorTheme,
29
22
  variant,
30
- shape,
31
- fontWeight,
32
- ...rest
23
+ size,
24
+ css: cssProp,
25
+ ...props
33
26
  } = _ref;
34
- return (0, _jsxRuntime.jsx)(_SafeLink.default, {
35
- to: to,
36
- ref: ref,
37
- css: (0, _button.buttonStyleV2)({
38
- colorTheme,
39
- size,
40
- variant,
41
- inverted,
42
- shape,
43
- fontWeight
44
- }),
45
- ...rest,
46
- children: children
27
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_SafeLink.SafeLink, {
28
+ ...props,
29
+ css: _css.css.raw(_primitives.buttonBaseRecipe.raw({
30
+ variant
31
+ }), _primitives.buttonRecipe.raw({
32
+ size
33
+ }), cssProp),
34
+ ref: ref
47
35
  });
48
- });
49
- var _default = exports.default = SafeLinkButton;
36
+ });
@@ -5,12 +5,11 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  */
8
- /** @jsxImportSource @emotion/react */
9
8
  import { ReactNode } from "react";
10
- import { ButtonStyleProps } from "@ndla/button";
9
+ import { IconButtonVariantProps } from "@ndla/primitives";
11
10
  import { SafeLinkProps } from "./SafeLink";
12
- interface Props extends SafeLinkProps, ButtonStyleProps {
11
+ export interface SafeLinkIconButtonProps extends SafeLinkProps, IconButtonVariantProps {
13
12
  children: ReactNode;
13
+ to: string;
14
14
  }
15
- declare const SafeLinkIconButton: import("react").ForwardRefExoticComponent<Omit<Props, "ref"> & import("react").RefAttributes<HTMLAnchorElement>>;
16
- export default SafeLinkIconButton;
15
+ export declare const SafeLinkIconButton: import("react").ForwardRefExoticComponent<Omit<SafeLinkIconButtonProps, "ref"> & import("react").RefAttributes<HTMLAnchorElement>>;
@@ -3,12 +3,12 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = void 0;
6
+ exports.SafeLinkIconButton = void 0;
7
7
  var _react = require("react");
8
- var _button = require("@ndla/button");
9
- var _SafeLink = _interopRequireDefault(require("./SafeLink"));
10
- var _jsxRuntime = require("@emotion/react/jsx-runtime");
11
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
8
+ var _primitives = require("@ndla/primitives");
9
+ var _css = require("@ndla/styled-system/css");
10
+ var _SafeLink = require("./SafeLink");
11
+ var _jsxRuntime = require("react/jsx-runtime");
12
12
  /**
13
13
  * Copyright (c) 2022-present, NDLA.
14
14
  *
@@ -17,27 +17,17 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
17
17
  *
18
18
  */
19
19
 
20
- /** @jsxImportSource @emotion/react */
21
-
22
- const SafeLinkIconButton = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
20
+ const SafeLinkIconButton = exports.SafeLinkIconButton = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
23
21
  let {
24
- inverted,
25
- size,
26
- colorTheme,
27
22
  variant,
28
- fontWeight,
29
- ...rest
23
+ css: cssProp,
24
+ ...props
30
25
  } = _ref;
31
- return (0, _jsxRuntime.jsx)(_SafeLink.default, {
32
- css: (0, _button.iconButtonStyle)({
33
- colorTheme,
34
- size,
35
- variant,
36
- inverted,
37
- fontWeight
38
- }),
39
- ...rest,
26
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_SafeLink.SafeLink, {
27
+ ...props,
28
+ css: _css.css.raw(_primitives.buttonBaseRecipe.raw({
29
+ variant
30
+ }), _primitives.iconButtonRecipe.raw(), cssProp),
40
31
  ref: ref
41
32
  });
42
- });
43
- var _default = exports.default = SafeLinkIconButton;
33
+ });
package/lib/index.d.ts CHANGED
@@ -5,8 +5,10 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  */
8
- export { default as MissingRouterContext } from "./MissingRouterContext";
9
- export { default as SafeLinkButton } from "./SafeLinkButton";
10
- export { default as SafeLinkIconButton } from "./SafeLinkIconButton";
11
- export { default as SafeLink } from "./SafeLink";
8
+ export { MissingRouterContext } from "./MissingRouterContext";
9
+ export { SafeLinkButton } from "./SafeLinkButton";
10
+ export type { SafeLinkIconButtonProps } from "./SafeLinkIconButton";
11
+ export { SafeLinkIconButton } from "./SafeLinkIconButton";
12
+ export type { SafeLinkButtonProps } from "./SafeLinkButton";
13
+ export { SafeLink } from "./SafeLink";
12
14
  export type { SafeLinkProps } from "./SafeLink";
package/lib/index.js CHANGED
@@ -6,29 +6,28 @@ Object.defineProperty(exports, "__esModule", {
6
6
  Object.defineProperty(exports, "MissingRouterContext", {
7
7
  enumerable: true,
8
8
  get: function () {
9
- return _MissingRouterContext.default;
9
+ return _MissingRouterContext.MissingRouterContext;
10
10
  }
11
11
  });
12
12
  Object.defineProperty(exports, "SafeLink", {
13
13
  enumerable: true,
14
14
  get: function () {
15
- return _SafeLink.default;
15
+ return _SafeLink.SafeLink;
16
16
  }
17
17
  });
18
18
  Object.defineProperty(exports, "SafeLinkButton", {
19
19
  enumerable: true,
20
20
  get: function () {
21
- return _SafeLinkButton.default;
21
+ return _SafeLinkButton.SafeLinkButton;
22
22
  }
23
23
  });
24
24
  Object.defineProperty(exports, "SafeLinkIconButton", {
25
25
  enumerable: true,
26
26
  get: function () {
27
- return _SafeLinkIconButton.default;
27
+ return _SafeLinkIconButton.SafeLinkIconButton;
28
28
  }
29
29
  });
30
- var _MissingRouterContext = _interopRequireDefault(require("./MissingRouterContext"));
31
- var _SafeLinkButton = _interopRequireDefault(require("./SafeLinkButton"));
32
- var _SafeLinkIconButton = _interopRequireDefault(require("./SafeLinkIconButton"));
33
- var _SafeLink = _interopRequireDefault(require("./SafeLink"));
34
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
30
+ var _MissingRouterContext = require("./MissingRouterContext");
31
+ var _SafeLinkButton = require("./SafeLinkButton");
32
+ var _SafeLinkIconButton = require("./SafeLinkIconButton");
33
+ var _SafeLink = require("./SafeLink");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ndla/safelink",
3
- "version": "5.1.15",
3
+ "version": "6.0.0-alpha.0",
4
4
  "description": "SafeLink component for NDLA",
5
5
  "license": "GPL-3.0",
6
6
  "main": "lib/index.js",
@@ -9,7 +9,8 @@
9
9
  "scripts": {
10
10
  "build": "node ../../scripts/build.js package",
11
11
  "build:types": "tsc -p tsconfig.build.json",
12
- "prepublish": "yarn build:types"
12
+ "build:panda": "mkdir -p dist && concurrently 'panda cssgen --minimal --outfile dist/styles.css' 'panda ship --outfile dist/panda.buildinfo.json'",
13
+ "prepublish": "concurrently 'yarn build:types' 'yarn build:panda'"
13
14
  },
14
15
  "repository": {
15
16
  "type": "git",
@@ -21,22 +22,25 @@
21
22
  ],
22
23
  "author": "ndla@knowit.no",
23
24
  "files": [
24
- "scss",
25
+ "dist",
25
26
  "lib",
26
27
  "es"
27
28
  ],
28
29
  "dependencies": {
29
- "@ndla/button": "^14.0.5-alpha.0",
30
- "@ndla/icons": "^7.0.6-alpha.0"
30
+ "@ndla/primitives": "^0.0.17",
31
+ "@ndla/styled-system": "^0.0.8"
32
+ },
33
+ "devDependencies": {
34
+ "@ndla/preset-panda": "^0.0.10",
35
+ "@pandacss/dev": "^0.42.0"
31
36
  },
32
37
  "peerDependencies": {
33
- "@emotion/react": "^11.10.4",
34
- "@emotion/styled": "^11.10.4",
35
- "react": ">= 16.8.0",
38
+ "react": ">= 18",
39
+ "react-dom": ">= 18",
36
40
  "react-router-dom": "^6.3.0"
37
41
  },
38
42
  "publishConfig": {
39
43
  "access": "public"
40
44
  },
41
- "gitHead": "8c3254246b993068a867ab9ec9594347d5ebf439"
45
+ "gitHead": "93dde6fe4aaca52642f8fa0a27f4acad359207cb"
42
46
  }