@adyen/adyen-platform-experience-web
Version:

68 lines (67 loc) • 2.48 kB
JavaScript
import { jsx as e } from "../../../external/.pnpm/preact@10.28.2/node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js";
import g from "classnames";
import { ButtonVariant as m } from "../Button/types.js";
import { TypographyVariant as r, TypographyElement as d } from "../Typography/types.js";
import p from "../Typography/Typography.js";
import { AlertIcon as v } from "./AlertIcon.js";
import { AlertVariantOption as a } from "./types.js";
/* empty css */
import B from "../../../core/Context/preact/useCoreContext.js";
import h from "../Button/Button.js";
import { Icon as C } from "../Icon/Icon.js";
const $ = ({
className: y,
description: o,
closeButton: u,
title: n,
type: l,
children: _,
onClose: i,
actions: s,
variant: t = a.DEFAULT,
"data-testid": T
}) => {
const { i18n: f } = B(), I = !!s?.length, N = i && (t !== a.TIP || u);
return /* @__PURE__ */ e(
"div",
{
"data-testid": T,
className: g("adyen-pe-alert", `adyen-pe-alert--${l}`, `adyen-pe-alert--${t}`, y),
role: "alert",
children: [
/* @__PURE__ */ e(v, { type: l, className: "adyen-pe-alert__icon" }),
/* @__PURE__ */ e("div", { className: "adyen-pe-alert__content-container", children: [
/* @__PURE__ */ e("div", { className: "adyen-pe-alert__content", children: [
n && t !== a.TIP && /* @__PURE__ */ e(p, { className: "adyen-pe-alert__title", el: d.DIV, variant: r.BODY, wide: !0, strongest: !0, children: n }),
o && /* @__PURE__ */ e(
p,
{
className: "adyen-pe-alert__description",
el: d.DIV,
variant: t === a.TIP ? r.CAPTION : r.BODY,
wide: !0,
children: o
}
),
_
] }),
I && /* @__PURE__ */ e("div", { className: "adyen-pe-alert__actions", children: s?.map((c, A) => /* @__PURE__ */ e(h, { onClick: c.onClick, variant: m.TERTIARY, children: c.label }, A)) })
] }),
N && /* @__PURE__ */ e("div", { className: "adyen-pe-alert__close-button", children: /* @__PURE__ */ e(
h,
{
iconButton: !0,
variant: m.TERTIARY,
onClick: i,
"aria-label": f.get("common.actions.dismiss.labels.dismiss"),
children: /* @__PURE__ */ e(C, { name: "cross" })
}
) })
]
}
);
};
export {
$ as Alert,
$ as default
};