{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"file-upload-dropzone","type":"registry:component","title":"File Upload Dropzone","description":"A real drag-and-drop file zone: the border marches and glows while files are over it, rows show thumbnails, progress from your own upload callback, retry and remove, and the limits in the hint are actually enforced. No dependencies.","dependencies":[],"registryDependencies":[],"files":[{"path":"components/viberdy/file-upload-dropzone.tsx","content":"\"use client\";\n\nimport { useEffect, useId, useRef, useState } from \"react\";\nimport type { ChangeEvent, CSSProperties, DragEvent, PointerEvent } from \"react\";\n\ntype Status = \"selected\" | \"uploading\" | \"done\" | \"error\" | \"rejected\";\n\ninterface Item {\n  id: number;\n  file: File;\n  status: Status;\n  progress: number;\n  message?: string;\n  url?: string;\n  leaving?: boolean;\n}\n\nexport interface RejectedFile {\n  file: File;\n  reason: string;\n}\n\nconst DEFAULT_ACCEPT = [\".png\", \".pdf\"];\nconst DEFAULT_ACCENT = \"#ef4444\";\nconst COLOR_RE = /^(#[0-9a-f]{3,8}|(rgb|hsl)a?\\([\\d\\s.,%/a-z]+\\))$/i;\nconst EASE = \"cubic-bezier(.2,.8,.2,1)\";\n\nconst CSS = [\n  \"@keyframes fud-march{to{stroke-dashoffset:-26}}\",\n  \"@keyframes fud-in{from{grid-template-rows:0fr;opacity:0;transform:translateY(-6px)}to{grid-template-rows:1fr;opacity:1;transform:none}}\",\n  \"@keyframes fud-sheen{from{transform:translateX(-120%)}to{transform:translateX(320%)}}\",\n  \"@keyframes fud-draw{from{stroke-dashoffset:18}to{stroke-dashoffset:0}}\",\n  \"@keyframes fud-pop{0%{transform:scale(.5);opacity:0}60%{transform:scale(1.18)}100%{transform:scale(1);opacity:1}}\",\n  \".fud-input{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0;opacity:0}\",\n  \".fud-zone{position:relative;display:flex;flex-direction:column;align-items:center;gap:4px;border-radius:20px;padding:30px 24px 26px;text-align:center;cursor:pointer;user-select:none;-webkit-user-select:none;background:color-mix(in srgb,currentColor 3%,transparent);transition:background-color .25s,box-shadow .3s,transform .4s \" + EASE + \"}\",\n  \".fud-zone:hover{background:color-mix(in srgb,currentColor 5%,transparent)}\",\n  \".fud-zone[data-drag='true']{background:color-mix(in srgb,var(--fud-a) 9%,transparent);box-shadow:0 0 0 4px color-mix(in srgb,var(--fud-a) 16%,transparent),0 18px 50px -18px color-mix(in srgb,var(--fud-a) 55%,transparent);transform:scale(1.012)}\",\n  \".fud-zone[data-disabled='true']{opacity:.5;cursor:not-allowed}\",\n  \".fud-input:focus-visible + .fud-zone{outline:2px solid var(--fud-a)!important;outline-offset:3px;border-radius:20px!important}\",\n  \".fud-glow{position:absolute;inset:0;border-radius:inherit;pointer-events:none;opacity:0;transition:opacity .3s;background:radial-gradient(220px circle at var(--fud-x,50%) var(--fud-y,50%),color-mix(in srgb,var(--fud-a) 20%,transparent),transparent 70%)}\",\n  \".fud-zone:hover .fud-glow,.fud-zone[data-drag='true'] .fud-glow{opacity:1}\",\n  \".fud-rect{fill:none;stroke:currentColor;stroke-opacity:.28;stroke-width:1.5;stroke-dasharray:6 7;transition:stroke-opacity .25s}\",\n  \".fud-zone:hover .fud-rect{stroke-opacity:.5}\",\n  \".fud-zone[data-drag='true'] .fud-rect{stroke:var(--fud-a);stroke-opacity:1;animation:fud-march .8s linear infinite}\",\n  \".fud-icon{position:relative;margin-bottom:6px;color:color-mix(in srgb,currentColor 55%,transparent);transition:color .25s}\",\n  \".fud-zone:hover .fud-icon{color:currentColor}\",\n  \".fud-zone[data-drag='true'] .fud-icon{color:var(--fud-a)}\",\n  \".fud-sheet{transform-box:fill-box;transition:transform .5s cubic-bezier(.34,1.56,.64,1);transform:translateY(7px)}\",\n  \".fud-zone:hover .fud-sheet{transform:translateY(1px)}\",\n  \".fud-zone[data-drag='true'] .fud-sheet{transform:translateY(-6px) scale(1.04)}\",\n  \".fud-row{display:grid;grid-template-rows:1fr;animation:fud-in .38s \" + EASE + \" backwards;transition:grid-template-rows .28s cubic-bezier(.4,0,.2,1),opacity .22s,transform .28s}\",\n  \".fud-row[data-leaving='true']{grid-template-rows:0fr;opacity:0;transform:translateX(10px)}\",\n  \".fud-row>div{min-height:0;overflow:hidden;padding:3px 2px 0}\",\n  \".fud-btn{display:inline-flex;align-items:center;justify-content:center;width:40px;height:40px;flex:none;border-radius:10px;border:0;background:transparent;color:color-mix(in srgb,currentColor 55%,transparent);cursor:pointer;transition:background-color .15s,color .15s,transform .15s}\",\n  \".fud-btn:hover{background:color-mix(in srgb,currentColor 9%,transparent);color:currentColor}\",\n  \".fud-btn:active{transform:scale(.9)}\",\n  \".fud-btn:focus-visible{outline:2px solid var(--fud-a)!important;outline-offset:-2px;border-radius:10px!important}\",\n  \".fud-bar{position:absolute;left:0;bottom:0;height:2px;overflow:hidden;background:var(--fud-a);transition:width .3s ease-out}\",\n  \".fud-bar::after{content:'';position:absolute;inset:0;width:40%;background:linear-gradient(90deg,transparent,rgba(255,255,255,.7),transparent);animation:fud-sheen 1.1s linear infinite}\",\n  \".fud-check{stroke-dasharray:18;animation:fud-draw .4s .05s ease-out backwards}\",\n  \".fud-tick{animation:fud-pop .45s cubic-bezier(.34,1.56,.64,1) backwards}\",\n  \".fud-clear{height:40px;padding:0 8px;margin:-8px -8px -8px 0;border:0;background:transparent;font:inherit;font-size:12px;color:color-mix(in srgb,currentColor 55%,transparent);cursor:pointer;border-radius:8px;transition:color .15s}\",\n  \".fud-clear:hover{color:currentColor}\",\n  \".fud-clear:focus-visible{outline:2px solid var(--fud-a)!important;outline-offset:-2px;border-radius:8px!important}\",\n  \"@media (prefers-reduced-motion:reduce){.fud-zone,.fud-sheet,.fud-row,.fud-btn,.fud-bar{transition:none!important;animation:none!important}.fud-row,.fud-check,.fud-tick{animation:none!important}.fud-zone[data-drag='true']{transform:none}.fud-zone[data-drag='true'] .fud-rect{animation:none}.fud-bar::after{display:none}}\",\n].join(\"\\n\");\n\nfunction formatSize(n: number): string {\n  if (n < 1024) return n + \" B\";\n  if (n < 1024 * 1024) return (n / 1024).toFixed(n < 10240 ? 1 : 0) + \" KB\";\n  return (n / (1024 * 1024)).toFixed(n < 10 * 1024 * 1024 ? 1 : 0) + \" MB\";\n}\n\nfunction extOf(name: string): string {\n  const i = name.lastIndexOf(\".\");\n  return i > 0 && i < name.length - 1 ? name.slice(i + 1, i + 5).toUpperCase() : \"FILE\";\n}\n\nfunction hueFor(file: File): string {\n  const e = extOf(file.name).toLowerCase();\n  if (file.type.startsWith(\"image/\")) return \"#38bdf8\";\n  if (e === \"pdf\") return \"#ef4444\";\n  if ([\"zip\", \"rar\", \"7z\", \"gz\", \"tar\"].includes(e)) return \"#f59e0b\";\n  if ([\"csv\", \"xls\", \"xlsx\"].includes(e)) return \"#22c55e\";\n  return \"currentColor\";\n}\n\nfunction matchesAccept(file: File, accept: string[]): boolean {\n  if (!accept.length) return true;\n  const name = file.name.toLowerCase();\n  const type = file.type.toLowerCase();\n  return accept.some((raw) => {\n    const t = raw.trim().toLowerCase();\n    if (!t) return false;\n    if (t.startsWith(\".\")) return name.endsWith(t);\n    if (t.endsWith(\"/*\")) return type.startsWith(t.slice(0, -1));\n    return type === t;\n  });\n}\n\nexport function FileUploadDropzone({\n  hint = \"PNG, PDF up to 10MB\",\n  accept = DEFAULT_ACCEPT,\n  maxMb = 10,\n  maxBytes,\n  onFiles,\n  onUpload,\n  onReject,\n  multiple = true,\n  disabled = false,\n  accent = DEFAULT_ACCENT,\n  className = \"\",\n}: {\n  hint?: string;\n  /** Extensions (\".png\") or MIME types (\"image/*\") actually enforced. Keep in step with `hint`. */\n  accept?: string[];\n  /** Size ceiling in megabytes. Keep this in step with the hint. */\n  maxMb?: number;\n  /** Exact byte ceiling. Overrides maxMb when given. */\n  maxBytes?: number;\n  /** Fires with the newly accepted File[] each time files are added. */\n  onFiles?: (files: File[]) => void;\n  /**\n   * Optional. Do the real upload for one file and call `report(0..100)` as it\n   * progresses. Resolve when finished, reject (or throw) to show a failed row\n   * with Retry. `signal` aborts when the row is removed or cancelled.\n   * Without it the component only LISTS selected files and says so.\n   */\n  onUpload?: (file: File, report: (percent: number) => void, signal: AbortSignal) => Promise<void>;\n  /** Fires with files that failed the type or size check. */\n  onReject?: (rejected: RejectedFile[]) => void;\n  multiple?: boolean;\n  disabled?: boolean;\n  /** Drag, focus and progress colour (hex, rgb() or hsl()). */\n  accent?: string;\n  className?: string;\n}) {\n  const sizeLimit = maxBytes ?? maxMb * 1024 * 1024;\n  const color = COLOR_RE.test(accent) ? accent : DEFAULT_ACCENT;\n  const clipId = \"fudclip\" + useId().replace(/[^a-zA-Z0-9]/g, \"\");\n  const [items, setItems] = useState<Item[]>([]);\n  const [dragging, setDragging] = useState(false);\n  const [dragCount, setDragCount] = useState(0);\n  const [note, setNote] = useState(\"\");\n  const zoneRef = useRef<HTMLDivElement>(null);\n  const depth = useRef(0);\n  const nextId = useRef(1);\n  const onUploadRef = useRef(onUpload);\n  const ctrls = useRef(new Map<number, AbortController>());\n  const urls = useRef(new Map<number, string>());\n  const timers = useRef(new Set<number>());\n\n  useEffect(() => {\n    onUploadRef.current = onUpload;\n  });\n\n  useEffect(() => {\n    const c = ctrls.current;\n    const u = urls.current;\n    const t = timers.current;\n    return () => {\n      c.forEach((ctl) => ctl.abort());\n      c.clear();\n      t.forEach((id) => window.clearTimeout(id));\n      t.clear();\n      u.forEach((url) => URL.revokeObjectURL(url));\n      u.clear();\n    };\n  }, []);\n\n  const patch = (id: number, p: Partial<Item>) =>\n    setItems((prev) => prev.map((it) => (it.id === id ? { ...it, ...p } : it)));\n\n  function run(id: number, file: File) {\n    const fn = onUploadRef.current;\n    if (!fn) return;\n    const ctl = new AbortController();\n    ctrls.current.set(id, ctl);\n    patch(id, { status: \"uploading\", progress: 0, message: undefined });\n    const report = (p: number) => {\n      if (ctl.signal.aborted || !Number.isFinite(p)) return;\n      patch(id, { progress: Math.max(0, Math.min(100, p)) });\n    };\n    Promise.resolve()\n      .then(() => fn(file, report, ctl.signal))\n      .then(\n        () => {\n          if (ctl.signal.aborted) return;\n          ctrls.current.delete(id);\n          patch(id, { status: \"done\", progress: 100 });\n        },\n        (err: unknown) => {\n          if (ctl.signal.aborted) return;\n          ctrls.current.delete(id);\n          patch(id, { status: \"error\", message: err instanceof Error && err.message ? err.message : \"Upload failed\" });\n        },\n      );\n  }\n\n  function cancel(id: number) {\n    const ctl = ctrls.current.get(id);\n    if (!ctl) return;\n    ctl.abort();\n    ctrls.current.delete(id);\n    patch(id, { status: \"error\", message: \"Cancelled\" });\n  }\n\n  function dropRows(ids: number[]) {\n    if (!ids.length) return;\n    ids.forEach((id) => {\n      ctrls.current.get(id)?.abort();\n      ctrls.current.delete(id);\n    });\n    const reduce = window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n    const finish = () => {\n      setItems((prev) => prev.filter((it) => !ids.includes(it.id)));\n      ids.forEach((id) => {\n        const u = urls.current.get(id);\n        if (u) URL.revokeObjectURL(u);\n        urls.current.delete(id);\n      });\n    };\n    if (reduce) {\n      finish();\n      return;\n    }\n    setItems((prev) => prev.map((it) => (ids.includes(it.id) ? { ...it, leaving: true } : it)));\n    const t = window.setTimeout(() => {\n      timers.current.delete(t);\n      finish();\n    }, 290);\n    timers.current.add(t);\n  }\n\n  function addFiles(list: File[]) {\n    if (disabled || !list.length) return;\n    const incoming = multiple ? list : list.slice(0, 1);\n    const accepted: File[] = [];\n    const rejected: RejectedFile[] = [];\n    const rows: Item[] = [];\n    for (const file of incoming) {\n      const id = nextId.current++;\n      let reason = \"\";\n      if (!matchesAccept(file, accept)) reason = \"Type not allowed (.\" + extOf(file.name).toLowerCase() + \")\";\n      else if (file.size > sizeLimit) reason = \"Too large: \" + formatSize(file.size) + \", limit \" + formatSize(sizeLimit);\n      if (reason) {\n        rejected.push({ file, reason });\n        rows.push({ id, file, status: \"rejected\", progress: 0, message: reason });\n        continue;\n      }\n      let url: string | undefined;\n      if (file.type.startsWith(\"image/\")) {\n        url = URL.createObjectURL(file);\n        urls.current.set(id, url);\n      }\n      accepted.push(file);\n      rows.push({ id, file, status: onUploadRef.current ? \"uploading\" : \"selected\", progress: 0, url });\n    }\n    if (!multiple) dropRows(items.map((it) => it.id));\n    setItems((prev) => [...(multiple ? prev : []), ...rows]);\n    rows.forEach((r) => {\n      if (r.status === \"uploading\") run(r.id, r.file);\n    });\n    if (accepted.length) onFiles?.(accepted);\n    if (rejected.length) onReject?.(rejected);\n    setNote(\n      (accepted.length ? \"Added \" + accepted.length + (accepted.length === 1 ? \" file. \" : \" files. \") : \"\") +\n        rejected.map((r) => r.file.name + \" rejected: \" + r.reason + \". \").join(\"\"),\n    );\n  }\n\n  const hasFiles = (e: DragEvent) => Array.from(e.dataTransfer.types).includes(\"Files\");\n\n  function onDragEnter(e: DragEvent) {\n    if (disabled || !hasFiles(e)) return;\n    e.preventDefault();\n    depth.current += 1;\n    setDragging(true);\n    setDragCount(e.dataTransfer.items.length);\n  }\n  function onDragOver(e: DragEvent) {\n    if (disabled || !hasFiles(e)) return;\n    e.preventDefault();\n    e.dataTransfer.dropEffect = \"copy\";\n  }\n  function onDragLeave() {\n    depth.current = Math.max(0, depth.current - 1);\n    if (depth.current === 0) setDragging(false);\n  }\n  function onDrop(e: DragEvent) {\n    e.preventDefault();\n    depth.current = 0;\n    setDragging(false);\n    addFiles(Array.from(e.dataTransfer.files));\n  }\n  function onChange(e: ChangeEvent<HTMLInputElement>) {\n    addFiles(Array.from(e.target.files ?? []));\n    e.target.value = \"\";\n  }\n  function onMove(e: PointerEvent<HTMLLabelElement>) {\n    const z = zoneRef.current;\n    if (!z) return;\n    const r = z.getBoundingClientRect();\n    if (!r.width || !r.height) return;\n    z.style.setProperty(\"--fud-x\", (e.clientX - r.left) * (z.offsetWidth / r.width) + \"px\");\n    z.style.setProperty(\"--fud-y\", (e.clientY - r.top) * (z.offsetHeight / r.height) + \"px\");\n  }\n\n  const live = items.filter((it) => it.status !== \"rejected\" && !it.leaving);\n  const uploading = live.filter((it) => it.status === \"uploading\").length;\n  const done = live.filter((it) => it.status === \"done\").length;\n  const n = live.length;\n  const plural = (k: number) => k + (k === 1 ? \" file\" : \" files\");\n  let summary = plural(n) + \" selected, not uploaded\";\n  if (onUpload) summary = uploading ? plural(n) + \", \" + uploading + \" uploading\" : done === n ? plural(n) + \", all uploaded\" : plural(n);\n\n  return (\n    <>\n      <style>{CSS}</style>\n      <div className={\"w-full max-w-sm \" + className} style={{ \"--fud-a\": color } as CSSProperties}>\n        <label\n          onDragEnter={onDragEnter}\n          onDragOver={onDragOver}\n          onDragLeave={onDragLeave}\n          onDrop={onDrop}\n          onPointerMove={onMove}\n          className=\"block\"\n        >\n          <input\n            type=\"file\"\n            multiple={multiple}\n            disabled={disabled}\n            accept={accept.join(\",\")}\n            className=\"fud-input\"\n            onChange={onChange}\n          />\n          <div ref={zoneRef} className=\"fud-zone\" data-drag={dragging} data-disabled={disabled}>\n            <span aria-hidden className=\"fud-glow\" />\n            <svg aria-hidden className=\"pointer-events-none absolute\" style={{ inset: 1, width: \"calc(100% - 2px)\", height: \"calc(100% - 2px)\", overflow: \"visible\" }}>\n              <rect className=\"fud-rect\" x=\"0\" y=\"0\" width=\"100%\" height=\"100%\" rx=\"19\" />\n            </svg>\n            <svg aria-hidden className=\"fud-icon\" width=\"64\" height=\"64\" viewBox=\"0 0 64 64\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\n              <defs>\n                <clipPath id={clipId}>\n                  <rect x=\"0\" y=\"-20\" width=\"64\" height=\"62\" />\n                </clipPath>\n              </defs>\n              <g clipPath={\"url(#\" + clipId + \")\"}>\n                <g className=\"fud-sheet\">\n                  <rect x=\"19\" y=\"10\" width=\"26\" height=\"32\" rx=\"4\" />\n                  <path d=\"M32 33V19M26.5 24.5 32 19l5.5 5.5\" />\n                </g>\n              </g>\n              <path d=\"M10 38v8a5 5 0 0 0 5 5h34a5 5 0 0 0 5-5v-8\" />\n            </svg>\n            <p className=\"m-0 text-[15px] font-medium leading-snug\">\n              {dragging ? (\n                dragCount > 1 ? \"Release to add \" + dragCount + \" files\" : \"Release to add the file\"\n              ) : (\n                <>\n                  Drag files here or <span style={{ textDecoration: \"underline\", textUnderlineOffset: 3, textDecorationColor: \"color-mix(in srgb,currentColor 40%,transparent)\" }}>browse</span>\n                </>\n              )}\n            </p>\n            <p className=\"m-0 text-xs\" style={{ color: \"color-mix(in srgb,currentColor 55%,transparent)\" }}>\n              {hint}\n            </p>\n          </div>\n        </label>\n\n        <div role=\"status\" aria-live=\"polite\" className=\"fud-input\">\n          {note}\n        </div>\n\n        {items.length > 0 && (\n          <div className=\"mt-3\">\n            <div className=\"mb-1 flex items-center justify-between px-0.5 text-xs\" style={{ color: \"color-mix(in srgb,currentColor 55%,transparent)\" }}>\n              <span>{summary}</span>\n              <button type=\"button\" className=\"fud-clear\" onClick={() => dropRows(items.map((it) => it.id))}>\n                Clear all\n              </button>\n            </div>\n            <ul aria-label=\"Files\" className=\"m-0 flex list-none flex-col p-0\">\n              {items.map((it) => (\n                <li key={it.id} className=\"fud-row\" data-leaving={it.leaving ? \"true\" : undefined}>\n                  <div>\n                    <Row\n                      it={it}\n                      onRemove={() => dropRows([it.id])}\n                      onCancel={() => cancel(it.id)}\n                      onRetry={() => run(it.id, it.file)}\n                    />\n                  </div>\n                </li>\n              ))}\n            </ul>\n          </div>\n        )}\n      </div>\n    </>\n  );\n}\n\nfunction Row({ it, onRemove, onCancel, onRetry }: { it: Item; onRemove: () => void; onCancel: () => void; onRetry: () => void }) {\n  const { file, status } = it;\n  const bad = status === \"error\" || status === \"rejected\";\n  const hue = hueFor(file);\n  const pct = Math.round(it.progress);\n  let meta = formatSize(file.size) + \" · Selected\";\n  if (status === \"uploading\") meta = pct + \"% of \" + formatSize(file.size);\n  else if (status === \"done\") meta = formatSize(file.size) + \" · Uploaded\";\n  else if (bad) meta = it.message ?? \"Failed\";\n  return (\n    <div\n      className=\"relative flex items-center gap-2.5 overflow-hidden rounded-xl py-1.5 pl-2 pr-1\"\n      style={{\n        border: \"1px solid \" + (bad ? \"color-mix(in srgb,#ef4444 45%,transparent)\" : \"color-mix(in srgb,currentColor 13%,transparent)\"),\n        background: bad ? \"color-mix(in srgb,#ef4444 6%,transparent)\" : \"color-mix(in srgb,currentColor 3%,transparent)\",\n      }}\n    >\n      <span\n        aria-hidden\n        className=\"relative flex h-10 w-10 flex-none items-center justify-center overflow-hidden rounded-lg\"\n        style={{ background: \"color-mix(in srgb,currentColor 7%,transparent)\" }}\n      >\n        <svg width=\"28\" height=\"34\" viewBox=\"0 0 28 34\" fill=\"none\" style={{ color: hue }}>\n          <path d=\"M5 3h12l7 7v19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2Z\" stroke=\"currentColor\" strokeWidth=\"1.6\" strokeLinejoin=\"round\" />\n          <path d=\"M17 3v5a2 2 0 0 0 2 2h5\" stroke=\"currentColor\" strokeWidth=\"1.6\" strokeLinejoin=\"round\" />\n          <text x=\"13.5\" y=\"25\" textAnchor=\"middle\" fontSize=\"7\" fontWeight=\"700\" fill=\"currentColor\" style={{ letterSpacing: 0.2 }}>\n            {extOf(file.name)}\n          </text>\n        </svg>\n        {it.url && (\n          // eslint-disable-next-line @next/next/no-img-element\n          <img\n            src={it.url}\n            alt=\"\"\n            className=\"absolute inset-0 h-full w-full object-cover\"\n            onError={(e) => {\n              e.currentTarget.style.display = \"none\";\n            }}\n          />\n        )}\n      </span>\n      <span className=\"min-w-0 flex-1\">\n        <span className=\"block truncate text-[13px] font-medium leading-tight\">{file.name}</span>\n        <span\n          className=\"mt-0.5 flex items-center gap-1 truncate text-[11.5px] leading-tight\"\n          style={{ color: bad ? \"#ef4444\" : \"color-mix(in srgb,currentColor 55%,transparent)\" }}\n        >\n          {status === \"done\" && (\n            <svg className=\"fud-tick\" aria-hidden width=\"12\" height=\"12\" viewBox=\"0 0 12 12\" fill=\"none\" stroke=\"#22c55e\" strokeWidth=\"1.8\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\n              <circle cx=\"6\" cy=\"6\" r=\"5.2\" strokeWidth=\"1.2\" />\n              <path className=\"fud-check\" d=\"M3.6 6.2 5.3 7.9 8.5 4.4\" />\n            </svg>\n          )}\n          <span className=\"truncate\">{meta}</span>\n        </span>\n      </span>\n      {bad && status === \"error\" && (\n        <button type=\"button\" className=\"fud-btn\" aria-label={\"Retry \" + file.name} onClick={onRetry}>\n          <svg aria-hidden width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.6\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\n            <path d=\"M13.5 8a5.5 5.5 0 1 1-1.8-4.1M13.5 2.5v3h-3\" />\n          </svg>\n        </button>\n      )}\n      <button\n        type=\"button\"\n        className=\"fud-btn\"\n        aria-label={status === \"uploading\" ? \"Cancel upload of \" + file.name : status === \"rejected\" ? \"Dismiss \" + file.name : \"Remove \" + file.name}\n        onClick={status === \"uploading\" ? onCancel : onRemove}\n      >\n        <svg aria-hidden width=\"14\" height=\"14\" viewBox=\"0 0 14 14\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.6\" strokeLinecap=\"round\">\n          <path d=\"M3 3l8 8M11 3l-8 8\" />\n        </svg>\n      </button>\n      {status === \"uploading\" && (\n        <div\n          role=\"progressbar\"\n          aria-label={\"Uploading \" + file.name}\n          aria-valuemin={0}\n          aria-valuemax={100}\n          aria-valuenow={pct}\n          className=\"fud-bar\"\n          style={{ width: Math.max(it.progress, 3) + \"%\" }}\n        />\n      )}\n    </div>\n  );\n}\n","type":"registry:component","target":"components/viberdy/file-upload-dropzone.tsx"}],"meta":{"tier":"free","tags":["upload","dropzone","drag-drop","form","progress","validation","file-input"],"href":"https://viberdy.dev/library/file-upload-dropzone","aiPrompt":"Create a dependency-free React + Tailwind component named FileUploadDropzone (\"use client\", one file, no framer-motion, no icon library; icons are inline SVG).\n\nProps (all optional): hint = \"PNG, PDF up to 10MB\", accept = [\".png\", \".pdf\"] (extensions or MIME types, \"image/*\" supported), maxMb = 10, maxBytes (overrides maxMb), onFiles(files: File[]) called with newly ACCEPTED files, onUpload(file, report, signal) => Promise<void> (optional; report(0..100) drives the progress bar, resolve = done, reject = error row with Retry, signal aborts on cancel/remove), onReject(rejected: {file, reason}[]), multiple = true, disabled = false, accent = \"#ef4444\" (validate hex/rgb/hsl with a regex, fall back to default), className. Root is `w-full max-w-sm`.\n\nNEVER fake an upload. Without onUpload, rows are labelled \"Selected\" and the header reads \"N files selected, not uploaded\". Enforce accept and size on dropped AND picked files (client check only; say so in a comment).\n\nStructure: <label> wrapping a visually hidden real <input type=file multiple accept={accept.join(\",\")}> and a zone <div>. Render CSS in a plain <style> element beside the label (React 18 and 19 safe). Colours come from currentColor via color-mix (3% fill, 28% dashed stroke) so it works on light and dark pages; only the accent (CSS var --fud-a) is fixed. Focus: `.fud-input:focus-visible + .fud-zone` gets a 2px accent outline, offset 3px, !important.\n\nZone: radius 20px, padding 30/24/26, centred column. The dashed border is an SVG rect (stroke 1.5, dasharray 6 7, rx 19) inset 1px, not a CSS border. Icon: 64px SVG, a tray (open box path) with a sheet (rect 26x32 with an up arrow) clipped at the tray line; sheet rests at translateY(7px), hover 1px, drag -6px scale 1.04 on cubic-bezier(.34,1.56,.64,1) 0.5s, icon turns accent. Pointer glow: radial-gradient 220px at --fud-x/--fud-y (set via ref from pointermove, mapped to layout px with offsetWidth/rect.width), accent 20%, visible on hover and drag. Dragging: count dragenter/dragleave depth so children don't flicker; react only if dataTransfer.types includes \"Files\"; dropEffect copy; while dragging the border turns accent and marches (keyframes stroke-dashoffset to -26, 0.8s linear infinite), fill accent 9%, ring 0 0 0 4px accent 16% plus a soft 50px accent shadow, scale 1.012, copy \"Release to add N files\". Title 15px/500 \"Drag files here or browse\" (browse underlined), hint 12px at 55%.\n\nRows (below, 12px gap, ul aria-label=\"Files\"): header with summary (\"2 files, 1 uploading\" / \"N files selected, not uploaded\") and a \"Clear all\" text button. Each row: rounded-xl, 1px border 13% currentColor, 3% fill, 40px tile (image thumbnail via URL.createObjectURL with onError fallback, else a folded-page SVG with the extension, tinted by type), name 13px/500 truncated, meta 11.5px (size, \"42% of 3.1 MB\", \"Uploaded\" with a drawn green check, or the red error message), buttons 40x40: Retry (error only), Cancel/Remove/Dismiss. Uploading: a 2px accent bar along the row bottom, width = max(progress, 3)%, transition .3s ease-out, with a moving sheen. Rejected rows: red border, 6% red fill, reason text (\"Type not allowed (.exe)\", \"Too large: 12 MB, limit 10 MB\"). Rows enter with a 0.38s keyframe (grid-template-rows 0fr to 1fr, opacity, translateY -6px) and leave by collapsing grid rows over 0.28s (remove from state after 290ms).\n\nLifecycle: revoke every object URL on removal and unmount, abort in-flight uploads on unmount, clear timers. Single mode (multiple=false) replaces the current file. A polite sr-only live region announces added and rejected files. prefers-reduced-motion: no march, no spring, no row animation, no shimmer, instant removal. Output one self-contained component file.","license":"https://viberdy.dev/license"}}