{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "toast",
  "type": "registry:ui",
  "title": "Toast",
  "description": "Short notices that stack in a corner and dismiss themselves.",
  "categories": [
    "feedback"
  ],
  "dependencies": [
    "@base-ui/react@1.9.0",
    "@hugeicons/core-free-icons@4.4.0",
    "@hugeicons/react@1.1.10"
  ],
  "registryDependencies": [
    "https://sprout.tulipfarm.ai/r/sprout-base.json",
    "https://sprout.tulipfarm.ai/r/button.json",
    "https://sprout.tulipfarm.ai/r/spinner.json"
  ],
  "files": [
    {
      "path": "registry/sprout/components/ui/toast.tsx",
      "type": "registry:ui",
      "target": "components/ui/toast.tsx",
      "content": "'use client';\n\nimport type { ReactNode } from 'react';\nimport { Toast as ToastPrimitive } from '@base-ui/react/toast';\nimport { CheckCircleIcon } from '@/lib/sprout/icons/check-circle-icon';\nimport { CloseCircleIcon } from '@/lib/sprout/icons/close-circle-icon';\nimport { CloseIcon } from '@/lib/sprout/icons/close-icon';\nimport { DangerIcon } from '@/lib/sprout/icons/danger-icon';\nimport { InfoIcon } from '@/lib/sprout/icons/info-icon';\nimport { stateClassName } from '@/lib/sprout/classes';\nimport { Button } from '@/components/ui/button';\nimport { Spinner } from '@/components/ui/spinner';\n\nexport const toastTypeNames = ['success', 'error', 'warning', 'info', 'loading'] as const;\n\nexport type ToastType = (typeof toastTypeNames)[number];\n\nexport type ToastManager = ReturnType<typeof ToastPrimitive.createToastManager>;\n\nexport const createToastManager = ToastPrimitive.createToastManager;\n\nexport const useToastManager = ToastPrimitive.useToastManager;\n\nexport const toast: ToastManager = createToastManager();\n\nexport type ToastProviderProps = ToastPrimitive.Provider.Props;\n\nexport function ToastProvider(props: ToastProviderProps) {\n  return <ToastPrimitive.Provider {...props} />;\n}\n\nexport type ToastPortalProps = ToastPrimitive.Portal.Props;\n\nexport function ToastPortal(props: ToastPortalProps) {\n  return <ToastPrimitive.Portal data-slot=\"toast-portal\" {...props} />;\n}\n\nexport type ToastViewportProps = ToastPrimitive.Viewport.Props;\n\nexport function ToastViewport({ className, ...props }: ToastViewportProps) {\n  return (\n    <ToastPrimitive.Viewport\n      data-slot=\"toast-viewport\"\n      {...props}\n      className={stateClassName<ToastPrimitive.Viewport.State>('sprout-toast-viewport', className)}\n    />\n  );\n}\n\nexport type ToastProps = ToastPrimitive.Root.Props;\n\nexport function Toast({ className, ...props }: ToastProps) {\n  return (\n    <ToastPrimitive.Root\n      data-slot=\"toast\"\n      {...props}\n      className={stateClassName<ToastPrimitive.Root.State>('sprout-toast', className)}\n    />\n  );\n}\n\nexport type ToastContentProps = ToastPrimitive.Content.Props;\n\nexport function ToastContent({ className, ...props }: ToastContentProps) {\n  return (\n    <ToastPrimitive.Content\n      data-slot=\"toast-content\"\n      {...props}\n      className={stateClassName<ToastPrimitive.Content.State>('sprout-toast-content', className)}\n    />\n  );\n}\n\nexport type ToastTitleProps = ToastPrimitive.Title.Props;\n\nexport function ToastTitle({ className, ...props }: ToastTitleProps) {\n  return (\n    <ToastPrimitive.Title\n      data-slot=\"toast-title\"\n      {...props}\n      className={stateClassName<ToastPrimitive.Title.State>('sprout-toast-title', className)}\n    />\n  );\n}\n\nexport type ToastDescriptionProps = ToastPrimitive.Description.Props;\n\nexport function ToastDescription({ className, ...props }: ToastDescriptionProps) {\n  return (\n    <ToastPrimitive.Description\n      data-slot=\"toast-description\"\n      {...props}\n      className={stateClassName<ToastPrimitive.Description.State>('sprout-toast-description', className)}\n    />\n  );\n}\n\nexport type ToastActionProps = ToastPrimitive.Action.Props;\n\nexport function ToastAction({\n  className,\n  render = <Button variant=\"outline\" size=\"sm\" />,\n  ...props\n}: ToastActionProps) {\n  return (\n    <ToastPrimitive.Action\n      data-slot=\"toast-action\"\n      render={render}\n      {...props}\n      className={stateClassName<ToastPrimitive.Action.State>('sprout-toast-action', className)}\n    />\n  );\n}\n\nexport type ToastCloseProps = ToastPrimitive.Close.Props;\n\nexport function ToastClose({\n  className,\n  children,\n  render = <Button variant=\"ghost\" size=\"icon-sm\" />,\n  ...props\n}: ToastCloseProps) {\n  return (\n    <ToastPrimitive.Close\n      data-slot=\"toast-close\"\n      aria-label=\"Close toast\"\n      render={render}\n      {...props}\n      className={stateClassName<ToastPrimitive.Close.State>('sprout-toast-close', className)}\n    >\n      {children ?? <CloseIcon aria-hidden=\"true\" />}\n    </ToastPrimitive.Close>\n  );\n}\n\nconst toastIcons: Record<ToastType, ReactNode> = {\n  success: <CheckCircleIcon aria-hidden=\"true\" />,\n  info: <InfoIcon aria-hidden=\"true\" />,\n  warning: <DangerIcon aria-hidden=\"true\" />,\n  error: <CloseCircleIcon aria-hidden=\"true\" />,\n  loading: <Spinner aria-hidden=\"true\" />,\n};\n\nfunction ToastIcon({ type }: { type: string | undefined }) {\n  const icon = type && type in toastIcons ? toastIcons[type as ToastType] : null;\n  if (!icon) return null;\n  return (\n    <span data-slot=\"toast-icon\" data-type={type} className=\"sprout-toast-icon\">\n      {icon}\n    </span>\n  );\n}\n\nfunction ToastList() {\n  const { toasts } = useToastManager();\n  return toasts.map(item => (\n    <Toast key={item.id} toast={item}>\n      <ToastContent>\n        <ToastIcon type={item.type} />\n        <div className=\"sprout-toast-text\">\n          <ToastTitle />\n          <ToastDescription />\n        </div>\n        <ToastAction />\n        <ToastClose />\n      </ToastContent>\n    </Toast>\n  ));\n}\n\nexport interface ToasterProps extends ToastProviderProps {\n  toastManager?: ToastProviderProps['toastManager'];\n}\n\nexport function Toaster({ children, toastManager = toast, ...props }: ToasterProps) {\n  return (\n    <ToastProvider toastManager={toastManager} {...props}>\n      {children}\n      <ToastPortal>\n        <ToastViewport>\n          <ToastList />\n        </ToastViewport>\n      </ToastPortal>\n    </ToastProvider>\n  );\n}\n"
    },
    {
      "path": "registry/sprout/lib/sprout/icons/check-circle-icon.tsx",
      "type": "registry:lib",
      "target": "lib/sprout/icons/check-circle-icon.tsx",
      "content": "import { CheckmarkCircle02Icon as glyph } from '@hugeicons/core-free-icons';\nimport { createIcon } from '@/lib/sprout/icons/create-icon';\n\nexport const CheckCircleIcon = /* @__PURE__ */ createIcon(glyph, 'CheckCircleIcon');\n"
    },
    {
      "path": "registry/sprout/lib/sprout/icons/close-circle-icon.tsx",
      "type": "registry:lib",
      "target": "lib/sprout/icons/close-circle-icon.tsx",
      "content": "import { CancelCircleIcon as glyph } from '@hugeicons/core-free-icons';\nimport { createIcon } from '@/lib/sprout/icons/create-icon';\n\nexport const CloseCircleIcon = /* @__PURE__ */ createIcon(glyph, 'CloseCircleIcon');\n"
    },
    {
      "path": "registry/sprout/lib/sprout/icons/close-icon.tsx",
      "type": "registry:lib",
      "target": "lib/sprout/icons/close-icon.tsx",
      "content": "import { Cancel01Icon as glyph } from '@hugeicons/core-free-icons';\nimport { createIcon } from '@/lib/sprout/icons/create-icon';\n\nexport const CloseIcon = /* @__PURE__ */ createIcon(glyph, 'CloseIcon');\n"
    },
    {
      "path": "registry/sprout/lib/sprout/icons/create-icon.tsx",
      "type": "registry:lib",
      "target": "lib/sprout/icons/create-icon.tsx",
      "content": "import { HugeiconsIcon, type IconSvgElement } from '@hugeicons/react';\nimport type { ReactElement, Ref, SVGProps } from 'react';\n\nexport const iconSizes = {\n  xs: 12,\n  sm: 14,\n  md: 16,\n  lg: 18,\n  xl: 20,\n  '2xl': 24,\n} as const;\n\nexport type IconSize = keyof typeof iconSizes;\n\nexport const iconStrokeWidth = 1.5;\n\nexport type IconProps = Omit<SVGProps<SVGSVGElement>, 'ref'> & {\n  size?: IconSize | number;\n  ref?: Ref<SVGSVGElement>;\n};\n\nexport type IconComponent = (props: IconProps) => ReactElement;\n\nexport function createIcon(glyph: IconSvgElement, name: string): IconComponent {\n  const Icon = ({ size = '2xl', strokeWidth = iconStrokeWidth, ...props }: IconProps) => (\n    <HugeiconsIcon\n      icon={glyph}\n      size={typeof size === 'number' ? size : iconSizes[size]}\n      strokeWidth={Number(strokeWidth)}\n      {...props}\n    />\n  );\n  Icon.displayName = name;\n  return Icon;\n}\n"
    },
    {
      "path": "registry/sprout/lib/sprout/icons/danger-icon.tsx",
      "type": "registry:lib",
      "target": "lib/sprout/icons/danger-icon.tsx",
      "content": "import { Alert01Icon as glyph } from '@hugeicons/core-free-icons';\nimport { createIcon } from '@/lib/sprout/icons/create-icon';\n\nexport const DangerIcon = /* @__PURE__ */ createIcon(glyph, 'DangerIcon');\n"
    },
    {
      "path": "registry/sprout/lib/sprout/icons/info-icon.tsx",
      "type": "registry:lib",
      "target": "lib/sprout/icons/info-icon.tsx",
      "content": "import { InformationCircleIcon as glyph } from '@hugeicons/core-free-icons';\nimport { createIcon } from '@/lib/sprout/icons/create-icon';\n\nexport const InfoIcon = /* @__PURE__ */ createIcon(glyph, 'InfoIcon');\n"
    }
  ],
  "css": {
    "@layer components": {
      ".sprout-toast-viewport": {
        "inset-inline": "16px",
        "z-index": "50",
        "pointer-events": "none",
        "outline": "none",
        "width": "auto",
        "max-width": "24rem",
        "margin-inline": "auto",
        "position": "fixed",
        "bottom": "16px"
      },
      "@media (width >= 640px)": {
        ".sprout-toast-viewport": {
          "width": "100%",
          "margin-inline": "0",
          "inset-inline": "auto 16px"
        }
      },
      ".sprout-toast": {
        "--sprout-toast-gap": ".625rem",
        "--sprout-toast-peek": ".625rem",
        "--sprout-toast-height": "var(--toast-frontmost-height, var(--toast-height))",
        "--sprout-toast-scale": "max(0, calc(1 - var(--toast-index) * .06))",
        "--sprout-toast-shrink": "calc(1 - var(--sprout-toast-scale))",
        "--sprout-toast-offset-y": "calc(var(--toast-offset-y) * -1 - var(--toast-index) * var(--sprout-toast-gap) + var(--toast-swipe-movement-y))",
        "z-index": "calc(1000 - var(--toast-index))",
        "box-sizing": "border-box",
        "width": "100%",
        "height": "var(--sprout-toast-height)",
        "border": "1px solid var(--sprout-line)",
        "border-radius": "var(--sprout-radius-panel)",
        "background": "var(--sprout-surface)",
        "color": "var(--sprout-text)",
        "box-shadow": "var(--sprout-shadow-overlay)",
        "font-family": "var(--sprout-font)",
        "font-size": "var(--sprout-text-sm)",
        "pointer-events": "auto",
        "transform-origin": "bottom",
        "transform": "translateX(var(--toast-swipe-movement-x))\n      translateY(calc(var(--toast-swipe-movement-y) - var(--toast-index) * var(--sprout-toast-peek) - var(--sprout-toast-shrink) *\n            var(--sprout-toast-height)))\n      scale(var(--sprout-toast-scale))",
        "user-select": "none",
        "will-change": "transform",
        "outline": "none",
        "line-height": "1.25rem",
        "position": "absolute",
        "bottom": "0",
        "right": "0"
      },
      ".sprout-toast:after": {
        "width": "100%",
        "height": "calc(var(--sprout-toast-gap) + 1px)",
        "content": "\"\"",
        "position": "absolute",
        "top": "100%",
        "left": "0"
      },
      ".sprout-toast:focus-visible": {
        "outline": "var(--sprout-focus-width) solid var(--sprout-focus-ring)",
        "outline-offset": "0"
      },
      ".sprout-toast[data-expanded]": {
        "height": "var(--toast-height)",
        "transform": "translateX(var(--toast-swipe-movement-x)) translateY(var(--sprout-toast-offset-y))"
      },
      ".sprout-toast[data-limited]": {
        "opacity": "0"
      },
      ".sprout-toast[data-ending-style][data-swipe-direction=\"down\"]": {
        "transform": "translateY(calc(var(--toast-swipe-movement-y) + 150%))"
      },
      ".sprout-toast[data-ending-style][data-swipe-direction=\"up\"]": {
        "transform": "translateY(calc(var(--toast-swipe-movement-y) - 150%))"
      },
      ".sprout-toast[data-ending-style][data-swipe-direction=\"left\"]": {
        "transform": "translateX(calc(var(--toast-swipe-movement-x) - 150%)) translateY(var(--sprout-toast-offset-y))"
      },
      ".sprout-toast[data-ending-style][data-swipe-direction=\"right\"]": {
        "transform": "translateX(calc(var(--toast-swipe-movement-x) + 150%)) translateY(var(--sprout-toast-offset-y))"
      },
      ".sprout-toast-content": {
        "box-sizing": "border-box",
        "align-items": "center",
        "gap": "10px",
        "height": "100%",
        "padding": "12px 10px 12px 14px",
        "display": "flex",
        "overflow": "hidden"
      },
      ".sprout-toast-content[data-behind]:not([data-expanded])": {
        "opacity": "0"
      },
      ".sprout-toast-icon": {
        "color": "var(--sprout-text)",
        "flex-shrink": "0",
        "align-self": "flex-start",
        "margin-top": "2px",
        "display": "inline-flex"
      },
      ".sprout-toast-icon > svg": {
        "pointer-events": "none",
        "width": "16px",
        "height": "16px"
      },
      ".sprout-toast-icon[data-type=\"error\"]": {
        "color": "var(--sprout-danger)"
      },
      ".sprout-toast-text": {
        "overflow-wrap": "anywhere",
        "flex-direction": "column",
        "flex": "1",
        "gap": "2px",
        "min-width": "0",
        "display": "flex"
      },
      ".sprout-toast-title": {
        "font-size": "var(--sprout-text-sm)",
        "margin": "0",
        "font-weight": "500",
        "line-height": "1.25rem"
      },
      ".sprout-toast-description": {
        "color": "var(--sprout-muted)",
        "font-size": "var(--sprout-text-sm)",
        "margin": "0",
        "line-height": "1.25rem"
      },
      ".sprout-toast-action": {
        "flex-shrink": "0"
      },
      ".sprout-toast-close": {
        "color": "var(--sprout-muted)",
        "flex-shrink": "0",
        "align-self": "flex-start",
        "position": "relative"
      },
      ".sprout-toast-close:after": {
        "content": "\"\"",
        "position": "absolute",
        "inset": "-8px"
      },
      "@media (hover: hover)": {
        ".sprout-toast-close:hover": {
          "color": "var(--sprout-text)"
        }
      },
      "@media (forced-colors: active)": {
        ".sprout-toast": {
          "border-color": "canvastext"
        }
      },
      "@media (prefers-reduced-motion: no-preference)": {
        ".sprout-toast": {
          "transition": "transform var(--sprout-motion-normal) var(--sprout-motion-ease),\n        opacity var(--sprout-motion-normal) var(--sprout-motion-ease),\n        height var(--sprout-motion-fast) var(--sprout-motion-ease)"
        },
        ".sprout-toast-content": {
          "transition": "opacity var(--sprout-motion-fast) var(--sprout-motion-ease)"
        },
        ".sprout-toast[data-starting-style], .sprout-toast[data-ending-style]:not([data-limited]):not([data-swipe-direction])": {
          "transform": "translateY(150%)"
        }
      },
      "@media (prefers-reduced-motion: reduce)": {
        ".sprout-toast": {
          "transition": "opacity var(--sprout-motion-fast) linear"
        },
        ".sprout-toast:is([data-starting-style], [data-ending-style])": {
          "opacity": "0"
        }
      }
    }
  },
  "docs": "Docs and examples: https://sprout.tulipfarm.ai/components/toast/",
  "meta": {
    "source": "packages/sprout/src/components/toast.tsx"
  }
}
