UNPKG

@payfit/unity-components

Version:

65 lines (64 loc) • 2.21 kB
import { IconButton as e } from "../icon-button/IconButton.js"; import { ToastTitle as t } from "./parts/ToastTitle.js"; import { Children as n, Fragment as r, isValidElement as i } from "react"; import { uyTv as a } from "@payfit/unity-themes"; import { jsx as o, jsxs as s } from "react/jsx-runtime"; import { useTranslation as c } from "react-i18next"; import { Icon as l } from "@payfit/unity-icons"; //#region src/core/components/toast/UnityToast.tsx var u = a({ slots: { base: "uy:sm:max-w-52 uy:border uy:border-solid uy:rounded-125 uy:text-content-neutral uy:bg-surface-neutral uy:shadow-300 uy:p-150 uy:flex uy:gap-125 uy:border-border-neutral", contentWrapper: "uy:flex uy:grow uy:ml-125 uy:flex-col", divider: " uy:hidden" }, variants: { variant: { success: "", error: "" } } }), d = (e) => { let a = i(e) && e.type === r ? e.props.children : e; if (n.toArray(a).filter((e) => i(e) && e.type === t).length !== 1) throw Error("UnityToast must have one ToastTitle component"); }, f = ({ children: t, onClose: n, variant: r, ...i }) => { let { t: a } = c("unity"); d(t); let { base: f, contentWrapper: p, divider: m } = u({ variant: r }); return /* @__PURE__ */ s("div", { "data-dd-privacy": "mask", ...i, tabIndex: -1, role: r === "error" ? "alert" : "status", "aria-atomic": "true", "aria-live": r === "error" ? "assertive" : "polite", className: f(), children: [ /* @__PURE__ */ s("div", { className: "uy:flex uy:flex-row uy:grow", children: [/* @__PURE__ */ o(l, { src: r === "success" ? "CheckCircleFilled" : "WarningCircleFilled", color: r === "success" ? "content.success" : "content.danger", className: "uy:mt-100", alt: a((e) => e.unity.component.toast.icon.status) }), /* @__PURE__ */ o("div", { className: p(), children: t })] }), /* @__PURE__ */ o("div", { role: "presentation", className: m() }), /* @__PURE__ */ o(e, { icon: "CloseOutlined", iconRole: "presentation", label: a((e) => e.unity.component.common.close.label), variant: "ghost", color: "neutral", onClick: n }) ] }); }; f.displayName = "UnityToast"; //#endregion export { f as UnityToast };