@dt-dds/react-link 1.0.0-beta.16

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 ADDED
@@ -0,0 +1,142 @@
1
+ # @dt-ui/react-link
2
+
3
+ ## 1.0.0-beta.16
4
+
5
+ ### Patch Changes
6
+
7
+ - chore: fix publish after npmjs.org pkg unpublish
8
+ - Updated dependencies
9
+ - @dt-dds/react-button@1.0.0-beta.39
10
+
11
+ ## 1.0.0-beta.15
12
+
13
+ ### Major Changes
14
+
15
+ - refactor!: rename pkg and publish to npmjs
16
+
17
+ ### Patch Changes
18
+
19
+ - Updated dependencies
20
+ - @dt-dds/icons@1.0.0-beta.4
21
+ - @dt-dds/react-button@1.0.0-beta.38
22
+ - @dt-dds/react-core@1.0.0-beta.41
23
+ - @dt-dds/react-icon@1.0.0-beta.42
24
+
25
+ ## 0.1.0-beta.14
26
+
27
+ ### Patch Changes
28
+
29
+ - refactor: drop icon funcional state
30
+ - Updated dependencies
31
+ - @dt-ui/react-icon@0.1.0-beta.41
32
+
33
+ ## 0.1.0-beta.13
34
+
35
+ ### Patch Changes
36
+
37
+ - refactor: theme typography values
38
+ - Updated dependencies
39
+ - @dt-ui/react-core@0.1.0-beta.40
40
+ - @dt-ui/react-button@0.1.0-beta.37
41
+ - @dt-ui/react-icon@0.1.0-beta.40
42
+
43
+ ## 0.1.0-beta.12
44
+
45
+ ### Minor Changes
46
+
47
+ - feat: update shadow theme values
48
+
49
+ ### Patch Changes
50
+
51
+ - Updated dependencies
52
+ - @dt-ui/react-core@0.1.0-beta.39
53
+ - @dt-ui/react-button@0.1.0-beta.36
54
+ - @dt-ui/react-icon@0.1.0-beta.39
55
+
56
+ ## 0.1.0-beta.11
57
+
58
+ ### Minor Changes
59
+
60
+ - feat: add new icon font sizes
61
+
62
+ ### Patch Changes
63
+
64
+ - Updated dependencies
65
+ - @dt-ui/react-icon@0.1.0-beta.38
66
+
67
+ ## 0.1.0-beta.10
68
+
69
+ ### Patch Changes
70
+
71
+ - chore: update theme font-styles
72
+ - Updated dependencies
73
+ - @dt-ui/react-core@0.1.0-beta.38
74
+ - @dt-ui/react-button@0.1.0-beta.35
75
+ - @dt-ui/react-icon@0.1.0-beta.37
76
+
77
+ ## 0.1.0-beta.9
78
+
79
+ ### Patch Changes
80
+
81
+ - chore: review OSS files
82
+ - Updated dependencies
83
+ - @dt-ui/icons@0.1.0-beta.3
84
+ - @dt-ui/react-button@0.1.0-beta.34
85
+ - @dt-ui/react-core@0.1.0-beta.37
86
+ - @dt-ui/react-icon@0.1.0-beta.36
87
+
88
+ ## 0.1.0-beta.8
89
+
90
+ ### Minor Changes
91
+
92
+ - feat: add mobile breakpoint for button
93
+
94
+ ### Patch Changes
95
+
96
+ - Updated dependencies
97
+ - @dt-ui/react-button@0.1.0-beta.33
98
+
99
+ ## 0.1.0-beta.7
100
+
101
+ ### Patch Changes
102
+
103
+ - refactor: repalce enum with type
104
+
105
+ ## 0.1.0-beta.6
106
+
107
+ ### Patch Changes
108
+
109
+ - fix: link build
110
+
111
+ ## 0.1.0-beta.5
112
+
113
+ ### Minor Changes
114
+
115
+ - feat: add icon to link
116
+
117
+ ## 0.1.0-beta.4
118
+
119
+ ### Patch Changes
120
+
121
+ - chore: update contextual colors
122
+ - Updated dependencies
123
+ - @dt-ui/react-button@0.1.0-beta.32
124
+ - @dt-ui/react-core@0.1.0-beta.36
125
+
126
+ ## 0.1.0-beta.3
127
+
128
+ ### Minor Changes
129
+
130
+ - feat: add active state to link
131
+
132
+ ## 0.1.0-beta.2
133
+
134
+ ### Minor Changes
135
+
136
+ - feat: update link according to design
137
+
138
+ ## 0.1.0-beta.1
139
+
140
+ ### Patch Changes
141
+
142
+ - chore: link independent pkg
package/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Daimler Truck AG.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,70 @@
1
+ # Link Package
2
+
3
+ The link component is used as a navigational element to navigate users to another location and it allows to easily customize anchor elements.
4
+
5
+ ## Link Usage
6
+
7
+ ```jsx
8
+ import { Link } from '@dt-dds/react-link';
9
+
10
+ export const App = () => {
11
+ return <Link href='/'>Some text</Link>;
12
+ };
13
+ ```
14
+
15
+ ## Properties
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
+
25
+ This component inherits all native anchor properties. [Learn more](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a).
26
+
27
+ ## Stack
28
+
29
+ - [TypeScript](https://www.typescriptlang.org/) for static type checking
30
+ - [React](https://reactjs.org/) — JavaScript library for user interfaces
31
+ - [Emotion](https://emotion.sh/docs/introduction) — for writing css styles with JavaScript
32
+ - [Storybook](https://storybook.js.org/) — UI component environment powered by Vite
33
+ - [Jest](https://jestjs.io/) - JavaScript Testing Framework
34
+ - [React Testing Library](https://testing-library.com/) - to test UI components in a user-centric way
35
+ - [ESLint](https://eslint.org/) for code linting
36
+ - [Prettier](https://prettier.io) for code formatting
37
+ - [Tsup](https://github.com/egoist/tsup) — TypeScript bundler powered by esbuild
38
+ - [Yarn](https://yarnpkg.com/) from managing packages
39
+
40
+ ## Commands
41
+
42
+ - `yarn build` - Build the package
43
+ - `yarn dev` - Run the package locally
44
+ - `yarn lint` - Lint all files within this package
45
+ - `yarn test` - Run all unit tests
46
+ - `yarn test:report` - Open the test coverage report
47
+ - `yarn test:update:snapshot` - Run all unit tests and update the snapshot
48
+
49
+ ## Compilation
50
+
51
+ Running `yarn build` from the root of the package will use [tsup](https://tsup.egoist.dev/) to compile the raw TypeScript and React code to plain JavaScript.
52
+
53
+ The `/dist` folder contains the compiled output.
54
+
55
+ ```bash
56
+ link
57
+ └── dist
58
+ ├── index.d.ts <-- Types
59
+ ├── index.js <-- CommonJS version
60
+ └── index.mjs <-- ES Modules version
61
+ ...
62
+ ```
63
+
64
+ ## Versioning
65
+
66
+ Follows [semantic versioning](https://semver.org/)
67
+
68
+ ## &copy; License
69
+
70
+ Licensed under [MIT License](LICENSE.md)
@@ -0,0 +1,25 @@
1
+ import { BaseProps, Theme } from '@dt-dds/react-core';
2
+ import * as react from 'react';
3
+ import { Code } from '@dt-dds/icons';
4
+ import { IconProps } from '@dt-dds/react-icon';
5
+
6
+ interface LinkProps extends BaseProps, React.AnchorHTMLAttributes<HTMLAnchorElement> {
7
+ isDisabled?: boolean;
8
+ onClick?: () => void;
9
+ size?: LinkSize;
10
+ variant?: LinkVariant;
11
+ icon?: Code;
12
+ }
13
+ declare const Link: react.ForwardRefExoticComponent<LinkProps & react.RefAttributes<HTMLAnchorElement>>;
14
+
15
+ type LinkVariant = 'primary' | 'secondary';
16
+ type LinkSize = 'small' | 'medium' | 'large';
17
+
18
+ declare const iconSize: Record<LinkSize, IconProps['size']>;
19
+
20
+ declare module '@emotion/react' {
21
+ interface Theme extends Theme {
22
+ }
23
+ }
24
+
25
+ export { Link, LinkProps, LinkSize, LinkVariant, iconSize };
package/dist/index.js ADDED
@@ -0,0 +1,169 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __defProps = Object.defineProperties;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
7
+ var __getOwnPropNames = Object.getOwnPropertyNames;
8
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
9
+ var __getProtoOf = Object.getPrototypeOf;
10
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
11
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
12
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
13
+ var __spreadValues = (a, b) => {
14
+ for (var prop in b || (b = {}))
15
+ if (__hasOwnProp.call(b, prop))
16
+ __defNormalProp(a, prop, b[prop]);
17
+ if (__getOwnPropSymbols)
18
+ for (var prop of __getOwnPropSymbols(b)) {
19
+ if (__propIsEnum.call(b, prop))
20
+ __defNormalProp(a, prop, b[prop]);
21
+ }
22
+ return a;
23
+ };
24
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
25
+ var __objRest = (source, exclude) => {
26
+ var target = {};
27
+ for (var prop in source)
28
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
29
+ target[prop] = source[prop];
30
+ if (source != null && __getOwnPropSymbols)
31
+ for (var prop of __getOwnPropSymbols(source)) {
32
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
33
+ target[prop] = source[prop];
34
+ }
35
+ return target;
36
+ };
37
+ var __export = (target, all) => {
38
+ for (var name in all)
39
+ __defProp(target, name, { get: all[name], enumerable: true });
40
+ };
41
+ var __copyProps = (to, from, except, desc) => {
42
+ if (from && typeof from === "object" || typeof from === "function") {
43
+ for (let key of __getOwnPropNames(from))
44
+ if (!__hasOwnProp.call(to, key) && key !== except)
45
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
46
+ }
47
+ return to;
48
+ };
49
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
50
+ // If the importer is in node compatibility mode or this is not an ESM
51
+ // file that has been converted to a CommonJS file using a Babel-
52
+ // compatible transform (i.e. "__esModule" has not been set), then set
53
+ // "default" to the CommonJS "module.exports" for node compatibility.
54
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
55
+ mod
56
+ ));
57
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
58
+
59
+ // index.ts
60
+ var link_exports = {};
61
+ __export(link_exports, {
62
+ Link: () => Link,
63
+ iconSize: () => iconSize
64
+ });
65
+ module.exports = __toCommonJS(link_exports);
66
+
67
+ // src/Link.tsx
68
+ var import_react_icon = require("@dt-dds/react-icon");
69
+ var import_react = require("react");
70
+
71
+ // src/Link.styled.ts
72
+ var import_styled = __toESM(require("@emotion/styled"));
73
+ var LinkStyled = import_styled.default.a`
74
+ ${({ theme, disabled, size, variant = "primary" }) => `
75
+ color: ${theme.palette[variant].default};
76
+ text-decoration: none;
77
+ display: inline-flex;
78
+ align-items: center;
79
+ gap: ${theme.spacing["5xs"]};
80
+
81
+ ${disabled && `
82
+ color: ${theme.palette[variant].light};
83
+ cursor: not-allowed;
84
+ `};
85
+
86
+ ${!disabled && `
87
+ &:hover > span {
88
+ text-decoration: underline;
89
+ }
90
+
91
+ &:active {
92
+ color: ${theme.palette[variant].dark};
93
+ text-decoration: none;
94
+ }
95
+ `};
96
+
97
+ &:focus-visible {
98
+ outline: 2px solid ${theme.palette.primary.default};
99
+ }
100
+
101
+ ${size == "large" && `
102
+ ${theme.fontStyles.body1Bold}
103
+ `};
104
+
105
+ ${size == "medium" && `
106
+ ${theme.fontStyles.body2Bold}
107
+ `};
108
+
109
+ ${size == "small" && `
110
+ ${theme.fontStyles.body3Bold}
111
+ `};
112
+ `}
113
+ `;
114
+
115
+ // src/Link.tsx
116
+ var import_jsx_runtime = require("react/jsx-runtime");
117
+ var Link = (0, import_react.forwardRef)(
118
+ (_a, ref) => {
119
+ var _b = _a, {
120
+ isDisabled,
121
+ children,
122
+ size = "medium",
123
+ dataTestId,
124
+ onClick,
125
+ variant,
126
+ href,
127
+ style,
128
+ icon
129
+ } = _b, rest = __objRest(_b, [
130
+ "isDisabled",
131
+ "children",
132
+ "size",
133
+ "dataTestId",
134
+ "onClick",
135
+ "variant",
136
+ "href",
137
+ "style",
138
+ "icon"
139
+ ]);
140
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
141
+ LinkStyled,
142
+ __spreadProps(__spreadValues(__spreadValues({
143
+ "data-testid": dataTestId != null ? dataTestId : "link",
144
+ disabled: isDisabled,
145
+ ref,
146
+ size,
147
+ style,
148
+ variant
149
+ }, !isDisabled && { href, onClick }), rest), {
150
+ children: [
151
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children }),
152
+ icon ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_icon.Icon, { code: icon, color: "inherit", size: iconSize[size] }) : null
153
+ ]
154
+ })
155
+ );
156
+ }
157
+ );
158
+
159
+ // src/constants/constants.ts
160
+ var iconSize = {
161
+ small: "xs",
162
+ medium: "s",
163
+ large: "l"
164
+ };
165
+ // Annotate the CommonJS export names for ESM import in node:
166
+ 0 && (module.exports = {
167
+ Link,
168
+ iconSize
169
+ });
package/dist/index.mjs ADDED
@@ -0,0 +1,134 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ var __objRest = (source, exclude) => {
21
+ var target = {};
22
+ for (var prop in source)
23
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
24
+ target[prop] = source[prop];
25
+ if (source != null && __getOwnPropSymbols)
26
+ for (var prop of __getOwnPropSymbols(source)) {
27
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
28
+ target[prop] = source[prop];
29
+ }
30
+ return target;
31
+ };
32
+
33
+ // src/Link.tsx
34
+ import { Icon } from "@dt-dds/react-icon";
35
+ import { forwardRef } from "react";
36
+
37
+ // src/Link.styled.ts
38
+ import styled from "@emotion/styled";
39
+ var LinkStyled = styled.a`
40
+ ${({ theme, disabled, size, variant = "primary" }) => `
41
+ color: ${theme.palette[variant].default};
42
+ text-decoration: none;
43
+ display: inline-flex;
44
+ align-items: center;
45
+ gap: ${theme.spacing["5xs"]};
46
+
47
+ ${disabled && `
48
+ color: ${theme.palette[variant].light};
49
+ cursor: not-allowed;
50
+ `};
51
+
52
+ ${!disabled && `
53
+ &:hover > span {
54
+ text-decoration: underline;
55
+ }
56
+
57
+ &:active {
58
+ color: ${theme.palette[variant].dark};
59
+ text-decoration: none;
60
+ }
61
+ `};
62
+
63
+ &:focus-visible {
64
+ outline: 2px solid ${theme.palette.primary.default};
65
+ }
66
+
67
+ ${size == "large" && `
68
+ ${theme.fontStyles.body1Bold}
69
+ `};
70
+
71
+ ${size == "medium" && `
72
+ ${theme.fontStyles.body2Bold}
73
+ `};
74
+
75
+ ${size == "small" && `
76
+ ${theme.fontStyles.body3Bold}
77
+ `};
78
+ `}
79
+ `;
80
+
81
+ // src/Link.tsx
82
+ import { jsx, jsxs } from "react/jsx-runtime";
83
+ var Link = forwardRef(
84
+ (_a, ref) => {
85
+ var _b = _a, {
86
+ isDisabled,
87
+ children,
88
+ size = "medium",
89
+ dataTestId,
90
+ onClick,
91
+ variant,
92
+ href,
93
+ style,
94
+ icon
95
+ } = _b, rest = __objRest(_b, [
96
+ "isDisabled",
97
+ "children",
98
+ "size",
99
+ "dataTestId",
100
+ "onClick",
101
+ "variant",
102
+ "href",
103
+ "style",
104
+ "icon"
105
+ ]);
106
+ return /* @__PURE__ */ jsxs(
107
+ LinkStyled,
108
+ __spreadProps(__spreadValues(__spreadValues({
109
+ "data-testid": dataTestId != null ? dataTestId : "link",
110
+ disabled: isDisabled,
111
+ ref,
112
+ size,
113
+ style,
114
+ variant
115
+ }, !isDisabled && { href, onClick }), rest), {
116
+ children: [
117
+ /* @__PURE__ */ jsx("span", { children }),
118
+ icon ? /* @__PURE__ */ jsx(Icon, { code: icon, color: "inherit", size: iconSize[size] }) : null
119
+ ]
120
+ })
121
+ );
122
+ }
123
+ );
124
+
125
+ // src/constants/constants.ts
126
+ var iconSize = {
127
+ small: "xs",
128
+ medium: "s",
129
+ large: "l"
130
+ };
131
+ export {
132
+ Link,
133
+ iconSize
134
+ };
package/package.json ADDED
@@ -0,0 +1,57 @@
1
+ {
2
+ "name": "@dt-dds/react-link",
3
+ "version": "1.0.0-beta.16",
4
+ "license": "MIT",
5
+ "exports": {
6
+ ".": "./dist/index.js"
7
+ },
8
+ "main": "./dist/index.js",
9
+ "module": "./dist/index.mjs",
10
+ "types": "./dist/index.d.ts",
11
+ "files": [
12
+ "dist/**"
13
+ ],
14
+ "scripts": {
15
+ "build": "tsup",
16
+ "dev": "tsup --watch",
17
+ "lint": "eslint --cache .",
18
+ "test": "jest",
19
+ "test:report": "open ./jest-coverage/lcov-report/index.html",
20
+ "test:update:snapshot": "jest -u"
21
+ },
22
+ "dependencies": {
23
+ "@dt-dds/icons": "1.0.0-beta.4",
24
+ "@dt-dds/react-button": "1.0.0-beta.39",
25
+ "@dt-dds/react-core": "1.0.0-beta.41",
26
+ "@dt-dds/react-icon": "1.0.0-beta.42"
27
+ },
28
+ "devDependencies": {
29
+ "@babel/core": "^7.22.9",
30
+ "@babel/preset-env": "^7.22.9",
31
+ "@babel/preset-react": "^7.22.5",
32
+ "@babel/preset-typescript": "^7.23.3",
33
+ "@emotion/babel-plugin": "^11.11.0",
34
+ "@emotion/css": "^11.7.1",
35
+ "@emotion/jest": "^11.10.0",
36
+ "@emotion/react": "^11.8.2",
37
+ "@emotion/styled": "^11.8.1",
38
+ "@types/react": "^18.0.9",
39
+ "@types/react-dom": "^18.0.4",
40
+ "babel-loader": "^8.3.0",
41
+ "eslint-config-custom": "*",
42
+ "eslint-plugin-storybook": "^9.1.0",
43
+ "jest-config": "*",
44
+ "react": "^18.1.0",
45
+ "react-dom": "^18.2.0",
46
+ "tsconfig": "*",
47
+ "tsup": "^6.6.3",
48
+ "typescript": "^4.5.3"
49
+ },
50
+ "peerDependencies": {
51
+ "@emotion/css": "^11.7.1",
52
+ "@emotion/react": "^11.8.2",
53
+ "@emotion/styled": "^11.8.1",
54
+ "react": ">=17.0.2",
55
+ "react-dom": ">=17.0.2"
56
+ }
57
+ }