@bonprix-ds/react-alert 1.0.8 → 1.1.1
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 +3 -110
- package/dist/src/Alert.d.ts +18 -5
- package/dist/src/Alert.js +101 -0
- package/dist/src/Alert.js.map +1 -0
- package/dist/src/constants.js +11 -0
- package/dist/src/constants.js.map +1 -0
- package/package.json +11 -10
- package/dist/index.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,110 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
import "
|
|
3
|
-
|
|
4
|
-
import t from "@bonprix-ds/react-icon";
|
|
5
|
-
import n from "@bonprix-ds/react-icon-button";
|
|
6
|
-
import r from "@bonprix-ds/react-typography";
|
|
7
|
-
import { jsx as i, jsxs as a } from "react/jsx-runtime";
|
|
8
|
-
//#region src/Alert.tsx
|
|
9
|
-
var o = e({
|
|
10
|
-
slots: {
|
|
11
|
-
root: "preflight m-0 flex justify-between items-start p-5 rounded gap-4 [word-break:break-word]",
|
|
12
|
-
iconAndContent: "flex gap-2",
|
|
13
|
-
content: "typography-body1 text-clr-on-bg-high gap-0.5 pt-0.5",
|
|
14
|
-
title: "",
|
|
15
|
-
icon: ""
|
|
16
|
-
},
|
|
17
|
-
variants: {
|
|
18
|
-
status: {
|
|
19
|
-
success: {
|
|
20
|
-
root: "bg-clr-bg-success",
|
|
21
|
-
title: "text-clr-fg-success",
|
|
22
|
-
icon: "fill-clr-fg-success"
|
|
23
|
-
},
|
|
24
|
-
info: {
|
|
25
|
-
root: "bg-clr-bg-info",
|
|
26
|
-
title: "text-clr-fg-info",
|
|
27
|
-
icon: "fill-clr-fg-info"
|
|
28
|
-
},
|
|
29
|
-
warning: {
|
|
30
|
-
root: "bg-clr-bg-alert",
|
|
31
|
-
title: "text-clr-fg-alert",
|
|
32
|
-
icon: "fill-clr-fg-alert"
|
|
33
|
-
},
|
|
34
|
-
error: {
|
|
35
|
-
root: "bg-clr-bg-error",
|
|
36
|
-
title: "text-clr-fg-error",
|
|
37
|
-
icon: "fill-clr-fg-error"
|
|
38
|
-
}
|
|
39
|
-
},
|
|
40
|
-
alertVariant: {
|
|
41
|
-
primary: { title: "text-clr-on-bg-high" },
|
|
42
|
-
secondary: { root: "p-0 rounded-none bg-transparent" }
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}), s = {
|
|
46
|
-
warning: {
|
|
47
|
-
icon: "alert",
|
|
48
|
-
label: "Warnung"
|
|
49
|
-
},
|
|
50
|
-
info: {
|
|
51
|
-
icon: "hint",
|
|
52
|
-
label: "Hinweis"
|
|
53
|
-
},
|
|
54
|
-
success: {
|
|
55
|
-
icon: "success",
|
|
56
|
-
label: "Erfolg"
|
|
57
|
-
},
|
|
58
|
-
error: {
|
|
59
|
-
icon: "error",
|
|
60
|
-
label: "Fehler"
|
|
61
|
-
}
|
|
62
|
-
}, c = ({ isOpen: e, variant: c = "primary", status: l, title: u, children: d, showCloseIcon: f = !0, onClose: p = () => null, nonCritical: m = !1, titleTag: h = "h2" }) => {
|
|
63
|
-
let { root: g, content: _, title: v, iconAndContent: y, icon: b } = o({
|
|
64
|
-
status: l,
|
|
65
|
-
alertVariant: c
|
|
66
|
-
});
|
|
67
|
-
if (!e) return null;
|
|
68
|
-
let x = s[l].icon, S = s[l].label;
|
|
69
|
-
return /* @__PURE__ */ a("div", {
|
|
70
|
-
className: g(),
|
|
71
|
-
role: m ? void 0 : "alert",
|
|
72
|
-
"aria-label": S,
|
|
73
|
-
"data-bpds": "alert",
|
|
74
|
-
"data-bpds-status": l,
|
|
75
|
-
"data-bpds-variant": c,
|
|
76
|
-
children: [/* @__PURE__ */ a("div", {
|
|
77
|
-
className: y(),
|
|
78
|
-
children: [/* @__PURE__ */ i(t, {
|
|
79
|
-
variant: x,
|
|
80
|
-
className: b()
|
|
81
|
-
}), /* @__PURE__ */ a("div", {
|
|
82
|
-
className: _(),
|
|
83
|
-
children: [u && /* @__PURE__ */ i("div", {
|
|
84
|
-
className: v(),
|
|
85
|
-
children: /* @__PURE__ */ i(r, {
|
|
86
|
-
variant: "h6",
|
|
87
|
-
color: "inherit",
|
|
88
|
-
component: h,
|
|
89
|
-
children: u
|
|
90
|
-
})
|
|
91
|
-
}), d]
|
|
92
|
-
})]
|
|
93
|
-
}), f && /* @__PURE__ */ i(n, {
|
|
94
|
-
variant: "tertiary",
|
|
95
|
-
icon: "closer",
|
|
96
|
-
size: "small",
|
|
97
|
-
label: "Schließen",
|
|
98
|
-
onClick: p
|
|
99
|
-
})]
|
|
100
|
-
});
|
|
101
|
-
}, l = [
|
|
102
|
-
"success",
|
|
103
|
-
"info",
|
|
104
|
-
"warning",
|
|
105
|
-
"error"
|
|
106
|
-
], u = ["primary", "secondary"];
|
|
107
|
-
//#endregion
|
|
108
|
-
export { c as default, l as levels, u as values };
|
|
109
|
-
|
|
110
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
import e from "./src/Alert.js";
|
|
2
|
+
import { levels as t, values as n } from "./src/constants.js";
|
|
3
|
+
export { e as default, t as levels, n as values };
|
package/dist/src/Alert.d.ts
CHANGED
|
@@ -2,14 +2,12 @@ import React from "react";
|
|
|
2
2
|
import { levels, values } from "./constants";
|
|
3
3
|
type StatusLevel = (typeof levels)[number];
|
|
4
4
|
type VariantValue = (typeof values)[number];
|
|
5
|
-
|
|
6
|
-
/** Toggles the visibility of the component. Must be used in conjunction with `onClose`. */
|
|
7
|
-
isOpen: boolean;
|
|
5
|
+
interface BaseProps {
|
|
8
6
|
/** The status of the alert. The colors and the icon of the component will adjust appropriately to signal the status level.*/
|
|
9
7
|
status: StatusLevel;
|
|
10
8
|
/** The message of the alert. */
|
|
11
9
|
children: string;
|
|
12
|
-
/** Callback, which is triggered when the visibility of the component (
|
|
10
|
+
/** Callback, which is triggered when the visibility of the component (open/closed) changes. Should be used to control the component from the outside, if the user clicks on the close icon. */
|
|
13
11
|
onClose?: () => void;
|
|
14
12
|
/** Variant of the alert. Depends on the prominence level you require. */
|
|
15
13
|
variant?: VariantValue;
|
|
@@ -22,5 +20,20 @@ export interface Props {
|
|
|
22
20
|
/** If `title` is used, you can define the used header element. */
|
|
23
21
|
titleTag?: "h1" | "h2" | "h3" | "h4" | "h5" | "h6";
|
|
24
22
|
}
|
|
25
|
-
|
|
23
|
+
type OpenProps = BaseProps & {
|
|
24
|
+
/** Toggles the visibility of the component. Must be used in conjunction with `onClose`. */
|
|
25
|
+
open: boolean;
|
|
26
|
+
/** @deprecated [is-open-prop] Use `open` instead. */
|
|
27
|
+
isOpen?: never;
|
|
28
|
+
};
|
|
29
|
+
type DeprecatedOpenProps = BaseProps & {
|
|
30
|
+
open?: never;
|
|
31
|
+
/**
|
|
32
|
+
* Toggles the visibility of the component. Must be used in conjunction with `onClose`.
|
|
33
|
+
* @deprecated [is-open-prop] Use `open` instead.
|
|
34
|
+
*/
|
|
35
|
+
isOpen: boolean;
|
|
36
|
+
};
|
|
37
|
+
export type Props = DeprecatedOpenProps | OpenProps;
|
|
38
|
+
declare const Alert: ({ open, isOpen, variant, status, title, children, showCloseIcon, onClose, nonCritical, titleTag: TitleTag, }: Props) => React.JSX.Element | null;
|
|
26
39
|
export default Alert;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import "react";
|
|
3
|
+
import { tv as e } from "tailwind-variants";
|
|
4
|
+
import t from "@bonprix-ds/react-icon-button";
|
|
5
|
+
import { AlertIcon as n, CloserIcon as r, ErrorIcon as i, HintIcon as a, SuccessIcon as o } from "@bonprix-ds/react-icon/icons";
|
|
6
|
+
import { warnDeprecated as s } from "@bonprix-ds/utils/deprecation";
|
|
7
|
+
import { jsx as c, jsxs as l } from "react/jsx-runtime";
|
|
8
|
+
//#region src/Alert.tsx
|
|
9
|
+
var u = e({
|
|
10
|
+
slots: {
|
|
11
|
+
root: "preflight m-0 flex items-start justify-between gap-4 rounded p-5 [word-break:break-word]",
|
|
12
|
+
iconAndContent: "flex gap-2",
|
|
13
|
+
content: "typography-body1 gap-0.5 pt-0.5 text-clr-on-bg-high",
|
|
14
|
+
title: "",
|
|
15
|
+
icon: ""
|
|
16
|
+
},
|
|
17
|
+
variants: {
|
|
18
|
+
status: {
|
|
19
|
+
success: {
|
|
20
|
+
root: "bg-clr-bg-success",
|
|
21
|
+
title: "text-clr-fg-success",
|
|
22
|
+
icon: "fill-clr-fg-success"
|
|
23
|
+
},
|
|
24
|
+
info: {
|
|
25
|
+
root: "bg-clr-bg-info",
|
|
26
|
+
title: "text-clr-fg-info",
|
|
27
|
+
icon: "fill-clr-fg-info"
|
|
28
|
+
},
|
|
29
|
+
warning: {
|
|
30
|
+
root: "bg-clr-bg-alert",
|
|
31
|
+
title: "text-clr-fg-alert",
|
|
32
|
+
icon: "fill-clr-fg-alert"
|
|
33
|
+
},
|
|
34
|
+
error: {
|
|
35
|
+
root: "bg-clr-bg-error",
|
|
36
|
+
title: "text-clr-fg-error",
|
|
37
|
+
icon: "fill-clr-fg-error"
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
alertVariant: {
|
|
41
|
+
primary: { title: "text-clr-on-bg-high" },
|
|
42
|
+
secondary: { root: "rounded-none bg-transparent p-0" }
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}), d = {
|
|
46
|
+
warning: {
|
|
47
|
+
icon: n,
|
|
48
|
+
label: "Warnung"
|
|
49
|
+
},
|
|
50
|
+
info: {
|
|
51
|
+
icon: a,
|
|
52
|
+
label: "Hinweis"
|
|
53
|
+
},
|
|
54
|
+
success: {
|
|
55
|
+
icon: o,
|
|
56
|
+
label: "Erfolg"
|
|
57
|
+
},
|
|
58
|
+
error: {
|
|
59
|
+
icon: i,
|
|
60
|
+
label: "Fehler"
|
|
61
|
+
}
|
|
62
|
+
}, f = ({ open: e, isOpen: n, variant: i = "primary", status: a, title: o, children: f, showCloseIcon: p = !0, onClose: m = () => null, nonCritical: h = !1, titleTag: g = "h2" }) => {
|
|
63
|
+
n !== void 0 && s("is-open-prop");
|
|
64
|
+
let { root: _, content: v, title: y, iconAndContent: b, icon: x } = u({
|
|
65
|
+
status: a,
|
|
66
|
+
alertVariant: i
|
|
67
|
+
});
|
|
68
|
+
if (!(e ?? n)) return null;
|
|
69
|
+
let S = d[a].icon, C = d[a].label;
|
|
70
|
+
return /* @__PURE__ */ l("div", {
|
|
71
|
+
className: _(),
|
|
72
|
+
role: h ? void 0 : "alert",
|
|
73
|
+
"aria-label": C,
|
|
74
|
+
"data-bpds": "alert",
|
|
75
|
+
"data-bpds-status": a,
|
|
76
|
+
"data-bpds-variant": i,
|
|
77
|
+
children: [/* @__PURE__ */ l("div", {
|
|
78
|
+
className: b(),
|
|
79
|
+
children: [/* @__PURE__ */ c(S, { className: x() }), /* @__PURE__ */ l("div", {
|
|
80
|
+
className: v(),
|
|
81
|
+
children: [o && /* @__PURE__ */ c("div", {
|
|
82
|
+
className: y(),
|
|
83
|
+
children: /* @__PURE__ */ c(g, {
|
|
84
|
+
className: "typography-h6 my-0 text-start text-inherit",
|
|
85
|
+
children: o
|
|
86
|
+
})
|
|
87
|
+
}), f]
|
|
88
|
+
})]
|
|
89
|
+
}), p && /* @__PURE__ */ c(t, {
|
|
90
|
+
variant: "tertiary",
|
|
91
|
+
icon: /* @__PURE__ */ c(r, {}),
|
|
92
|
+
size: "small",
|
|
93
|
+
label: "Schließen",
|
|
94
|
+
onClick: m
|
|
95
|
+
})]
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
//#endregion
|
|
99
|
+
export { f as default };
|
|
100
|
+
|
|
101
|
+
//# sourceMappingURL=Alert.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Alert.js","names":["IconButton","generateClasses","tv","alertVariants","AlertIcon","HintIcon","SuccessIcon","ErrorIcon","Alert","TitleTag","isOpen","warnDeprecated","titleStyle","variant","open","StatusIcon","status","statusAriaLabel","root","nonCritical","iconAndContent","icon","content","title","children","showCloseIcon","CloserIcon","onClose"],"sources":["../../src/Alert.tsx"],"sourcesContent":["\"use client\";\n\nimport React from \"react\";\nimport { tv } from \"tailwind-variants\";\n\nimport IconButton from \"@bonprix-ds/react-icon-button\";\nimport { AlertIcon, CloserIcon, ErrorIcon, HintIcon, SuccessIcon } from \"@bonprix-ds/react-icon/icons\";\nimport { warnDeprecated } from \"@bonprix-ds/utils/deprecation\";\n\nimport { levels, values } from \"./constants\";\n\nconst generateClasses = tv({\n slots: {\n // `word-break` not `overflow-wrap`: only the legacy `break-word` value also relaxes the\n // content-based minimum size of the flex items below, so the word wraps instead of widening them.\n root: \"preflight m-0 flex items-start justify-between gap-4 rounded p-5 [word-break:break-word]\",\n iconAndContent: \"flex gap-2\",\n content: \"typography-body1 gap-0.5 pt-0.5 text-clr-on-bg-high\",\n title: \"\",\n icon: \"\",\n },\n variants: {\n status: {\n success: {\n root: \"bg-clr-bg-success\",\n title: \"text-clr-fg-success\",\n icon: \"fill-clr-fg-success\",\n },\n info: {\n root: \"bg-clr-bg-info\",\n title: \"text-clr-fg-info\",\n icon: \"fill-clr-fg-info\",\n },\n warning: {\n root: \"bg-clr-bg-alert\",\n title: \"text-clr-fg-alert\",\n icon: \"fill-clr-fg-alert\",\n },\n error: {\n root: \"bg-clr-bg-error\",\n title: \"text-clr-fg-error\",\n icon: \"fill-clr-fg-error\",\n },\n },\n alertVariant: {\n primary: {\n title: \"text-clr-on-bg-high\",\n },\n secondary: {\n root: \"rounded-none bg-transparent p-0\",\n },\n },\n },\n});\n\ntype StatusLevel = (typeof levels)[number];\ntype VariantValue = (typeof values)[number];\n\ninterface BaseProps {\n /** The status of the alert. The colors and the icon of the component will adjust appropriately to signal the status level.*/\n status: StatusLevel;\n /** The message of the alert. */\n children: string;\n /** Callback, which is triggered when the visibility of the component (open/closed) changes. Should be used to control the component from the outside, if the user clicks on the close icon. */\n onClose?: () => void;\n /** Variant of the alert. Depends on the prominence level you require. */\n variant?: VariantValue;\n /** An optional title of the alert. The titel sums up the message briefly. */\n title?: string;\n /** Controls, if the close icon should be shown. When the alert shoulnd't be closed actively, this property can be set to `false`. */\n showCloseIcon?: boolean;\n /** Removes role=\"alert\" from component if set to `true`. The alert content is not read by assistive technologies right away then. */\n nonCritical?: boolean;\n /** If `title` is used, you can define the used header element. */\n titleTag?: \"h1\" | \"h2\" | \"h3\" | \"h4\" | \"h5\" | \"h6\";\n}\n\ntype OpenProps = BaseProps & {\n /** Toggles the visibility of the component. Must be used in conjunction with `onClose`. */\n open: boolean;\n /** @deprecated [is-open-prop] Use `open` instead. */\n isOpen?: never;\n};\n\ntype DeprecatedOpenProps = BaseProps & {\n open?: never;\n /**\n * Toggles the visibility of the component. Must be used in conjunction with `onClose`.\n * @deprecated [is-open-prop] Use `open` instead.\n */\n isOpen: boolean;\n};\n\nexport type Props = DeprecatedOpenProps | OpenProps;\n\ninterface AlertMap {\n icon: React.ComponentType<{ className?: string }>;\n label: string;\n}\n\nconst alertVariants: Record<StatusLevel, AlertMap> = {\n warning: {\n icon: AlertIcon,\n label: \"Warnung\",\n },\n info: {\n icon: HintIcon,\n label: \"Hinweis\",\n },\n success: {\n icon: SuccessIcon,\n label: \"Erfolg\",\n },\n error: {\n icon: ErrorIcon,\n label: \"Fehler\",\n },\n};\n\nconst Alert = ({\n open,\n isOpen,\n variant = \"primary\",\n status,\n title,\n children,\n showCloseIcon = true,\n onClose = () => null,\n nonCritical = false,\n titleTag: TitleTag = \"h2\",\n}: Props) => {\n if (isOpen !== undefined) warnDeprecated(\"is-open-prop\");\n const { root, content, title: titleStyle, iconAndContent, icon } = generateClasses({ status, alertVariant: variant });\n if (!(open ?? isOpen)) return null;\n\n const StatusIcon = alertVariants[status].icon;\n const statusAriaLabel = alertVariants[status].label;\n const closeLabel = \"Schließen\";\n\n return (\n <div\n className={root()}\n role={nonCritical ? undefined : \"alert\"}\n aria-label={statusAriaLabel}\n data-bpds=\"alert\"\n data-bpds-status={status}\n data-bpds-variant={variant}\n >\n <div className={iconAndContent()}>\n <StatusIcon className={icon()} />\n <div className={content()}>\n {title && (\n <div className={titleStyle()}>\n <TitleTag className=\"typography-h6 my-0 text-start text-inherit\">{title}</TitleTag>\n </div>\n )}\n {children}\n </div>\n </div>\n {showCloseIcon && <IconButton variant=\"tertiary\" icon={<CloserIcon />} size=\"small\" label={closeLabel} onClick={onClose} />}\n </div>\n );\n};\n\nexport default Alert;\n"],"mappings":";;;;;;;;AAWA,IAAMC,IAAkBC,EAAG;CACzB,OAAO;EAGL,MAAM;EACN,gBAAgB;EAChB,SAAS;EACT,OAAO;EACP,MAAM;CACR;CACA,UAAU;EACR,QAAQ;GACN,SAAS;IACP,MAAM;IACN,OAAO;IACP,MAAM;GACR;GACA,MAAM;IACJ,MAAM;IACN,OAAO;IACP,MAAM;GACR;GACA,SAAS;IACP,MAAM;IACN,OAAO;IACP,MAAM;GACR;GACA,OAAO;IACL,MAAM;IACN,OAAO;IACP,MAAM;GACR;EACF;EACA,cAAc;GACZ,SAAS,EACP,OAAO,sBACT;GACA,WAAW,EACT,MAAM,kCACR;EACF;CACF;AACF,CAAC,GA+CKC,IAA+C;CACnD,SAAS;EACP,MAAMC;EACN,OAAO;CACT;CACA,MAAM;EACJ,MAAMC;EACN,OAAO;CACT;CACA,SAAS;EACP,MAAMC;EACN,OAAO;CACT;CACA,OAAO;EACL,MAAMC;EACN,OAAO;CACT;AACF,GAEMC,KAAS,EACb,SACA,WACA,aAAU,WACV,WACA,UACA,aACA,mBAAgB,IAChB,mBAAgB,MAChB,iBAAc,IACd,UAAUC,IAAW,WACV;CACX,AAAIC,MAAW,KAAA,KAAWC,EAAe,cAAc;CACvD,IAAM,EAAE,SAAM,YAAS,OAAOC,GAAY,mBAAgB,YAASX,EAAgB;EAAE;EAAQ,cAAcY;CAAQ,CAAC;CACpH,IAAI,EAAEC,KAAQJ,IAAS,OAAO;CAE9B,IAAMK,IAAaZ,EAAca,EAAO,CAAC,MACnCC,IAAkBd,EAAca,EAAO,CAAC;CAG9C,OACE,kBAAC,OAAD;EACE,WAAWE,EAAK;EAChB,MAAMC,IAAc,KAAA,IAAY;EAChC,cAAYF;EACZ,aAAU;EACV,oBAAkBD;EAClB,qBAAmBH;EANrB,UAAA,CAQE,kBAAC,OAAD;GAAK,WAAWO,EAAe;GAA/B,UAAA,CACE,kBAACL,GAAD,EAAY,WAAWM,EAAK,EAAI,CAAA,GAChC,kBAAC,OAAD;IAAK,WAAWC,EAAQ;IAAxB,UAAA,CACGC,KACC,kBAAC,OAAD;KAAK,WAAWX,EAAW;KACzB,UAAA,kBAACH,GAAD;MAAU,WAAU;MAA8C,UAAAc;KAAgB,CAAA;IAC/E,CAAA,GAENC,CACE;GACF,CAAA,CAAA;EACJ,CAAA,GAAAC,KAAiB,kBAACzB,GAAD;GAAY,SAAQ;GAAW,MAAM,kBAAC0B,GAAD,CAAa,CAAA;GAAG,MAAK;GAAQ,OAAO;GAAY,SAASC;EAAU,CAAA,CACvH;;AAET"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","names":["levels","values"],"sources":["../../src/constants.ts"],"sourcesContent":["export const levels = [\"success\", \"info\", \"warning\", \"error\"] as const;\nexport const values = [\"primary\", \"secondary\"] as const;\n"],"mappings":";AAAA,IAAaA,IAAS;CAAC;CAAW;CAAQ;CAAW;AAAO,GAC/CC,IAAS,CAAC,WAAW,WAAW"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bonprix-ds/react-alert",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "Alert component, implemented in React, for the Bonprix Design System.",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -32,20 +32,21 @@
|
|
|
32
32
|
"provenance": true
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@bonprix-ds/react-icon": "1.2.
|
|
36
|
-
"@bonprix-ds/
|
|
37
|
-
"@bonprix-ds/react-
|
|
38
|
-
"@bonprix-ds/utils": "0.2.2"
|
|
35
|
+
"@bonprix-ds/react-icon-button": "1.2.3",
|
|
36
|
+
"@bonprix-ds/utils": "0.4.0",
|
|
37
|
+
"@bonprix-ds/react-icon": "1.3.0"
|
|
39
38
|
},
|
|
40
39
|
"devDependencies": {
|
|
40
|
+
"@testing-library/dom": "10.4.2",
|
|
41
|
+
"@testing-library/react": "16.3.3",
|
|
41
42
|
"@types/react": "19.3.0",
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"vite": "
|
|
43
|
+
"vite": "8.3.2",
|
|
44
|
+
"vitest": "4.1.11",
|
|
45
|
+
"@bonprix-ds/vite-config": "0.0.0"
|
|
45
46
|
},
|
|
46
47
|
"peerDependencies": {
|
|
47
|
-
"react": "^19
|
|
48
|
-
"react-dom": "^19
|
|
48
|
+
"react": "^19",
|
|
49
|
+
"react-dom": "^19",
|
|
49
50
|
"tailwind-variants": "0.3.1"
|
|
50
51
|
},
|
|
51
52
|
"scripts": {
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/Alert.tsx","../src/constants.ts"],"sourcesContent":["\"use client\";\n\nimport React from \"react\";\nimport { tv } from \"tailwind-variants\";\n\nimport Icon, { type IconType } from \"@bonprix-ds/react-icon\";\nimport IconButton from \"@bonprix-ds/react-icon-button\";\nimport Typography from \"@bonprix-ds/react-typography\";\n\nimport { levels, values } from \"./constants\";\n\nconst generateClasses = tv({\n slots: {\n // `word-break` not `overflow-wrap`: only the legacy `break-word` value also relaxes the\n // content-based minimum size of the flex items below, so the word wraps instead of widening them.\n root: \"preflight m-0 flex justify-between items-start p-5 rounded gap-4 [word-break:break-word]\",\n iconAndContent: \"flex gap-2\",\n content: \"typography-body1 text-clr-on-bg-high gap-0.5 pt-0.5\",\n title: \"\",\n icon: \"\",\n },\n variants: {\n status: {\n success: {\n root: \"bg-clr-bg-success\",\n title: \"text-clr-fg-success\",\n icon: \"fill-clr-fg-success\",\n },\n info: {\n root: \"bg-clr-bg-info\",\n title: \"text-clr-fg-info\",\n icon: \"fill-clr-fg-info\",\n },\n warning: {\n root: \"bg-clr-bg-alert\",\n title: \"text-clr-fg-alert\",\n icon: \"fill-clr-fg-alert\",\n },\n error: {\n root: \"bg-clr-bg-error\",\n title: \"text-clr-fg-error\",\n icon: \"fill-clr-fg-error\",\n },\n },\n alertVariant: {\n primary: {\n title: \"text-clr-on-bg-high\",\n },\n secondary: {\n root: \"p-0 rounded-none bg-transparent\",\n },\n },\n },\n});\n\ntype StatusLevel = (typeof levels)[number];\ntype VariantValue = (typeof values)[number];\n\nexport interface Props {\n /** Toggles the visibility of the component. Must be used in conjunction with `onClose`. */\n isOpen: boolean;\n /** The status of the alert. The colors and the icon of the component will adjust appropriately to signal the status level.*/\n status: StatusLevel;\n /** The message of the alert. */\n children: string;\n /** Callback, which is triggered when the visibility of the component (opened/closed) changes. Should be used to control the component from the outside, if the user clicks on the close icon. */\n onClose?: () => void;\n /** Variant of the alert. Depends on the prominence level you require. */\n variant?: VariantValue;\n /** An optional title of the alert. The titel sums up the message briefly. */\n title?: string;\n /** Controls, if the close icon should be shown. When the alert shoulnd't be closed actively, this property can be set to `false`. */\n showCloseIcon?: boolean;\n /** Removes role=\"alert\" from component if set to `true`. The alert content is not read by assistive technologies right away then. */\n nonCritical?: boolean;\n /** If `title` is used, you can define the used header element. */\n titleTag?: \"h1\" | \"h2\" | \"h3\" | \"h4\" | \"h5\" | \"h6\";\n}\n\ninterface AlertMap {\n icon: IconType;\n label: string;\n}\n\nconst alertVariants: Record<StatusLevel, AlertMap> = {\n warning: {\n icon: \"alert\",\n label: \"Warnung\",\n },\n info: {\n icon: \"hint\",\n label: \"Hinweis\",\n },\n success: {\n icon: \"success\",\n label: \"Erfolg\",\n },\n error: {\n icon: \"error\",\n label: \"Fehler\",\n },\n};\n\nconst Alert = ({\n isOpen,\n variant = \"primary\",\n status,\n title,\n children,\n showCloseIcon = true,\n onClose = () => null,\n nonCritical = false,\n titleTag = \"h2\",\n}: Props) => {\n const { root, content, title: titleStyle, iconAndContent, icon } = generateClasses({ status, alertVariant: variant });\n if (!isOpen) return null;\n\n const iconVariant = alertVariants[status].icon;\n const statusAriaLabel = alertVariants[status].label;\n const closeLabel = \"Schließen\";\n\n return (\n <div\n className={root()}\n role={nonCritical ? undefined : \"alert\"}\n aria-label={statusAriaLabel}\n data-bpds=\"alert\"\n data-bpds-status={status}\n data-bpds-variant={variant}\n >\n <div className={iconAndContent()}>\n <Icon variant={iconVariant} className={icon()} />\n <div className={content()}>\n {title && (\n <div className={titleStyle()}>\n <Typography variant=\"h6\" color=\"inherit\" component={titleTag}>\n {title}\n </Typography>\n </div>\n )}\n {children}\n </div>\n </div>\n {showCloseIcon && <IconButton variant=\"tertiary\" icon=\"closer\" size=\"small\" label={closeLabel} onClick={onClose} />}\n </div>\n );\n};\n\nexport default Alert;\n","export const levels = [\"success\", \"info\", \"warning\", \"error\"] as const;\nexport const values = [\"primary\", \"secondary\"] as const;\n"],"mappings":";;;;;;;;AAWA,IAAM,IAAkB,EAAG;CACzB,OAAO;EAGL,MAAM;EACN,gBAAgB;EAChB,SAAS;EACT,OAAO;EACP,MAAM;CACR;CACA,UAAU;EACR,QAAQ;GACN,SAAS;IACP,MAAM;IACN,OAAO;IACP,MAAM;GACR;GACA,MAAM;IACJ,MAAM;IACN,OAAO;IACP,MAAM;GACR;GACA,SAAS;IACP,MAAM;IACN,OAAO;IACP,MAAM;GACR;GACA,OAAO;IACL,MAAM;IACN,OAAO;IACP,MAAM;GACR;EACF;EACA,cAAc;GACZ,SAAS,EACP,OAAO,sBACT;GACA,WAAW,EACT,MAAM,kCACR;EACF;CACF;AACF,CAAC,GA+BK,IAA+C;CACnD,SAAS;EACP,MAAM;EACN,OAAO;CACT;CACA,MAAM;EACJ,MAAM;EACN,OAAO;CACT;CACA,SAAS;EACP,MAAM;EACN,OAAO;CACT;CACA,OAAO;EACL,MAAM;EACN,OAAO;CACT;AACF,GAEM,KAAS,EACb,WACA,aAAU,WACV,WACA,UACA,aACA,mBAAgB,IAChB,mBAAgB,MAChB,iBAAc,IACd,cAAW,WACA;CACX,IAAM,EAAE,SAAM,YAAS,OAAO,GAAY,mBAAgB,YAAS,EAAgB;EAAE;EAAQ,cAAc;CAAQ,CAAC;CACpH,IAAI,CAAC,GAAQ,OAAO;CAEpB,IAAM,IAAc,EAAc,EAAO,CAAC,MACpC,IAAkB,EAAc,EAAO,CAAC;CAG9C,OACE,kBAAC,OAAD;EACE,WAAW,EAAK;EAChB,MAAM,IAAc,KAAA,IAAY;EAChC,cAAY;EACZ,aAAU;EACV,oBAAkB;EAClB,qBAAmB;EANrB,UAAA,CAQE,kBAAC,OAAD;GAAK,WAAW,EAAe;GAA/B,UAAA,CACE,kBAAC,GAAD;IAAM,SAAS;IAAa,WAAW,EAAK;GAAI,CAAA,GAChD,kBAAC,OAAD;IAAK,WAAW,EAAQ;IAAxB,UAAA,CACG,KACC,kBAAC,OAAD;KAAK,WAAW,EAAW;KACzB,UAAA,kBAAC,GAAD;MAAY,SAAQ;MAAK,OAAM;MAAU,WAAW;MACjD,UAAA;KACS,CAAA;IACT,CAAA,GAEN,CACE;GACF,CAAA,CAAA;EACJ,CAAA,GAAA,KAAiB,kBAAC,GAAD;GAAY,SAAQ;GAAW,MAAK;GAAS,MAAK;GAAQ,OAAO;GAAY,SAAS;EAAU,CAAA,CAC/G;;AAET,GClJa,IAAS;CAAC;CAAW;CAAQ;CAAW;AAAO,GAC/C,IAAS,CAAC,WAAW,WAAW"}
|