{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "multi-view-switcher",
  "title": "Multi View Switcher",
  "description": "One set of items shown as a list grouped by status, a board with columns or a gallery of cards, and every card flies to its new place when you switch. Search, owner filters and sorting apply to all views, 1 / 2 / 3 switch views from the keyboard, and changing an item's status in the details panel moves it to its new group.",
  "dependencies": [
    "motion",
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/multi-view-switcher/multi-view-switcher.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { AnimatePresence, LayoutGroup, 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\ntype View = \"list\" | \"board\" | \"gallery\";\ntype Status = \"Backlog\" | \"In progress\" | \"Review\" | \"Done\";\ntype Priority = \"Low\" | \"Medium\" | \"High\";\nexport interface ViewItem {\n  id: string;\n  title: string;\n  status: Status;\n  owner: string;\n  priority: Priority;\n  due: string; // YYYY-MM-DD\n  cover: string;\n}\n\nexport interface MultiViewSwitcherProps {\n  items?: ViewItem[];\n  defaultView?: View;\n  onItemsChange?: (items: ViewItem[]) => 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)\", panel: \"#0E0E0E\", card: \"#141414\", col: \"#101010\", border: \"rgba(255,255,255,0.08)\", hover: \"rgba(255,255,255,0.05)\", on: \"#F5F4F1\", onText: \"#0A0A0A\", ring: \"rgba(245,244,241,0.6)\" },\n  light: { bg: \"#FAFAF8\", text: \"#0A0A0A\", muted: \"rgba(10,10,10,0.62)\", faint: \"rgba(10,10,10,0.4)\", panel: \"#F4F4F1\", card: \"#FFFFFF\", col: \"#F2F2EF\", border: \"rgba(10,10,10,0.09)\", hover: \"rgba(10,10,10,0.04)\", on: \"#0A0A0A\", onText: \"#FAFAF8\", ring: \"rgba(10,10,10,0.5)\" },\n};\nconst STATUSES: Status[] = [\"Backlog\", \"In progress\", \"Review\", \"Done\"];\nconst STATUS_COLOR: Record<Status, string> = { Backlog: \"#A1A1AA\", \"In progress\": \"#60A5FA\", Review: \"#FBBF24\", Done: \"#34D399\" };\nconst PRIORITY_RANK: Record<Priority, number> = { High: 0, Medium: 1, Low: 2 };\nconst OWNERS: Record<string, string> = { \"Lena Brandt\": \"#60A5FA\", \"Daniel Reyes\": \"#F472B6\", \"Mia Okafor\": \"#A78BFA\", \"Tomás Ferreira\": \"#34D399\" };\nconst ITEMS: ViewItem[] = [\n  { id: \"t1\", title: \"Pricing page redesign\", status: \"In progress\", owner: \"Mia Okafor\", priority: \"High\", due: \"2026-11-14\", cover: \"#6366F1\" },\n  { id: \"t2\", title: \"Onboarding email series\", status: \"Review\", owner: \"Lena Brandt\", priority: \"Medium\", due: \"2026-11-12\", cover: \"#0EA5E9\" },\n  { id: \"t3\", title: \"SSO for Team plan\", status: \"In progress\", owner: \"Daniel Reyes\", priority: \"High\", due: \"2026-11-20\", cover: \"#F43F5E\" },\n  { id: \"t4\", title: \"Usage export to CSV\", status: \"Done\", owner: \"Tomás Ferreira\", priority: \"Low\", due: \"2026-11-06\", cover: \"#10B981\" },\n  { id: \"t5\", title: \"Churn dashboard\", status: \"Backlog\", owner: \"Lena Brandt\", priority: \"Medium\", due: \"2026-11-28\", cover: \"#F59E0B\" },\n  { id: \"t6\", title: \"Mobile nav polish\", status: \"Review\", owner: \"Mia Okafor\", priority: \"Low\", due: \"2026-11-13\", cover: \"#A855F7\" },\n  { id: \"t7\", title: \"Webhook retries\", status: \"Backlog\", owner: \"Daniel Reyes\", priority: \"High\", due: \"2026-11-24\", cover: \"#14B8A6\" },\n  { id: \"t8\", title: \"Customer stories page\", status: \"Done\", owner: \"Tomás Ferreira\", priority: \"Medium\", due: \"2026-11-04\", cover: \"#EC4899\" },\n];\nconst MONTHS = [\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\"];\nconst dueLabel = (d: string) => `${MONTHS[Number(d.slice(5, 7)) - 1]} ${Number(d.slice(8))}`;\nconst initials = (n: string) =>\n  n\n    .split(\" \")\n    .map((w) => w[0])\n    .join(\"\");\n\nconst VIEW_ICONS: Record<View, string> = {\n  list: \"M8 6h12M8 12h12M8 18h12M4 6h.01M4 12h.01M4 18h.01\",\n  board: \"M4 4h4v16H4zM10 4h4v10h-4zM16 4h4v13h-4z\",\n  gallery: \"M4 4h7v7H4zM13 4h7v7h-7zM4 13h7v7H4zM13 13h7v7h-7z\",\n};\n\nexport function MultiViewSwitcher({ items: initial = ITEMS, defaultView = \"list\", onItemsChange, theme = \"dark\", className }: MultiViewSwitcherProps) {\n  const p = PALETTES[theme];\n  const reduce = !!useReducedMotion();\n  const uid = React.useId();\n  const [items, setItems] = React.useState(initial);\n  const [view, setView] = React.useState<View>(defaultView);\n  const [query, setQuery] = React.useState(\"\");\n  const [owners, setOwners] = React.useState<string[]>([]);\n  const [sort, setSort] = React.useState<\"due\" | \"priority\" | \"title\">(\"due\");\n  const [openId, setOpenId] = React.useState<string | null>(null);\n  const rootRef = React.useRef<HTMLElement>(null);\n\n  React.useEffect(() => {\n    const onKey = (e: KeyboardEvent) => {\n      if ((e.target as HTMLElement).closest(\"input, textarea, select\")) return;\n      if (!rootRef.current?.contains(document.activeElement) && document.activeElement !== document.body) return;\n      const v = ({ \"1\": \"list\", \"2\": \"board\", \"3\": \"gallery\" } as Record<string, View>)[e.key];\n      if (v) setView(v);\n      if (e.key === \"Escape\") setOpenId(null);\n    };\n    document.addEventListener(\"keydown\", onKey);\n    return () => document.removeEventListener(\"keydown\", onKey);\n  }, []);\n\n  const shown = items\n    .filter((i) => (!owners.length || owners.includes(i.owner)) && i.title.toLowerCase().includes(query.trim().toLowerCase()))\n    .sort((a, b) => (sort === \"due\" ? a.due.localeCompare(b.due) : sort === \"priority\" ? PRIORITY_RANK[a.priority] - PRIORITY_RANK[b.priority] || a.due.localeCompare(b.due) : a.title.localeCompare(b.title)));\n  const open = items.find((i) => i.id === openId) ?? null;\n\n  const setStatus = (id: string, status: Status) => {\n    const next = items.map((i) => (i.id === id ? { ...i, status } : i));\n    setItems(next);\n    onItemsChange?.(next);\n  };\n\n  const ring = { [\"--tw-ring-color\" as string]: p.ring, [\"--tw-ring-offset-color\" as string]: p.bg } as React.CSSProperties;\n  const focus = \"outline-none focus-visible:ring-2 focus-visible:ring-offset-2\";\n  const layout = reduce ? undefined : { type: \"spring\" as const, stiffness: 420, damping: 38 };\n  const avatar = (o: string, size = 22) => (\n    <span className=\"grid shrink-0 place-items-center rounded-full font-semibold\" style={{ width: size, height: size, fontSize: size * 0.42, background: `${OWNERS[o] ?? p.muted}2e`, color: OWNERS[o] ?? p.muted }} title={o}>\n      {initials(o)}\n    </span>\n  );\n  const statusPill = (s: Status) => (\n    <span className=\"inline-flex shrink-0 items-center gap-1.5 rounded-full px-2 py-0.5 text-[11.5px]\" style={{ background: `${STATUS_COLOR[s]}1f`, color: STATUS_COLOR[s] }}>\n      <span className=\"h-1.5 w-1.5 rounded-full\" style={{ background: STATUS_COLOR[s] }} />\n      {s}\n    </span>\n  );\n  const prio = (pr: Priority) => (\n    <span className=\"flex shrink-0 items-end gap-[2px]\" aria-label={`${pr} priority`} title={`${pr} priority`}>\n      {[0, 1, 2].map((i) => (\n        <span key={i} className=\"w-[3px] rounded-sm\" style={{ height: 5 + i * 3, background: i < 3 - PRIORITY_RANK[pr] ? p.text : p.border }} />\n      ))}\n    </span>\n  );\n  // One card element per item; the same layoutId in every view lets it fly to its new place.\n  const card = (i: ViewItem, kind: View) => (\n    <motion.button\n      key={i.id}\n      layoutId={reduce ? undefined : `${uid}-${i.id}`}\n      transition={layout}\n      type=\"button\"\n      onClick={() => setOpenId(i.id)}\n      aria-label={`${i.title}, ${i.status}, ${i.owner}, due ${dueLabel(i.due)}`}\n      className={cn(\"relative flex w-full min-w-0 cursor-pointer overflow-hidden border text-left\", focus, kind === \"list\" ? \"items-center gap-3 rounded-lg px-3 py-2.5\" : kind === \"board\" ? \"flex-col gap-2.5 rounded-xl p-3\" : \"flex-col rounded-xl\")}\n      style={{ background: p.card, borderColor: openId === i.id ? p.on : p.border, color: p.text, ...ring }}\n    >\n      {kind === \"gallery\" && <motion.span layout=\"position\" className=\"block h-20 w-full\" style={{ background: `linear-gradient(135deg, ${i.cover}, ${i.cover}55)` }} />}\n      <motion.span layout=\"position\" className={cn(\"flex min-w-0 items-center gap-2\", kind === \"list\" ? \"flex-1\" : \"w-full\", kind === \"gallery\" && \"px-3 pt-3\")}>\n        {kind === \"list\" && <span className=\"h-2 w-2 shrink-0 rounded-full\" style={{ background: STATUS_COLOR[i.status] }} />}\n        <span className=\"truncate text-[13.5px] font-medium\">{i.title}</span>\n      </motion.span>\n      <motion.span layout=\"position\" className={cn(\"flex shrink-0 items-center gap-3\", kind !== \"list\" && \"w-full justify-between\", kind === \"gallery\" && \"px-3 pt-2 pb-3\")}>\n        {kind === \"gallery\" && statusPill(i.status)}\n        {kind !== \"gallery\" && prio(i.priority)}\n        <span className=\"flex items-center gap-2\">\n          <span className=\"text-[12px] tabular-nums\" style={{ color: p.faint }}>\n            {dueLabel(i.due)}\n          </span>\n          {avatar(i.owner)}\n        </span>\n      </motion.span>\n    </motion.button>\n  );\n\n  const empty = (\n    <p className=\"m-0 py-16 text-center text-[13px]\" style={{ color: p.faint }}>\n      Nothing matches. Clear the search or owner filter.\n    </p>\n  );\n\n  return (\n    <section ref={rootRef} className={cn(\"@container w-full\", className)} style={{ background: p.bg, color: p.text }}>\n      <div className=\"mx-auto max-w-6xl px-4 py-8 @[640px]:px-6 @[640px]:py-10\">\n        <div className=\"flex flex-wrap items-end justify-between gap-3\">\n          <div>\n            <h2 className=\"m-0 text-[22px] font-semibold tracking-[-0.01em]\">Q4 roadmap</h2>\n            <p className=\"m-0 mt-1 text-[13px]\" style={{ color: p.muted }}>\n              {shown.length} of {items.length} items · {items.filter((i) => i.status === \"Done\").length} done\n            </p>\n          </div>\n          <div role=\"radiogroup\" aria-label=\"View\" className=\"flex rounded-lg border p-0.5\" style={{ borderColor: p.border, background: p.panel }}>\n            {([\"list\", \"board\", \"gallery\"] as const).map((v, n) => (\n              <button\n                key={v}\n                type=\"button\"\n                role=\"radio\"\n                aria-checked={view === v}\n                tabIndex={view === v ? 0 : -1}\n                onClick={() => setView(v)}\n                onKeyDown={(e) => {\n                  const order: View[] = [\"list\", \"board\", \"gallery\"];\n                  const d = e.key === \"ArrowRight\" ? 1 : e.key === \"ArrowLeft\" ? -1 : 0;\n                  if (!d) return;\n                  e.preventDefault();\n                  const nv = order[(order.indexOf(view) + d + 3) % 3];\n                  setView(nv);\n                  (e.currentTarget.parentElement?.querySelector(`[data-v=\"${nv}\"]`) as HTMLElement | null)?.focus();\n                }}\n                data-v={v}\n                className={cn(\"relative flex h-8 cursor-pointer items-center gap-1.5 rounded-md border-0 bg-transparent px-2.5 text-[12.5px] font-medium capitalize @[480px]:px-3\", focus)}\n                style={{ color: view === v ? p.onText : p.muted, ...ring }}\n                title={`${v} (${n + 1})`}\n              >\n                {view === v && <motion.span layoutId={`${uid}-view`} className=\"absolute inset-0 rounded-md\" style={{ background: p.on }} transition={reduce ? { duration: 0 } : { type: \"spring\", stiffness: 520, damping: 38 }} />}\n                <svg className=\"relative\" width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.9\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n                  <path d={VIEW_ICONS[v]} />\n                </svg>\n                <span className=\"relative\">{v}</span>\n              </button>\n            ))}\n          </div>\n        </div>\n\n        {/* Filters */}\n        <div className=\"mt-5 flex flex-wrap items-center gap-2 border-y py-3\" style={{ borderColor: p.border }}>\n          <div className=\"relative min-w-0 basis-full @[640px]:max-w-[240px] @[640px]:basis-auto @[640px]:flex-none\">\n            <svg className=\"pointer-events-none absolute top-1/2 left-2.5 -translate-y-1/2\" width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke={p.faint} 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            <input value={query} onChange={(e) => setQuery(e.target.value)} placeholder=\"Search items\" aria-label=\"Search items\" className={cn(\"h-8 w-full rounded-lg border pr-3 pl-8 text-[13px]\", focus)} style={{ borderColor: p.border, background: p.panel, color: p.text, ...ring }} />\n          </div>\n          <div className=\"flex items-center gap-1\" role=\"group\" aria-label=\"Filter by owner\">\n            {Object.keys(OWNERS).map((o) => {\n              const on = owners.includes(o);\n              return (\n                <button key={o} type=\"button\" aria-pressed={on} aria-label={o} onClick={() => setOwners((cur) => (on ? cur.filter((x) => x !== o) : [...cur, o]))} className={cn(\"cursor-pointer rounded-full border-0 bg-transparent p-0.5 transition-opacity\", focus)} style={{ opacity: owners.length && !on ? 0.4 : 1, boxShadow: on ? `0 0 0 1.5px ${OWNERS[o]}` : \"0 0 0 0 transparent\", ...ring }}>\n                  {avatar(o, 24)}\n                </button>\n              );\n            })}\n            {owners.length > 0 && (\n              <button type=\"button\" onClick={() => setOwners([])} className={cn(\"ml-1 cursor-pointer rounded-md border-0 bg-transparent px-1.5 text-[12px]\", focus)} style={{ color: p.muted, ...ring }}>\n                Clear\n              </button>\n            )}\n          </div>\n          <label className=\"ml-auto flex items-center gap-2 text-[12.5px]\" style={{ color: p.faint }}>\n            Sort\n            <select value={sort} onChange={(e) => setSort(e.target.value as typeof sort)} className={cn(\"h-8 cursor-pointer rounded-lg border px-2 text-[12.5px]\", focus)} style={{ borderColor: p.border, background: p.panel, color: p.text, ...ring }}>\n              <option value=\"due\">Due date</option>\n              <option value=\"priority\">Priority</option>\n              <option value=\"title\">Title</option>\n            </select>\n          </label>\n        </div>\n\n        {/* Views */}\n        <div className=\"mt-5 grid grid-cols-[minmax(0,1fr)] gap-5 @[900px]:grid-cols-[minmax(0,1fr)_auto]\">\n          <LayoutGroup id={uid}>\n            {!shown.length ? (\n              empty\n            ) : view === \"list\" ? (\n              <div className=\"flex min-w-0 flex-col gap-5\">\n                {STATUSES.map((s) => {\n                  const list = shown.filter((i) => i.status === s);\n                  if (!list.length) return null;\n                  return (\n                    <motion.div key={s} layout={!reduce} transition={layout}>\n                      <p className=\"m-0 mb-2 flex items-center gap-2 text-[12px] font-medium\" style={{ color: p.faint }}>\n                        <span className=\"h-1.5 w-1.5 rounded-full\" style={{ background: STATUS_COLOR[s] }} />\n                        {s} <span className=\"tabular-nums\">{list.length}</span>\n                      </p>\n                      <div className=\"flex flex-col gap-1.5\">{list.map((i) => card(i, \"list\"))}</div>\n                    </motion.div>\n                  );\n                })}\n              </div>\n            ) : view === \"board\" ? (\n              <div className=\"-mx-4 flex snap-x snap-mandatory gap-3 overflow-x-auto px-4 pb-2 @[760px]:mx-0 @[760px]:grid @[760px]:grid-cols-4 @[760px]:overflow-visible @[760px]:px-0\">\n                {STATUSES.map((s) => {\n                  const list = shown.filter((i) => i.status === s);\n                  return (\n                    <div key={s} className=\"flex w-[78%] min-w-0 shrink-0 snap-start flex-col gap-2 rounded-xl p-2 @[760px]:w-auto\" style={{ background: p.col }}>\n                      <p className=\"m-0 flex items-center gap-2 px-1 pt-1 text-[12px] font-medium\" style={{ color: p.muted }}>\n                        <span className=\"h-1.5 w-1.5 rounded-full\" style={{ background: STATUS_COLOR[s] }} />\n                        {s}\n                        <span className=\"ml-auto tabular-nums\" style={{ color: p.faint }}>\n                          {list.length}\n                        </span>\n                      </p>\n                      {list.map((i) => card(i, \"board\"))}\n                      {!list.length && (\n                        <span className=\"rounded-lg border border-dashed px-2 py-5 text-center text-[12px]\" style={{ borderColor: p.border, color: p.faint }}>\n                          Empty\n                        </span>\n                      )}\n                    </div>\n                  );\n                })}\n              </div>\n            ) : (\n              <div className=\"grid min-w-0 grid-cols-1 gap-3 @[480px]:grid-cols-2 @[760px]:grid-cols-3 @[1100px]:grid-cols-4\">{shown.map((i) => card(i, \"gallery\"))}</div>\n            )}\n          </LayoutGroup>\n\n          {/* Details */}\n          <AnimatePresence initial={false}>\n            {open && (\n              <motion.aside key=\"details\" initial={reduce ? false : { opacity: 0, x: 12 }} animate={{ opacity: 1, x: 0 }} exit={reduce ? undefined : { opacity: 0, x: 12 }} transition={{ duration: 0.18 }} className=\"h-fit rounded-2xl border p-4 @[900px]:sticky @[900px]:top-4 @[900px]:w-[280px]\" style={{ background: p.card, borderColor: p.border }} aria-labelledby={`${uid}-d`}>\n                <div className=\"h-14 rounded-lg\" style={{ background: `linear-gradient(135deg, ${open.cover}, ${open.cover}44)` }} />\n                <div className=\"mt-3 flex items-start justify-between gap-2\">\n                  <h3 id={`${uid}-d`} className=\"m-0 text-[15px] font-semibold\">\n                    {open.title}\n                  </h3>\n                  <button type=\"button\" onClick={() => setOpenId(null)} aria-label=\"Close details\" className={cn(\"grid h-7 w-7 shrink-0 cursor-pointer place-items-center rounded-md border-0 bg-transparent text-[16px]\", focus)} style={{ color: p.muted, ...ring }}>\n                    ×\n                  </button>\n                </div>\n                <dl className=\"m-0 mt-3 grid grid-cols-[80px_1fr] gap-y-2.5 text-[12.5px]\">\n                  <dt style={{ color: p.faint }}>Owner</dt>\n                  <dd className=\"m-0 flex items-center gap-2\">\n                    {avatar(open.owner, 20)} {open.owner}\n                  </dd>\n                  <dt style={{ color: p.faint }}>Due</dt>\n                  <dd className=\"m-0 tabular-nums\">{dueLabel(open.due)}</dd>\n                  <dt style={{ color: p.faint }}>Priority</dt>\n                  <dd className=\"m-0 flex items-center gap-2\">\n                    {prio(open.priority)} {open.priority}\n                  </dd>\n                </dl>\n                <p className=\"m-0 mt-4 mb-2 text-[12px]\" style={{ color: p.faint }}>\n                  Status\n                </p>\n                <div role=\"radiogroup\" aria-label=\"Status\" className=\"grid grid-cols-2 gap-1.5\">\n                  {STATUSES.map((s) => (\n                    <button key={s} type=\"button\" role=\"radio\" aria-checked={open.status === s} onClick={() => setStatus(open.id, s)} className={cn(\"flex cursor-pointer items-center gap-1.5 rounded-lg border px-2 py-1.5 text-left text-[12px]\", focus)} style={{ borderColor: open.status === s ? STATUS_COLOR[s] : p.border, background: open.status === s ? `${STATUS_COLOR[s]}1a` : \"transparent\", color: p.text, ...ring }}>\n                      <span className=\"h-1.5 w-1.5 rounded-full\" style={{ background: STATUS_COLOR[s] }} />\n                      {s}\n                    </button>\n                  ))}\n                </div>\n              </motion.aside>\n            )}\n          </AnimatePresence>\n        </div>\n      </div>\n    </section>\n  );\n}\n\nexport default MultiViewSwitcher;\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}