{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "file-list",
  "type": "registry:component",
  "title": "File List",
  "description": "Files and folders with a list and grid view, type-colored icons, multi-select checkboxes and a selection toolbar that slides in.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "lists",
    "files",
    "folders",
    "grid",
    "select",
    "toolbar",
    "drive"
  ],
  "docs": "https://hyperblur.dev/effects/file-list",
  "files": [
    {
      "path": "registry/hyperblur/file-list.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/file-list.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport type FileKind = \"folder\" | \"image\" | \"doc\" | \"sheet\" | \"code\" | \"video\" | \"audio\" | \"archive\" | \"pdf\";\nexport type FileView = \"list\" | \"grid\";\n\nexport interface FileItem {\n  id: string;\n  name: string;\n  kind: FileKind;\n  size?: string;\n  modified: string;\n}\n\nexport const defaultFiles: FileItem[] = [\n  { id: \"f1\", name: \"Brand assets\", kind: \"folder\", size: \"24 items\", modified: \"Oct 30\" },\n  { id: \"f2\", name: \"Q3 report.pdf\", kind: \"pdf\", size: \"2.4 MB\", modified: \"Oct 28\" },\n  { id: \"f3\", name: \"Roadmap 2027.docx\", kind: \"doc\", size: \"184 KB\", modified: \"Oct 27\" },\n  { id: \"f4\", name: \"Forecast.xlsx\", kind: \"sheet\", size: \"612 KB\", modified: \"Oct 26\" },\n  { id: \"f5\", name: \"hero-shot.png\", kind: \"image\", size: \"3.1 MB\", modified: \"Oct 24\" },\n  { id: \"f6\", name: \"Launch teaser.mp4\", kind: \"video\", size: \"48.7 MB\", modified: \"Oct 22\" },\n  { id: \"f7\", name: \"tokens.json\", kind: \"code\", size: \"8 KB\", modified: \"Oct 20\" },\n  { id: \"f8\", name: \"Podcast intro.wav\", kind: \"audio\", size: \"11.2 MB\", modified: \"Oct 18\" },\n  { id: \"f9\", name: \"Archive 2026.zip\", kind: \"archive\", size: \"96 MB\", modified: \"Oct 12\" },\n];\n\nexport interface FileListProps extends Omit<React.HTMLAttributes<HTMLDivElement>, \"onChange\"> {\n  files?: FileItem[];\n  title?: string;\n  view?: FileView;\n  defaultView?: FileView;\n  onViewChange?: (view: FileView) => void;\n  selected?: string[];\n  defaultSelected?: string[];\n  onSelectionChange?: (ids: string[]) => void;\n  onDownload?: (ids: string[]) => void;\n  onDelete?: (ids: string[]) => void;\n  accent?: string;\n}\n\nconst css = `\n.hb-fls {\n  --hb-fls-accent: #2f7bff;\n  container-type: inline-size;\n  position: relative;\n  display: flex;\n  flex-direction: column;\n  width: 100%;\n  min-width: 0;\n  box-sizing: border-box;\n  font-family: inherit;\n  font-size: 13px;\n  line-height: 1.4;\n  color: #ededed;\n}\n.hb-fls *, .hb-fls *::before, .hb-fls *::after { box-sizing: border-box; font-family: inherit; }\n.hb-fls-bar { position: relative; height: 38px; margin-bottom: 4px; overflow: hidden; border-radius: 10px; }\n.hb-fls-head {\n  position: absolute;\n  inset: 0;\n  display: flex;\n  align-items: center;\n  justify-content: space-between;\n  gap: 10px;\n  padding: 0 4px 0 8px;\n  transition: transform .32s cubic-bezier(.2, .8, .2, 1), opacity .24s ease;\n}\n.hb-fls-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }\n.hb-fls-title span { margin-left: 8px; font-weight: 400; font-size: 12px; color: #8f8f8f; }\n.hb-fls-toggle { display: inline-flex; padding: 2px; border: 1px solid #262626; border-radius: 9px; background: #111111; }\n.hb-fls-vbtn {\n  display: grid;\n  place-items: center;\n  width: 28px;\n  height: 24px;\n  padding: 0;\n  border: 0;\n  border-radius: 7px;\n  background: none;\n  color: #8f8f8f;\n  cursor: pointer;\n  transition: background-color .18s ease, color .18s ease;\n}\n.hb-fls-vbtn svg { width: 14px; height: 14px; }\n.hb-fls-vbtn:hover { color: #ededed; }\n.hb-fls-vbtn[aria-pressed=\"true\"] { background: #262626; color: #ededed; }\n.hb-fls-sel {\n  position: absolute;\n  inset: 0;\n  display: flex;\n  align-items: center;\n  gap: 6px;\n  padding: 0 6px 0 12px;\n  border: 1px solid color-mix(in srgb, var(--hb-fls-accent) 40%, transparent);\n  border-radius: 10px;\n  background: color-mix(in srgb, var(--hb-fls-accent) 14%, #111111);\n  transform: translateY(-110%);\n  opacity: 0;\n  visibility: hidden;\n  transition: transform .32s cubic-bezier(.2, .8, .2, 1), opacity .24s ease, visibility 0s linear .32s;\n}\n.hb-fls[data-selecting=\"true\"] .hb-fls-sel { transform: none; opacity: 1; visibility: visible; transition-delay: 0s; }\n.hb-fls[data-selecting=\"true\"] .hb-fls-head { transform: translateY(110%); opacity: 0; }\n.hb-fls-count { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; font-weight: 500; font-variant-numeric: tabular-nums; white-space: nowrap; }\n.hb-fls-act {\n  display: inline-flex;\n  align-items: center;\n  gap: 6px;\n  height: 26px;\n  padding: 0 10px;\n  border: 1px solid transparent;\n  border-radius: 8px;\n  background: rgba(255, 255, 255, .08);\n  color: #ededed;\n  font-size: 12px;\n  font-weight: 500;\n  cursor: pointer;\n  transition: background-color .15s ease, border-color .15s ease;\n}\n.hb-fls-act svg { width: 13px; height: 13px; }\n.hb-fls-act:hover { background: rgba(255, 255, 255, .14); }\n.hb-fls-act[data-danger=\"true\"] { color: #ff6b6b; background: rgba(255, 90, 90, .12); }\n.hb-fls-act[data-danger=\"true\"]:hover { background: rgba(255, 90, 90, .2); }\n.hb-fls-x {\n  display: grid;\n  place-items: center;\n  width: 26px;\n  height: 26px;\n  padding: 0;\n  border: 0;\n  border-radius: 8px;\n  background: none;\n  color: #a1a1a1;\n  cursor: pointer;\n}\n.hb-fls-x svg { width: 12px; height: 12px; }\n.hb-fls-x:hover { background: rgba(255, 255, 255, .1); color: #ededed; }\n.hb-fls-vbtn:focus-visible, .hb-fls-act:focus-visible, .hb-fls-x:focus-visible, .hb-fls-input:focus-visible + .hb-fls-box {\n  outline: 2px solid color-mix(in srgb, var(--hb-fls-accent) 80%, transparent);\n  outline-offset: 1px;\n}\n.hb-fls-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }\n.hb-fls[data-view=\"grid\"] .hb-fls-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }\n.hb-fls-item {\n  position: relative;\n  display: flex;\n  align-items: center;\n  gap: 10px;\n  min-width: 0;\n  padding: 7px 8px;\n  border: 1px solid transparent;\n  border-radius: 10px;\n  cursor: pointer;\n  user-select: none;\n  transition: background-color .15s ease, border-color .15s ease;\n}\n.hb-fls-item:hover { background: rgba(255, 255, 255, .045); }\n.hb-fls-item[data-selected=\"true\"] {\n  background: color-mix(in srgb, var(--hb-fls-accent) 13%, transparent);\n  border-color: color-mix(in srgb, var(--hb-fls-accent) 38%, transparent);\n}\n.hb-fls-check { position: relative; flex: none; width: 18px; height: 18px; display: block; }\n.hb-fls-input {\n  position: absolute;\n  inset: 0;\n  width: 100%;\n  height: 100%;\n  margin: 0;\n  opacity: 0;\n  cursor: pointer;\n}\n.hb-fls-box {\n  position: absolute;\n  inset: 0;\n  display: grid;\n  place-items: center;\n  border: 1.5px solid #3a3a3a;\n  border-radius: 5px;\n  background: #0a0a0a;\n  color: #fff;\n  pointer-events: none;\n  transition: background-color .15s ease, border-color .15s ease, transform .15s ease;\n}\n.hb-fls-box svg { width: 11px; height: 11px; opacity: 0; transform: scale(.5); transition: opacity .15s ease, transform .2s cubic-bezier(.3, 1.5, .5, 1); }\n.hb-fls-input:checked + .hb-fls-box { background: var(--hb-fls-accent); border-color: var(--hb-fls-accent); }\n.hb-fls-input:checked + .hb-fls-box svg { opacity: 1; transform: none; }\n.hb-fls-icon { flex: none; width: 24px; height: 24px; color: var(--hb-fls-kind); }\n.hb-fls-icon svg { width: 100%; height: 100%; display: block; }\n.hb-fls-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n.hb-fls-meta { flex: none; width: 62px; text-align: right; font-size: 12px; color: #8f8f8f; font-variant-numeric: tabular-nums; white-space: nowrap; }\n.hb-fls-date { flex: none; width: 44px; text-align: right; font-size: 12px; color: #6b6b6b; white-space: nowrap; }\n.hb-fls[data-view=\"grid\"] .hb-fls-item {\n  flex-direction: column;\n  align-items: stretch;\n  gap: 6px;\n  padding: 10px 8px 8px;\n  border-color: #1f1f1f;\n  background: #111111;\n}\n.hb-fls[data-view=\"grid\"] .hb-fls-item:hover { background: #151515; border-color: #2a2a2a; }\n.hb-fls[data-view=\"grid\"] .hb-fls-item[data-selected=\"true\"] {\n  background: color-mix(in srgb, var(--hb-fls-accent) 13%, #111111);\n  border-color: color-mix(in srgb, var(--hb-fls-accent) 45%, transparent);\n}\n.hb-fls[data-view=\"grid\"] .hb-fls-check {\n  position: absolute;\n  top: 7px;\n  left: 7px;\n  opacity: 0;\n  transition: opacity .15s ease;\n}\n.hb-fls[data-view=\"grid\"] .hb-fls-item:hover .hb-fls-check,\n.hb-fls[data-view=\"grid\"] .hb-fls-item[data-selected=\"true\"] .hb-fls-check,\n.hb-fls[data-view=\"grid\"] .hb-fls-item:focus-within .hb-fls-check,\n.hb-fls[data-view=\"grid\"][data-selecting=\"true\"] .hb-fls-check { opacity: 1; }\n.hb-fls[data-view=\"grid\"] .hb-fls-icon { width: 38px; height: 38px; margin: 4px auto 2px; }\n.hb-fls[data-view=\"grid\"] .hb-fls-name { flex: none; text-align: center; font-size: 12px; }\n.hb-fls[data-view=\"grid\"] .hb-fls-meta { width: auto; text-align: center; font-size: 11px; }\n.hb-fls[data-view=\"grid\"] .hb-fls-date { display: none; }\n.hb-fls-empty { padding: 26px 12px; text-align: center; color: #8f8f8f; }\n.hb-fls-sr {\n  position: absolute;\n  width: 1px;\n  height: 1px;\n  margin: -1px;\n  overflow: hidden;\n  clip: rect(0 0 0 0);\n  white-space: nowrap;\n}\n@container (max-width: 300px) {\n  .hb-fls-lbl { display: none; }\n  .hb-fls[data-view=\"list\"] .hb-fls-date { display: none; }\n}\n@media (prefers-reduced-motion: reduce) {\n  .hb-fls-head, .hb-fls-sel, .hb-fls-item, .hb-fls-box, .hb-fls-box svg, .hb-fls-vbtn, .hb-fls-act { transition: none !important; }\n}\n`;\n\nconst kindColor: Record<FileKind, string> = {\n  folder: \"#f5b84a\",\n  image: \"#3ecf8e\",\n  doc: \"#5b9bff\",\n  sheet: \"#2fc7a4\",\n  code: \"#a98bff\",\n  video: \"#ff6fa8\",\n  audio: \"#ff9a4a\",\n  archive: \"#9a9aa6\",\n  pdf: \"#ff6b6b\",\n};\n\nconst glyph: Record<Exclude<FileKind, \"folder\">, React.ReactNode> = {\n  image: <path d=\"M8 18l3-4.2 2.2 2.8 1.6-2 2.2 3.4z\" fill=\"currentColor\" stroke=\"none\" />,\n  doc: <path d=\"M8.5 12.5h7M8.5 15.2h7M8.5 17.9h4.5\" />,\n  sheet: <path d=\"M8.5 12.5h7v6h-7zM8.5 15.5h7M12 12.5v6\" />,\n  code: <path d=\"M10.4 13l-2 2.4 2 2.4M13.6 13l2 2.4-2 2.4\" />,\n  video: <path d=\"M10.2 12.8v5.2l4.4-2.6z\" fill=\"currentColor\" stroke=\"none\" />,\n  audio: <path d=\"M9 14.5v2M11.5 12.5v6M14 13.5v4M16.2 15v1\" />,\n  archive: <path d=\"M12 12v1.6M12 15v1.6M10.6 18.2h2.8\" />,\n  pdf: <path d=\"M8.5 12.8h7M8.5 15.4h7M8.5 18h3.4\" />,\n};\n\nfunction FileIcon({ kind }: { kind: FileKind }) {\n  const style = { \"--hb-fls-kind\": kindColor[kind] } as React.CSSProperties;\n  return (\n    <span className=\"hb-fls-icon\" style={style} aria-hidden=\"true\">\n      {kind === \"folder\" ? (\n        <svg viewBox=\"0 0 24 24\" fill=\"none\">\n          <path\n            d=\"M3 7.2A2.2 2.2 0 0 1 5.2 5h4.1c.6 0 1.1.3 1.5.7l1 1.1c.2.2.5.3.8.3h6.2A2.2 2.2 0 0 1 21 9.3v8.5A2.2 2.2 0 0 1 18.8 20H5.2A2.2 2.2 0 0 1 3 17.8z\"\n            fill=\"currentColor\"\n            fillOpacity=\".22\"\n            stroke=\"currentColor\"\n            strokeWidth=\"1.5\"\n            strokeLinejoin=\"round\"\n          />\n        </svg>\n      ) : (\n        <svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\n          <path d=\"M6.5 3h7.2L19 8.3V19.5a1.5 1.5 0 0 1-1.5 1.5h-11A1.5 1.5 0 0 1 5 19.5v-15A1.5 1.5 0 0 1 6.5 3z\" fill=\"currentColor\" fillOpacity=\".14\" />\n          <path d=\"M13.5 3v5.5H19\" />\n          {glyph[kind]}\n        </svg>\n      )}\n    </span>\n  );\n}\n\nexport function FileList({\n  files = defaultFiles,\n  title = \"Documents\",\n  view,\n  defaultView = \"list\",\n  onViewChange,\n  selected,\n  defaultSelected = [],\n  onSelectionChange,\n  onDownload,\n  onDelete,\n  accent = \"#2f7bff\",\n  className = \"\",\n  style,\n  ...rest\n}: FileListProps) {\n  const sourceKey = files.map((f) => f.id).join(\"|\");\n  const [seenKey, setSeenKey] = React.useState(sourceKey);\n  const [items, setItems] = React.useState<FileItem[]>(files);\n  const [innerView, setInnerView] = React.useState<FileView>(defaultView);\n  const [innerSelected, setInnerSelected] = React.useState<string[]>(defaultSelected);\n  const refs = React.useRef(new Map<string, HTMLLIElement>());\n  const before = React.useRef<Map<string, DOMRect> | null>(null);\n\n  if (seenKey !== sourceKey) {\n    setSeenKey(sourceKey);\n    setItems(files);\n  }\n\n  const currentView = view ?? innerView;\n  const chosen = selected ?? innerSelected;\n  const ids = chosen.filter((id) => items.some((f) => f.id === id));\n  const selecting = ids.length > 0;\n\n  React.useLayoutEffect(() => {\n    const first = before.current;\n    before.current = null;\n    if (!first) return;\n    if (window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches) return;\n    refs.current.forEach((el, id) => {\n      const from = first.get(id);\n      if (!from) return;\n      const to = el.getBoundingClientRect();\n      const dx = from.left - to.left;\n      const dy = from.top - to.top;\n      if (!dx && !dy) return;\n      el.animate(\n        [\n          { transform: `translate(${dx.toFixed(1)}px, ${dy.toFixed(1)}px)`, opacity: 0.55 },\n          { transform: \"none\", opacity: 1 },\n        ],\n        { duration: 380, easing: \"cubic-bezier(.2, .8, .2, 1)\" },\n      );\n    });\n  }, [currentView]);\n\n  const setView = (next: FileView) => {\n    if (next === currentView) return;\n    const snapshot = new Map<string, DOMRect>();\n    refs.current.forEach((el, id) => snapshot.set(id, el.getBoundingClientRect()));\n    before.current = snapshot;\n    if (view === undefined) setInnerView(next);\n    onViewChange?.(next);\n  };\n\n  const commit = (next: string[]) => {\n    if (selected === undefined) setInnerSelected(next);\n    onSelectionChange?.(next);\n  };\n\n  const toggle = (id: string) => {\n    commit(ids.includes(id) ? ids.filter((x) => x !== id) : [...ids, id]);\n  };\n\n  const remove = () => {\n    const gone = new Set(ids);\n    setItems((prev) => prev.filter((f) => !gone.has(f.id)));\n    commit([]);\n    onDelete?.(ids);\n  };\n\n  const vars = { \"--hb-fls-accent\": accent, ...style } as React.CSSProperties;\n\n  return (\n    <div\n      className={`hb-fls ${className}`}\n      style={vars}\n      data-view={currentView}\n      data-selecting={selecting}\n      {...rest}\n    >\n      <style href=\"hb-file-list\" precedence=\"default\">{css}</style>\n      <div className=\"hb-fls-bar\">\n        <div className=\"hb-fls-head\">\n          <span className=\"hb-fls-title\">\n            {title}\n            <span>{`${items.length} items`}</span>\n          </span>\n          <span className=\"hb-fls-toggle\" role=\"group\" aria-label=\"View\">\n            <button type=\"button\" className=\"hb-fls-vbtn\" aria-label=\"List view\" aria-pressed={currentView === \"list\"} onClick={() => setView(\"list\")}>\n              <svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" aria-hidden=\"true\">\n                <path d=\"M5.5 4h8M5.5 8h8M5.5 12h8M2.5 4h.01M2.5 8h.01M2.5 12h.01\" />\n              </svg>\n            </button>\n            <button type=\"button\" className=\"hb-fls-vbtn\" aria-label=\"Grid view\" aria-pressed={currentView === \"grid\"} onClick={() => setView(\"grid\")}>\n              <svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n                <rect x=\"2.5\" y=\"2.5\" width=\"4.6\" height=\"4.6\" rx=\"1\" />\n                <rect x=\"8.9\" y=\"2.5\" width=\"4.6\" height=\"4.6\" rx=\"1\" />\n                <rect x=\"2.5\" y=\"8.9\" width=\"4.6\" height=\"4.6\" rx=\"1\" />\n                <rect x=\"8.9\" y=\"8.9\" width=\"4.6\" height=\"4.6\" rx=\"1\" />\n              </svg>\n            </button>\n          </span>\n        </div>\n        <div className=\"hb-fls-sel\" inert={!selecting} aria-hidden={!selecting}>\n          <span className=\"hb-fls-count\">{`${ids.length} selected`}</span>\n          <button type=\"button\" className=\"hb-fls-act\" onClick={() => onDownload?.(ids)}>\n            <svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n              <path d=\"M8 2.5v7.5M4.8 7.2L8 10.4l3.2-3.2M3 13h10\" />\n            </svg>\n            <span className=\"hb-fls-lbl\">Download</span>\n          </button>\n          <button type=\"button\" className=\"hb-fls-act\" data-danger=\"true\" onClick={remove}>\n            <svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n              <path d=\"M2.5 4.5h11M6 4.5V3h4v1.5M4 4.5l.6 8.2a1 1 0 0 0 1 .8h4.8a1 1 0 0 0 1-.8l.6-8.2\" />\n            </svg>\n            <span className=\"hb-fls-lbl\">Delete</span>\n          </button>\n          <button type=\"button\" className=\"hb-fls-x\" aria-label=\"Clear selection\" onClick={() => commit([])}>\n            <svg viewBox=\"0 0 12 12\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.6\" strokeLinecap=\"round\" aria-hidden=\"true\">\n              <path d=\"M2.5 2.5l7 7M9.5 2.5l-7 7\" />\n            </svg>\n          </button>\n        </div>\n      </div>\n      <span className=\"hb-fls-sr\" role=\"status\" aria-live=\"polite\">\n        {selecting ? `${ids.length} selected` : \"No files selected\"}\n      </span>\n      {items.length > 0 ? (\n        <ul className=\"hb-fls-list\" aria-label={title}>\n          {items.map((file) => {\n            const checked = ids.includes(file.id);\n            return (\n              <li\n                key={file.id}\n                className=\"hb-fls-item\"\n                data-selected={checked}\n                ref={(el) => {\n                  if (el) refs.current.set(file.id, el);\n                  else refs.current.delete(file.id);\n                }}\n                onClick={() => toggle(file.id)}\n              >\n                <span className=\"hb-fls-check\">\n                  <input\n                    type=\"checkbox\"\n                    className=\"hb-fls-input\"\n                    checked={checked}\n                    aria-label={`Select ${file.name}`}\n                    onChange={() => toggle(file.id)}\n                    onClick={(event) => event.stopPropagation()}\n                  />\n                  <span className=\"hb-fls-box\" aria-hidden=\"true\">\n                    <svg viewBox=\"0 0 12 12\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\n                      <path d=\"M2.4 6.4l2.3 2.3 4.9-5\" />\n                    </svg>\n                  </span>\n                </span>\n                <FileIcon kind={file.kind} />\n                <span className=\"hb-fls-name\">{file.name}</span>\n                {file.size && <span className=\"hb-fls-meta\">{file.size}</span>}\n                <span className=\"hb-fls-date\">{file.modified}</span>\n              </li>\n            );\n          })}\n        </ul>\n      ) : (\n        <div className=\"hb-fls-empty\">This folder is empty</div>\n      )}\n    </div>\n  );\n}\n"
    }
  ]
}