{
  "package": "@blade-ai/weft",
  "status": "beta",
  "version": "0.1.0",
  "updated": "2026-11-24",
  "component": "FileUpload",
  "import": "import { FileUpload } from \"@blade-ai/weft/components/file-upload\";",
  "docs": "/components/file-upload",
  "description": "Adds files by dragging them in or browsing. Each file shows its progress, then a success or error state; the hint states accepted types and the size limit. Square, flat and token-driven.",
  "props": [
    {
      "name": "label",
      "type": "string",
      "default": null,
      "required": true,
      "description": "Field label."
    },
    {
      "name": "labelPosition",
      "type": "\"top\" | \"left\"",
      "values": [
        "top",
        "left"
      ],
      "default": "top",
      "required": false,
      "description": "Label above or to the left."
    },
    {
      "name": "accept",
      "type": "string",
      "default": null,
      "required": false,
      "description": "Allowed extensions, e.g. \".pdf,.csv\". Drives the hint and on-drop validation. Default: any type."
    },
    {
      "name": "maxSize",
      "type": "number",
      "default": null,
      "required": false,
      "description": "Max size per file in bytes; shown in MB in the hint. Default: no limit."
    },
    {
      "name": "maxFiles",
      "type": "number",
      "default": null,
      "required": false,
      "description": "Max number of files when isMultiple. Default: UNDEFINED · needs decision (no limit for now)."
    },
    {
      "name": "isMultiple",
      "type": "boolean",
      "default": false,
      "required": false,
      "description": "One file or several."
    },
    {
      "name": "files",
      "type": "UploadFile[]",
      "default": [],
      "required": false,
      "description": "Controlled list, one row each: { id, name, size, type, status, progress (0–100), errorText }. status: queued · uploading · success · error · removing."
    },
    {
      "name": "onFilesAdded",
      "type": "(files: File[]) => void",
      "default": null,
      "required": false,
      "description": "Called with the files that passed client-side validation, on drop or pick."
    },
    {
      "name": "onFilesRejected",
      "type": "(rejections: { file, reason }[]) => void",
      "default": null,
      "required": false,
      "description": "Called with rejected files and a reason: tooLarge · wrongType · tooMany · duplicate. Duplicate detection key and outcome: UNDEFINED · needs decision (not emitted)."
    },
    {
      "name": "onRemove",
      "type": "(id: string) => void",
      "default": null,
      "required": false,
      "description": "Remove an uploaded file, or cancel one that is queued or uploading."
    },
    {
      "name": "onRetry",
      "type": "(id: string) => void",
      "default": null,
      "required": false,
      "description": "Retry a failed upload (network or server errors only)."
    },
    {
      "name": "helpText · errorText",
      "type": "ReactNode",
      "default": null,
      "required": false,
      "description": "Guidance or field-level error under the drop zone."
    },
    {
      "name": "isInvalid",
      "type": "boolean",
      "default": false,
      "required": false,
      "description": "Shows errorText and the invalid border."
    },
    {
      "name": "isRequired",
      "type": "boolean",
      "default": false,
      "required": false,
      "description": "Marks the field as required."
    },
    {
      "name": "isDisabled",
      "type": "boolean",
      "default": false,
      "required": false,
      "description": "Disables the drop zone and every file action."
    },
    {
      "name": "name · accessibilityLabel · testID",
      "type": "string",
      "default": null,
      "required": false,
      "description": "Form field name on the hidden file input · accessible name override · test selector."
    }
  ],
  "states": [
    {
      "name": "dropzone · idle",
      "trigger": "Default",
      "tokens": "bg surface.background.gray.subtle · border interactive.border.gray.default 1px dashed · pattern interactive.background.gray.faded dots + surface.background.primary.subtle → surface.background.primary.faint wash",
      "notes": "Pattern layer sits under all content."
    },
    {
      "name": "dropzone · hover",
      "trigger": "Pointer over the zone",
      "tokens": "bg surface.background.gray.moderate · border interactive.border.gray.highlighted",
      "notes": "Whole zone is the hit area."
    },
    {
      "name": "dropzone · focus-visible",
      "trigger": "Keyboard focus",
      "tokens": "border interactive.border.primary.default · ring interactive.border.primary.faded 3px box-shadow",
      "notes": ":focus-visible only."
    },
    {
      "name": "dropzone · drag-over valid",
      "trigger": "Files dragged over, type accepted",
      "tokens": "bg interactive.background.primary.faded · border interactive.border.positive.default · wash surface.background.primary.intense",
      "notes": "Text swaps to \"Drop files to upload\"; browse hidden."
    },
    {
      "name": "dropzone · drag-over invalid",
      "trigger": "Files dragged over, type not accepted",
      "tokens": "bg feedback.background.negative.subtle · border feedback.border.negative.intense · text feedback.text.negative.intense · wash off",
      "notes": "Best effort: DataTransferItem.type is often empty. Fallback = validate on drop (UNDEFINED · needs decision)."
    },
    {
      "name": "dropzone · disabled",
      "trigger": "isDisabled",
      "tokens": "bg interactive.background.gray.disabled · opacity opacity.600",
      "notes": "Not focusable; drops ignored; aria-disabled=\"true\"."
    },
    {
      "name": "dropzone · error",
      "trigger": "Too large · wrong type · too many",
      "tokens": "border feedback.border.negative.intense · message feedback.text.negative.intense",
      "notes": "Which files are kept on overflow: UNDEFINED · needs decision (first N are kept)."
    },
    {
      "name": "dropzone · uploading",
      "trigger": "Files in the list",
      "tokens": "idle tokens · file rows below",
      "notes": "Zone stays interactive or locks while uploading: UNDEFINED · needs decision (stays interactive)."
    },
    {
      "name": "row · queued",
      "trigger": "status = queued",
      "tokens": "bg surface.background.gray.subtle · border surface.border.gray.muted (1px inset) · track feedback.background.neutral.subtle · fill 0%",
      "notes": "\"2.4 MB · Waiting to upload\"."
    },
    {
      "name": "row · uploading",
      "trigger": "status = uploading",
      "tokens": "fill feedback.background.positive.intense width = % · meta surface.text.gray.muted",
      "notes": "\"1.2 of 2.4 MB · 50%\"; role=\"progressbar\". No indeterminate state: UNDEFINED · needs decision."
    },
    {
      "name": "row · success",
      "trigger": "status = success",
      "tokens": "meta surface.text.gray.muted",
      "notes": "\"Uploaded · 2.4 MB\"; progress removed; action is Remove."
    },
    {
      "name": "row · error",
      "trigger": "status = error",
      "tokens": "border feedback.border.negative.intense · icon feedback.icon.negative.intense on feedback.background.negative.subtle · Retry interactive.text.primary.normal",
      "notes": "Retry only for network/server failures."
    },
    {
      "name": "row · removing",
      "trigger": "status = removing",
      "tokens": "opacity opacity.600",
      "notes": "Actions inert until onRemove resolves."
    },
    {
      "name": "row · type icon",
      "trigger": "By extension",
      "tokens": "icon surface.icon.gray.muted on surface.background.gray.moderate",
      "notes": "PDF · sheet (.csv .xls .xlsx) · image (.jpg .png). Thumbnail preview: UNDEFINED · needs decision."
    },
    {
      "name": "row · long name",
      "trigger": "Name wider than the row",
      "tokens": "name flex 1 · min-width 0",
      "notes": "Truncates in the middle and keeps the end; full name in the title and aria-label."
    }
  ],
  "sizes": [
    {
      "property": "Dropzone",
      "value": "width fill (440 in forms) · padding 24 · gap 8 · 1px dashed border",
      "token": "spacing.7 · spacing.3 · border.width.thin"
    },
    {
      "property": "Icon badge · icon",
      "value": "36 square · 16",
      "token": "size.36 · size.16"
    },
    {
      "property": "Pattern",
      "value": "1px dots on a 3px pitch",
      "token": "interactive.background.gray.faded (literal pitch)"
    },
    {
      "property": "Brand wash",
      "value": "135° linear, subtle → transparent at 70%; drag-over uses primary.intense",
      "token": "surface.background.primary.subtle · intense"
    },
    {
      "property": "FileRow",
      "value": "padding 12 · gap 12 · 1px inset border · list gap 8",
      "token": "spacing.4 · spacing.3"
    },
    {
      "property": "ProgressBar",
      "value": "height 4 · square ends",
      "token": "size.4"
    },
    {
      "property": "Remove · Retry",
      "value": "28 icon button · text link",
      "token": "size.28"
    },
    {
      "property": "Radius",
      "value": "0",
      "token": "border.radius.none"
    }
  ],
  "behaviour": {
    "add files": "Drag and drop onto the zone, or click / Enter / Space to open the native picker. Both call the same handler.",
    "validation timing": "Client-side, immediately on drop or pick, before any upload: type (accept), size (maxSize), count (maxFiles).",
    "partially invalid multi-drop": "Valid files are added; invalid ones are rejected via onFilesRejected and shown as a zone error naming them.",
    "maxFiles overflow": "Which files are kept (first N, or none): UNDEFINED · needs decision. Fallback: first N kept.",
    "progress reporting": "Consumer updates files[].progress 0–100; the row shows a bar and \"x of y MB · %\". No indeterminate state: UNDEFINED · needs decision.",
    "cancel / remove during upload": "Remove on a queued/uploading row = cancel; the consumer aborts the request and sets status \"removing\" until onRemove resolves.",
    "retry": "Only for network/server errors; size/type errors never reach the list.",
    "duplicate files": "Detection key (name, name+size, hash) and outcome (skip or replace): UNDEFINED · needs decision.",
    "single file": "isMultiple=false: the uploaded row replaces the zone; Remove brings it back.",
    "zone while uploading": "Stays interactive or locks: UNDEFINED · needs decision.",
    "drag-over type check": "Best effort from DataTransferItem.type; if empty, show valid drag-over and validate on drop.",
    "image preview": "Thumbnail instead of glyph for images: UNDEFINED · needs decision."
  },
  "keyboard": [
    {
      "key": "Tab",
      "action": "Dropzone (button) → each file row: Retry → Remove / Cancel."
    },
    {
      "key": "Enter / Space on the dropzone",
      "action": "Opens the native picker."
    },
    {
      "key": "Enter / Space on Retry / Remove",
      "action": "Acts on that file."
    },
    {
      "key": "After remove",
      "action": "Focus moves to the next row, else the previous, else the dropzone."
    },
    {
      "key": "Disabled",
      "action": "Dropzone and actions are skipped (not focusable)."
    },
    {
      "key": "Focus ring",
      "action": ":focus-visible only, interactive.border.primary.faded 3px."
    }
  ],
  "accessibility": {
    "summary": "The dropzone is a native button that opens a hidden file input; rows are list items.",
    "aria": [
      {
        "element": "Dropzone",
        "attributes": "<button> aria-describedby=\"hint help error\" · aria-labelledby = label + zone text",
        "when": "Always"
      },
      {
        "element": "Hidden input",
        "attributes": "<input type=\"file\" accept multiple hidden> + <label for>",
        "when": "Always"
      },
      {
        "element": "Dropzone",
        "attributes": "aria-invalid=\"true\" · error id in describedby",
        "when": "Invalid"
      },
      {
        "element": "Live region",
        "attributes": "<div role=\"status\" aria-live=\"polite\">: \"x added\" · \"x uploaded\" · \"x failed: reason\" · \"2 files weren't added\"",
        "when": "Files change"
      },
      {
        "element": "ProgressBar",
        "attributes": "role=\"progressbar\" aria-valuenow aria-valuemin=0 aria-valuemax=100 aria-label=file name",
        "when": "Queued / uploading"
      },
      {
        "element": "Actions",
        "attributes": "aria-label=\"Remove | Cancel upload of | Retry {file}\"",
        "when": "Each row"
      },
      {
        "element": "Pattern + icons",
        "attributes": "aria-hidden=\"true\"",
        "when": "Always"
      },
      {
        "element": "Dropzone",
        "attributes": "aria-disabled=\"true\"",
        "when": "isDisabled"
      }
    ]
  },
  "usage": {
    "do": [
      "State types and size in the hint before a file is picked.",
      "Keep the Pattern layer under all content and inside the surface padding.",
      "Name the file in every error and announcement.",
      "Replace the zone with the row for single uploads."
    ],
    "dont": [
      "Don't place content over the pattern without the surface padding.",
      "Don't raise the wash above lime/100 at rest; it must never compete with the copy.",
      "Don't show Retry for size or type errors.",
      "Don't show MIME types, bytes or server codes."
    ]
  },
  "example": "<FileUpload label=\"Bank statement\" accept=\".pdf,.csv\" maxSize={10 * 1024 * 1024} files={files} onFilesAdded={upload} onRemove={remove} onRetry={retry} helpText=\"Upload this month’s statement to verify your account.\" />"
}
