UNPKG

@cerberus-design/react

Version:

The Cerberus Design React component library.

68 lines (63 loc) 2.51 kB
'use client'; 'use strict'; Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); const jsxRuntime = require('react/jsx-runtime'); const jsx = require('styled-system/jsx'); const button = require('../button/button.cjs'); const show = require('../show/show.cjs'); const parts = require('./parts.cjs'); const matchIcon = require('./match-icon.cjs'); const closeTrigger = require('./close-trigger.cjs'); const toaster = require('./toaster.cjs'); const toaster$1 = require('../../node_modules/.pnpm/@ark-ui_react@5.29.1_react-dom@19.2.1_react@19.2.1__react@19.2.1/node_modules/@ark-ui/react/dist/components/toast/toaster.cjs'); function getEmphasis(type) { return type.includes("subtle") ? "low" : "high"; } function NotificationCenter(props) { const cachedToaster = props.toaster || toaster.toaster; return /* @__PURE__ */ jsxRuntime.jsx(toaster$1.Toaster, { toaster: cachedToaster, children: (toast) => /* @__PURE__ */ jsxRuntime.jsxs( parts.NotificationParts.Root, { "data-emphasis": getEmphasis( toast.type ?? "info" ), children: [ /* @__PURE__ */ jsxRuntime.jsx( matchIcon.MatchNotificationIcon, { type: toast.type } ), /* @__PURE__ */ jsxRuntime.jsxs(jsx.Box, { flex: "1", paddingBlock: "sm", children: [ /* @__PURE__ */ jsxRuntime.jsx(parts.NotificationParts.Heading, { children: toast.title }), /* @__PURE__ */ jsxRuntime.jsx(parts.NotificationParts.Description, { children: toast.description }), /* @__PURE__ */ jsxRuntime.jsx(show.Show, { when: toast.action, children: /* @__PURE__ */ jsxRuntime.jsx(parts.NotificationParts.ActionTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx( button.Button, { palette: toast.type, usage: "ghost", size: "sm", children: toast.action?.label } ) }) }) ] }), /* @__PURE__ */ jsxRuntime.jsx(closeTrigger.ToastCloseTrigger, {}) ] }, toast.id ) }); } function useNotificationCenter() { function notify(options) { toaster.toaster.create({ title: options.heading, description: options.description, type: options.palette, action: options.action }); } return { ...toaster.toaster, notify }; } exports.NotificationCenter = NotificationCenter; exports.getEmphasis = getEmphasis; exports.useNotificationCenter = useNotificationCenter;