{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "page-header-actions",
  "title": "Page header actions",
  "description": "Page header patterns in one scrolling page: breadcrumb, avatar, inline rename, status badge, primary and overflow actions, tabs with counts, filter chips, a delete confirmation, and a sticky header that compacts on scroll.",
  "dependencies": [
    "lucide-react"
  ],
  "registryDependencies": [
    "https://goodui.dev/r/avatar.json",
    "https://goodui.dev/r/breadcrumb.json",
    "https://goodui.dev/r/button.json",
    "https://goodui.dev/r/dropdown-menu.json",
    "https://goodui.dev/r/tabs.json"
  ],
  "files": [
    {
      "path": "registry/blocks/app-shell/page-header-actions.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { Archive, Check, Copy, Download, Filter, MoreHorizontal, Pencil, Plus, Share2, Trash2, X } from \"lucide-react\"\nimport { Avatar, AvatarGroup } from \"@/components/goodui/avatar\"\nimport { Breadcrumb } from \"@/components/goodui/breadcrumb\"\nimport { Button } from \"@/components/goodui/button\"\nimport { DropdownMenu } from \"@/components/goodui/dropdown-menu\"\nimport { Tabs } from \"@/components/goodui/tabs\"\nimport { cn } from \"@/lib/utils\"\n\n/* ---------- Demo data ---------- */\n\ntype TabKey = \"overview\" | \"bookings\" | \"notes\" | \"files\"\nconst TABS: { value: TabKey; label: string; count?: number }[] = [\n  { value: \"overview\", label: \"Overview\" },\n  { value: \"bookings\", label: \"Bookings\", count: 42 },\n  { value: \"notes\", label: \"Notes\", count: 7 },\n  { value: \"files\", label: \"Files\", count: 3 },\n]\nconst FILTERS = [\"Last 90 days\", \"Balayage\", \"Maya Okafor\"]\nconst BOOKINGS = Array.from({ length: 18 }, (_, i) => ({\n  id: i,\n  date: `${[\"Oct\", \"Sep\", \"Aug\", \"Jul\"][Math.floor(i / 5)]} ${28 - (i % 5) * 6}`,\n  service: [\"Balayage\", \"Gloss & tone\", \"Cut & style\", \"Olaplex treatment\", \"Root touch-up\"][i % 5]!,\n  staff: [\"Maya Okafor\", \"Priya Shah\"][i % 2]!,\n  price: [195, 85, 70, 60, 120][i % 5]!,\n  status: i === 0 ? \"Upcoming\" : i % 7 === 3 ? \"No-show\" : \"Completed\",\n}))\n\nconst ring = \"outline-none focus-visible:ring-2 focus-visible:ring-ring/60 focus-visible:ring-offset-1 focus-visible:ring-offset-background\"\n\n/* ---------- Block ---------- */\n\nexport default function PageHeaderActions() {\n  const [tab, setTab] = React.useState<TabKey>(\"bookings\")\n  const [filters, setFilters] = React.useState<string[]>(FILTERS)\n  const [stuck, setStuck] = React.useState(false)\n  const [status, setStatus] = React.useState<\"active\" | \"archived\">(\"active\")\n  const [editing, setEditing] = React.useState(false)\n  const [name, setName] = React.useState(\"Maya Chen\")\n  const [draft, setDraft] = React.useState(name)\n  const [toast, setToast] = React.useState<string | null>(null)\n  const [confirmDelete, setConfirmDelete] = React.useState(false)\n  const scroller = React.useRef<HTMLDivElement>(null)\n  const sentinel = React.useRef<HTMLDivElement>(null)\n\n  // The sticky header compacts once the hero scrolls out of view.\n  React.useEffect(() => {\n    const root = scroller.current\n    const el = sentinel.current\n    if (!root || !el) return\n    const io = new IntersectionObserver(([e]) => setStuck(!(e?.isIntersecting ?? true)), { root, threshold: 0 })\n    io.observe(el)\n    return () => io.disconnect()\n  }, [])\n\n  const say = (t: string) => {\n    setToast(t)\n    setTimeout(() => setToast(null), 1800)\n  }\n  const saveName = () => {\n    if (draft.trim()) setName(draft.trim())\n    setEditing(false)\n  }\n  const exportCsv = () => {\n    const rows = [[\"date\", \"service\", \"staff\", \"price\", \"status\"], ...BOOKINGS.map((b) => [b.date, b.service, b.staff, b.price, b.status])]\n    const blob = new Blob([rows.map((r) => r.join(\",\")).join(\"\\n\")], { type: \"text/csv\" })\n    const url = URL.createObjectURL(blob)\n    const a = document.createElement(\"a\")\n    a.href = url\n    a.download = `${name.toLowerCase().replace(/\\s+/g, \"-\")}-bookings.csv`\n    a.click()\n    setTimeout(() => URL.revokeObjectURL(url), 1000)\n    say(\"Export started\")\n  }\n  const shown = filters.includes(\"Balayage\") ? BOOKINGS.filter((b) => b.service === \"Balayage\" || b.service === \"Gloss & tone\") : BOOKINGS\n\n  return (\n    <div className=\"p-4 md:p-6\">\n      <div className=\"relative mx-auto h-[640px] max-w-5xl overflow-hidden rounded-2xl border bg-background shadow-sm\">\n        <div ref={scroller} className=\"h-full overflow-y-auto\">\n          {/* Breadcrumb row scrolls away; the header below sticks */}\n          <div className=\"px-4 pt-4 sm:px-6\">\n            <Breadcrumb size=\"sm\" variant=\"slash\" items={[{ label: \"Clients\", onClick: () => say(\"Back to clients\") }, { label: \"VIP\", onClick: () => say(\"VIP segment\") }, { label: name }]} />\n          </div>\n          <div ref={sentinel} className=\"h-px\" aria-hidden=\"true\" />\n\n          <header className={cn(\"sticky top-0 z-10 border-b bg-background/90 backdrop-blur transition-[padding,box-shadow]\", stuck ? \"shadow-sm\" : \"\")}>\n            <div className={cn(\"flex items-start gap-4 px-4 transition-[padding] sm:px-6\", stuck ? \"py-2\" : \"py-4\")}>\n              <Avatar name={name} size={stuck ? \"md\" : \"xl\"} ring=\"gradient\" className=\"transition-all\" />\n              <div className=\"min-w-0 flex-1\">\n                <div className=\"flex flex-wrap items-center gap-2\">\n                  {editing ? (\n                    <form\n                      className=\"flex items-center gap-1.5\"\n                      onSubmit={(e) => {\n                        e.preventDefault()\n                        saveName()\n                      }}\n                    >\n                      <label htmlFor=\"ph-name\" className=\"sr-only\">\n                        Client name\n                      </label>\n                      <input id=\"ph-name\" autoFocus value={draft} onChange={(e) => setDraft(e.target.value)} onKeyDown={(e) => e.key === \"Escape\" && setEditing(false)} className={cn(\"h-8 rounded-lg border bg-background px-2 text-lg font-semibold\", ring)} />\n                      <Button size=\"xs\" type=\"submit\" iconOnly aria-label=\"Save name\">\n                        <Check />\n                      </Button>\n                      <Button size=\"xs\" variant=\"ghost\" tone=\"neutral\" type=\"button\" iconOnly aria-label=\"Cancel\" onClick={() => setEditing(false)}>\n                        <X />\n                      </Button>\n                    </form>\n                  ) : (\n                    <h1 className={cn(\"font-semibold tracking-tight transition-[font-size]\", stuck ? \"text-lg\" : \"text-2xl\")}>{name}</h1>\n                  )}\n                  <span className={cn(\"rounded-full px-2 py-0.5 text-[11px] font-medium\", status === \"active\" ? \"bg-emerald-500/12 text-emerald-700 dark:text-emerald-300\" : \"bg-muted text-foreground/70\")}>{status === \"active\" ? \"Active · VIP\" : \"Archived\"}</span>\n                  {!editing && (\n                    <button type=\"button\" aria-label=\"Rename client\" onClick={() => { setDraft(name); setEditing(true) }} className={cn(\"rounded-md p-1 text-muted-foreground hover:bg-muted hover:text-foreground\", ring)}>\n                      <Pencil className=\"size-3.5\" />\n                    </button>\n                  )}\n                </div>\n                {!stuck && (\n                  <p className=\"mt-0.5 text-sm text-muted-foreground motion-safe:animate-in motion-safe:fade-in-0\">\n                    Client since Jan 2024 · 42 visits · $4,180 lifetime · prefers Maya\n                  </p>\n                )}\n              </div>\n              <div className=\"flex shrink-0 items-center gap-2\">\n                <AvatarGroup size=\"sm\" max={2} className=\"hidden sm:flex\">\n                  <Avatar name=\"Maya Okafor\" size=\"sm\" />\n                  <Avatar name=\"Priya Shah\" size=\"sm\" />\n                  <Avatar name=\"Lena Park\" size=\"sm\" />\n                </AvatarGroup>\n                <Button variant=\"outline\" tone=\"neutral\" size=\"sm\" iconLeft={<Share2 />} className=\"hidden sm:inline-flex\" onClick={() => { navigator.clipboard?.writeText(\"https://app.fadeco.com/clients/maya-chen\").catch(() => {}); say(\"Profile link copied\") }}>\n                  Share\n                </Button>\n                <Button size=\"sm\" iconLeft={<Plus />} onClick={() => say(\"New booking for \" + name)}>\n                  Book\n                </Button>\n                <DropdownMenu\n                  align=\"end\"\n                  items={[\n                    { label: \"Export bookings\", icon: <Download />, shortcut: \"Mod+E\", onSelect: exportCsv },\n                    { label: \"Copy profile link\", icon: <Copy />, onSelect: () => { navigator.clipboard?.writeText(\"https://app.fadeco.com/clients/maya-chen\").catch(() => {}); say(\"Profile link copied\") } },\n                    { label: status === \"active\" ? \"Archive client\" : \"Restore client\", icon: <Archive />, onSelect: () => { setStatus((s) => (s === \"active\" ? \"archived\" : \"active\")); say(status === \"active\" ? \"Client archived\" : \"Client restored\") } },\n                    { type: \"separator\" },\n                    { label: \"Delete client\", icon: <Trash2 />, destructive: true, onSelect: () => setConfirmDelete(true) },\n                  ]}\n                  trigger={\n                    <Button variant=\"ghost\" tone=\"neutral\" size=\"sm\" iconOnly aria-label=\"More actions\">\n                      <MoreHorizontal />\n                    </Button>\n                  }\n                />\n              </div>\n            </div>\n            <div className=\"flex flex-col gap-2 px-4 pb-0 sm:flex-row sm:items-end sm:justify-between sm:px-6\">\n              <Tabs variant=\"underline\" size=\"sm\" value={tab} onValueChange={(v) => setTab(v as TabKey)} listLabel=\"Client sections\" items={TABS.map((t) => ({ value: t.value, label: t.label, count: t.count }))} className=\"-mb-px\" />\n              <div className=\"flex flex-wrap items-center gap-1.5 pb-2\">\n                <Filter className=\"size-3.5 text-muted-foreground\" aria-hidden=\"true\" />\n                {filters.map((f) => (\n                  <span key={f} className=\"inline-flex h-6 items-center gap-1 rounded-full border bg-card pr-1 pl-2 text-[11px] font-medium\">\n                    {f}\n                    <button type=\"button\" aria-label={`Remove filter ${f}`} onClick={() => setFilters((l) => l.filter((x) => x !== f))} className={cn(\"rounded-full p-0.5 text-muted-foreground hover:bg-muted hover:text-foreground\", ring)}>\n                      <X className=\"size-3\" />\n                    </button>\n                  </span>\n                ))}\n                {filters.length < FILTERS.length && (\n                  <button type=\"button\" onClick={() => setFilters(FILTERS)} className={cn(\"h-6 rounded-full border border-dashed px-2 text-[11px] text-muted-foreground hover:border-foreground hover:text-foreground\", ring)}>\n                    Reset filters\n                  </button>\n                )}\n              </div>\n            </div>\n          </header>\n\n          {/* Confirm delete */}\n          {confirmDelete && (\n            <div role=\"alertdialog\" aria-label=\"Delete client?\" className=\"mx-4 mt-4 flex flex-wrap items-center gap-3 rounded-xl border border-rose-500/40 bg-rose-500/8 p-3 text-sm sm:mx-6\">\n              <Trash2 className=\"size-4 text-rose-700 dark:text-rose-300\" aria-hidden=\"true\" />\n              <span className=\"flex-1\">Delete {name} and all 42 bookings? This cannot be undone.</span>\n              <Button size=\"xs\" variant=\"ghost\" tone=\"neutral\" onClick={() => setConfirmDelete(false)}>\n                Keep\n              </Button>\n              <Button size=\"xs\" tone=\"danger\" onClick={() => { setConfirmDelete(false); say(\"Client deleted (demo)\") }}>\n                Delete\n              </Button>\n            </div>\n          )}\n\n          {/* Content */}\n          <div className=\"p-4 sm:p-6\">\n            {tab === \"bookings\" && (\n              <div className=\"overflow-hidden rounded-xl border bg-card\">\n                <table className=\"w-full text-sm\">\n                  <thead className=\"bg-muted/40 text-xs text-muted-foreground\">\n                    <tr>\n                      <th scope=\"col\" className=\"px-4 py-2 text-left font-medium\">Date</th>\n                      <th scope=\"col\" className=\"px-3 py-2 text-left font-medium\">Service</th>\n                      <th scope=\"col\" className=\"hidden px-3 py-2 text-left font-medium sm:table-cell\">With</th>\n                      <th scope=\"col\" className=\"px-3 py-2 text-right font-medium\">Price</th>\n                      <th scope=\"col\" className=\"px-4 py-2 text-right font-medium\">Status</th>\n                    </tr>\n                  </thead>\n                  <tbody>\n                    {shown.map((b) => (\n                      <tr key={b.id} className=\"border-t hover:bg-muted/40\">\n                        <td className=\"px-4 py-2.5 text-muted-foreground tabular-nums\">{b.date}</td>\n                        <td className=\"px-3 py-2.5 font-medium\">{b.service}</td>\n                        <td className=\"hidden px-3 py-2.5 sm:table-cell\">{b.staff}</td>\n                        <td className=\"px-3 py-2.5 text-right tabular-nums\">${b.price}</td>\n                        <td className=\"px-4 py-2.5 text-right\">\n                          <span className={cn(\"rounded-full px-2 py-0.5 text-[11px] font-medium\", b.status === \"Upcoming\" ? \"bg-primary/10 text-primary\" : b.status === \"No-show\" ? \"bg-rose-500/12 text-rose-700 dark:text-rose-300\" : \"bg-muted text-foreground/70\")}>{b.status}</span>\n                        </td>\n                      </tr>\n                    ))}\n                  </tbody>\n                </table>\n              </div>\n            )}\n            {tab === \"overview\" && (\n              <div className=\"grid gap-3 sm:grid-cols-3\">\n                {[\n                  [\"Visits\", \"42\"],\n                  [\"Lifetime value\", \"$4,180\"],\n                  [\"Average ticket\", \"$99\"],\n                  [\"Rebook rate\", \"81%\"],\n                  [\"No-shows\", \"1\"],\n                  [\"Next visit\", \"Nov 12\"],\n                ].map(([l, v]) => (\n                  <div key={l} className=\"rounded-xl border bg-card p-4\">\n                    <p className=\"text-xs text-muted-foreground\">{l}</p>\n                    <p className=\"text-2xl font-semibold tracking-tight tabular-nums\">{v}</p>\n                  </div>\n                ))}\n              </div>\n            )}\n            {tab === \"notes\" && (\n              <ul className=\"flex flex-col gap-2\">\n                {[\"Allergic to PPD: use ammonia-free color only.\", \"Likes her coffee black, no sugar.\", \"Referred Sofia Rossi and Jonas Weber.\", \"Prefers appointments before 11:00.\", \"Ask about her sister's wedding in May.\", \"Uses Olaplex at home.\", \"Parks in the back lot.\"].map((n) => (\n                  <li key={n} className=\"rounded-xl border bg-card px-4 py-3 text-sm\">\n                    {n}\n                  </li>\n                ))}\n              </ul>\n            )}\n            {tab === \"files\" && (\n              <ul className=\"grid gap-3 sm:grid-cols-3\">\n                {[\"Color formula.pdf\", \"Before-after Oct.jpg\", \"Consent form.pdf\"].map((f) => (\n                  <li key={f} className=\"rounded-xl border bg-card p-4 text-sm font-medium\">\n                    {f}\n                  </li>\n                ))}\n              </ul>\n            )}\n            <p className=\"mt-6 text-center text-xs text-muted-foreground\">Scroll up and down: the header compacts and stays put.</p>\n          </div>\n        </div>\n\n        <div aria-live=\"polite\" className=\"pointer-events-none absolute inset-x-0 bottom-4 flex justify-center\">\n          {toast && <div className=\"rounded-full bg-foreground px-4 py-2 text-sm text-background shadow-lg motion-safe:animate-in motion-safe:fade-in-0 motion-safe:slide-in-from-bottom-2\">{toast}</div>}\n        </div>\n      </div>\n    </div>\n  )\n}\n",
      "type": "registry:component",
      "target": "components/goodui/page-header-actions.tsx"
    }
  ],
  "categories": [
    "app-shell"
  ],
  "type": "registry:block"
}
