{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "update-available-snackbar",
  "title": "Update Available Snackbar",
  "description": "A snackbar that says a new version is ready with Reload and Later buttons, that does not time out because the choice matters, and that is announced once. Use this when a service worker has downloaded a new version and the person decides when to reload.",
  "registryDependencies": [
    "button"
  ],
  "files": [
    {
      "path": "registry/patterns/update-available-snackbar/update-available-snackbar.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\n\nimport { Button } from \"@/components/ui/button\"\n\nexport interface UpdateAvailableSnackbarProps {\n  open: boolean\n  onReload: () => void\n  onLater: () => void\n}\n\nexport function UpdateAvailableSnackbar({\n  open,\n  onReload,\n  onLater,\n}: UpdateAvailableSnackbarProps) {\n  const returnFocus = React.useRef<Element | null>(null)\n\n  React.useEffect(() => {\n    if (open) returnFocus.current = document.activeElement\n  }, [open])\n\n  return (\n    <div\n      role=\"status\"\n      aria-live=\"polite\"\n      className=\"pointer-events-none fixed inset-x-0 bottom-[max(1rem,env(safe-area-inset-bottom))] z-50 flex justify-center px-4\"\n    >\n      {open && (\n        <div className=\"bg-foreground text-background animate-in fade-in-0 slide-in-from-bottom-2 pointer-events-auto flex w-full max-w-md items-center gap-3 rounded-xl p-3 shadow-lg motion-reduce:animate-none\">\n          <p className=\"flex-1 text-sm\">\n            A new version is ready. Your work is saved.\n          </p>\n          <Button size=\"sm\" variant=\"secondary\" onClick={onReload}>\n            Reload\n          </Button>\n          <Button\n            size=\"sm\"\n            variant=\"ghost\"\n            className=\"text-background hover:text-background\"\n            onClick={() => {\n              onLater()\n              ;(returnFocus.current as HTMLElement | null)?.focus?.()\n            }}\n          >\n            Later\n          </Button>\n        </div>\n      )}\n    </div>\n  )\n}\n",
      "type": "registry:block"
    }
  ],
  "type": "registry:block"
}