{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "transfer-list",
  "title": "Transfer List",
  "description": "Two lists side by side for moving items from one set to another, such as available and granted permissions: tick items and send them across with the arrows (or double-click one), move everything at once, search each side, and watch rows glide between the lists.",
  "dependencies": [
    "motion",
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/transfer-list/transfer-list.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { motion, AnimatePresence, LayoutGroup, 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 TransferItem {\n  id: string;\n  label: string;\n  description?: string;\n  disabled?: boolean;\n}\n\nexport interface TransferListProps {\n  items?: TransferItem[];\n  /** Ids in the right-hand (chosen) list. */\n  value?: string[];\n  defaultValue?: string[];\n  onValueChange?: (ids: string[]) => void;\n  titles?: [string, string];\n  searchable?: boolean;\n  /** Height of each list, in px. */\n  height?: number;\n  theme?: \"dark\" | \"light\";\n  className?: string;\n}\n\nconst PALETTES = {\n  dark: { text: \"#F5F4F1\", muted: \"rgba(245,244,241,0.52)\", faint: \"rgba(245,244,241,0.28)\", panel: \"#0E0E0E\", border: \"rgba(255,255,255,0.1)\", line: \"rgba(255,255,255,0.07)\", hover: \"rgba(255,255,255,0.05)\", sel: \"rgba(255,255,255,0.08)\", box: \"rgba(255,255,255,0.22)\", fill: \"#F5F4F1\", onFill: \"#0A0A0A\", input: \"rgba(255,255,255,0.04)\", focus: \"rgba(245,244,241,0.85)\" },\n  light: { text: \"#0A0A0A\", muted: \"rgba(10,10,10,0.52)\", faint: \"rgba(10,10,10,0.28)\", panel: \"#FFFFFF\", border: \"rgba(10,10,10,0.12)\", line: \"rgba(10,10,10,0.07)\", hover: \"rgba(10,10,10,0.04)\", sel: \"rgba(10,10,10,0.06)\", box: \"rgba(10,10,10,0.25)\", fill: \"#0A0A0A\", onFill: \"#FFFFFF\", input: \"rgba(10,10,10,0.03)\", focus: \"rgba(10,10,10,0.85)\" },\n};\n\nconst DEFAULT_ITEMS: TransferItem[] = [\n  { id: \"read\", label: \"Read projects\", description: \"View every project and file\" },\n  { id: \"comment\", label: \"Comment\", description: \"Leave notes and replies\" },\n  { id: \"edit\", label: \"Edit content\", description: \"Change pages and components\" },\n  { id: \"publish\", label: \"Publish\", description: \"Push changes live\" },\n  { id: \"invite\", label: \"Invite members\", description: \"Add people to the workspace\" },\n  { id: \"billing\", label: \"Manage billing\", description: \"Plans, invoices and cards\" },\n  { id: \"api\", label: \"API keys\", description: \"Create and revoke tokens\" },\n  { id: \"delete\", label: \"Delete projects\", description: \"Remove projects for good\", disabled: true },\n];\n\nfunction Box({ state, p }: { state: \"on\" | \"off\" | \"mixed\"; p: (typeof PALETTES)[\"dark\"] }) {\n  const on = state !== \"off\";\n  return (\n    <span aria-hidden=\"true\" className=\"flex shrink-0 items-center justify-center\" style={{ width: 16, height: 16, borderRadius: 5, border: `1.5px solid ${on ? p.fill : p.box}`, background: on ? p.fill : \"transparent\", transition: \"background 0.15s ease, border-color 0.15s ease\" }}>\n      {state === \"on\" && (\n        <svg width=\"10\" height=\"10\" viewBox=\"0 0 12 12\" fill=\"none\">\n          <path d=\"M2.4 6.3 4.9 8.7 9.6 3.4\" stroke={p.onFill} strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n        </svg>\n      )}\n      {state === \"mixed\" && <span style={{ width: 8, height: 2, borderRadius: 1, background: p.onFill }} />}\n    </span>\n  );\n}\n\nexport function TransferList({ items = DEFAULT_ITEMS, value, defaultValue = [\"read\", \"comment\"], onValueChange, titles = [\"Available\", \"Granted\"], searchable = true, height = 300, theme = \"dark\", className }: TransferListProps) {\n  const p = PALETTES[theme];\n  const uid = React.useId();\n  const reduce = Boolean(useReducedMotion());\n  const [internal, setInternal] = React.useState<string[]>(defaultValue);\n  const chosen = value ?? internal;\n  const [checked, setChecked] = React.useState<Set<string>>(new Set());\n  const [queries, setQueries] = React.useState<[string, string]>([\"\", \"\"]);\n\n  const commit = (next: string[]) => {\n    // Keep the chosen list in the original item order so moving back and forth is predictable.\n    const ordered = items.map((i) => i.id).filter((id) => next.includes(id));\n    if (value === undefined) setInternal(ordered);\n    onValueChange?.(ordered);\n  };\n\n  const sides = [items.filter((i) => !chosen.includes(i.id)), items.filter((i) => chosen.includes(i.id))] as const;\n  const visible = sides.map((list, s) => list.filter((i) => i.label.toLowerCase().includes(queries[s].trim().toLowerCase())));\n\n  const move = (from: 0 | 1, all: boolean) => {\n    const pick = visible[from].filter((i) => !i.disabled && (all || checked.has(i.id))).map((i) => i.id);\n    if (!pick.length) return;\n    commit(from === 0 ? [...chosen, ...pick] : chosen.filter((id) => !pick.includes(id)));\n    setChecked((c) => new Set([...c].filter((id) => !pick.includes(id))));\n  };\n\n  // Double-clicking a row sends just that row across.\n  const moveOne = (from: 0 | 1, id: string) => {\n    commit(from === 0 ? [...chosen, id] : chosen.filter((x) => x !== id));\n    setChecked((c) => new Set([...c].filter((x) => x !== id)));\n  };\n\n  const toggle = (id: string) =>\n    setChecked((c) => {\n      const next = new Set(c);\n      if (next.has(id)) next.delete(id);\n      else next.add(id);\n      return next;\n    });\n\n  const spring = reduce ? { duration: 0 } : { type: \"spring\" as const, stiffness: 420, damping: 36 };\n\n  const panel = (s: 0 | 1) => {\n    const list = visible[s];\n    const enabled = list.filter((i) => !i.disabled);\n    const n = enabled.filter((i) => checked.has(i.id)).length;\n    const all: \"on\" | \"off\" | \"mixed\" = n === 0 ? \"off\" : n === enabled.length ? \"on\" : \"mixed\";\n    return (\n      <div className=\"flex min-w-0 flex-1 flex-col overflow-hidden\" style={{ borderRadius: 16, background: p.panel, border: `1px solid ${p.border}` }}>\n        <div className=\"flex items-center\" style={{ gap: 10, padding: \"12px 14px\", borderBottom: `1px solid ${p.line}` }}>\n          <button\n            type=\"button\"\n            role=\"checkbox\"\n            aria-checked={all === \"mixed\" ? \"mixed\" : all === \"on\"}\n            aria-label={`Select all in ${titles[s]}`}\n            disabled={!enabled.length}\n            onClick={() => setChecked((c) => {\n              const next = new Set(c);\n              enabled.forEach((i) => (all === \"on\" ? next.delete(i.id) : next.add(i.id)));\n              return next;\n            })}\n            className=\"flex cursor-pointer items-center rounded border-none bg-transparent p-0 outline-none focus-visible:ring-2 disabled:cursor-default disabled:opacity-40\"\n            style={{ [\"--tw-ring-color\" as string]: p.focus }}\n          >\n            <Box state={all} p={p} />\n          </button>\n          <span className=\"flex-1 text-[13.5px] font-semibold\">{titles[s]}</span>\n          <span className=\"text-[12px] tabular-nums\" style={{ color: p.muted }} aria-live=\"polite\">\n            {n > 0 ? `${n} / ${sides[s].length} selected` : `${sides[s].length} ${sides[s].length === 1 ? \"item\" : \"items\"}`}\n          </span>\n        </div>\n        {searchable && (\n          <div style={{ padding: \"10px 10px 4px\" }}>\n            <label className=\"relative flex items-center\">\n              <svg className=\"pointer-events-none absolute left-2.5\" width=\"13\" height=\"13\" viewBox=\"0 0 24 24\" fill=\"none\" stroke={p.muted} 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\n                type=\"search\"\n                value={queries[s]}\n                onChange={(e) => setQueries((q) => (s === 0 ? [e.target.value, q[1]] : [q[0], e.target.value]))}\n                placeholder=\"Search\"\n                aria-label={`Search ${titles[s]}`}\n                className=\"h-8 w-full rounded-lg text-[13px] outline-none\"\n                style={{ padding: \"0 10px 0 30px\", background: p.input, border: `1px solid ${p.line}`, color: p.text }}\n              />\n            </label>\n          </div>\n        )}\n        <ul role=\"listbox\" aria-multiselectable=\"true\" aria-label={titles[s]} className=\"m-0 flex list-none flex-col overflow-y-auto p-0\" style={{ height, padding: 6, scrollbarWidth: \"thin\" }}>\n          <AnimatePresence initial={false} mode=\"popLayout\">\n            {list.map((item) => {\n              const isOn = checked.has(item.id);\n              return (\n                <motion.li\n                  key={item.id}\n                  layoutId={`${uid}-${item.id}`}\n                  role=\"option\"\n                  aria-selected={isOn}\n                  aria-disabled={item.disabled || undefined}\n                  tabIndex={item.disabled ? -1 : 0}\n                  onClick={() => !item.disabled && toggle(item.id)}\n                  onDoubleClick={() => !item.disabled && moveOne(s, item.id)}\n                  onKeyDown={(e) => {\n                    if ((e.key === \" \" || e.key === \"Enter\") && !item.disabled) {\n                      e.preventDefault();\n                      toggle(item.id);\n                    }\n                  }}\n                  initial={{ opacity: 0 }}\n                  animate={{ opacity: 1 }}\n                  exit={{ opacity: 0 }}\n                  transition={spring}\n                  className=\"flex cursor-pointer items-center rounded-xl outline-none select-none focus-visible:ring-2\"\n                  style={{ gap: 10, padding: \"8px 10px\", background: isOn ? p.sel : \"transparent\", opacity: item.disabled ? 0.45 : 1, cursor: item.disabled ? \"not-allowed\" : \"pointer\", [\"--tw-ring-color\" as string]: p.focus }}\n                  whileHover={item.disabled || isOn ? undefined : { backgroundColor: p.hover }}\n                >\n                  <Box state={isOn ? \"on\" : \"off\"} p={p} />\n                  <span className=\"flex min-w-0 flex-col\">\n                    <span className=\"truncate text-[13.5px] font-medium\" style={{ color: p.text }}>\n                      {item.label}\n                    </span>\n                    {item.description && (\n                      <span className=\"truncate text-[12px]\" style={{ color: p.muted }}>\n                        {item.description}\n                      </span>\n                    )}\n                  </span>\n                </motion.li>\n              );\n            })}\n          </AnimatePresence>\n          {list.length === 0 && (\n            <li role=\"none\" className=\"flex flex-1 items-center justify-center text-[12.5px]\" style={{ color: p.faint }}>\n              {queries[s] ? \"No matches\" : \"Nothing here yet\"}\n            </li>\n          )}\n        </ul>\n      </div>\n    );\n  };\n\n  const leftChecked = visible[0].some((i) => checked.has(i.id) && !i.disabled);\n  const rightChecked = visible[1].some((i) => checked.has(i.id) && !i.disabled);\n  const btn = (label: string, d: string, onClick: () => void, disabled: boolean) => (\n    <button\n      type=\"button\"\n      aria-label={label}\n      title={label}\n      onClick={onClick}\n      disabled={disabled}\n      className=\"flex cursor-pointer items-center justify-center rounded-lg outline-none focus-visible:ring-2 disabled:cursor-default disabled:opacity-30\"\n      style={{ width: 36, height: 34, background: p.panel, border: `1px solid ${p.border}`, color: p.text, transition: \"opacity 0.15s ease\", [\"--tw-ring-color\" as string]: p.focus }}\n    >\n      <svg width=\"15\" height=\"15\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n        <path d={d} />\n      </svg>\n    </button>\n  );\n\n  return (\n    <LayoutGroup id={uid}>\n      <div className={cn(\"flex w-full flex-col items-stretch sm:flex-row sm:items-center\", className)} style={{ gap: 12, fontFamily: \"Inter, sans-serif\", color: p.text }}>\n        {panel(0)}\n        <div className=\"flex justify-center sm:flex-col\" style={{ gap: 6 }}>\n          {btn(\"Move selected right\", \"m9 6 6 6-6 6\", () => move(0, false), !leftChecked)}\n          {btn(\"Move all right\", \"m6 6 6 6-6 6M13 6l6 6-6 6\", () => move(0, true), !visible[0].some((i) => !i.disabled))}\n          {btn(\"Move selected left\", \"m15 6-6 6 6 6\", () => move(1, false), !rightChecked)}\n          {btn(\"Move all left\", \"m18 6-6 6 6 6M11 6l-6 6 6 6\", () => move(1, true), !visible[1].some((i) => !i.disabled))}\n        </div>\n        {panel(1)}\n      </div>\n    </LayoutGroup>\n  );\n}\n\nexport default TransferList;\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}