@dt-dds/react-link 1.0.0-beta.86 → 1.0.0-beta.88

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/CHANGELOG.md CHANGED
@@ -1,5 +1,31 @@
1
1
  # @dt-ui/react-link
2
2
 
3
+ ## 1.0.0-beta.88
4
+
5
+ ### Minor Changes
6
+
7
+ - feat: prevent transient props from leaking on Link
8
+
9
+ ## 1.0.0-beta.87
10
+
11
+ ### Minor Changes
12
+
13
+ - feat: implement new Link design variants
14
+
15
+ ### Patch Changes
16
+
17
+ - chore: update to ESLint 10
18
+ - chore: update to ESLint 9
19
+ - fix: default icon type in themes
20
+ - Updated dependencies
21
+ - Updated dependencies
22
+ - Updated dependencies
23
+ - @dt-dds/icons@1.0.0-beta.7
24
+ - @dt-dds/react-core@1.0.0-beta.60
25
+ - @dt-dds/react-icon@1.0.0-beta.64
26
+ - @dt-dds/react-button@1.0.0-beta.109
27
+ - @dt-dds/themes@1.0.0-beta.15
28
+
3
29
  ## 1.0.0-beta.86
4
30
 
5
31
  ### Patch Changes
package/README.md CHANGED
@@ -14,15 +14,18 @@ export const App = () => {
14
14
 
15
15
  ## Properties
16
16
 
17
- | Property | Type | Default | Description |
18
- | ------------ | ------------- | ------------ | ----------------------------------------------- |
19
- | `children` | `ReactNode` | - | Child components to be rendered |
20
- | `dataTestId` | `string` | tag | Customizable test identifier |
21
- | `onClick` | `function` | - | The triggered function when the Link is clicked |
22
- | `isDisabled` | `boolean` | `false` | Specifies if the element should be disabled |
23
- | `size` | `LinkSize` | `medium` | Specifies the text size of the element |
24
- | `variant` | `LinkVariant` | `standalone` | Specifies the type of link |
25
- | `color` | `LinkColor` | `accent` | Specifies the color of the link |
17
+ | Property | Type | Default | Description |
18
+ | ------------ | ---------------- | ------------ | ----------------------------------------------- |
19
+ | `as` | `ElementType` | `a` | Renders the link as a different element or component |
20
+ | `children` | `ReactNode` | - | Child components to be rendered |
21
+ | `dataTestId` | `string` | `link` | Customizable test identifier |
22
+ | `onClick` | `function` | - | The triggered function when the Link is clicked |
23
+ | `isDisabled` | `boolean` | `false` | Specifies if the element should be disabled |
24
+ | `size` | `LinkSize` | `medium` | Specifies the text size of the element |
25
+ | `variant` | `LinkVariant` | `standalone` | Specifies the type of link |
26
+ | `color` | `LinkColor` | `primary` | Specifies the color of the link |
27
+ | `fontWeight` | `LinkFontWeight` | `regular` | Specifies the font weight of the link |
28
+ | `icon` | `Code` | - | Adds an icon next to the link text |
26
29
 
27
30
  This component inherits all native anchor properties. [Learn more](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a).
28
31
 
package/dist/index.d.mts CHANGED
@@ -1,19 +1,23 @@
1
1
  import { CustomTheme } from '@dt-dds/themes';
2
2
  import * as react from 'react';
3
+ import { ElementType } from 'react';
3
4
  import { Code } from '@dt-dds/icons';
4
5
  import { BaseProps, ComponentSize } from '@dt-dds/react-core';
5
6
 
6
7
  interface LinkProps extends BaseProps, React.AnchorHTMLAttributes<HTMLAnchorElement> {
8
+ as?: ElementType;
7
9
  isDisabled?: boolean;
8
10
  onClick?: (event: React.MouseEvent<HTMLAnchorElement, MouseEvent>) => void;
9
11
  size?: LinkSize;
10
12
  color?: LinkColor;
13
+ fontWeight?: LinkFontWeight;
11
14
  icon?: Code;
12
15
  variant?: LinkVariant;
13
16
  }
14
17
  declare const Link: react.ForwardRefExoticComponent<LinkProps & react.RefAttributes<HTMLAnchorElement>>;
15
18
 
16
- type LinkColor = 'accent' | 'secondary';
19
+ type LinkColor = 'primary' | 'secondary';
20
+ type LinkFontWeight = 'regular' | 'bold';
17
21
  type LinkSize = Extract<ComponentSize, 'small' | 'medium' | 'large'>;
18
22
  type LinkVariant = 'standalone' | 'inline';
19
23
 
@@ -22,4 +26,4 @@ declare module '@emotion/react' {
22
26
  }
23
27
  }
24
28
 
25
- export { Link, type LinkColor, type LinkProps, type LinkSize, type LinkVariant };
29
+ export { Link, type LinkColor, type LinkFontWeight, type LinkProps, type LinkSize, type LinkVariant };
package/dist/index.d.ts CHANGED
@@ -1,19 +1,23 @@
1
1
  import { CustomTheme } from '@dt-dds/themes';
2
2
  import * as react from 'react';
3
+ import { ElementType } from 'react';
3
4
  import { Code } from '@dt-dds/icons';
4
5
  import { BaseProps, ComponentSize } from '@dt-dds/react-core';
5
6
 
6
7
  interface LinkProps extends BaseProps, React.AnchorHTMLAttributes<HTMLAnchorElement> {
8
+ as?: ElementType;
7
9
  isDisabled?: boolean;
8
10
  onClick?: (event: React.MouseEvent<HTMLAnchorElement, MouseEvent>) => void;
9
11
  size?: LinkSize;
10
12
  color?: LinkColor;
13
+ fontWeight?: LinkFontWeight;
11
14
  icon?: Code;
12
15
  variant?: LinkVariant;
13
16
  }
14
17
  declare const Link: react.ForwardRefExoticComponent<LinkProps & react.RefAttributes<HTMLAnchorElement>>;
15
18
 
16
- type LinkColor = 'accent' | 'secondary';
19
+ type LinkColor = 'primary' | 'secondary';
20
+ type LinkFontWeight = 'regular' | 'bold';
17
21
  type LinkSize = Extract<ComponentSize, 'small' | 'medium' | 'large'>;
18
22
  type LinkVariant = 'standalone' | 'inline';
19
23
 
@@ -22,4 +26,4 @@ declare module '@emotion/react' {
22
26
  }
23
27
  }
24
28
 
25
- export { Link, type LinkColor, type LinkProps, type LinkSize, type LinkVariant };
29
+ export { Link, type LinkColor, type LinkFontWeight, type LinkProps, type LinkSize, type LinkVariant };
package/dist/index.js CHANGED
@@ -68,68 +68,87 @@ var import_react = require("react");
68
68
  var import_react_icon = require("@dt-dds/react-icon");
69
69
 
70
70
  // src/Link.styled.ts
71
+ var import_is_prop_valid = __toESM(require("@emotion/is-prop-valid"));
71
72
  var import_styled = __toESM(require("@emotion/styled"));
72
- var LinkStyled = import_styled.default.a`
73
- ${({ theme, disabled, size, variant = "standalone", color = "accent" }) => {
74
- const linkColor = variant === "inline" ? "accent" : color;
73
+ var fontStyleMap = {
74
+ inline: {
75
+ large: { regular: "linkLgRegular", bold: "linkLgBold" },
76
+ medium: { regular: "linkMdRegular", bold: "linkMdBold" },
77
+ small: { regular: "linkSmRegular", bold: "linkSmBold" }
78
+ },
79
+ standalone: {
80
+ large: { regular: "bodyLgRegular", bold: "bodyLgBold" },
81
+ medium: { regular: "bodyMdRegular", bold: "bodyMdBold" },
82
+ small: { regular: "bodySmRegular", bold: "bodySmBold" }
83
+ }
84
+ };
85
+ var colorMap = (palette) => ({
86
+ inline: {
87
+ primary: {
88
+ default: palette.accent.default,
89
+ hover: palette.accent.dark,
90
+ active: palette.accent.medium,
91
+ disabled: palette.content.light
92
+ },
93
+ secondary: {
94
+ default: palette.accent.default,
95
+ hover: palette.accent.dark,
96
+ active: palette.accent.medium,
97
+ disabled: palette.content.light
98
+ }
99
+ },
100
+ standalone: {
101
+ primary: {
102
+ default: palette.primary.default,
103
+ hover: palette.accent.default,
104
+ active: palette.accent.default,
105
+ disabled: palette.primary.light
106
+ },
107
+ secondary: {
108
+ default: palette.secondary.default,
109
+ hover: palette.secondary.dark,
110
+ active: palette.secondary.medium,
111
+ disabled: palette.secondary.light
112
+ }
113
+ }
114
+ });
115
+ var LinkStyled = (0, import_styled.default)("a", {
116
+ shouldForwardProp: (prop) => (0, import_is_prop_valid.default)(prop) && !prop.startsWith("$")
117
+ })`
118
+ ${({
119
+ theme,
120
+ $disabled,
121
+ $size = "medium",
122
+ $variant = "standalone",
123
+ $color = "primary",
124
+ $fontWeight = "regular"
125
+ }) => {
126
+ const colors = colorMap(theme.palette)[$variant][$color];
75
127
  return `
76
- color: ${theme.palette[linkColor].default};
77
- display: inline-flex;
78
- align-items: center;
79
- gap: ${theme.spacing.spacing_20};
128
+ color: ${colors.default};
129
+ display: inline-flex;
130
+ align-items: center;
131
+ gap: ${theme.spacing.spacing_10};
80
132
 
133
+ ${theme.fontStyles[fontStyleMap[$variant][$size][$fontWeight]]};
81
134
 
82
- ${size == "large" && `
83
- ${theme.fontStyles.bodyLgBold}
84
- `};
135
+ ${$disabled ? `
136
+ color: ${colors.disabled};
137
+ cursor: not-allowed;
138
+ ` : `
139
+ &:hover {
140
+ color: ${colors.hover};
141
+ }
85
142
 
86
- ${size == "medium" && `
87
- ${theme.fontStyles.bodyMdBold}
88
- `};
143
+ &:active {
144
+ color: ${colors.active};
145
+ }
146
+ `};
89
147
 
90
- ${size == "small" && `
91
- ${theme.fontStyles.bodySmBold}
92
- `};
93
-
94
- ${disabled && `
95
- color: ${theme.palette[linkColor].light};
96
- cursor: not-allowed;
97
-
98
- ${variant === "inline" && `
99
- text-decoration: underline;
100
- `}
101
- `};
102
-
103
- ${!disabled && `
104
- ${variant === "inline" ? `
105
- text-decoration: underline;
106
-
107
- &:hover {
108
- color: ${theme.palette[linkColor].medium};
109
- }
110
- ` : `
111
- &:hover {
112
- text-decoration: underline;
113
- }
114
-
115
- &:has(span):hover {
116
- text-decoration: none;
117
-
118
- span {
119
- text-decoration: underline;
120
- }
121
- }
122
-
123
- &:active {
124
- color: ${theme.palette[linkColor].dark};
125
- text-decoration: none;
126
- }`}
127
- `};
128
-
129
- &:focus-visible {
130
- outline: 2px solid ${theme.palette.primary.default};
131
- }
132
- `;
148
+ &:focus-visible {
149
+ outline: 2px solid ${theme.palette.primary.default};
150
+ }
151
+ `;
133
152
  }}
134
153
  `;
135
154
 
@@ -144,6 +163,7 @@ var Link = (0, import_react.forwardRef)(
144
163
  dataTestId,
145
164
  onClick,
146
165
  variant,
166
+ fontWeight = "regular",
147
167
  href,
148
168
  style,
149
169
  icon,
@@ -155,6 +175,7 @@ var Link = (0, import_react.forwardRef)(
155
175
  "dataTestId",
156
176
  "onClick",
157
177
  "variant",
178
+ "fontWeight",
158
179
  "href",
159
180
  "style",
160
181
  "icon",
@@ -163,13 +184,14 @@ var Link = (0, import_react.forwardRef)(
163
184
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
164
185
  LinkStyled,
165
186
  __spreadProps(__spreadValues(__spreadValues({
166
- color,
187
+ $color: color,
167
188
  "data-testid": dataTestId != null ? dataTestId : "link",
168
- disabled: isDisabled,
189
+ $disabled: isDisabled,
190
+ $fontWeight: fontWeight,
169
191
  ref,
170
- size,
192
+ $size: size,
171
193
  style,
172
- variant
194
+ $variant: variant
173
195
  }, !isDisabled && { href, onClick }), rest), {
174
196
  children: variant === "inline" || !icon ? children : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
175
197
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children }),
package/dist/index.mjs CHANGED
@@ -35,68 +35,87 @@ import { forwardRef } from "react";
35
35
  import { Icon } from "@dt-dds/react-icon";
36
36
 
37
37
  // src/Link.styled.ts
38
+ import isPropValid from "@emotion/is-prop-valid";
38
39
  import styled from "@emotion/styled";
39
- var LinkStyled = styled.a`
40
- ${({ theme, disabled, size, variant = "standalone", color = "accent" }) => {
41
- const linkColor = variant === "inline" ? "accent" : color;
40
+ var fontStyleMap = {
41
+ inline: {
42
+ large: { regular: "linkLgRegular", bold: "linkLgBold" },
43
+ medium: { regular: "linkMdRegular", bold: "linkMdBold" },
44
+ small: { regular: "linkSmRegular", bold: "linkSmBold" }
45
+ },
46
+ standalone: {
47
+ large: { regular: "bodyLgRegular", bold: "bodyLgBold" },
48
+ medium: { regular: "bodyMdRegular", bold: "bodyMdBold" },
49
+ small: { regular: "bodySmRegular", bold: "bodySmBold" }
50
+ }
51
+ };
52
+ var colorMap = (palette) => ({
53
+ inline: {
54
+ primary: {
55
+ default: palette.accent.default,
56
+ hover: palette.accent.dark,
57
+ active: palette.accent.medium,
58
+ disabled: palette.content.light
59
+ },
60
+ secondary: {
61
+ default: palette.accent.default,
62
+ hover: palette.accent.dark,
63
+ active: palette.accent.medium,
64
+ disabled: palette.content.light
65
+ }
66
+ },
67
+ standalone: {
68
+ primary: {
69
+ default: palette.primary.default,
70
+ hover: palette.accent.default,
71
+ active: palette.accent.default,
72
+ disabled: palette.primary.light
73
+ },
74
+ secondary: {
75
+ default: palette.secondary.default,
76
+ hover: palette.secondary.dark,
77
+ active: palette.secondary.medium,
78
+ disabled: palette.secondary.light
79
+ }
80
+ }
81
+ });
82
+ var LinkStyled = styled("a", {
83
+ shouldForwardProp: (prop) => isPropValid(prop) && !prop.startsWith("$")
84
+ })`
85
+ ${({
86
+ theme,
87
+ $disabled,
88
+ $size = "medium",
89
+ $variant = "standalone",
90
+ $color = "primary",
91
+ $fontWeight = "regular"
92
+ }) => {
93
+ const colors = colorMap(theme.palette)[$variant][$color];
42
94
  return `
43
- color: ${theme.palette[linkColor].default};
44
- display: inline-flex;
45
- align-items: center;
46
- gap: ${theme.spacing.spacing_20};
47
-
95
+ color: ${colors.default};
96
+ display: inline-flex;
97
+ align-items: center;
98
+ gap: ${theme.spacing.spacing_10};
48
99
 
49
- ${size == "large" && `
50
- ${theme.fontStyles.bodyLgBold}
51
- `};
100
+ ${theme.fontStyles[fontStyleMap[$variant][$size][$fontWeight]]};
52
101
 
53
- ${size == "medium" && `
54
- ${theme.fontStyles.bodyMdBold}
55
- `};
102
+ ${$disabled ? `
103
+ color: ${colors.disabled};
104
+ cursor: not-allowed;
105
+ ` : `
106
+ &:hover {
107
+ color: ${colors.hover};
108
+ }
56
109
 
57
- ${size == "small" && `
58
- ${theme.fontStyles.bodySmBold}
59
- `};
110
+ &:active {
111
+ color: ${colors.active};
112
+ }
113
+ `};
60
114
 
61
- ${disabled && `
62
- color: ${theme.palette[linkColor].light};
63
- cursor: not-allowed;
64
-
65
- ${variant === "inline" && `
66
- text-decoration: underline;
67
- `}
68
- `};
69
-
70
- ${!disabled && `
71
- ${variant === "inline" ? `
72
- text-decoration: underline;
73
-
74
- &:hover {
75
- color: ${theme.palette[linkColor].medium};
76
- }
77
- ` : `
78
- &:hover {
79
- text-decoration: underline;
80
- }
81
-
82
- &:has(span):hover {
83
- text-decoration: none;
84
-
85
- span {
86
- text-decoration: underline;
87
- }
88
- }
89
-
90
- &:active {
91
- color: ${theme.palette[linkColor].dark};
92
- text-decoration: none;
93
- }`}
94
- `};
95
-
96
- &:focus-visible {
97
- outline: 2px solid ${theme.palette.primary.default};
98
- }
99
- `;
115
+ &:focus-visible {
116
+ outline: 2px solid ${theme.palette.primary.default};
117
+ }
118
+ `;
100
119
  }}
101
120
  `;
102
121
 
@@ -111,6 +130,7 @@ var Link = forwardRef(
111
130
  dataTestId,
112
131
  onClick,
113
132
  variant,
133
+ fontWeight = "regular",
114
134
  href,
115
135
  style,
116
136
  icon,
@@ -122,6 +142,7 @@ var Link = forwardRef(
122
142
  "dataTestId",
123
143
  "onClick",
124
144
  "variant",
145
+ "fontWeight",
125
146
  "href",
126
147
  "style",
127
148
  "icon",
@@ -130,13 +151,14 @@ var Link = forwardRef(
130
151
  return /* @__PURE__ */ jsx(
131
152
  LinkStyled,
132
153
  __spreadProps(__spreadValues(__spreadValues({
133
- color,
154
+ $color: color,
134
155
  "data-testid": dataTestId != null ? dataTestId : "link",
135
- disabled: isDisabled,
156
+ $disabled: isDisabled,
157
+ $fontWeight: fontWeight,
136
158
  ref,
137
- size,
159
+ $size: size,
138
160
  style,
139
- variant
161
+ $variant: variant
140
162
  }, !isDisabled && { href, onClick }), rest), {
141
163
  children: variant === "inline" || !icon ? children : /* @__PURE__ */ jsxs(Fragment, { children: [
142
164
  /* @__PURE__ */ jsx("span", { children }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dt-dds/react-link",
3
- "version": "1.0.0-beta.86",
3
+ "version": "1.0.0-beta.88",
4
4
  "license": "MIT",
5
5
  "exports": {
6
6
  ".": "./dist/index.js"
@@ -20,11 +20,11 @@
20
20
  "test:update:snapshot": "jest -u"
21
21
  },
22
22
  "dependencies": {
23
- "@dt-dds/icons": "1.0.0-beta.6",
24
- "@dt-dds/react-button": "1.0.0-beta.108",
25
- "@dt-dds/react-core": "1.0.0-beta.59",
26
- "@dt-dds/react-icon": "1.0.0-beta.63",
27
- "@dt-dds/themes": "1.0.0-beta.14"
23
+ "@dt-dds/icons": "1.0.0-beta.7",
24
+ "@dt-dds/react-button": "1.0.0-beta.109",
25
+ "@dt-dds/react-core": "1.0.0-beta.60",
26
+ "@dt-dds/react-icon": "1.0.0-beta.64",
27
+ "@dt-dds/themes": "1.0.0-beta.15"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@babel/core": "^7.22.9",