{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "files-01",
  "description": "A dropzone showing the accepted types and size limit, with each upload's progress and cancel, retry and remove actions.",
  "registryDependencies": [
    "card",
    "button",
    "https://www.dashboardblocks.com/r/radix/files.json",
    "https://www.dashboardblocks.com/r/radix/format.json"
  ],
  "files": [
    {
      "path": "registry/components/dashboardblocks/files/files-01.tsx",
      "content": "'use client'\n\nimport {\n  FileDropzone,\n  type FileUpload,\n  FileUploadItem,\n  FileUploadList,\n  type UploadFn,\n  summarizeUploads,\n  useFileUploads,\n} from '@/registry/components/dashboardblocks/files'\nimport { formatPercent } from '@/registry/lib/dashboardblocks/format'\n\nimport { Button } from '@/components/ui/button'\nimport { Card, CardContent } from '@/components/ui/card'\n\ninterface Files1Props {\n  /** File types the picker offers, as in an input's `accept`. */\n  accept: string\n  acceptHint: string\n  description: string\n  initialUploads?: FileUpload[]\n  maxFiles: number\n  /** Largest file in bytes. */\n  maxSize: number\n  title: string\n  upload: UploadFn\n}\n\nconst MB = 1024 * 1024\n\nconst exampleProps: Omit<Files1Props, 'upload'> = {\n  accept: '.pdf,.png,.jpg,.jpeg,.docx,.xlsx,.pptx,.zip',\n  acceptHint: 'PDF, PNG, JPG, Office files or ZIP, up to 25 MB each',\n  description: 'Briefs, artwork and contracts for the Fall launch campaign.',\n  initialUploads: [\n    {\n      id: 'fall-launch-brief',\n      name: 'fall-launch-brief.pdf',\n      progress: 1,\n      size: 2.4 * MB,\n      status: 'done',\n      type: 'application/pdf',\n    },\n    {\n      id: 'hero-banner',\n      name: 'hero-banner@2x.png',\n      progress: 1,\n      size: 6.8 * MB,\n      status: 'done',\n      type: 'image/png',\n    },\n    {\n      error: 'Larger than 25 MB',\n      id: 'raw-footage',\n      name: 'launch-film-raw-footage.zip',\n      progress: 0,\n      rejected: true,\n      size: 412 * MB,\n      status: 'error',\n      type: 'application/zip',\n    },\n  ],\n  maxFiles: 10,\n  maxSize: 25 * MB,\n  title: 'Fall launch files',\n}\n\nconst Files1 = (props: Files1Props) => {\n  const {\n    accept,\n    acceptHint,\n    description,\n    initialUploads,\n    maxFiles,\n    maxSize,\n    title,\n    upload,\n  } = props\n  const { add, cancel, clear, remove, retry, uploads } = useFileUploads({\n    initialUploads,\n    upload,\n  })\n  const summary = summarizeUploads(uploads)\n\n  let status = `${summary.done} of ${uploads.length} ${uploads.length === 1 ? 'file' : 'files'} uploaded`\n  if (summary.active > 0) {\n    status = `Uploading ${summary.active} ${summary.active === 1 ? 'file' : 'files'}…`\n  } else if (summary.failed > 0) {\n    status += `, ${summary.failed} failed`\n  }\n\n  return (\n    <Card>\n      <CardContent>\n        <section className='@container flex flex-col gap-3'>\n          <header className='flex flex-col gap-0.5'>\n            <h2 className='font-semibold tracking-tight'>{title}</h2>\n            <p className='text-muted-foreground text-sm'>{description}</p>\n          </header>\n          <FileDropzone\n            accept={accept}\n            hint={acceptHint}\n            maxFiles={maxFiles}\n            maxSize={maxSize}\n            onFiles={add}\n          />\n          <p aria-live='polite' className='sr-only'>\n            {uploads.length > 0 && status}\n          </p>\n          {uploads.length > 0 && (\n            <section aria-label='Uploads' className='flex flex-col gap-1'>\n              <div className='flex min-h-8 items-center justify-between gap-2'>\n                <p className='text-muted-foreground text-sm tabular-nums'>\n                  <span aria-hidden>{status}</span>\n                  {summary.active > 0 && (\n                    <span aria-hidden>\n                      {' '}\n                      {formatPercent(summary.progress, {\n                        maximumFractionDigits: 0,\n                      })}\n                    </span>\n                  )}\n                </p>\n                {summary.done > 0 && (\n                  <Button variant='ghost' size='sm' onClick={() => clear()}>\n                    Clear uploaded\n                  </Button>\n                )}\n              </div>\n              <FileUploadList>\n                {uploads.map((item) => (\n                  <FileUploadItem\n                    key={item.id}\n                    upload={item}\n                    onCancel={cancel}\n                    onRemove={remove}\n                    onRetry={retry}\n                  />\n                ))}\n              </FileUploadList>\n            </section>\n          )}\n        </section>\n      </CardContent>\n    </Card>\n  )\n}\n\nexport { Files1, exampleProps as files1ExampleProps, type Files1Props }\n",
      "type": "registry:component",
      "target": "@components/dashboardblocks/files/files-01.tsx"
    }
  ],
  "meta": {
    "shows": "A dropzone showing the accepted types and size limit, with each upload's progress and cancel, retry and remove actions.",
    "size": "half",
    "usedWith": [
      "files-02",
      "files-03"
    ],
    "component": "Files1",
    "props": "{ accept: string; acceptHint: string; description: string; initialUploads?: { error?: string; file?: File; id: string; name: string; progress: number; rejected?: boolean; size: number; status: \"error\" | \"done\" | \"queued\" | \"canceled\" | \"uploading\"; type: string; url?: string }[]; maxFiles: number; maxSize: number; title: string; upload: (file: File, options: { onProgress: (progress: number) => void; signal: AbortSignal }) => Promise<void | { url?: string }> }"
  },
  "type": "registry:component"
}
