@bonprix-ds/react-wrapper-button 0.0.0-stage → 1.1.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.
- package/dist/index.js +2 -0
- package/dist/no-styles.js +1 -0
- package/dist/src/Button.js +60 -0
- package/dist/src/Button.js.map +1 -0
- package/dist/src/ButtonRegistration.js +11 -0
- package/dist/src/ButtonRegistration.js.map +1 -0
- package/dist/styles.js +1 -0
- package/package.json +58 -3
- package/README.md +0 -3
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import e from "./ButtonRegistration.js";
|
|
2
|
+
import { isValidElement as t } from "react";
|
|
3
|
+
import { IconSlot as n } from "@bonprix-ds/react-icon";
|
|
4
|
+
import { jsx as r, jsxs as i } from "react/jsx-runtime";
|
|
5
|
+
//#region src/Button.tsx
|
|
6
|
+
var a = "h-4 w-4 fill-current", o = (e) => {
|
|
7
|
+
if (typeof e == "string") return e;
|
|
8
|
+
if (!t(e)) return;
|
|
9
|
+
let { type: n, props: r } = e;
|
|
10
|
+
if (typeof n == "function" && "variant" in n && typeof n.variant == "string") return n.variant;
|
|
11
|
+
if (n !== "svg") return;
|
|
12
|
+
let i = r["data-bpds-variant"];
|
|
13
|
+
return typeof i == "string" ? i : void 0;
|
|
14
|
+
}, s = ({ component: t = "button", children: s, variant: c = "primary", size: l = "medium", icon: u, iconPosition: d = "start", contentWidth: f = !1, loading: p = !1, disabled: m = !1, ...h }) => {
|
|
15
|
+
let g = t, { type: _, href: v, onClick: y, tabIndex: b, ...x } = h, S = t === "button", C = t === "a", w = m || p, T = S ? {
|
|
16
|
+
type: _ ?? "button",
|
|
17
|
+
disabled: m || void 0,
|
|
18
|
+
"aria-disabled": p ? "true" : void 0
|
|
19
|
+
} : {
|
|
20
|
+
href: C && m ? void 0 : v,
|
|
21
|
+
role: C && m ? "link" : void 0,
|
|
22
|
+
"aria-disabled": w ? "true" : void 0,
|
|
23
|
+
tabIndex: !C && m ? -1 : b
|
|
24
|
+
}, E = /* @__PURE__ */ r(n, {
|
|
25
|
+
icon: u,
|
|
26
|
+
className: a
|
|
27
|
+
});
|
|
28
|
+
return /* @__PURE__ */ i("bpds-button", {
|
|
29
|
+
className: "preflight",
|
|
30
|
+
variant: c,
|
|
31
|
+
size: l,
|
|
32
|
+
loading: p ? "true" : "false",
|
|
33
|
+
"content-width": f ? "true" : "false",
|
|
34
|
+
children: [/* @__PURE__ */ i(g, {
|
|
35
|
+
...x,
|
|
36
|
+
...T,
|
|
37
|
+
onClick: w ? void 0 : y,
|
|
38
|
+
"data-bpds": "button",
|
|
39
|
+
"data-bpds-variant": c,
|
|
40
|
+
"data-bpds-size": l,
|
|
41
|
+
"data-bpds-content-width": f,
|
|
42
|
+
"data-bpds-icon": o(u),
|
|
43
|
+
children: [
|
|
44
|
+
d === "start" && E,
|
|
45
|
+
s,
|
|
46
|
+
d === "end" && E,
|
|
47
|
+
p && /* @__PURE__ */ r("span", {
|
|
48
|
+
"data-bpds-button-status": !0,
|
|
49
|
+
role: "status",
|
|
50
|
+
children: "Lade..."
|
|
51
|
+
})
|
|
52
|
+
]
|
|
53
|
+
}), /* @__PURE__ */ r(e, {})]
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
s.displayName = "Button";
|
|
57
|
+
//#endregion
|
|
58
|
+
export { s as default };
|
|
59
|
+
|
|
60
|
+
//# sourceMappingURL=Button.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Button.js","names":["ButtonRegistration","ICON_CLASSES","iconName","icon","isValidElement","type","variant","props","Button","Component","component","nativeProps","isButton","isLink","unavailable","disabled","loading","controlProps","href","tabIndex","iconSlot","IconSlot","contentWidth","onClick","size","iconPosition","children"],"sources":["../../src/Button.tsx"],"sourcesContent":["import React, { isValidElement, type ComponentProps, type ElementType } from \"react\";\n\nimport type { ButtonBaseProps } from \"@bonprix-ds/react-button\";\nimport { IconSlot, type IconOrElement } from \"@bonprix-ds/react-icon\";\n\nimport ButtonRegistration from \"./ButtonRegistration\";\n\ninterface BaseProps extends ButtonBaseProps {\n /** If `true`, the component cannot be used. A link (`component=\"a\"`) loses its `href`; a custom `component` keeps it and leaves the tab order. */\n disabled?: boolean;\n}\n\nexport type Props<C extends ElementType = \"button\"> = BaseProps & {\n /** The semantic component to render the Button. Preferrably `\"button\"`, `\"a\"` 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\ninterface ControlProps {\n type?: \"button\" | \"submit\" | \"reset\";\n href?: unknown;\n onClick?: unknown;\n tabIndex?: number;\n}\n\n// The Tailwind preset makes `Icon`'s own size and fill `!important`, so the stylesheet cannot\n// change them. `twMerge` inside `Icon` replaces them with these.\nconst ICON_CLASSES = \"h-4 w-4 fill-current\";\n\n// `data-bpds-icon` reads the same whether the consumer passes the name, the icon component (its type carries\n// the name as a static `variant`) or an `<svg>` a Server Component already rendered from it (`data-bpds-variant`).\n// Same rule as `BaseButton` from DESY-1714, so selectors such as `[data-bpds-icon=\"closer\"]` match both Buttons.\nconst iconName = (icon: IconOrElement | undefined): string | undefined => {\n if (typeof icon === \"string\") return icon;\n if (!isValidElement(icon)) return undefined;\n const { type, props } = icon;\n if (typeof type === \"function\" && \"variant\" in type && typeof type.variant === \"string\") return type.variant;\n if (type !== \"svg\") return undefined;\n const variant = (props as { \"data-bpds-variant\"?: unknown })[\"data-bpds-variant\"];\n return typeof variant === \"string\" ? variant : undefined;\n};\n\n// No \"use client\" here: a Server Component has to be able to pass a component such as Next's `Link`.\n// `ButtonRegistration` is rendered rather than only imported, which puts its client reference into the\n// RSC payload, so the browser loads the stylesheet and registers the element.\nconst Button = <C extends ElementType = \"button\">({\n component = \"button\" as C,\n children,\n variant = \"primary\",\n size = \"medium\",\n icon,\n iconPosition = \"start\",\n contentWidth = false,\n loading = false,\n disabled = false,\n ...props\n}: Props<C>) => {\n const Component: ElementType = component;\n const { type, href, onClick, tabIndex, ...nativeProps } = props as ControlProps;\n const isButton = component === \"button\";\n const isLink = component === \"a\";\n const unavailable = disabled || loading;\n\n const controlProps = isButton\n ? { type: type ?? \"button\", disabled: disabled || undefined, \"aria-disabled\": loading ? \"true\" : undefined }\n : {\n href: isLink && disabled ? undefined : href,\n role: isLink && disabled ? \"link\" : undefined,\n \"aria-disabled\": unavailable ? \"true\" : undefined,\n tabIndex: !isLink && disabled ? -1 : tabIndex,\n };\n\n const iconSlot = <IconSlot icon={icon} className={ICON_CLASSES} />;\n\n return (\n <bpds-button\n className=\"preflight\"\n variant={variant}\n size={size}\n loading={loading ? \"true\" : \"false\"}\n content-width={contentWidth ? \"true\" : \"false\"}\n >\n <Component\n {...nativeProps}\n {...controlProps}\n onClick={unavailable ? undefined : onClick}\n data-bpds=\"button\"\n data-bpds-variant={variant}\n data-bpds-size={size}\n data-bpds-content-width={contentWidth}\n data-bpds-icon={iconName(icon)}\n >\n {iconPosition === \"start\" && iconSlot}\n {children}\n {iconPosition === \"end\" && iconSlot}\n {loading && (\n <span data-bpds-button-status role=\"status\">\n Lade...\n </span>\n )}\n </Component>\n <ButtonRegistration />\n </bpds-button>\n );\n};\n\nButton.displayName = \"Button\";\n\nexport default Button;\n"],"mappings":";;;;;AA0BA,IAAMC,IAAe,wBAKfC,KAAY,MAAwD;CACxE,IAAI,OAAOC,KAAS,UAAU,OAAOA;CACrC,IAAI,CAACC,EAAeD,CAAI,GAAG;CAC3B,IAAM,EAAE,SAAM,aAAUA;CACxB,IAAI,OAAOE,KAAS,cAAc,aAAaA,KAAQ,OAAOA,EAAK,WAAY,UAAU,OAAOA,EAAK;CACrG,IAAIA,MAAS,OAAO;CACpB,IAAMC,IAAWC,EAA4C;CAC7D,OAAO,OAAOD,KAAY,WAAWA,IAAU,KAAA;AACjD,GAKME,KAA4C,EAChD,eAAY,UACZ,aACA,aAAU,WACV,UAAO,UACP,SACA,kBAAe,SACf,kBAAe,IACf,aAAU,IACV,cAAW,IACX,GAAGD,QACW;CACd,IAAME,IAAyBC,GACzB,EAAE,SAAM,SAAM,YAAS,aAAU,GAAGC,MAAgBJ,GACpDK,IAAWF,MAAc,UACzBG,IAASH,MAAc,KACvBI,IAAcC,KAAYC,GAE1BC,IAAeL,IACjB;EAAE,MAAMP,KAAQ;EAAU,UAAUU,KAAY,KAAA;EAAW,iBAAiBC,IAAU,SAAS,KAAA;CAAU,IACzG;EACE,MAAMH,KAAUE,IAAW,KAAA,IAAYG;EACvC,MAAML,KAAUE,IAAW,SAAS,KAAA;EACpC,iBAAiBD,IAAc,SAAS,KAAA;EACxC,UAAU,CAACD,KAAUE,IAAW,KAAKI;CACvC,GAEEC,IAAW,kBAACC,GAAD;EAAgB;EAAM,WAAWpB;CAAe,CAAA;CAEjE,OACE,kBAAC,eAAD;EACE,WAAU;EACD;EACH;EACN,SAASe,IAAU,SAAS;EAC5B,iBAAeM,IAAe,SAAS;EALzC,UAAA,CAOE,kBAACb,GAAD;GACE,GAAIE;GACJ,GAAIM;GACJ,SAASH,IAAc,KAAA,IAAYS;GACnC,aAAU;GACV,qBAAmBjB;GACnB,kBAAgBkB;GAChB,2BAAyBF;GACzB,kBAAgBpB,EAASC,CAAI;GAR/B,UAAA;IAUGsB,MAAiB,WAAWL;IAC5BM;IACAD,MAAiB,SAASL;IAC1BJ,KACC,kBAAC,QAAD;KAAM,2BAAA;KAAwB,MAAK;KAAS,UAAA;IAEtC,CAAA;GAEC;EACX,CAAA,GAAA,kBAAChB,GAAD,CAAqB,CAAA,CACV;;AAEjB;AAEA,EAAO,cAAc"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import "#styles";
|
|
3
|
+
//#region src/ButtonRegistration.tsx
|
|
4
|
+
typeof window < "u" && import("@bonprix-ds/bpds-button").then(({ Button: e }) => {
|
|
5
|
+
customElements.get("bpds-button") || customElements.define("bpds-button", e);
|
|
6
|
+
});
|
|
7
|
+
var e = () => null;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { e as default };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=ButtonRegistration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ButtonRegistration.js","names":["ButtonElement","ButtonRegistration"],"sources":["../../src/ButtonRegistration.tsx"],"sourcesContent":["\"use client\";\n\nimport \"@bonprix-ds/bpds-button/button.css\";\n\n// The element class is loaded lazily and only in the browser: `class X extends HTMLElement` is\n// evaluated at module scope, and `HTMLElement` does not exist in Node. The registry check sits inside\n// the callback because the tag can be taken during the await, and `define` throws on a duplicate name.\nif (typeof window !== \"undefined\") {\n void import(\"@bonprix-ds/bpds-button\").then(({ Button: ButtonElement }) => {\n if (!customElements.get(\"bpds-button\")) customElements.define(\"bpds-button\", ButtonElement);\n });\n}\n\nconst ButtonRegistration = () => null;\n\nexport default ButtonRegistration;\n"],"mappings":";;;AAOI,OAAO,SAAW,OACpB,OAAY,0BAA0B,CAAC,MAAM,EAAE,QAAQA,QAAoB;CACzE,AAAK,eAAe,IAAI,aAAa,KAAG,eAAe,OAAO,eAAeA,CAAa;AAC5F,CAAC;AAGH,IAAMC,UAA2B"}
|
package/dist/styles.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "@bonprix-ds/bpds-button/button.css";
|
package/package.json
CHANGED
|
@@ -1,6 +1,61 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bonprix-ds/react-wrapper-button",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"description": "Button component, implemented as a React wrapper around bpds-button, for the Bonprix Design System.",
|
|
5
|
+
"keywords": [],
|
|
6
|
+
"license": "UNLICENSED",
|
|
7
|
+
"author": "",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/bonprix/design-system.git",
|
|
11
|
+
"directory": "packages/react-wrappers/button"
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"dist",
|
|
15
|
+
"!dist/tsconfig.tsbuildinfo",
|
|
16
|
+
"!dist/vite.config.d.ts",
|
|
17
|
+
"!dist/**/*.test.d.ts"
|
|
18
|
+
],
|
|
19
|
+
"type": "module",
|
|
20
|
+
"sideEffects": [
|
|
21
|
+
"**/*.css",
|
|
22
|
+
"./dist/styles.js"
|
|
23
|
+
],
|
|
24
|
+
"module": "./dist/index.js",
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
26
|
+
"imports": {
|
|
27
|
+
"#styles": {
|
|
28
|
+
"browser": "./dist/styles.js",
|
|
29
|
+
"default": "./dist/no-styles.js"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"exports": {
|
|
33
|
+
".": {
|
|
34
|
+
"import": "./dist/index.js",
|
|
35
|
+
"types": "./dist/index.d.ts",
|
|
36
|
+
"default": "./dist/index.js"
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
"publishConfig": {
|
|
40
|
+
"access": "public",
|
|
41
|
+
"provenance": true
|
|
42
|
+
},
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"@bonprix-ds/bpds-button": "1.1.0",
|
|
45
|
+
"@bonprix-ds/utils": "0.5.0",
|
|
46
|
+
"@bonprix-ds/react-icon": "1.3.1",
|
|
47
|
+
"@bonprix-ds/react-button": "1.1.4"
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"@types/react": "19.3.0",
|
|
51
|
+
"vite": "8.3.2",
|
|
52
|
+
"@bonprix-ds/vite-config": "0.0.0"
|
|
53
|
+
},
|
|
54
|
+
"peerDependencies": {
|
|
55
|
+
"react": "^19",
|
|
56
|
+
"react-dom": "^19"
|
|
57
|
+
},
|
|
58
|
+
"scripts": {
|
|
59
|
+
"build": "vite build"
|
|
60
|
+
}
|
|
6
61
|
}
|
package/README.md
DELETED