@bonprix-ds/react-link 1.0.4 → 1.0.6

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.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  export { default } from "./src/Link";
2
- export type { Props as LinkProps } from "./src/Link";
2
+ export type { LinkBaseProps, Props as LinkProps } from "./src/Link";
@@ -1,12 +1,13 @@
1
1
  import type { ComponentProps, ElementType } from "react";
2
2
  import React from "react";
3
- interface BaseProps {
3
+ export interface LinkBaseProps {
4
4
  /** The content of the link. */
5
5
  children: string;
6
- /** if `true`, an arrow will be shown in the end of the content. */
6
+ /** If `true`, an arrow will be shown before or after the content, depending on `arrowPosition`. */
7
7
  showArrow?: boolean;
8
8
  /** The position of the arrow, if `showArrow` is set to `true`. */
9
9
  arrowPosition?: "left" | "right";
10
+ /** If set to `true`, the link will match `body2`, otherwise `body1`. */
10
11
  small?: boolean;
11
12
  /** If set to `true`, the underline will be hidden. */
12
13
  hideUnderline?: boolean;
@@ -15,9 +16,9 @@ interface BaseProps {
15
16
  /** If `true`, inverts the colors of the component. */
16
17
  inverted?: boolean;
17
18
  }
18
- export type Props<C extends ElementType = "a"> = BaseProps & {
19
- /** The semantic component to render the Link. Preferrably `"a"`, `"button"` or something like `Link` from NextJS. Native props will be passed to this component. */
19
+ export type Props<C extends ElementType = "a"> = LinkBaseProps & {
20
+ /** The semantic component to render the Link. Preferably `"a"`, `"button"` or something like `Link` from NextJS. Native props will be passed to this component. */
20
21
  component?: C;
21
- } & Omit<ComponentProps<C>, keyof BaseProps | "component">;
22
+ } & Omit<ComponentProps<C>, keyof LinkBaseProps | "component">;
22
23
  declare const Link: <C extends ElementType>({ children, small, hideUnderline, showArrow, arrowPosition, srLabel, inverted, component, ...props }: Props<C>) => React.JSX.Element;
23
24
  export default Link;
package/dist/src/Link.js CHANGED
@@ -12,10 +12,6 @@ var o = e({
12
12
  variants: {
13
13
  small: { true: { label: "typography-link-small" } },
14
14
  hideUnderline: { true: { label: "no-underline hover:underline" } },
15
- arrowPosition: {
16
- left: "",
17
- right: "flex-row-reverse justify-end"
18
- },
19
15
  inverted: {
20
16
  false: {
21
17
  base: "focus-visible:outline-clr-primary",
@@ -33,10 +29,9 @@ var o = e({
33
29
  let h = p, g = p === "button" ? { type: "button" } : {}, { base: _, icon: v, label: y } = o({
34
30
  small: s,
35
31
  hideUnderline: c,
36
- arrowPosition: u,
37
32
  inverted: f
38
33
  }), b = /* @__PURE__ */ a(r, { children: [
39
- l && i(u === "left" ? t : n, { className: v() }),
34
+ l && u === "left" && /* @__PURE__ */ i(t, { className: v() }),
40
35
  d && /* @__PURE__ */ i("span", {
41
36
  className: "sr-only",
42
37
  children: d
@@ -45,7 +40,8 @@ var o = e({
45
40
  "aria-hidden": d ? "true" : void 0,
46
41
  className: y(),
47
42
  children: e
48
- })
43
+ }),
44
+ l && u === "right" && /* @__PURE__ */ i(n, { className: v() })
49
45
  ] });
50
46
  return /* @__PURE__ */ i(h, {
51
47
  ...m,
@@ -1 +1 @@
1
- {"version":3,"file":"Link.js","names":["_Fragment","generateClasses","tv","Link","props","Component","component","buttonDefaultProps","content","Fragment","showArrow","jsx","arrowPosition","ArrowLeftIcon","ArrowRightIcon","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 { ArrowLeftIcon, ArrowRightIcon } from \"@bonprix-ds/react-icon/icons\";\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 && (arrowPosition === \"left\" ? <ArrowLeftIcon className={icon()} /> : <ArrowRightIcon 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,IAAMC,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,kBAAAR,GAAA,EAAA,UAAA;EACGU,KAAyCC,EAA3BC,MAAkB,SAAUC,IAAuCC,GAAxC,EAAe,WAAWC,EAAK,EAAI,CAAwC;EAGpHC,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,kBAACZ,GAAD;EACE,GAAID;EACJ,GAAIG;EACJ,WAAWW,EAAK;EAChB,aAAU;EACV,mBAAiBC;EACjB,4BAA0BC;EAC1B,4BAA0BR;EAC1B,wBAAsBF;EACtB,sBAAoBW;EAEnB,UAAAb;CACQ,CAAA;AAEf"}
1
+ {"version":3,"file":"Link.js","names":["_Fragment","generateClasses","tv","Link","props","Component","component","buttonDefaultProps","content","Fragment","showArrow","arrowPosition","ArrowLeftIcon","icon","srLabel","label","ArrowRightIcon","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 { ArrowLeftIcon, ArrowRightIcon } from \"@bonprix-ds/react-icon/icons\";\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 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\nexport interface LinkBaseProps {\n /** The content of the link. */\n children: string;\n /** If `true`, an arrow will be shown before or after the content, depending on `arrowPosition`. */\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\"> = LinkBaseProps & {\n /** The semantic component to render the Link. Preferably `\"a\"`, `\"button\"` or something like `Link` from NextJS. Native props will be passed to this component. */\n component?: C;\n} & Omit<ComponentProps<C>, keyof LinkBaseProps | \"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, inverted });\n\n const content = (\n <>\n {showArrow && arrowPosition === \"left\" && <ArrowLeftIcon 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 {showArrow && arrowPosition === \"right\" && <ArrowRightIcon className={icon()} />}\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,IAAMC,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,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;CAAS,CAAC,GAE1EO,IACJ,kBAAAR,GAAA,EAAA,UAAA;EACGU,KAAaC,MAAkB,UAAU,kBAACC,GAAD,EAAe,WAAWC,EAAK,EAAI,CAAA;EAG5EC,KAAW,kBAAC,QAAD;GAAM,WAAU;GAAW,UAAAA;EAAc,CAAA;EACrD,kBAAC,QAAD;GAAM,eAAaA,IAAU,SAAS,KAAA;GAAW,WAAWC,EAAM;GAC/D;EACG,CAAA;EACLL,KAAaC,MAAkB,WAAW,kBAACK,GAAD,EAAgB,WAAWH,EAAK,EAAI,CAAA;CAC/E,EAAA,CAAA;CAGJ,OACE,kBAACR,GAAD;EACE,GAAID;EACJ,GAAIG;EACJ,WAAWU,EAAK;EAChB,aAAU;EACV,mBAAiBC;EACjB,4BAA0BC;EAC1B,4BAA0BR;EAC1B,wBAAsBD;EACtB,sBAAoBU;EAEnB,UAAAZ;CACQ,CAAA;AAEf"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bonprix-ds/react-link",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "Link component, implemented in React, for the Bonprix Design System.",
5
5
  "keywords": [],
6
6
  "license": "UNLICENSED",
@@ -32,12 +32,12 @@
32
32
  "provenance": true
33
33
  },
34
34
  "dependencies": {
35
- "@bonprix-ds/react-icon": "1.3.0",
36
- "@bonprix-ds/utils": "0.4.0"
35
+ "@bonprix-ds/react-icon": "1.3.2",
36
+ "@bonprix-ds/utils": "0.5.0"
37
37
  },
38
38
  "devDependencies": {
39
39
  "@types/react": "19.3.0",
40
- "vite": "8.3.2",
40
+ "vite": "8.3.3",
41
41
  "@bonprix-ds/vite-config": "0.0.0"
42
42
  },
43
43
  "peerDependencies": {