{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "section-heading",
  "title": "Section Heading",
  "description": "A section heading for inside a page: title with a count, description, a search that expands from an icon, a primary action, status tabs with counts, a sort menu and a grid or list switch, wired to the content under it so filtering, sorting and layout changes animate.",
  "dependencies": [
    "motion",
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/section-heading/section-heading.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { AnimatePresence, motion, 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 interface SectionItem {\n  id: string;\n  title: string;\n  owner: string;\n  status: \"active\" | \"paused\" | \"archived\";\n  updated: number;\n  color: string;\n  progress: number;\n}\n\nexport interface SectionHeadingProps {\n  title?: string;\n  description?: string;\n  items?: SectionItem[];\n  actionLabel?: string;\n  onAction?: () => void;\n  theme?: \"dark\" | \"light\";\n  className?: string;\n}\n\nconst PALETTES = {\n  dark: { bg: \"#0A0A0A\", text: \"#F5F4F1\", muted: \"rgba(245,244,241,0.62)\", faint: \"rgba(245,244,241,0.36)\", card: \"#121212\", tile: \"#161616\", border: \"rgba(255,255,255,0.09)\", chip: \"rgba(255,255,255,0.06)\", hover: \"rgba(255,255,255,0.04)\", on: \"#F5F4F1\", onText: \"#0A0A0A\", green: \"#4ADE80\", amber: \"#FBBF24\", ring: \"rgba(245,244,241,0.6)\", pop: \"#181818\", shadow: \"0 20px 50px -16px rgba(0,0,0,0.8)\", track: \"rgba(255,255,255,0.08)\" },\n  light: { bg: \"#FAFAF8\", text: \"#0A0A0A\", muted: \"rgba(10,10,10,0.62)\", faint: \"rgba(10,10,10,0.4)\", card: \"#FFFFFF\", tile: \"#FAFAF8\", border: \"rgba(10,10,10,0.09)\", chip: \"rgba(10,10,10,0.05)\", hover: \"rgba(10,10,10,0.03)\", on: \"#0A0A0A\", onText: \"#FAFAF8\", green: \"#15803D\", amber: \"#B45309\", ring: \"rgba(10,10,10,0.5)\", pop: \"#FFFFFF\", shadow: \"0 20px 50px -20px rgba(0,0,0,0.25)\", track: \"rgba(10,10,10,0.07)\" },\n};\n\nconst DEFAULT_ITEMS: SectionItem[] = [\n  { id: \"1\", title: \"Website v3\", owner: \"Mara\", status: \"active\", updated: 1, color: \"#FB923C\", progress: 64 },\n  { id: \"2\", title: \"Mobile app\", owner: \"Daniel\", status: \"active\", updated: 3, color: \"#A78BFA\", progress: 41 },\n  { id: \"3\", title: \"Brand refresh\", owner: \"Lena\", status: \"active\", updated: 0, color: \"#4ADE80\", progress: 88 },\n  { id: \"4\", title: \"Data warehouse\", owner: \"Tomás\", status: \"paused\", updated: 12, color: \"#60A5FA\", progress: 22 },\n  { id: \"5\", title: \"Help center\", owner: \"Noor\", status: \"active\", updated: 5, color: \"#F472B6\", progress: 53 },\n  { id: \"6\", title: \"Partner portal\", owner: \"Priya\", status: \"archived\", updated: 40, color: \"#FBBF24\", progress: 100 },\n];\nconst SORTS = [\n  { id: \"updated\", label: \"Last updated\" },\n  { id: \"name\", label: \"Name\" },\n  { id: \"progress\", label: \"Progress\" },\n] as const;\ntype SortId = (typeof SORTS)[number][\"id\"];\ntype Tab = \"all\" | \"active\" | \"paused\" | \"archived\";\n\nconst ago = (d: number) => (d === 0 ? \"Today\" : d === 1 ? \"Yesterday\" : `${d}d ago`);\n\nexport function SectionHeading({ title = \"Projects\", description = \"Everything your team is working on, in one place.\", items = DEFAULT_ITEMS, actionLabel = \"New project\", onAction, theme = \"dark\", className }: SectionHeadingProps) {\n  const p = PALETTES[theme];\n  const reduce = !!useReducedMotion();\n  const uid = React.useId();\n  const [tab, setTab] = React.useState<Tab>(\"all\");\n  const [sort, setSort] = React.useState<SortId>(\"updated\");\n  const [view, setView] = React.useState<\"grid\" | \"list\">(\"grid\");\n  const [sortOpen, setSortOpen] = React.useState(false);\n  const [q, setQ] = React.useState(\"\");\n  const [searchOpen, setSearchOpen] = React.useState(false);\n  const focusSearch = React.useCallback((el: HTMLInputElement | null) => el?.focus(), []);\n\n  React.useEffect(() => {\n    if (!sortOpen) return;\n    const down = (e: MouseEvent) => !(e.target as HTMLElement).closest(\"[data-sort]\") && setSortOpen(false);\n    const key = (e: KeyboardEvent) => e.key === \"Escape\" && setSortOpen(false);\n    document.addEventListener(\"mousedown\", down);\n    document.addEventListener(\"keydown\", key);\n    return () => {\n      document.removeEventListener(\"mousedown\", down);\n      document.removeEventListener(\"keydown\", key);\n    };\n  }, [sortOpen]);\n\n  const count = (t: Tab) => items.filter((i) => t === \"all\" || i.status === t).length;\n  const query = q.trim().toLowerCase();\n  const rows = items\n    .filter((i) => (tab === \"all\" || i.status === tab) && (!query || `${i.title} ${i.owner}`.toLowerCase().includes(query)))\n    .sort((a, b) => (sort === \"name\" ? a.title.localeCompare(b.title) : sort === \"progress\" ? b.progress - a.progress : a.updated - b.updated));\n\n  const ring = { [\"--tw-ring-color\" as string]: p.ring, [\"--tw-ring-offset-color\" as string]: p.card } as React.CSSProperties;\n  const focus = \"outline-none focus-visible:ring-2 focus-visible:ring-offset-2\";\n  const statusColor = (s: SectionItem[\"status\"]) => (s === \"active\" ? p.green : s === \"paused\" ? p.amber : p.faint);\n\n  return (\n    <section className={cn(\"@container w-full\", className)} style={{ background: p.bg, color: p.text }}>\n      <div className=\"mx-auto max-w-5xl px-4 py-10 @[640px]:px-6 @[640px]:py-14\">\n        <div className=\"rounded-2xl border p-5 @[640px]:p-6\" style={{ background: p.card, borderColor: p.border }}>\n          {/* Heading */}\n          <div className=\"flex flex-col gap-4 @[640px]:flex-row @[640px]:items-start @[640px]:justify-between\">\n            <div className=\"min-w-0\">\n              <h2 className=\"m-0 flex items-center gap-2 text-[19px] font-semibold tracking-[-0.015em]\">\n                {title}\n                <span className=\"rounded-full px-2 py-0.5 text-[12px] font-medium tabular-nums\" style={{ background: p.chip, color: p.muted }}>\n                  {items.length}\n                </span>\n              </h2>\n              <p className=\"m-0 mt-1 text-[13.5px]\" style={{ color: p.muted }}>\n                {description}\n              </p>\n            </div>\n            <div className=\"flex items-center gap-2\">\n              <AnimatePresence initial={false} mode=\"popLayout\">\n                {searchOpen ? (\n                  <motion.label key=\"search\" initial={reduce ? false : { width: 36, opacity: 0 }} animate={{ width: 200, opacity: 1 }} exit={reduce ? undefined : { width: 36, opacity: 0 }} className=\"relative block overflow-hidden\">\n                    <span className=\"sr-only\">Search {title.toLowerCase()}</span>\n                    <input ref={focusSearch} type=\"search\" value={q} onChange={(e) => setQ(e.target.value)} onBlur={() => !q && setSearchOpen(false)} onKeyDown={(e) => {\n                        if (e.key === \"Escape\") {\n                          setQ(\"\");\n                          setSearchOpen(false);\n                        }\n                      }} placeholder=\"Search\" className={cn(\"h-9 w-full rounded-lg border px-3 text-[13px]\", focus)} style={{ borderColor: p.border, background: \"transparent\", color: p.text, ...ring }} />\n                  </motion.label>\n                ) : (\n                  <motion.button key=\"sbtn\" type=\"button\" aria-label=\"Search\" onClick={() => setSearchOpen(true)} initial={reduce ? false : { opacity: 0 }} animate={{ opacity: 1 }} className={cn(\"flex h-9 w-9 cursor-pointer items-center justify-center rounded-lg border bg-transparent\", focus)} style={{ borderColor: p.border, color: p.muted, ...ring }}>\n                    <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" aria-hidden=\"true\">\n                      <circle cx=\"11\" cy=\"11\" r=\"7\" />\n                      <path d=\"m20 20-3.5-3.5\" />\n                    </svg>\n                  </motion.button>\n                )}\n              </AnimatePresence>\n              <button type=\"button\" onClick={onAction} className={cn(\"flex h-9 shrink-0 cursor-pointer items-center gap-1.5 rounded-lg border-0 px-3.5 text-[13px] font-medium\", focus)} style={{ background: p.on, color: p.onText, ...ring }}>\n                <svg width=\"13\" height=\"13\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2.2\" strokeLinecap=\"round\" aria-hidden=\"true\">\n                  <path d=\"M12 5v14M5 12h14\" />\n                </svg>\n                {actionLabel}\n              </button>\n            </div>\n          </div>\n\n          {/* Toolbar */}\n          <div className=\"mt-5 flex flex-wrap items-center justify-between gap-3 border-b\" style={{ borderColor: p.border }}>\n            <div role=\"tablist\" aria-label={`Filter ${title.toLowerCase()}`} className=\"-mb-px flex gap-1 overflow-x-auto\">\n              {([\"all\", \"active\", \"paused\", \"archived\"] as Tab[]).map((t) => (\n                <button key={t} type=\"button\" role=\"tab\" aria-selected={tab === t} onClick={() => setTab(t)} className={cn(\"relative shrink-0 cursor-pointer border-0 bg-transparent px-2.5 pt-1 pb-3 text-[13px] capitalize\", focus)} style={{ color: tab === t ? p.text : p.muted, ...ring }}>\n                  {t} <span className=\"tabular-nums\" style={{ color: p.faint }}>{count(t)}</span>\n                  {tab === t && <motion.span layoutId={`${uid}-tab`} className=\"absolute inset-x-1.5 bottom-0 h-[2px] rounded-full\" style={{ background: p.on }} transition={reduce ? { duration: 0 } : { type: \"spring\", stiffness: 500, damping: 38 }} />}\n                </button>\n              ))}\n            </div>\n            <div className=\"mb-2 flex items-center gap-2\">\n              <div className=\"relative\" data-sort>\n                <button type=\"button\" aria-haspopup=\"listbox\" aria-expanded={sortOpen} onClick={() => setSortOpen((o) => !o)} className={cn(\"flex h-8 cursor-pointer items-center gap-1.5 rounded-lg border-0 bg-transparent px-2 text-[12.5px]\", focus)} style={{ color: p.muted, ...ring }}>\n                  <svg width=\"13\" height=\"13\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.8\" strokeLinecap=\"round\" aria-hidden=\"true\">\n                    <path d=\"M7 4v16m0 0-3-3m3 3 3-3M17 20V4m0 0-3 3m3-3 3 3\" />\n                  </svg>\n                  {SORTS.find((s) => s.id === sort)?.label}\n                </button>\n                <AnimatePresence>\n                  {sortOpen && (\n                    <motion.ul initial={reduce ? false : { opacity: 0, y: -4 }} animate={{ opacity: 1, y: 0 }} exit={reduce ? undefined : { opacity: 0, y: -4 }} transition={{ duration: 0.14 }} role=\"listbox\" aria-label=\"Sort by\" className=\"absolute right-0 z-20 m-0 mt-1 w-44 list-none rounded-xl border p-1.5\" style={{ background: p.pop, borderColor: p.border, boxShadow: p.shadow }}>\n                      {SORTS.map((s) => (\n                        <li key={s.id} role=\"option\" aria-selected={sort === s.id}>\n                          <button\n                            type=\"button\"\n                            onClick={() => {\n                              setSort(s.id);\n                              setSortOpen(false);\n                            }}\n                            className={cn(\"flex w-full cursor-pointer items-center justify-between rounded-lg border-0 bg-transparent px-2.5 py-1.5 text-left text-[13px] hover:bg-[var(--sh-h)]\", focus)}\n                            style={{ color: p.text, [\"--sh-h\" as string]: p.hover, ...ring }}\n                          >\n                            {s.label}\n                            {sort === s.id && (\n                              <svg width=\"13\" height=\"13\" viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2.2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n                                <path d=\"m3 8.5 3 3 7-7\" />\n                              </svg>\n                            )}\n                          </button>\n                        </li>\n                      ))}\n                    </motion.ul>\n                  )}\n                </AnimatePresence>\n              </div>\n              <div role=\"radiogroup\" aria-label=\"Layout\" className=\"flex rounded-lg border p-0.5\" style={{ borderColor: p.border }}>\n                {([\"grid\", \"list\"] as const).map((v) => (\n                  <button key={v} type=\"button\" role=\"radio\" aria-checked={view === v} aria-label={v === \"grid\" ? \"Grid\" : \"List\"} onClick={() => setView(v)} className={cn(\"relative flex h-7 w-8 cursor-pointer items-center justify-center rounded-md border-0 bg-transparent\", focus)} style={{ color: view === v ? p.text : p.faint, ...ring }}>\n                    {view === v && <motion.span layoutId={`${uid}-view`} className=\"absolute inset-0 rounded-md\" style={{ background: p.chip }} transition={reduce ? { duration: 0 } : { type: \"spring\", stiffness: 500, damping: 38 }} />}\n                    <svg className=\"relative\" width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.8\" strokeLinecap=\"round\" aria-hidden=\"true\">\n                      {v === \"grid\" ? <path d=\"M4 4h6v6H4zM14 4h6v6h-6zM4 14h6v6H4zM14 14h6v6h-6z\" /> : <path d=\"M8 6h12M8 12h12M8 18h12M4 6h.01M4 12h.01M4 18h.01\" />}\n                    </svg>\n                  </button>\n                ))}\n              </div>\n            </div>\n          </div>\n\n          {/* Content that follows the heading */}\n          <ul className={cn(\"m-0 mt-4 list-none p-0\", view === \"grid\" ? \"grid gap-2.5 @[480px]:grid-cols-2 @[760px]:grid-cols-3\" : \"flex flex-col gap-1.5\")} aria-live=\"polite\">\n            <AnimatePresence initial={false} mode=\"popLayout\">\n              {rows.map((i) => (\n                <motion.li key={i.id} layout={!reduce} initial={reduce ? false : { opacity: 0, scale: 0.97 }} animate={{ opacity: 1, scale: 1 }} exit={reduce ? undefined : { opacity: 0, scale: 0.97, transition: { duration: 0.12 } }} transition={{ duration: 0.22 }} className={cn(\"rounded-xl border\", view === \"grid\" ? \"p-4\" : \"flex items-center gap-4 px-4 py-3\")} style={{ borderColor: p.border, background: p.tile }}>\n                  <div className={cn(\"flex items-center gap-3\", view === \"list\" && \"min-w-0 flex-1\")}>\n                    <span className=\"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg text-[12px] font-bold\" style={{ background: `${i.color}22`, color: i.color }}>\n                      {i.title[0]}\n                    </span>\n                    <span className=\"min-w-0\">\n                      <span className=\"block truncate text-[13.5px] font-medium\">{i.title}</span>\n                      <span className=\"block text-[12px]\" style={{ color: p.faint }}>\n                        {i.owner} · {ago(i.updated)}\n                      </span>\n                    </span>\n                  </div>\n                  <div className={cn(\"flex items-center gap-2\", view === \"grid\" ? \"mt-4\" : \"w-40 shrink-0\")}>\n                    <span className=\"h-1.5 flex-1 overflow-hidden rounded-full\" style={{ background: p.track }}>\n                      <span className=\"block h-full rounded-full\" style={{ width: `${i.progress}%`, background: i.color }} />\n                    </span>\n                    <span className=\"w-9 text-right text-[12px] tabular-nums\" style={{ color: p.muted }}>\n                      {i.progress}%\n                    </span>\n                  </div>\n                  {view === \"list\" && (\n                    <span className=\"hidden w-20 items-center gap-1.5 text-[12px] capitalize @[560px]:flex\" style={{ color: statusColor(i.status) }}>\n                      <span className=\"h-1.5 w-1.5 rounded-full\" style={{ background: statusColor(i.status) }} aria-hidden=\"true\" />\n                      {i.status}\n                    </span>\n                  )}\n                </motion.li>\n              ))}\n            </AnimatePresence>\n          </ul>\n          {rows.length === 0 && (\n            <p className=\"m-0 py-10 text-center text-[13.5px]\" style={{ color: p.muted }}>\n              Nothing here{query ? ` for “${q}”` : \"\"}.\n            </p>\n          )}\n        </div>\n      </div>\n    </section>\n  );\n}\n\nexport default SectionHeading;\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}