{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "notification-center",
  "title": "Notification Center",
  "description": "A bell button with an unread badge that opens a notification panel: All and Unread tabs, Today and Earlier groups, unread dots, mark as read on click, mark all as read, per-item remove and full keyboard support.",
  "dependencies": [
    "motion",
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/notification-center/notification-center.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { motion, AnimatePresence, useReducedMotion } from \"motion/react\";\nimport { clsx, type ClassValue } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nfunction cn(...inputs: ClassValue[]) {\n  return twMerge(clsx(inputs));\n}\n\nexport type NotificationCenterSize = \"sm\" | \"md\" | \"lg\";\n\nexport interface NotificationItem {\n  id: string;\n  /** Who or what it's from; shown as the avatar's initials when there's no avatar image. */\n  actor: string;\n  /** What happened, shown after the actor: \"commented on Q3 roadmap\". */\n  title: string;\n  /** Optional quoted text or detail under the title. */\n  body?: string;\n  /** A ready-made label such as \"2m\" or \"Yesterday\". */\n  time: string;\n  /** Section heading this item sits under, e.g. \"Today\" or \"Earlier\". */\n  group?: string;\n  avatar?: string;\n  read?: boolean;\n}\n\nexport interface NotificationCenterProps {\n  items?: NotificationItem[];\n  defaultItems?: NotificationItem[];\n  onItemsChange?: (items: NotificationItem[]) => void;\n  onItemClick?: (item: NotificationItem) => void;\n  open?: boolean;\n  defaultOpen?: boolean;\n  onOpenChange?: (open: boolean) => void;\n  title?: string;\n  /** Which edge of the bell the panel lines up with. */\n  align?: \"start\" | \"end\";\n  size?: NotificationCenterSize;\n  theme?: \"dark\" | \"light\";\n  width?: number;\n  emptyText?: string;\n  className?: string;\n}\n\nconst PALETTES = {\n  dark: { text: \"#F5F4F1\", muted: \"rgba(245,244,241,0.52)\", faint: \"rgba(245,244,241,0.14)\", bg: \"rgba(255,255,255,0.03)\", panel: \"#111111\", hover: \"rgba(255,255,255,0.06)\", border: \"rgba(255,255,255,0.12)\", borderHover: \"rgba(255,255,255,0.24)\", focus: \"rgba(245,244,241,0.85)\", pill: \"#F5F4F1\", pillText: \"#0A0A0A\", avatar: \"rgba(255,255,255,0.08)\", dot: \"#FF7A6B\", shadow: \"0 18px 48px rgba(0,0,0,0.5), 0 2px 8px rgba(0,0,0,0.35)\" },\n  light: { text: \"#0A0A0A\", muted: \"rgba(10,10,10,0.52)\", faint: \"rgba(10,10,10,0.1)\", bg: \"#FFFFFF\", panel: \"#FFFFFF\", hover: \"rgba(10,10,10,0.05)\", border: \"rgba(10,10,10,0.14)\", borderHover: \"rgba(10,10,10,0.28)\", focus: \"rgba(10,10,10,0.85)\", pill: \"#0A0A0A\", pillText: \"#FFFFFF\", avatar: \"rgba(10,10,10,0.06)\", dot: \"#E5484D\", shadow: \"0 18px 48px rgba(10,10,10,0.14), 0 2px 8px rgba(10,10,10,0.06)\" },\n};\n\nconst SIZES: Record<NotificationCenterSize, { font: number; small: number; button: number; icon: number; radius: number; avatar: number; pad: number }> = {\n  sm: { font: 13, small: 12, button: 36, icon: 17, radius: 11, avatar: 30, pad: 12 },\n  md: { font: 14, small: 12.5, button: 44, icon: 19, radius: 13, avatar: 34, pad: 14 },\n  lg: { font: 15.5, small: 13.5, button: 52, icon: 21, radius: 15, avatar: 38, pad: 16 },\n};\n\nconst DEFAULT_ITEMS: NotificationItem[] = [\n  { id: \"n1\", actor: \"Maya Chen\", title: \"commented on Q3 roadmap\", body: \"Love the new timeline. Can we pull the launch forward a week?\", time: \"2m\", group: \"Today\" },\n  { id: \"n2\", actor: \"Leo Park\", title: \"invited you to Brand refresh\", time: \"18m\", group: \"Today\" },\n  { id: \"n3\", actor: \"Stripe\", title: \"Payout of $4,280.00 is on its way\", time: \"1h\", group: \"Today\" },\n  { id: \"n4\", actor: \"Nora Wills\", title: \"approved your pull request #482\", time: \"Yesterday\", group: \"Earlier\", read: true },\n  { id: \"n5\", actor: \"Sam Ortiz\", title: \"mentioned you in Design review\", body: \"@you the spacing on the cards looks great now.\", time: \"Mon\", group: \"Earlier\", read: true },\n];\n\nfunction initials(name: string) {\n  const parts = name.trim().split(/\\s+/);\n  return ((parts[0]?.[0] ?? \"\") + (parts.length > 1 ? (parts[parts.length - 1][0] ?? \"\") : \"\")).toUpperCase();\n}\n\nfunction BellIcon({ size, ringing }: { size: number; ringing: boolean }) {\n  return (\n    <motion.svg\n      width={size}\n      height={size}\n      viewBox=\"0 0 20 20\"\n      fill=\"none\"\n      stroke=\"currentColor\"\n      strokeWidth=\"1.6\"\n      strokeLinecap=\"round\"\n      strokeLinejoin=\"round\"\n      aria-hidden=\"true\"\n      style={{ originX: \"50%\", originY: \"15%\" }}\n      animate={ringing ? { rotate: [0, 14, -12, 8, -5, 0] } : { rotate: 0 }}\n      transition={{ duration: 0.6, ease: \"easeOut\" }}\n    >\n      <path d=\"M5 8a5 5 0 0 1 10 0c0 3.8 1.4 5.2 1.9 5.7H3.1C3.6 13.2 5 11.8 5 8Z\" />\n      <path d=\"M8.2 16.2a1.9 1.9 0 0 0 3.6 0\" />\n    </motion.svg>\n  );\n}\n\nexport function NotificationCenter({\n  items,\n  defaultItems = DEFAULT_ITEMS,\n  onItemsChange,\n  onItemClick,\n  open,\n  defaultOpen = false,\n  onOpenChange,\n  title = \"Notifications\",\n  align = \"end\",\n  size = \"md\",\n  theme = \"dark\",\n  width = 380,\n  emptyText = \"You're all caught up.\",\n  className,\n}: NotificationCenterProps) {\n  const p = PALETTES[theme];\n  const s = SIZES[size];\n  const uid = React.useId();\n  const reduce = Boolean(useReducedMotion());\n  const rootRef = React.useRef<HTMLDivElement>(null);\n  const buttonRef = React.useRef<HTMLButtonElement>(null);\n  const listRef = React.useRef<HTMLUListElement>(null);\n\n  const [internalItems, setInternalItems] = React.useState(defaultItems);\n  const list = items ?? internalItems;\n  const setList = (next: NotificationItem[]) => {\n    if (items === undefined) setInternalItems(next);\n    onItemsChange?.(next);\n  };\n\n  const [internalOpen, setInternalOpen] = React.useState(defaultOpen);\n  const isOpen = open ?? internalOpen;\n  const setOpen = React.useCallback(\n    (next: boolean) => {\n      if (open === undefined) setInternalOpen(next);\n      onOpenChange?.(next);\n    },\n    [open, onOpenChange],\n  );\n\n  const [tab, setTab] = React.useState<\"all\" | \"unread\">(\"all\");\n  const [hoverBell, setHoverBell] = React.useState(false);\n  const unread = list.filter((n) => !n.read).length;\n  const visible = tab === \"unread\" ? list.filter((n) => !n.read) : list;\n\n  // Ring the bell when the unread count goes up.\n  const [ringKey, setRingKey] = React.useState(0);\n  const [prevUnread, setPrevUnread] = React.useState(unread);\n  if (unread !== prevUnread) {\n    if (unread > prevUnread) setRingKey((k) => k + 1);\n    setPrevUnread(unread);\n  }\n\n  React.useEffect(() => {\n    if (!isOpen) return;\n    const onDown = (e: PointerEvent) => {\n      if (rootRef.current && !rootRef.current.contains(e.target as Node)) setOpen(false);\n    };\n    const onKey = (e: KeyboardEvent) => {\n      if (e.key === \"Escape\") {\n        setOpen(false);\n        buttonRef.current?.focus();\n      }\n    };\n    document.addEventListener(\"pointerdown\", onDown);\n    document.addEventListener(\"keydown\", onKey);\n    return () => {\n      document.removeEventListener(\"pointerdown\", onDown);\n      document.removeEventListener(\"keydown\", onKey);\n    };\n  }, [isOpen, setOpen]);\n\n  const markRead = (id: string) => setList(list.map((n) => (n.id === id ? { ...n, read: true } : n)));\n  const markAll = () => setList(list.map((n) => ({ ...n, read: true })));\n  const remove = (id: string) => setList(list.filter((n) => n.id !== id));\n\n  // Arrow keys move between rows; Home/End jump to the ends.\n  const onListKey = (e: React.KeyboardEvent<HTMLUListElement>) => {\n    const rows = Array.from(listRef.current?.querySelectorAll<HTMLElement>(\"[data-nc-row]\") ?? []);\n    const i = rows.indexOf(document.activeElement as HTMLElement);\n    let next = -1;\n    if (e.key === \"ArrowDown\") next = Math.min(rows.length - 1, i + 1);\n    else if (e.key === \"ArrowUp\") next = Math.max(0, i - 1);\n    else if (e.key === \"Home\") next = 0;\n    else if (e.key === \"End\") next = rows.length - 1;\n    if (next >= 0) {\n      e.preventDefault();\n      rows[next]?.focus();\n    }\n  };\n\n  const groups: { name: string; items: NotificationItem[] }[] = [];\n  for (const n of visible) {\n    const name = n.group ?? \"\";\n    const g = groups.find((x) => x.name === name);\n    if (g) g.items.push(n);\n    else groups.push({ name, items: [n] });\n  }\n\n  return (\n    <div ref={rootRef} className={cn(\"relative inline-flex\", className)} style={{ fontFamily: \"Inter, sans-serif\" }}>\n      <motion.button\n        ref={buttonRef}\n        type=\"button\"\n        aria-label={unread ? `${title}, ${unread} unread` : title}\n        aria-haspopup=\"dialog\"\n        aria-expanded={isOpen}\n        aria-controls={`${uid}-panel`}\n        onClick={() => setOpen(!isOpen)}\n        onMouseEnter={() => setHoverBell(true)}\n        onMouseLeave={() => setHoverBell(false)}\n        whileTap={{ scale: 0.92 }}\n        className=\"relative flex cursor-pointer items-center justify-center outline-none focus-visible:ring-2\"\n        style={{ width: s.button, height: s.button, borderRadius: s.radius, background: isOpen || hoverBell ? p.hover : p.bg, border: `1px solid ${isOpen ? p.focus : hoverBell ? p.borderHover : p.border}`, color: p.text, transition: \"background 0.16s ease, border-color 0.16s ease\", [\"--tw-ring-color\" as string]: p.focus }}\n      >\n        <BellIcon key={ringKey} size={s.icon} ringing={ringKey > 0 && !reduce} />\n        <AnimatePresence>\n          {unread > 0 && (\n            <motion.span\n              key=\"badge\"\n              initial={{ scale: 0 }}\n              animate={{ scale: 1 }}\n              exit={{ scale: 0 }}\n              transition={{ type: \"spring\", stiffness: 520, damping: 28 }}\n              className=\"absolute flex items-center justify-center font-semibold tabular-nums\"\n              style={{ top: -5, right: -5, minWidth: 18, height: 18, padding: \"0 5px\", borderRadius: 9, background: p.dot, color: \"#0A0A0A\", fontSize: 11, lineHeight: 1, boxShadow: `0 0 0 2px ${theme === \"dark\" ? \"#0A0A0A\" : \"#FFFFFF\"}` }}\n            >\n              {unread > 9 ? \"9+\" : unread}\n            </motion.span>\n          )}\n        </AnimatePresence>\n      </motion.button>\n\n      <AnimatePresence>\n        {isOpen && (\n          <motion.div\n            id={`${uid}-panel`}\n            role=\"dialog\"\n            aria-label={title}\n            initial={reduce ? { opacity: 0 } : { opacity: 0, scale: 0.96, y: -4 }}\n            animate={{ opacity: 1, scale: 1, y: 0 }}\n            exit={reduce ? { opacity: 0 } : { opacity: 0, scale: 0.96, y: -4 }}\n            transition={{ duration: 0.16, ease: [0.22, 1, 0.36, 1] }}\n            className=\"absolute z-50 flex flex-col overflow-hidden\"\n            style={{ top: s.button + 8, [align === \"end\" ? \"right\" : \"left\"]: 0, width, maxWidth: \"calc(100vw - 32px)\", borderRadius: s.radius + 3, background: p.panel, border: `1px solid ${p.border}`, boxShadow: p.shadow, transformOrigin: align === \"end\" ? \"top right\" : \"top left\" }}\n          >\n            <div className=\"flex items-center justify-between\" style={{ padding: `${s.pad}px ${s.pad}px ${s.pad - 4}px` }}>\n              <span className=\"font-semibold tracking-[-0.01em]\" style={{ color: p.text, fontSize: s.font + 1 }}>\n                {title}\n              </span>\n              <button\n                type=\"button\"\n                onClick={markAll}\n                disabled={unread === 0}\n                className=\"cursor-pointer border-none bg-transparent p-0 font-medium outline-none focus-visible:underline disabled:cursor-default\"\n                style={{ color: unread ? p.text : p.muted, fontSize: s.small, opacity: unread ? 1 : 0.6, transition: \"color 0.16s ease\" }}\n              >\n                Mark all as read\n              </button>\n            </div>\n\n            <div className=\"flex\" style={{ padding: `0 ${s.pad}px ${s.pad - 4}px` }} role=\"tablist\" aria-label=\"Filter notifications\">\n              <div className=\"flex gap-1 p-[3px]\" style={{ borderRadius: 999, border: `1px solid ${p.border}`, background: p.bg }}>\n                {([\"all\", \"unread\"] as const).map((key) => (\n                  <button\n                    key={key}\n                    type=\"button\"\n                    role=\"tab\"\n                    aria-selected={tab === key}\n                    onClick={() => setTab(key)}\n                    className=\"relative cursor-pointer border-none bg-transparent font-semibold outline-none focus-visible:ring-2\"\n                    style={{ padding: \"4px 12px\", borderRadius: 999, fontSize: s.small, color: tab === key ? p.pillText : p.muted, transition: \"color 0.16s ease\", [\"--tw-ring-color\" as string]: p.focus }}\n                  >\n                    {tab === key && <motion.span layoutId={`${uid}-tab`} className=\"absolute inset-0\" style={{ borderRadius: 999, background: p.pill }} transition={{ type: \"spring\", stiffness: 500, damping: 38 }} />}\n                    <span className=\"relative\">\n                      {key === \"all\" ? \"All\" : \"Unread\"}\n                      {key === \"unread\" && unread > 0 ? ` ${unread}` : \"\"}\n                    </span>\n                  </button>\n                ))}\n              </div>\n            </div>\n\n            <div style={{ borderTop: `1px solid ${p.faint}`, maxHeight: 380, overflowY: \"auto\" }}>\n              {visible.length === 0 ? (\n                <div className=\"flex flex-col items-center gap-2 text-center\" style={{ padding: \"36px 24px\", color: p.muted, fontSize: s.font }}>\n                  <svg width=\"28\" height=\"28\" viewBox=\"0 0 20 20\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.4\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n                    <circle cx=\"10\" cy=\"10\" r=\"7.25\" />\n                    <path d=\"M6.8 10.2 8.9 12.3 13.3 7.9\" />\n                  </svg>\n                  {emptyText}\n                </div>\n              ) : (\n                <ul ref={listRef} className=\"m-0 list-none p-0\" onKeyDown={onListKey} aria-label={title}>\n                  <AnimatePresence initial={false}>\n                    {groups.map((g) => [\n                      g.name ? (\n                        <motion.li key={`g-${g.name}`} layout={!reduce} aria-hidden=\"true\" className=\"font-semibold uppercase\" style={{ padding: `${s.pad - 2}px ${s.pad}px 4px`, color: p.muted, fontSize: 11, letterSpacing: \"0.06em\" }}>\n                          {g.name}\n                        </motion.li>\n                      ) : null,\n                      ...g.items.map((n) => (\n                        <motion.li\n                          key={n.id}\n                          layout={!reduce}\n                          initial={{ opacity: 0 }}\n                          animate={{ opacity: 1 }}\n                          exit={{ opacity: 0, height: 0, transition: { duration: 0.18 } }}\n                          className=\"group relative\"\n                        >\n                          <div\n                            data-nc-row\n                            role=\"button\"\n                            tabIndex={0}\n                            aria-label={`${n.actor} ${n.title}${n.read ? \"\" : \", unread\"}, ${n.time}`}\n                            onClick={() => {\n                              if (!n.read) markRead(n.id);\n                              onItemClick?.(n);\n                            }}\n                            onKeyDown={(e) => {\n                              if (e.key === \"Enter\" || e.key === \" \") {\n                                e.preventDefault();\n                                if (!n.read) markRead(n.id);\n                                onItemClick?.(n);\n                              } else if (e.key === \"Delete\" || e.key === \"Backspace\") {\n                                e.preventDefault();\n                                remove(n.id);\n                              }\n                            }}\n                            className=\"flex cursor-pointer items-start outline-none focus-visible:ring-2 focus-visible:ring-inset\"\n                            style={{ gap: 11, padding: `10px ${s.pad + 26}px 10px ${s.pad}px`, [\"--tw-ring-color\" as string]: p.focus, transition: \"background 0.14s ease\" }}\n                            onMouseEnter={(e) => (e.currentTarget.style.background = p.hover)}\n                            onMouseLeave={(e) => (e.currentTarget.style.background = \"transparent\")}\n                          >\n                            <span className=\"relative shrink-0\">\n                              {n.avatar ? (\n                                // eslint-disable-next-line @next/next/no-img-element\n                                <img src={n.avatar} alt=\"\" className=\"block rounded-full object-cover\" style={{ width: s.avatar, height: s.avatar }} />\n                              ) : (\n                                <span className=\"flex items-center justify-center rounded-full font-semibold\" style={{ width: s.avatar, height: s.avatar, background: p.avatar, color: p.text, fontSize: s.small - 0.5, border: `1px solid ${p.faint}` }}>\n                                  {initials(n.actor)}\n                                </span>\n                              )}\n                            </span>\n                            <span className=\"min-w-0 flex-1\" style={{ fontSize: s.font, lineHeight: 1.45 }}>\n                              <span style={{ color: p.text }}>\n                                <span className=\"font-semibold\">{n.actor}</span> <span style={{ color: n.read ? p.muted : p.text }}>{n.title}</span>\n                              </span>\n                              {n.body && (\n                                <span className=\"mt-1 block\" style={{ color: p.muted, fontSize: s.small, lineHeight: 1.45, paddingLeft: 9, borderLeft: `2px solid ${p.faint}` }}>\n                                  {n.body}\n                                </span>\n                              )}\n                              <span className=\"mt-1 block tabular-nums\" style={{ color: p.muted, fontSize: s.small - 0.5 }}>\n                                {n.time}\n                              </span>\n                            </span>\n                          </div>\n\n                          <AnimatePresence>\n                            {!n.read && (\n                              <motion.span\n                                key=\"dot\"\n                                aria-hidden=\"true\"\n                                initial={{ scale: 0 }}\n                                animate={{ scale: 1 }}\n                                exit={{ scale: 0 }}\n                                className=\"pointer-events-none absolute rounded-full transition-opacity duration-150 group-focus-within:opacity-0 group-hover:opacity-0\"\n                                style={{ right: s.pad + 4, top: 17, width: 8, height: 8, background: p.dot }}\n                              />\n                            )}\n                          </AnimatePresence>\n\n                          <button\n                            type=\"button\"\n                            aria-label={`Remove notification from ${n.actor}`}\n                            onClick={() => remove(n.id)}\n                            className=\"absolute flex cursor-pointer items-center justify-center border-none bg-transparent opacity-0 outline-none transition-opacity duration-150 group-focus-within:opacity-100 group-hover:opacity-100 focus-visible:ring-2\"\n                            style={{ right: s.pad - 3, top: 10, width: 24, height: 24, borderRadius: 7, color: p.muted, [\"--tw-ring-color\" as string]: p.focus }}\n                            onMouseEnter={(e) => (e.currentTarget.style.color = p.text)}\n                            onMouseLeave={(e) => (e.currentTarget.style.color = p.muted)}\n                          >\n                            <svg width=\"12\" height=\"12\" viewBox=\"0 0 12 12\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.6\" strokeLinecap=\"round\" aria-hidden=\"true\">\n                              <path d=\"M3 3l6 6M9 3L3 9\" />\n                            </svg>\n                          </button>\n                        </motion.li>\n                      )),\n                    ])}\n                  </AnimatePresence>\n                </ul>\n              )}\n            </div>\n          </motion.div>\n        )}\n      </AnimatePresence>\n    </div>\n  );\n}\n\nexport default NotificationCenter;\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}