@bonprix-ds/react-link-group 1.0.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,29 @@
1
+ import { ComponentProps } from 'react';
2
+ import { default as default_2 } from 'react';
3
+ import { ElementType } from 'react';
4
+ import { ReactNode } from 'react';
5
+
6
+ declare interface BaseItemProps {
7
+ /** The content of the link. */
8
+ children: string;
9
+ /** Whether the link is the current page. Will be used to set the `aria-current` attribute. */
10
+ current?: boolean;
11
+ }
12
+
13
+ declare type ItemProps<C extends ElementType> = BaseItemProps & {
14
+ /** The semantic component to render the LinkGroup.Item. Preferrably `"a"` or something like `Link` from NextJS. Native props will be passed to this component. */
15
+ component?: C;
16
+ } & Omit<ComponentProps<C>, keyof BaseItemProps | "component">;
17
+
18
+ declare const LinkGroup: {
19
+ ({ children }: LinkGroupProps): default_2.JSX.Element;
20
+ Item: <C extends ElementType>({ children, current, component, ...props }: ItemProps<C>) => default_2.JSX.Element;
21
+ };
22
+ export default LinkGroup;
23
+
24
+ export declare interface LinkGroupProps {
25
+ /** The content of the LinkGroup. Only put `LinkGroup.Item`s inside. */
26
+ children: ReactNode;
27
+ }
28
+
29
+ export { }
package/dist/index.js ADDED
@@ -0,0 +1,46 @@
1
+ import { tabStyleContainerBase as e, tabStyleContainerVariant as t, tabStyleLabelClass as n, tabStyleLabelContainerBase as r, tabStyleLabelContainerVariant as i, tabStyleList as a } from "@bonprix-ds/internal-components";
2
+ import "react";
3
+ import { tv as o } from "tailwind-variants";
4
+ import { jsx as s } from "react/jsx-runtime";
5
+ //#region src/LinkGroup.tsx
6
+ var c = o({ base: a }), l = ({ children: e }) => /* @__PURE__ */ s("nav", {
7
+ "data-bpds": "link-group",
8
+ className: "preflight",
9
+ children: /* @__PURE__ */ s("ul", {
10
+ className: c(),
11
+ children: e
12
+ })
13
+ }), u = o({
14
+ slots: {
15
+ item: "flex",
16
+ link: [e, t],
17
+ linkLabel: [
18
+ r,
19
+ i,
20
+ n
21
+ ]
22
+ },
23
+ variants: { current: {
24
+ true: { link: "after:border-b-4 after:h-1 after:border-current" },
25
+ false: { link: "hover:after:border-b-2 hover:after:border-current" }
26
+ } }
27
+ });
28
+ l.Item = ({ children: e, current: t = !1, component: n = "a", ...r }) => {
29
+ let i = n, { link: a, item: o, linkLabel: c } = u({ current: t });
30
+ return /* @__PURE__ */ s("li", {
31
+ className: o(),
32
+ children: /* @__PURE__ */ s(i, {
33
+ className: a(),
34
+ ...r,
35
+ "aria-current": t ? "page" : void 0,
36
+ children: /* @__PURE__ */ s("span", {
37
+ className: c(),
38
+ children: e
39
+ })
40
+ })
41
+ });
42
+ };
43
+ //#endregion
44
+ export { l as default };
45
+
46
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/LinkGroup.tsx"],"sourcesContent":["import {\n tabStyleContainerBase,\n tabStyleContainerVariant,\n tabStyleLabelClass,\n tabStyleLabelContainerBase,\n tabStyleLabelContainerVariant,\n tabStyleList,\n} from \"@bonprix-ds/internal-components\";\nimport React, { ComponentProps, ElementType, ReactNode } from \"react\";\nimport { tv } from \"tailwind-variants\";\n\nexport interface Props {\n /** The content of the LinkGroup. Only put `LinkGroup.Item`s inside. */\n children: ReactNode;\n}\n\nconst generateListClasses = tv({\n base: tabStyleList,\n});\n\nconst LinkGroup = ({ children }: Props) => {\n return (\n <nav data-bpds=\"link-group\" className=\"preflight\">\n <ul className={generateListClasses()}>{children}</ul>\n </nav>\n );\n};\n\n// The links in this component are used in a group on our page, so we exclude `rel` and `target` intentionally here.\ninterface BaseItemProps {\n /** The content of the link. */\n children: string;\n /** Whether the link is the current page. Will be used to set the `aria-current` attribute. */\n current?: boolean;\n}\n\ntype ItemProps<C extends ElementType> = BaseItemProps & {\n /** The semantic component to render the LinkGroup.Item. Preferrably `\"a\"` or something like `Link` from NextJS. Native props will be passed to this component. */\n component?: C;\n} & Omit<ComponentProps<C>, keyof BaseItemProps | \"component\">;\n\nconst generateLinkClasses = tv({\n slots: {\n item: \"flex\",\n link: [tabStyleContainerBase, tabStyleContainerVariant],\n linkLabel: [tabStyleLabelContainerBase, tabStyleLabelContainerVariant, tabStyleLabelClass],\n },\n variants: {\n current: {\n true: {\n link: \"after:border-b-4 after:h-1 after:border-current\",\n },\n false: {\n link: \"hover:after:border-b-2 hover:after:border-current\",\n },\n },\n },\n});\n\nconst Item = <C extends ElementType>({ children, current = false, component = \"a\" as C, ...props }: ItemProps<C>) => {\n const Component: ElementType = component;\n const { link, item, linkLabel } = generateLinkClasses({ current });\n return (\n <li className={item()}>\n <Component className={link()} {...props} aria-current={current ? \"page\" : undefined}>\n <span className={linkLabel()}>{children}</span>\n </Component>\n </li>\n );\n};\n\nLinkGroup.Item = Item;\n\nexport default LinkGroup;\n"],"mappings":";;;;;AAgBA,IAAM,IAAsB,EAAG,EAC7B,MAAM,EACR,CAAC,GAEK,KAAa,EAAE,kBAEjB,kBAAC,OAAD;CAAK,aAAU;CAAa,WAAU;CACpC,UAAA,kBAAC,MAAD;EAAI,WAAW,EAAoB;EAAI;CAAa,CAAA;AACjD,CAAA,GAiBH,IAAsB,EAAG;CAC7B,OAAO;EACL,MAAM;EACN,MAAM,CAAC,GAAuB,CAAwB;EACtD,WAAW;GAAC;GAA4B;GAA+B;EAAkB;CAC3F;CACA,UAAU,EACR,SAAS;EACP,MAAM,EACJ,MAAM,kDACR;EACA,OAAO,EACL,MAAM,oDACR;CACF,EACF;AACF,CAAC;AAcD,EAAU,QAZ2B,EAAE,aAAU,aAAU,IAAO,eAAY,KAAU,GAAG,QAA0B;CACnH,IAAM,IAAyB,GACzB,EAAE,SAAM,SAAM,iBAAc,EAAoB,EAAE,WAAQ,CAAC;CACjE,OACE,kBAAC,MAAD;EAAI,WAAW,EAAK;EAClB,UAAA,kBAAC,GAAD;GAAW,WAAW,EAAK;GAAG,GAAI;GAAO,gBAAc,IAAU,SAAS,KAAA;GACxE,UAAA,kBAAC,QAAD;IAAM,WAAW,EAAU;IAAI;GAAe,CAAA;EACrC,CAAA;CACT,CAAA;AAER"}
package/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "@bonprix-ds/react-link-group",
3
+ "version": "1.0.0",
4
+ "description": "LinkGroup component, implemented in React, for the Bonprix Design System.",
5
+ "type": "module",
6
+ "publishConfig": {
7
+ "access": "public",
8
+ "provenance": true
9
+ },
10
+ "module": "./dist/index.js",
11
+ "sideEffects": false,
12
+ "exports": {
13
+ ".": {
14
+ "import": "./dist/index.js",
15
+ "types": "./dist/index.d.ts",
16
+ "default": "./dist/index.js"
17
+ }
18
+ },
19
+ "types": "./dist/index.d.ts",
20
+ "files": [
21
+ "dist"
22
+ ],
23
+ "keywords": [],
24
+ "author": "",
25
+ "license": "UNLICENSED",
26
+ "repository": {
27
+ "type": "git",
28
+ "url": "git+https://github.com/bonprix/design-system.git",
29
+ "directory": "packages/react/link-group"
30
+ },
31
+ "dependencies": {
32
+ "@bonprix-ds/internal-components": "0.1.5"
33
+ },
34
+ "peerDependencies": {
35
+ "react": "^19.0.0",
36
+ "react-dom": "^19.0.0",
37
+ "tailwind-variants": "0.3.1"
38
+ },
39
+ "devDependencies": {
40
+ "vite": "8.2.2",
41
+ "@types/react": "19.2.18",
42
+ "@vitejs/plugin-react": "6.1.1",
43
+ "rollup-preserve-directives": "1.1.3",
44
+ "unplugin-dts": "1.0.3",
45
+ "@microsoft/api-extractor": "7.59.0"
46
+ },
47
+ "scripts": {
48
+ "build": "vite build"
49
+ }
50
+ }