@redocly/theme 0.4.16 → 0.5.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,5 @@
1
+ interface AppCustomAttributesProps {
2
+ onChange: (value: Record<string, string>) => void;
3
+ }
4
+ export declare function AppCustomAttributes(_props: AppCustomAttributesProps): null;
5
+ export {};
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AppCustomAttributes = void 0;
4
+ function AppCustomAttributes(_props) {
5
+ return null;
6
+ }
7
+ exports.AppCustomAttributes = AppCustomAttributes;
8
+ //# sourceMappingURL=AppCustomAttributes.js.map
@@ -21,6 +21,10 @@ const EditButton = (0, styled_components_1.default)(Link_1.Link) `
21
21
  font-size: var(--font-size-base);
22
22
  font-family: var(--font-family-base);
23
23
  text-decoration: none;
24
+
25
+ @media print {
26
+ display: none;
27
+ }
24
28
  `;
25
29
  const ButtonIcon = styled_components_1.default.img `
26
30
  height: 14px;
@@ -15,7 +15,7 @@ function FooterColumn({ column }) {
15
15
  if (columnItem.type === 'error') {
16
16
  return null;
17
17
  }
18
- return columnItem.type === 'separator' ? (react_1.default.createElement(FooterSeparator, { key: columnItem.label + '_' + columnItemIndex }, columnItem.label)) : (react_1.default.createElement(FooterLink, { key: columnItemIndex, to: columnItem.link, "data-cy": columnItem.label }, columnItem.label));
18
+ return columnItem.type === 'separator' ? (react_1.default.createElement(FooterSeparator, { key: columnItem.label + '_' + columnItemIndex }, columnItem.label)) : (react_1.default.createElement(FooterLink, { key: columnItemIndex, to: columnItem.link, external: columnItem.external, target: columnItem.target, "data-cy": columnItem.label }, columnItem.label));
19
19
  })));
20
20
  }
21
21
  exports.FooterColumn = FooterColumn;
@@ -25,6 +25,9 @@ const Wrapper = styled_components_1.default.div `
25
25
  font-weight: var(--admonition-font-weight);
26
26
  line-height: var(--admonition-line-height);
27
27
 
28
+ print-color-adjust: exact;
29
+ -webkit-print-color-adjust: exact;
30
+
28
31
  ${({ type }) => `
29
32
  background-color: var(--admonition-${type}-background-color);
30
33
  color: var(--admonition-${type}-text-color);
@@ -66,6 +66,10 @@ const CopyCodeButton = styled_components_1.default.div `
66
66
  &:hover {
67
67
  cursor: pointer;
68
68
  }
69
+
70
+ @media print {
71
+ display: none;
72
+ }
69
73
  `;
70
74
  const DoneIndicator = styled_components_1.default.div `
71
75
  padding: var(--code-block-controls-padding);
@@ -149,6 +153,10 @@ const Wrapper = styled_components_1.default.div `
149
153
  border-radius: var(--code-block-border-radius);
150
154
  font-family: var(--code-font-family);
151
155
  background-color: var(--code-block-background-color);
156
+
157
+ print-color-adjust: exact;
158
+ -webkit-print-color-adjust: exact;
159
+
152
160
  code {
153
161
  background-color: transparent;
154
162
  border: 0;
@@ -16,7 +16,7 @@ function NavbarItem({ navItem, className }) {
16
16
  const item = navItem;
17
17
  const isActive = pathname === (0, utils_1.withPathPrefix)(item.link);
18
18
  return (react_1.default.createElement(exports.NavbarMenuItem, { active: isActive, "data-component-name": "Navbar/NavbarItem", className: className },
19
- react_1.default.createElement(exports.NavbarLink, { to: item.link, active: isActive },
19
+ react_1.default.createElement(exports.NavbarLink, { to: item.link, external: item.external, target: item.target, active: isActive },
20
20
  react_1.default.createElement(NavbarLabel, null, item.label))));
21
21
  }
22
22
  if (navItem.items) {
@@ -23,5 +23,9 @@ const PageNavigationWrapper = styled_components_1.default.div `
23
23
  display: flex;
24
24
  justify-content: space-between;
25
25
  margin: 25px 0;
26
+
27
+ @media print {
28
+ display: none;
29
+ }
26
30
  `;
27
31
  //# sourceMappingURL=PageNavigation.js.map
@@ -1,5 +1,4 @@
1
- /// <reference types="react" />
2
- import type { UniversalLinkProps } from '../ui/UniversalLink';
3
- export declare const MenuLink: import("styled-components").StyledComponent<(props: import("react").PropsWithChildren<object>) => JSX.Element, any, {
1
+ import { Link } from '../mocks/Link';
2
+ export declare const MenuLink: import("styled-components").StyledComponent<typeof Link, any, {
4
3
  'data-component-name': string;
5
- } & UniversalLinkProps, "data-component-name">;
4
+ }, "data-component-name">;
@@ -5,15 +5,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.MenuLink = void 0;
7
7
  const styled_components_1 = __importDefault(require("styled-components"));
8
- const UniversalLink_1 = require("../ui/UniversalLink");
9
- exports.MenuLink = (0, styled_components_1.default)(UniversalLink_1.UniversalLink).attrs(() => ({
8
+ const Link_1 = require("../mocks/Link");
9
+ exports.MenuLink = (0, styled_components_1.default)(Link_1.Link).attrs(() => ({
10
10
  'data-component-name': 'Sidebar/MenuLink',
11
11
  })) `
12
12
  text-decoration: none;
13
13
  color: var(--sidebar-item-text-color);
14
-
15
- &&.external-url:after {
16
- content: none;
17
- }
18
14
  `;
19
15
  //# sourceMappingURL=MenuLink.js.map
package/lib/mocks/Link.js CHANGED
@@ -1,16 +1,26 @@
1
1
  "use strict";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
2
13
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
14
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
15
  };
5
16
  Object.defineProperty(exports, "__esModule", { value: true });
6
17
  exports.Link = void 0;
7
18
  const react_1 = __importDefault(require("react"));
8
- const lodash_1 = require("lodash");
9
19
  // TODO: use real typings here
10
20
  // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
11
21
  function Link(props) {
22
+ const { active: _, httpVerb: _1, hasActiveSubItem: _2 } = props, filteredProps = __rest(props, ["active", "httpVerb", "hasActiveSubItem"]);
12
23
  // We omit "active" property to avoid "Warning: Received `false` for a non-boolean attribute `active`."
13
- const filteredProps = (0, lodash_1.omit)(props, ['active', 'httpVerb', 'hasActiveSubItem']);
14
24
  return react_1.default.createElement("a", Object.assign({ href: filteredProps.to }, filteredProps));
15
25
  }
16
26
  exports.Link = Link;
package/lib/ui/index.d.ts CHANGED
@@ -5,6 +5,5 @@ export * from '../ui/Box';
5
5
  export * from '../ui/Dropdown';
6
6
  export * from '../ui/Flex';
7
7
  export * from '../ui/Jumbotron';
8
- export * from '../ui/UniversalLink';
9
8
  export declare const LandingLayout: ({ children }: React.PropsWithChildren<object>) => React.ReactNode;
10
9
  export declare const EmptyLayout: ({ children }: React.PropsWithChildren<object>) => React.ReactNode;
package/lib/ui/index.js CHANGED
@@ -21,7 +21,6 @@ __exportStar(require("../ui/Box"), exports);
21
21
  __exportStar(require("../ui/Dropdown"), exports);
22
22
  __exportStar(require("../ui/Flex"), exports);
23
23
  __exportStar(require("../ui/Jumbotron"), exports);
24
- __exportStar(require("../ui/UniversalLink"), exports);
25
24
  const LandingLayout = ({ children }) => children;
26
25
  exports.LandingLayout = LandingLayout;
27
26
  exports.EmptyLayout = exports.LandingLayout;
package/package.json CHANGED
@@ -1,38 +1,35 @@
1
1
  {
2
2
  "name": "@redocly/theme",
3
- "version": "0.4.16",
3
+ "version": "0.5.0",
4
4
  "description": "Shared UI components",
5
5
  "author": "team@redocly.com",
6
6
  "license": "SEE LICENSE IN LICENSE",
7
7
  "main": "lib/index.js",
8
8
  "types": "lib/index.d.ts",
9
9
  "exports": {
10
+ "./package.json": "./package.json",
10
11
  ".": "./lib/index.js",
11
12
  "./Sidebar/*": "./lib/Sidebar/*.js",
12
13
  "./*": "./lib/*/index.js",
13
14
  "./src/": "./src/"
14
15
  },
15
16
  "scripts": {
16
- "start": "npm-run-all --parallel storybook generate-tokens:watch",
17
- "storybook": "start-storybook -p 6006",
18
- "build-storybook": "npm run generate-tokens && build-storybook",
19
- "generate-tokens": "ts-node scripts/generate-css-tokens.ts",
20
- "generate-tokens:watch": "ts-node-dev --respawn scripts/generate-css-tokens.ts",
17
+ "start": "npm-run-all --parallel storybook storybook:tokens:watch",
18
+ "watch": "tsc -p tsconfig.build.json && (concurrently \"tsc -w -p tsconfig.build.json\" \"tsc-alias -w -p tsconfig.build.json\")",
19
+ "ts:check": "tsc --noEmit --skipLibCheck",
21
20
  "clean": "rm -rf lib",
22
21
  "compile": "tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json",
23
22
  "build": "npm run clean && npm run compile",
24
- "build:on-rebuild": "tsc-alias -p tsconfig.build.json",
25
- "build:watch": "npm run clean && tsc-watch --project tsconfig.build.json --onSuccess \"npm run build:on-rebuild\"",
26
- "lint": "eslint . --ext .ts,.tsx --cache",
27
- "lint:fix": "eslint . --ext .ts,.tsx --fix",
28
- "prettier-base": "prettier \"**/*.{json,js,jsx,ts,tsx,yml,yaml,html,md}\"",
29
- "prettier": "npm run prettier-base -- --write",
30
- "prettier:check": "npm run prettier-base -- --check",
31
- "ts:check": "tsc --noEmit --skipLibCheck",
32
23
  "test": "jest",
24
+ "test:update": "jest -u",
33
25
  "test:watch": "jest --watch",
34
26
  "test:coverage": "jest --coverage",
35
- "test:updateSnapshot": "jest --updateSnapshot",
27
+ "test:coverage:html": "jest --coverage --coverageReporters html",
28
+ "e2e": "npx chromatic -b storybook:build --auto-accept-changes main --exit-once-uploaded",
29
+ "storybook": "start-storybook -p 6006",
30
+ "storybook:build": "npm run storybook:tokens && build-storybook",
31
+ "storybook:tokens": "ts-node scripts/generate-css-tokens.ts",
32
+ "storybook:tokens:watch": "ts-node-dev --respawn scripts/generate-css-tokens.ts",
36
33
  "chromatic": "chromatic --exit-zero-on-changes"
37
34
  },
38
35
  "peerDependencies": {
@@ -41,7 +38,7 @@
41
38
  "react": "^17.0.2",
42
39
  "react-dom": "^17.0.2",
43
40
  "react-router-dom": "^5.3.0",
44
- "styled-components": "^5.3.1",
41
+ "styled-components": "^5.3.6",
45
42
  "styled-system": "^5.1.5"
46
43
  },
47
44
  "devDependencies": {
@@ -55,7 +52,6 @@
55
52
  "@storybook/core-common": "^6.5.9",
56
53
  "@storybook/manager-webpack5": "^6.5.9",
57
54
  "@storybook/node-logger": "^6.5.9",
58
- "@storybook/preset-create-react-app": "^4.1.0",
59
55
  "@storybook/react": "^6.5.9",
60
56
  "@storybook/testing-library": "^0.0.11",
61
57
  "@storybook/theming": "^6.5.9",
@@ -75,34 +71,30 @@
75
71
  "@types/styled-system": "^5.1.13",
76
72
  "@typescript-eslint/eslint-plugin": "^5.23.0",
77
73
  "@typescript-eslint/parser": "^5.23.0",
78
- "chromatic": "^6.5.4",
79
- "esbuild": "^0.14.38",
80
- "jest": "^29.1.2",
81
- "jest-environment-jsdom": "^29.1.2",
74
+ "chromatic": "^6.10.2",
75
+ "esbuild": "^0.15.11",
76
+ "jest": "^29.2.0",
77
+ "jest-environment-jsdom": "^29.2.0",
82
78
  "jest-styled-components": "^7.1.1",
83
79
  "jest-when": "^3.5.1",
84
- "lint-staged": "^12.4.1",
85
- "lodash": "^4.17.21",
86
80
  "lodash.throttle": "^4.1.1",
87
81
  "npm-run-all": "^4.1.5",
88
- "prettier": "2.6.2",
89
82
  "react": "^17.0.2",
90
83
  "react-dom": "^17.0.2",
91
- "react-refresh": "^0.13.0",
84
+ "react-refresh": "^0.14.0",
92
85
  "react-router-dom": "^5.3.0",
93
- "react-scripts": "5.0.1",
94
86
  "storybook-addon-pseudo-states": "^1.15.1",
95
- "storybook-design-token": "^2.1.0",
96
- "styled-components": "^5.3.5",
87
+ "storybook-design-token": "^2.7.1",
88
+ "styled-components": "^5.3.6",
97
89
  "styled-system": "^5.1.5",
98
90
  "ts-jest": "^29.0.3",
99
91
  "ts-node": "^10.7.0",
100
- "ts-node-dev": "^1.1.8",
101
- "tsc-alias": "^1.6.7",
102
- "tsc-watch": "^5.0.3",
92
+ "ts-node-dev": "^2.0.0",
93
+ "tsc-alias": "^1.7.0",
103
94
  "tsconfig-paths-webpack-plugin": "^3.5.2",
104
- "typescript": "^4.6.4",
105
- "webpack": "^5.72.0"
95
+ "typescript": "^4.8.4",
96
+ "webpack": "^5.72.0",
97
+ "concurrently": "^7.4.0"
106
98
  },
107
99
  "dependencies": {
108
100
  "timeago.js": "^4.0.2"
@@ -0,0 +1,6 @@
1
+ interface AppCustomAttributesProps {
2
+ onChange: (value: Record<string, string>) => void;
3
+ }
4
+ export function AppCustomAttributes(_props: AppCustomAttributesProps) {
5
+ return null;
6
+ }
@@ -26,6 +26,10 @@ const EditButton = styled(Link)`
26
26
  font-size: var(--font-size-base);
27
27
  font-family: var(--font-family-base);
28
28
  text-decoration: none;
29
+
30
+ @media print {
31
+ display: none;
32
+ }
29
33
  `;
30
34
 
31
35
  const ButtonIcon = styled.img`
@@ -22,7 +22,13 @@ export function FooterColumn({ column }: FooterColumnProps): JSX.Element {
22
22
  {columnItem.label}
23
23
  </FooterSeparator>
24
24
  ) : (
25
- <FooterLink key={columnItemIndex} to={columnItem.link} data-cy={columnItem.label}>
25
+ <FooterLink
26
+ key={columnItemIndex}
27
+ to={columnItem.link}
28
+ external={columnItem.external}
29
+ target={columnItem.target}
30
+ data-cy={columnItem.label}
31
+ >
26
32
  {columnItem.label}
27
33
  </FooterLink>
28
34
  );
@@ -36,6 +36,9 @@ const Wrapper = styled.div<AdmonitionTypeProps>`
36
36
  font-weight: var(--admonition-font-weight);
37
37
  line-height: var(--admonition-line-height);
38
38
 
39
+ print-color-adjust: exact;
40
+ -webkit-print-color-adjust: exact;
41
+
39
42
  ${({ type }) => `
40
43
  background-color: var(--admonition-${type}-background-color);
41
44
  color: var(--admonition-${type}-text-color);
@@ -64,6 +64,10 @@ const CopyCodeButton = styled.div`
64
64
  &:hover {
65
65
  cursor: pointer;
66
66
  }
67
+
68
+ @media print {
69
+ display: none;
70
+ }
67
71
  `;
68
72
 
69
73
  const DoneIndicator = styled.div`
@@ -150,6 +154,10 @@ const Wrapper = styled.div`
150
154
  border-radius: var(--code-block-border-radius);
151
155
  font-family: var(--code-font-family);
152
156
  background-color: var(--code-block-background-color);
157
+
158
+ print-color-adjust: exact;
159
+ -webkit-print-color-adjust: exact;
160
+
153
161
  code {
154
162
  background-color: transparent;
155
163
  border: 0;
@@ -28,7 +28,7 @@ export function NavbarItem({ navItem, className }: NavbarItemProps): JSX.Element
28
28
  data-component-name="Navbar/NavbarItem"
29
29
  className={className}
30
30
  >
31
- <NavbarLink to={item.link} active={isActive}>
31
+ <NavbarLink to={item.link} external={item.external} target={item.target} active={isActive}>
32
32
  <NavbarLabel>{item.label}</NavbarLabel>
33
33
  </NavbarLink>
34
34
  </NavbarMenuItem>
@@ -24,4 +24,8 @@ const PageNavigationWrapper = styled.div`
24
24
  display: flex;
25
25
  justify-content: space-between;
26
26
  margin: 25px 0;
27
+
28
+ @media print {
29
+ display: none;
30
+ }
27
31
  `;
@@ -1,15 +1,10 @@
1
1
  import styled from 'styled-components';
2
2
 
3
- import { UniversalLink } from '@theme/ui/UniversalLink';
4
- import type { UniversalLinkProps } from '@theme/ui/UniversalLink';
3
+ import { Link } from '@portal/Link';
5
4
 
6
- export const MenuLink = styled(UniversalLink).attrs(() => ({
5
+ export const MenuLink = styled(Link).attrs(() => ({
7
6
  'data-component-name': 'Sidebar/MenuLink',
8
- }))<UniversalLinkProps>`
7
+ }))`
9
8
  text-decoration: none;
10
9
  color: var(--sidebar-item-text-color);
11
-
12
- &&.external-url:after {
13
- content: none;
14
- }
15
10
  `;
@@ -1,10 +1,9 @@
1
1
  import React from 'react';
2
- import { omit } from 'lodash';
3
2
 
4
3
  // TODO: use real typings here
5
4
  // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
6
5
  export function Link(props: any): JSX.Element {
6
+ const { active: _, httpVerb: _1, hasActiveSubItem: _2, ...filteredProps } = props;
7
7
  // We omit "active" property to avoid "Warning: Received `false` for a non-boolean attribute `active`."
8
- const filteredProps = omit(props, ['active', 'httpVerb', 'hasActiveSubItem']);
9
8
  return <a href={filteredProps.to} {...filteredProps} />;
10
9
  }
File without changes
@@ -6,6 +6,7 @@ export declare type ResolvedNavLinkItem = {
6
6
  label: string;
7
7
  items?: ResolvedNavItem[];
8
8
  external?: boolean;
9
+ target?: '_self' | '_blank';
9
10
  version?: string;
10
11
  isDefault?: boolean;
11
12
  versionFolderId?: string;
@@ -20,6 +21,8 @@ export declare type ResolvedNavGroupItem = {
20
21
  link?: string;
21
22
  label?: string;
22
23
  items?: ResolvedNavItem[];
24
+ external?: never;
25
+ target?: never;
23
26
  expanded?: string;
24
27
  version?: string;
25
28
  isDefault?: boolean;
package/src/ui/index.tsx CHANGED
@@ -6,7 +6,6 @@ export * from '@theme/ui/Box';
6
6
  export * from '@theme/ui/Dropdown';
7
7
  export * from '@theme/ui/Flex';
8
8
  export * from '@theme/ui/Jumbotron';
9
- export * from '@theme/ui/UniversalLink';
10
9
 
11
10
  export const LandingLayout = ({ children }: React.PropsWithChildren<object>): React.ReactNode =>
12
11
  children;
@@ -1,17 +0,0 @@
1
- import * as React from 'react';
2
- import type { LinkProps } from 'react-router-dom';
3
- export declare const withPropsFilter: (filterList: string[]) => (WrappedComponent: React.FunctionComponent) => (props: React.PropsWithChildren<object>) => JSX.Element;
4
- export interface PortalLinkProps<TState> extends LinkProps<TState> {
5
- activeClassName?: string;
6
- activeStyle?: object;
7
- onClick?: (event: React.MouseEvent<HTMLAnchorElement>) => void;
8
- partiallyActive?: boolean;
9
- replace?: boolean;
10
- state?: TState;
11
- to: string;
12
- }
13
- export interface UniversalLinkProps extends Partial<PortalLinkProps<object>> {
14
- external?: boolean;
15
- ref?: any;
16
- }
17
- export declare const UniversalLink: (props: React.PropsWithChildren<object>) => JSX.Element;
@@ -1,79 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.UniversalLink = exports.withPropsFilter = void 0;
30
- const React = __importStar(require("react"));
31
- const react_router_dom_1 = require("react-router-dom");
32
- const styled_components_1 = __importDefault(require("styled-components"));
33
- const isUrl_1 = require("../utils/isUrl");
34
- const Link_1 = require("../mocks/Link");
35
- const StyledExternalLink = styled_components_1.default.a `
36
- &.external-url {
37
- position: relative;
38
-
39
- :after {
40
- content: '';
41
- display: inline-block;
42
- position: absolute;
43
- background: var(--text-color);
44
- mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' version='1.1' x='0' y='0' viewBox='0 0 100 125' enable-background='new 0 0 100 100' xml:space='preserve'%3E%3Cpath d='M-408.2-318.5 98.6 4.8c0-0.1 0-0.2-0.1-0.3 0-0.1-0.1-0.2-0.1-0.3 0-0.1 0-0.1-0.1-0.2 0 0 0-0.1 0-0.1 0-0.1-0.1-0.2-0.2-0.3 0-0.1-0.1-0.2-0.2-0.3 -0.1-0.1-0.1-0.2-0.2-0.3C97.7 2.9 97.6 2.8 97.5 2.7c-0.1-0.1-0.2-0.2-0.3-0.3 -0.1-0.1-0.1-0.1-0.2-0.2 -0.1-0.1-0.2-0.2-0.3-0.2 -0.1-0.1-0.2-0.1-0.2-0.2 -0.1-0.1-0.2-0.1-0.3-0.2 -0.1 0-0.2-0.1-0.3-0.1 0 0-0.1 0-0.1-0.1 -0.1 0-0.2 0-0.2-0.1 -0.1 0-0.2-0.1-0.3-0.1 -0.1 0-0.2-0.1-0.4-0.1 -0.1 0-0.2 0-0.3 0 -0.1 0-0.3 0-0.4 0 -0.1 0-0.1 0-0.2 0L63.8 1.3c-2.5 0-4.6 2.1-4.6 4.6 0 2.5 2.1 4.6 4.6 4.5l19.3-0.1 -29.8 30.2c-1.1 1.1-1.5 2.7-1.2 4.1 0.2 0.9 0.6 1.7 1.3 2.4 0.9 0.9 2.1 1.3 3.2 1.3 1.2 0 2.3-0.5 3.2-1.4l0 0 29.8-30.2 0.1 19.3c0 2.5 2.1 4.6 4.6 4.5 1.3 0 2.4-0.5 3.2-1.4 0.8-0.8 1.3-2 1.3-3.2L98.7 5.7c0-0.1 0-0.1 0-0.2 0-0.1 0-0.2 0-0.4C98.6 5 98.6 4.9 98.6 4.8zM6.5 83.3c0 5.7 4.6 10.4 10.4 10.4l55.6 0.1c5.7 0 10.4-4.6 10.4-10.4l-0.1-40.8h6.1v40.8c0 9-7.3 16.3-16.3 16.3l-56.4-0.1c-8.6 0-15.6-7-15.6-15.6L0.6 27.8c0-9 7.3-16.3 16.3-16.3l41.1-0.1v6.1L17 17.5c-5.7 0-10.4 4.6-10.4 10.4L6.5 83.3z'/%3E%3C/svg%3E");
45
- mask-repeat: no-repeat;
46
- width: 10px;
47
- height: 10px;
48
- top: 50%;
49
- right: -15px;
50
- transform: translateY(-50%);
51
- }
52
- }
53
- `;
54
- // TODO: We're using our own Link component so probably filtering is not necessary here.
55
- // filter out unnecessary props
56
- const propsList = [
57
- 'color',
58
- 'size',
59
- 'variant',
60
- 'bgColor',
61
- 'bgImage',
62
- 'disableArrow',
63
- 'withIcon',
64
- 'maxWidth',
65
- 'inversed',
66
- 'transparent',
67
- 'large',
68
- ];
69
- const withPropsFilter = (filterList) => (WrappedComponent) => function WithPropsFilter(props) {
70
- const filteredProps = Object.fromEntries(Object.entries(props).filter(([key]) => !filterList.includes(key)));
71
- return React.createElement(WrappedComponent, Object.assign({}, filteredProps));
72
- };
73
- exports.withPropsFilter = withPropsFilter;
74
- exports.UniversalLink = (0, exports.withPropsFilter)(propsList)((props) => {
75
- var _a;
76
- return (typeof props.to === 'string' && ((0, isUrl_1.isUrl)(props.to) || props.to.startsWith('mailto:'))) ||
77
- props.external ? (React.createElement(StyledExternalLink, { style: props.style, href: props.to, target: props.target || (props.external && '_blank') || '_self', className: `${props.external ? 'external-url' : ''} ${props.className}`, rel: props.rel, "data-cy": `universalLink-${typeof props.children === 'string' ? props.children : 'with-nested-jsx'}` }, props.children)) : props.to == null ? (React.createElement("a", { onClick: props.onClick, className: props.className, style: props.style }, props.children)) : (React.createElement(Link_1.Link, Object.assign({}, props, { to: props.to, state: Object.assign({ previousPath: (_a = (0, react_router_dom_1.useLocation)()) === null || _a === void 0 ? void 0 : _a.pathname }, props.state) })));
78
- });
79
- //# sourceMappingURL=UniversalLink.js.map
@@ -1,97 +0,0 @@
1
- import * as React from 'react';
2
- import { useLocation } from 'react-router-dom';
3
- import styled from 'styled-components';
4
-
5
- import type { LinkProps } from 'react-router-dom';
6
-
7
- import { isUrl } from '@theme/utils/isUrl';
8
- import { Link } from '@portal/Link';
9
-
10
- const StyledExternalLink = styled.a`
11
- &.external-url {
12
- position: relative;
13
-
14
- :after {
15
- content: '';
16
- display: inline-block;
17
- position: absolute;
18
- background: var(--text-color);
19
- mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' version='1.1' x='0' y='0' viewBox='0 0 100 125' enable-background='new 0 0 100 100' xml:space='preserve'%3E%3Cpath d='M-408.2-318.5 98.6 4.8c0-0.1 0-0.2-0.1-0.3 0-0.1-0.1-0.2-0.1-0.3 0-0.1 0-0.1-0.1-0.2 0 0 0-0.1 0-0.1 0-0.1-0.1-0.2-0.2-0.3 0-0.1-0.1-0.2-0.2-0.3 -0.1-0.1-0.1-0.2-0.2-0.3C97.7 2.9 97.6 2.8 97.5 2.7c-0.1-0.1-0.2-0.2-0.3-0.3 -0.1-0.1-0.1-0.1-0.2-0.2 -0.1-0.1-0.2-0.2-0.3-0.2 -0.1-0.1-0.2-0.1-0.2-0.2 -0.1-0.1-0.2-0.1-0.3-0.2 -0.1 0-0.2-0.1-0.3-0.1 0 0-0.1 0-0.1-0.1 -0.1 0-0.2 0-0.2-0.1 -0.1 0-0.2-0.1-0.3-0.1 -0.1 0-0.2-0.1-0.4-0.1 -0.1 0-0.2 0-0.3 0 -0.1 0-0.3 0-0.4 0 -0.1 0-0.1 0-0.2 0L63.8 1.3c-2.5 0-4.6 2.1-4.6 4.6 0 2.5 2.1 4.6 4.6 4.5l19.3-0.1 -29.8 30.2c-1.1 1.1-1.5 2.7-1.2 4.1 0.2 0.9 0.6 1.7 1.3 2.4 0.9 0.9 2.1 1.3 3.2 1.3 1.2 0 2.3-0.5 3.2-1.4l0 0 29.8-30.2 0.1 19.3c0 2.5 2.1 4.6 4.6 4.5 1.3 0 2.4-0.5 3.2-1.4 0.8-0.8 1.3-2 1.3-3.2L98.7 5.7c0-0.1 0-0.1 0-0.2 0-0.1 0-0.2 0-0.4C98.6 5 98.6 4.9 98.6 4.8zM6.5 83.3c0 5.7 4.6 10.4 10.4 10.4l55.6 0.1c5.7 0 10.4-4.6 10.4-10.4l-0.1-40.8h6.1v40.8c0 9-7.3 16.3-16.3 16.3l-56.4-0.1c-8.6 0-15.6-7-15.6-15.6L0.6 27.8c0-9 7.3-16.3 16.3-16.3l41.1-0.1v6.1L17 17.5c-5.7 0-10.4 4.6-10.4 10.4L6.5 83.3z'/%3E%3C/svg%3E");
20
- mask-repeat: no-repeat;
21
- width: 10px;
22
- height: 10px;
23
- top: 50%;
24
- right: -15px;
25
- transform: translateY(-50%);
26
- }
27
- }
28
- `;
29
-
30
- // TODO: We're using our own Link component so probably filtering is not necessary here.
31
- // filter out unnecessary props
32
- const propsList = [
33
- 'color',
34
- 'size',
35
- 'variant',
36
- 'bgColor',
37
- 'bgImage',
38
- 'disableArrow',
39
- 'withIcon',
40
- 'maxWidth',
41
- 'inversed',
42
- 'transparent',
43
- 'large',
44
- ];
45
-
46
- export const withPropsFilter =
47
- (filterList: string[]) => (WrappedComponent: React.FunctionComponent) =>
48
- function WithPropsFilter(props: React.PropsWithChildren<object>): JSX.Element {
49
- const filteredProps = Object.fromEntries(
50
- Object.entries(props).filter(([key]) => !filterList.includes(key)),
51
- );
52
-
53
- return <WrappedComponent {...filteredProps} />;
54
- };
55
-
56
- export interface PortalLinkProps<TState> extends LinkProps<TState> {
57
- activeClassName?: string;
58
- activeStyle?: object;
59
- onClick?: (event: React.MouseEvent<HTMLAnchorElement>) => void;
60
- partiallyActive?: boolean;
61
- replace?: boolean;
62
- state?: TState;
63
- to: string;
64
- }
65
-
66
- export interface UniversalLinkProps extends Partial<PortalLinkProps<object>> {
67
- external?: boolean;
68
- ref?: any;
69
- }
70
-
71
- export const UniversalLink = withPropsFilter(propsList)((props: UniversalLinkProps) => {
72
- return (typeof props.to === 'string' && (isUrl(props.to) || props.to.startsWith('mailto:'))) ||
73
- props.external ? (
74
- <StyledExternalLink
75
- style={props.style}
76
- href={props.to}
77
- target={props.target || (props.external && '_blank') || '_self'}
78
- className={`${props.external ? 'external-url' : ''} ${props.className}`}
79
- rel={props.rel}
80
- data-cy={`universalLink-${
81
- typeof props.children === 'string' ? props.children : 'with-nested-jsx'
82
- }`}
83
- >
84
- {props.children}
85
- </StyledExternalLink>
86
- ) : props.to == null ? (
87
- <a onClick={props.onClick} className={props.className} style={props.style}>
88
- {props.children}
89
- </a>
90
- ) : (
91
- <Link
92
- {...props}
93
- to={props.to}
94
- state={{ previousPath: useLocation()?.pathname, ...props.state }}
95
- />
96
- );
97
- });