{
  "name": "toast",
  "type": "registry:ui",
  "framework": "react",
  "title": "Toast",
  "description": "A transient notification with a status icon that auto-dismisses after a timeout or when closed.",
  "dependencies": [
    "class-variance-authority",
    "radix-ui"
  ],
  "files": [
    {
      "path": "ui/toast.tsx",
      "content": "\"use client\"\n\nimport { cva, type VariantProps } from \"class-variance-authority\"\nimport { Toast as ToastPrimitive } from \"radix-ui\"\nimport * as React from \"react\"\n\nimport { cn } from \"@/lib/utils\"\n\nconst toastVariants = cva(\n  [\n    \"flex max-w-[360px] items-start gap-3 rounded-[var(--newt-radius-md)] border border-newt-border bg-newt-bg-elevated px-3.5 py-3 text-newt-text-primary shadow-elevation-high\",\n    \"focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-newt-text-link\",\n    /* The toast follows the pointer while it is swiped away. */\n    \"data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=cancel]:translate-x-0 data-[swipe=cancel]:transition-transform data-[swipe=cancel]:duration-fast data-[swipe=cancel]:ease-newt\",\n  ],\n  {\n    variants: {\n      variant: {\n        success: \"\",\n        error: \"\",\n      },\n    },\n    defaultVariants: {\n      variant: \"success\",\n    },\n  }\n)\n\nconst toastIconVariants = cva(\n  \"flex h-5 w-5 shrink-0 items-center justify-center rounded-full text-xs text-newt-on-accent\",\n  {\n    variants: {\n      variant: {\n        success: \"bg-newt-online\",\n        error: \"bg-newt-dnd\",\n      },\n    },\n    defaultVariants: {\n      variant: \"success\",\n    },\n  }\n)\n\ntype ToastVariant = NonNullable<VariantProps<typeof toastVariants>[\"variant\"]>\n\n/* The variant of the enclosing toast, which picks the icon's colour and glyph. */\nconst ToastVariantContext = React.createContext<ToastVariant>(\"success\")\n\n/*\n * Radix owns the behaviour: the dismiss timer and its pause on hover, focus\n * and window blur, swipe to dismiss, Escape, and the announcement to screen\n * readers. Only the look is newt/ui's. Every toast needs a `ToastProvider`\n * above it and a `ToastViewport` inside that provider.\n */\nconst ToastProvider = ToastPrimitive.Provider\n\n/*\n * The list every toast of the provider is rendered into, wherever the toast\n * itself is written. It floats at the bottom inline-end corner. Pass\n * `className=\"static items-start\"` to lay it out in the page flow instead.\n */\nconst ToastViewport = React.forwardRef<\n  React.ComponentRef<typeof ToastPrimitive.Viewport>,\n  React.ComponentPropsWithoutRef<typeof ToastPrimitive.Viewport>\n>(({ className, ...props }, ref) => (\n  <ToastPrimitive.Viewport\n    ref={ref}\n    className={cn(\n      \"fixed bottom-4 end-4 z-[130] m-0 flex max-w-[calc(100vw-2rem)] list-none flex-col items-end gap-3 p-0 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-newt-text-link\",\n      className\n    )}\n    {...props}\n  />\n))\nToastViewport.displayName = \"ToastViewport\"\n\nexport interface ToastProps\n  extends\n    React.ComponentPropsWithoutRef<typeof ToastPrimitive.Root>,\n    VariantProps<typeof toastVariants> {\n  /**\n   * Auto-dismiss after this many ms. Defaults to the provider's `duration`,\n   * which is 5000. Pass 0 to disable.\n   */\n  duration?: number\n}\n\nconst Toast = React.forwardRef<\n  React.ComponentRef<typeof ToastPrimitive.Root>,\n  ToastProps\n>(({ className, variant, duration, type = \"background\", ...props }, ref) => {\n  const resolved = variant ?? \"success\"\n  return (\n    <ToastVariantContext.Provider value={resolved}>\n      <ToastPrimitive.Root\n        ref={ref}\n        /* `background` announces politely; `foreground` interrupts. */\n        type={type}\n        /* Radix reads 0 as \"not set\" and falls back to the provider's value. */\n        duration={duration === 0 ? Infinity : duration}\n        data-variant={resolved}\n        className={cn(toastVariants({ variant }), className)}\n        {...props}\n      />\n    </ToastVariantContext.Provider>\n  )\n})\nToast.displayName = \"Toast\"\n\nconst ToastIcon = React.forwardRef<\n  HTMLDivElement,\n  React.HTMLAttributes<HTMLDivElement>\n>(({ className, children, ...props }, ref) => {\n  const variant = React.useContext(ToastVariantContext)\n  return (\n    <div\n      ref={ref}\n      aria-hidden=\"true\"\n      className={cn(toastIconVariants({ variant }), className)}\n      {...props}\n    >\n      {children ?? (variant === \"success\" ? \"✓\" : \"!\")}\n    </div>\n  )\n})\nToastIcon.displayName = \"ToastIcon\"\n\nconst ToastContent = React.forwardRef<\n  HTMLDivElement,\n  React.HTMLAttributes<HTMLDivElement>\n>(({ className, ...props }, ref) => (\n  <div ref={ref} className={cn(\"min-w-0 flex-1\", className)} {...props} />\n))\nToastContent.displayName = \"ToastContent\"\n\nconst ToastTitle = React.forwardRef<\n  React.ComponentRef<typeof ToastPrimitive.Title>,\n  React.ComponentPropsWithoutRef<typeof ToastPrimitive.Title>\n>(({ className, ...props }, ref) => (\n  <ToastPrimitive.Title\n    ref={ref}\n    className={cn(\"text-sm font-semibold\", className)}\n    {...props}\n  />\n))\nToastTitle.displayName = \"ToastTitle\"\n\nconst ToastDescription = React.forwardRef<\n  React.ComponentRef<typeof ToastPrimitive.Description>,\n  React.ComponentPropsWithoutRef<typeof ToastPrimitive.Description>\n>(({ className, ...props }, ref) => (\n  <ToastPrimitive.Description\n    ref={ref}\n    className={cn(\n      \"mt-0.5 text-[13px] text-[var(--newt-text-secondary)]\",\n      className\n    )}\n    {...props}\n  />\n))\nToastDescription.displayName = \"ToastDescription\"\n\n/*\n * A button that acts on the toast and then closes it. It has no look of its\n * own; wrap a Button with `asChild`. `altText` tells a screen reader user\n * another way to do the same thing, because the toast can be gone before\n * they reach the button.\n */\nconst ToastAction = ToastPrimitive.Action\n\nconst ToastClose = React.forwardRef<\n  React.ComponentRef<typeof ToastPrimitive.Close>,\n  React.ComponentPropsWithoutRef<typeof ToastPrimitive.Close>\n>(({ className, children, ...props }, ref) => (\n  <ToastPrimitive.Close\n    ref={ref}\n    aria-label=\"Dismiss\"\n    className={cn(\n      \"shrink-0 cursor-pointer border-0 bg-transparent p-0 text-base leading-none text-newt-text-muted transition-colors duration-fast ease-newt hover:text-newt-text-primary\",\n      className\n    )}\n    {...props}\n  >\n    {children ?? \"×\"}\n  </ToastPrimitive.Close>\n))\nToastClose.displayName = \"ToastClose\"\n\nexport {\n  ToastProvider,\n  ToastViewport,\n  Toast,\n  ToastIcon,\n  ToastContent,\n  ToastTitle,\n  ToastDescription,\n  ToastAction,\n  ToastClose,\n  toastVariants,\n  toastIconVariants,\n}\n",
      "type": "registry:ui"
    }
  ]
}