UNPKG

lightswind

Version:

A collection of beautifully crafted React Components, Blocks & Templates for Modern Developers. Create stunning web applications effortlessly by using our 160+ professional and animated react components.

23 lines 1.71 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Toaster = Toaster; const jsx_runtime_1 = require("react/jsx-runtime"); const use_toast_1 = require("@/hooks/use-toast"); const toast_1 = require("./toast"); const framer_motion_1 = require("framer-motion"); function Toaster({ position = "top-right" }) { const { toasts, dismiss } = (0, use_toast_1.useToast)(); return ((0, jsx_runtime_1.jsx)(toast_1.ToastProvider, { children: (0, jsx_runtime_1.jsx)(toast_1.ToastViewport, { position: position, children: (0, jsx_runtime_1.jsx)(framer_motion_1.AnimatePresence, { mode: "popLayout", children: toasts.map(({ id, title, description, action, type, variant, duration, ...props }) => { // Map toast type to variant if variant is not provided const toastVariant = variant || (type === "success" ? "success" : type === "warning" ? "warning" : type === "info" ? "info" : type === "destructive" ? "destructive" : "default"); return ((0, jsx_runtime_1.jsxs)(toast_1.Toast, { ...props, variant: toastVariant, duration: duration, onOpenChange: (open) => { if (!open) dismiss(id); }, children: [(0, jsx_runtime_1.jsxs)("div", { className: "grid gap-1", children: [title && (0, jsx_runtime_1.jsx)(toast_1.ToastTitle, { children: title }), description && (0, jsx_runtime_1.jsx)(toast_1.ToastDescription, { children: description })] }), action] }, id)); }) }) }) })); } //# sourceMappingURL=toaster.js.map