@bonprix-ds/react-link 1.0.2 → 1.0.3

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/dist/index.js CHANGED
@@ -1,69 +1,2 @@
1
- import "react";
2
- import { tv as e } from "tailwind-variants";
3
- import t from "@bonprix-ds/react-icon";
4
- import { Fragment as n, jsx as r, jsxs as i } from "react/jsx-runtime";
5
- //#region src/Link.tsx
6
- var a = e({
7
- base: ["preflight rounded-sm inline-flex before:content-['_'] before:whitespace-pre before:w-0 relative items-center", "focus-visible:outline outline-2 outline-offset-2 group"],
8
- slots: {
9
- icon: "h-4 w-4 inline-block",
10
- label: "typography-link-large underline underline-offset-2 hover:decoration-2 group-focus-visible:no-underline"
11
- },
12
- variants: {
13
- small: { true: { label: "typography-link-small" } },
14
- hideUnderline: { true: { label: "no-underline hover:underline" } },
15
- arrowPosition: {
16
- left: "",
17
- right: "flex-row-reverse justify-end"
18
- },
19
- inverted: {
20
- false: {
21
- base: "focus-visible:outline-clr-primary",
22
- icon: "fill-clr-primary",
23
- label: "text-clr-primary"
24
- },
25
- true: {
26
- base: "focus-visible:outline-clr-primary-inverse",
27
- icon: "fill-clr-primary-inverse",
28
- label: "text-clr-primary-inverse"
29
- }
30
- }
31
- }
32
- }), o = ({ children: e, small: o = !1, hideUnderline: s = !1, showArrow: c = !1, arrowPosition: l = "left", srLabel: u, inverted: d, component: f = "a", ...p }) => {
33
- let m = f, h = f === "button" ? { type: "button" } : {}, { base: g, icon: _, label: v } = a({
34
- small: o,
35
- hideUnderline: s,
36
- arrowPosition: l,
37
- inverted: d
38
- }), y = /* @__PURE__ */ i(n, { children: [
39
- c && /* @__PURE__ */ r(t, {
40
- variant: l === "left" ? "arrow-left" : "arrow-right",
41
- className: _()
42
- }),
43
- u && /* @__PURE__ */ r("span", {
44
- className: "sr-only",
45
- children: u
46
- }),
47
- /* @__PURE__ */ r("span", {
48
- "aria-hidden": u ? "true" : void 0,
49
- className: v(),
50
- children: e
51
- })
52
- ] });
53
- return /* @__PURE__ */ r(m, {
54
- ...p,
55
- ...h,
56
- className: g(),
57
- "data-bpds": "link",
58
- "data-bpds-small": o,
59
- "data-bpds-hide-underline": s,
60
- "data-bpds-arrow-position": l,
61
- "data-bpds-show-arrow": c,
62
- "data-bpds-inverted": d,
63
- children: y
64
- });
65
- };
66
- //#endregion
67
- export { o as default };
68
-
69
- //# sourceMappingURL=index.js.map
1
+ import e from "./src/Link.js";
2
+ export { e as default };
@@ -0,0 +1,69 @@
1
+ import "react";
2
+ import { tv as e } from "tailwind-variants";
3
+ import t from "@bonprix-ds/react-icon";
4
+ import { Fragment as n, jsx as r, jsxs as i } from "react/jsx-runtime";
5
+ //#region src/Link.tsx
6
+ var a = e({
7
+ base: ["preflight relative inline-flex items-center rounded-sm before:w-0 before:whitespace-pre before:content-['_']", "group outline-2 outline-offset-2 focus-visible:outline"],
8
+ slots: {
9
+ icon: "inline-block h-4 w-4",
10
+ label: "typography-link-large underline underline-offset-2 hover:decoration-2 group-focus-visible:no-underline"
11
+ },
12
+ variants: {
13
+ small: { true: { label: "typography-link-small" } },
14
+ hideUnderline: { true: { label: "no-underline hover:underline" } },
15
+ arrowPosition: {
16
+ left: "",
17
+ right: "flex-row-reverse justify-end"
18
+ },
19
+ inverted: {
20
+ false: {
21
+ base: "focus-visible:outline-clr-primary",
22
+ icon: "fill-clr-primary",
23
+ label: "text-clr-primary"
24
+ },
25
+ true: {
26
+ base: "focus-visible:outline-clr-primary-inverse",
27
+ icon: "fill-clr-primary-inverse",
28
+ label: "text-clr-primary-inverse"
29
+ }
30
+ }
31
+ }
32
+ }), o = ({ children: e, small: o = !1, hideUnderline: s = !1, showArrow: c = !1, arrowPosition: l = "left", srLabel: u, inverted: d, component: f = "a", ...p }) => {
33
+ let m = f, h = f === "button" ? { type: "button" } : {}, { base: g, icon: _, label: v } = a({
34
+ small: o,
35
+ hideUnderline: s,
36
+ arrowPosition: l,
37
+ inverted: d
38
+ }), y = /* @__PURE__ */ i(n, { children: [
39
+ c && /* @__PURE__ */ r(t, {
40
+ variant: l === "left" ? "arrow-left" : "arrow-right",
41
+ className: _()
42
+ }),
43
+ u && /* @__PURE__ */ r("span", {
44
+ className: "sr-only",
45
+ children: u
46
+ }),
47
+ /* @__PURE__ */ r("span", {
48
+ "aria-hidden": u ? "true" : void 0,
49
+ className: v(),
50
+ children: e
51
+ })
52
+ ] });
53
+ return /* @__PURE__ */ r(m, {
54
+ ...p,
55
+ ...h,
56
+ className: g(),
57
+ "data-bpds": "link",
58
+ "data-bpds-small": o,
59
+ "data-bpds-hide-underline": s,
60
+ "data-bpds-arrow-position": l,
61
+ "data-bpds-show-arrow": c,
62
+ "data-bpds-inverted": d,
63
+ children: y
64
+ });
65
+ };
66
+ //#endregion
67
+ export { o as default };
68
+
69
+ //# sourceMappingURL=Link.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Link.js","names":["_Fragment","Icon","generateClasses","tv","Link","props","Component","component","buttonDefaultProps","content","Fragment","showArrow","arrowPosition","icon","srLabel","label","base","small","hideUnderline","inverted"],"sources":["../../src/Link.tsx"],"sourcesContent":["import type { ComponentProps, ElementType } from \"react\";\nimport React from \"react\";\nimport { tv } from \"tailwind-variants\";\n\nimport Icon from \"@bonprix-ds/react-icon\";\n\nconst generateClasses = tv({\n /* the before: styles are used to create content that allows proper baseline alignment when suing inline-flex elements with text:\n https://stackoverflow.com/questions/73715565/how-to-get-a-flex-item-to-participate-in-baseline-alignment-and-be-centered\n https://www.w3.org/TR/css-flexbox-1/#flex-baselines\n */\n base: [\n \"preflight relative inline-flex items-center rounded-sm before:w-0 before:whitespace-pre before:content-['_']\",\n \"group outline-2 outline-offset-2 focus-visible:outline\",\n ],\n slots: {\n icon: \"inline-block h-4 w-4\",\n label: \"typography-link-large underline underline-offset-2 hover:decoration-2 group-focus-visible:no-underline\",\n },\n variants: {\n small: {\n true: {\n label: \"typography-link-small\",\n },\n },\n hideUnderline: {\n true: {\n label: \"no-underline hover:underline\",\n },\n },\n arrowPosition: {\n left: \"\",\n right: \"flex-row-reverse justify-end\",\n },\n inverted: {\n false: {\n base: \"focus-visible:outline-clr-primary\",\n icon: \"fill-clr-primary\",\n label: \"text-clr-primary\",\n },\n true: {\n base: \"focus-visible:outline-clr-primary-inverse\",\n icon: \"fill-clr-primary-inverse\",\n label: \"text-clr-primary-inverse\",\n },\n },\n },\n});\n\ninterface BaseProps {\n /** The content of the link. */\n children: string;\n /** if `true`, an arrow will be shown in the end of the content. */\n showArrow?: boolean;\n /** The position of the arrow, if `showArrow` is set to `true`. */\n arrowPosition?: \"left\" | \"right\";\n /* If set to `true`, the link will match `body2`, otherwise `body1`. */\n small?: boolean;\n /** If set to `true`, the underline will be hidden. */\n hideUnderline?: boolean;\n /** Alternative label for the screen reader. This can for example be used, if a proper name cannot be setup because of the position in the text. */\n srLabel?: string;\n /** If `true`, inverts the colors of the component. */\n inverted?: boolean;\n}\n\nexport type Props<C extends ElementType = \"a\"> = BaseProps & {\n /** The semantic component to render the Link. Preferrably `\"a\"`, `\"button\"` or something like `Link` from NextJS. Native props will be passed to this component. */\n component?: C;\n} & Omit<ComponentProps<C>, keyof BaseProps | \"component\">;\n\nconst Link = <C extends ElementType>({\n children,\n small = false,\n hideUnderline = false,\n showArrow = false,\n arrowPosition = \"left\",\n srLabel,\n inverted,\n component = \"a\" as C,\n ...props\n}: Props<C>) => {\n const Component: ElementType = component;\n const buttonDefaultProps = component === \"button\" ? { type: \"button\" } : {};\n\n const { base, icon, label } = generateClasses({ small, hideUnderline, arrowPosition, inverted });\n\n const content = (\n <>\n {showArrow && <Icon variant={arrowPosition === \"left\" ? \"arrow-left\" : \"arrow-right\"} className={icon()} />}\n {/* We need to style decoration-thickness directly on the label.\n Otherwise it wont be propagated because of the inline-flex on the anchor element */}\n {srLabel && <span className=\"sr-only\">{srLabel}</span>}\n <span aria-hidden={srLabel ? \"true\" : undefined} className={label()}>\n {children}\n </span>\n </>\n );\n\n return (\n <Component\n {...props}\n {...buttonDefaultProps}\n className={base()}\n data-bpds=\"link\"\n data-bpds-small={small}\n data-bpds-hide-underline={hideUnderline}\n data-bpds-arrow-position={arrowPosition}\n data-bpds-show-arrow={showArrow}\n data-bpds-inverted={inverted}\n >\n {content}\n </Component>\n );\n};\n\nexport default Link;\n"],"mappings":";;;;;AAMA,IAAME,IAAkBC,EAAG;CAKzB,MAAM,CACJ,gHACA,wDACF;CACA,OAAO;EACL,MAAM;EACN,OAAO;CACT;CACA,UAAU;EACR,OAAO,EACL,MAAM,EACJ,OAAO,wBACT,EACF;EACA,eAAe,EACb,MAAM,EACJ,OAAO,+BACT,EACF;EACA,eAAe;GACb,MAAM;GACN,OAAO;EACT;EACA,UAAU;GACR,OAAO;IACL,MAAM;IACN,MAAM;IACN,OAAO;GACT;GACA,MAAM;IACJ,MAAM;IACN,MAAM;IACN,OAAO;GACT;EACF;CACF;AACF,CAAC,GAwBKC,KAA+B,EACnC,aACA,WAAQ,IACR,mBAAgB,IAChB,eAAY,IACZ,mBAAgB,QAChB,YACA,aACA,eAAY,KACZ,GAAGC,QACW;CACd,IAAMC,IAAyBC,GACzBC,IAAqBD,MAAc,WAAW,EAAE,MAAM,SAAS,IAAI,CAAC,GAEpE,EAAE,SAAM,SAAM,aAAUL,EAAgB;EAAE;EAAO;EAAe;EAAe;CAAS,CAAC,GAEzFO,IACJ,kBAAAT,GAAA,EAAA,UAAA;EACGW,KAAa,kBAACV,GAAD;GAAM,SAASW,MAAkB,SAAS,eAAe;GAAe,WAAWC,EAAK;EAAI,CAAA;EAGzGC,KAAW,kBAAC,QAAD;GAAM,WAAU;GAAW,UAAAA;EAAc,CAAA;EACrD,kBAAC,QAAD;GAAM,eAAaA,IAAU,SAAS,KAAA;GAAW,WAAWC,EAAM;GAC/D;EACG,CAAA;CACN,EAAA,CAAA;CAGJ,OACE,kBAACT,GAAD;EACE,GAAID;EACJ,GAAIG;EACJ,WAAWQ,EAAK;EAChB,aAAU;EACV,mBAAiBC;EACjB,4BAA0BC;EAC1B,4BAA0BN;EAC1B,wBAAsBD;EACtB,sBAAoBQ;EAEnB,UAAAV;CACQ,CAAA;AAEf"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bonprix-ds/react-link",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "Link component, implemented in React, for the Bonprix Design System.",
5
5
  "keywords": [],
6
6
  "license": "UNLICENSED",
@@ -32,18 +32,17 @@
32
32
  "provenance": true
33
33
  },
34
34
  "dependencies": {
35
- "@bonprix-ds/react-icon": "1.2.1",
36
- "@bonprix-ds/utils": "0.2.2"
35
+ "@bonprix-ds/utils": "0.3.0",
36
+ "@bonprix-ds/react-icon": "1.2.2"
37
37
  },
38
38
  "devDependencies": {
39
39
  "@types/react": "19.3.0",
40
- "@vitejs/plugin-react": "6.1.1",
41
- "rollup-preserve-directives": "1.1.3",
42
- "vite": "8.3.0"
40
+ "vite": "8.3.2",
41
+ "@bonprix-ds/vite-config": "0.0.0"
43
42
  },
44
43
  "peerDependencies": {
45
- "react": "^19.3.0",
46
- "react-dom": "^19.3.0",
44
+ "react": "^19",
45
+ "react-dom": "^19",
47
46
  "tailwind-variants": "0.3.1"
48
47
  },
49
48
  "scripts": {
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/Link.tsx"],"sourcesContent":["import type { ComponentProps, ElementType } from \"react\";\nimport React from \"react\";\nimport { tv } from \"tailwind-variants\";\n\nimport Icon from \"@bonprix-ds/react-icon\";\n\nconst generateClasses = tv({\n /* the before: styles are used to create content that allows proper baseline alignment when suing inline-flex elements with text:\n https://stackoverflow.com/questions/73715565/how-to-get-a-flex-item-to-participate-in-baseline-alignment-and-be-centered\n https://www.w3.org/TR/css-flexbox-1/#flex-baselines\n */\n base: [\n \"preflight rounded-sm inline-flex before:content-['_'] before:whitespace-pre before:w-0 relative items-center\",\n \"focus-visible:outline outline-2 outline-offset-2 group\",\n ],\n slots: {\n icon: \"h-4 w-4 inline-block\",\n label: \"typography-link-large underline underline-offset-2 hover:decoration-2 group-focus-visible:no-underline\",\n },\n variants: {\n small: {\n true: {\n label: \"typography-link-small\",\n },\n },\n hideUnderline: {\n true: {\n label: \"no-underline hover:underline\",\n },\n },\n arrowPosition: {\n left: \"\",\n right: \"flex-row-reverse justify-end\",\n },\n inverted: {\n false: {\n base: \"focus-visible:outline-clr-primary\",\n icon: \"fill-clr-primary\",\n label: \"text-clr-primary\",\n },\n true: {\n base: \"focus-visible:outline-clr-primary-inverse\",\n icon: \"fill-clr-primary-inverse\",\n label: \"text-clr-primary-inverse\",\n },\n },\n },\n});\n\ninterface BaseProps {\n /** The content of the link. */\n children: string;\n /** if `true`, an arrow will be shown in the end of the content. */\n showArrow?: boolean;\n /** The position of the arrow, if `showArrow` is set to `true`. */\n arrowPosition?: \"left\" | \"right\";\n /* If set to `true`, the link will match `body2`, otherwise `body1`. */\n small?: boolean;\n /** If set to `true`, the underline will be hidden. */\n hideUnderline?: boolean;\n /** Alternative label for the screen reader. This can for example be used, if a proper name cannot be setup because of the position in the text. */\n srLabel?: string;\n /** If `true`, inverts the colors of the component. */\n inverted?: boolean;\n}\n\nexport type Props<C extends ElementType = \"a\"> = BaseProps & {\n /** The semantic component to render the Link. Preferrably `\"a\"`, `\"button\"` or something like `Link` from NextJS. Native props will be passed to this component. */\n component?: C;\n} & Omit<ComponentProps<C>, keyof BaseProps | \"component\">;\n\nconst Link = <C extends ElementType>({\n children,\n small = false,\n hideUnderline = false,\n showArrow = false,\n arrowPosition = \"left\",\n srLabel,\n inverted,\n component = \"a\" as C,\n ...props\n}: Props<C>) => {\n const Component: ElementType = component;\n const buttonDefaultProps = component === \"button\" ? { type: \"button\" } : {};\n\n const { base, icon, label } = generateClasses({ small, hideUnderline, arrowPosition, inverted });\n\n const content = (\n <>\n {showArrow && <Icon variant={arrowPosition === \"left\" ? \"arrow-left\" : \"arrow-right\"} className={icon()} />}\n {/* We need to style decoration-thickness directly on the label.\n Otherwise it wont be propagated because of the inline-flex on the anchor element */}\n {srLabel && <span className=\"sr-only\">{srLabel}</span>}\n <span aria-hidden={srLabel ? \"true\" : undefined} className={label()}>\n {children}\n </span>\n </>\n );\n\n return (\n <Component\n {...props}\n {...buttonDefaultProps}\n className={base()}\n data-bpds=\"link\"\n data-bpds-small={small}\n data-bpds-hide-underline={hideUnderline}\n data-bpds-arrow-position={arrowPosition}\n data-bpds-show-arrow={showArrow}\n data-bpds-inverted={inverted}\n >\n {content}\n </Component>\n );\n};\n\nexport default Link;\n"],"mappings":";;;;;AAMA,IAAM,IAAkB,EAAG;CAKzB,MAAM,CACJ,gHACA,wDACF;CACA,OAAO;EACL,MAAM;EACN,OAAO;CACT;CACA,UAAU;EACR,OAAO,EACL,MAAM,EACJ,OAAO,wBACT,EACF;EACA,eAAe,EACb,MAAM,EACJ,OAAO,+BACT,EACF;EACA,eAAe;GACb,MAAM;GACN,OAAO;EACT;EACA,UAAU;GACR,OAAO;IACL,MAAM;IACN,MAAM;IACN,OAAO;GACT;GACA,MAAM;IACJ,MAAM;IACN,MAAM;IACN,OAAO;GACT;EACF;CACF;AACF,CAAC,GAwBK,KAA+B,EACnC,aACA,WAAQ,IACR,mBAAgB,IAChB,eAAY,IACZ,mBAAgB,QAChB,YACA,aACA,eAAY,KACZ,GAAG,QACW;CACd,IAAM,IAAyB,GACzB,IAAqB,MAAc,WAAW,EAAE,MAAM,SAAS,IAAI,CAAC,GAEpE,EAAE,SAAM,SAAM,aAAU,EAAgB;EAAE;EAAO;EAAe;EAAe;CAAS,CAAC,GAEzF,IACJ,kBAAA,GAAA,EAAA,UAAA;EACG,KAAa,kBAAC,GAAD;GAAM,SAAS,MAAkB,SAAS,eAAe;GAAe,WAAW,EAAK;EAAI,CAAA;EAGzG,KAAW,kBAAC,QAAD;GAAM,WAAU;GAAW,UAAA;EAAc,CAAA;EACrD,kBAAC,QAAD;GAAM,eAAa,IAAU,SAAS,KAAA;GAAW,WAAW,EAAM;GAC/D;EACG,CAAA;CACN,EAAA,CAAA;CAGJ,OACE,kBAAC,GAAD;EACE,GAAI;EACJ,GAAI;EACJ,WAAW,EAAK;EAChB,aAAU;EACV,mBAAiB;EACjB,4BAA0B;EAC1B,4BAA0B;EAC1B,wBAAsB;EACtB,sBAAoB;EAEnB,UAAA;CACQ,CAAA;AAEf"}