{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "file-field",
  "title": "FileField",
  "description": "A labeled file input with a drop zone, on the Field contract.",
  "registryDependencies": [
    "@ouro/button",
    "@ouro/field",
    "@ouro/lib-cn",
    "@ouro/lib-env",
    "@ouro/lib-refs",
    "@ouro/lib-use-dev-messages",
    "@ouro/lib-use-field"
  ],
  "files": [
    {
      "path": "registry/ouro/components/ouro/file-field/file-field-styles.ts",
      "content": "export { acceptProblem, fileKey, formatSize, listClass, matchesAccept, nameClass, previewClass, promptClass, sizeClass, zoneClass };\n\n// Class strings and helpers for FileField, apart from the component so its file exports only\n// components (React Fast Refresh). Class strings are literal so the app's Tailwind finds them\n// when it compiles.\n\n/**\n * The drop zone: a dashed box at least 44px tall, in the primary tint while files are dragged\n * over it, outlined while the input inside it has keyboard focus. It fades with the field.\n *\n * @internal\n * @claim \"The drop zone: a dashed box\" registry/ouro/components/ouro/file-field/file-field.test.tsx verify:testExists(registry/ouro/components/ouro/file-field/file-field.test.tsx::FileField > outlines the zone while the input has keyboard focus)\n * @claim \"The drop zone: a dashed box\" registry/ouro/components/ouro/file-field/file-field.test.tsx verify:testExists(registry/ouro/components/ouro/file-field/file-field.test.tsx::FileField > highlights the zone while files are dragged over it)\n * @claim \"The drop zone: a dashed box\" registry/ouro/components/ouro/file-field/file-field.test.tsx verify:testExists(registry/ouro/components/ouro/file-field/file-field.test.tsx::FileField > is a labeled native file input inside a drop zone, on the Field contract)\n */\nconst zoneClass =\n  \"relative m-0 box-border flex min-h-11 w-full min-w-0 cursor-pointer flex-col items-center justify-center gap-1 px-4 py-6 \" +\n  \"rounded-ouro-lg border border-dashed border-input bg-transparent text-center text-muted-foreground \" +\n  \"outline-ring outline-offset-2 has-[input:focus-visible]:outline-2 has-[input:focus-visible]:outline-solid \" +\n  \"transition-[border-color,background-color] duration-(--ouro-duration-fast) ease-[ease] \" +\n  \"not-data-disabled:pointer-fine:hover:border-ring not-data-disabled:active:bg-accent/60 data-dragging:border-primary data-dragging:bg-primary/10 \" +\n  \"has-[input[aria-invalid=true]]:border-destructive \" +\n  \"data-disabled:cursor-not-allowed data-disabled:opacity-50 dark:bg-input/30\";\n\n/**\n * The text in the zone: 16px on phones, 14px from `sm` with a fine pointer.\n *\n * @internal\n * @claim \"The text in the zone: 16px\" registry/ouro/components/ouro/file-field/file-field.touch.test.tsx verify:testExists(registry/ouro/components/ouro/file-field/file-field.touch.test.tsx::keeps 16px prompt text and a remove button with a 44px hit area on a landscape phone)\n */\nconst promptClass = \"m-0 text-base leading-6 sm:pointer-fine:text-sm sm:pointer-fine:leading-5 [&_svg]:mx-auto [&_svg]:mb-1 [&_svg]:size-6\";\n\n/**\n * The chosen files, one row each.\n *\n * @internal\n * @claim \"The chosen files, one row each\" registry/ouro/components/ouro/file-field/file-field.test.tsx verify:testExists(registry/ouro/components/ouro/file-field/file-field.test.tsx::FileField > takes chosen files and lists them, with a preview for images)\n */\nconst listClass = \"m-0 grid list-none gap-2 p-0\";\n\n/**\n * An image's thumbnail, or a file icon in its place.\n *\n * @internal\n */\nconst previewClass =\n  \"flex size-10 shrink-0 items-center justify-center overflow-hidden rounded-ouro-md border border-solid border-border bg-muted text-muted-foreground object-cover [&_svg]:size-5\";\n\n/**\n * A file's name: one line, cut short with an ellipsis.\n *\n * @internal\n */\nconst nameClass = \"m-0 block min-w-0 truncate text-sm leading-5 font-medium text-foreground\";\n\n/**\n * A file's size.\n *\n * @internal\n */\nconst sizeClass = \"m-0 block text-sm leading-5 text-muted-foreground\";\n\n/**\n * A file's identity, to keep a file chosen twice in the list once: its name, size and type.\n *\n * @internal\n */\nfunction fileKey(file: File): string {\n  return `${file.name}\\u0000${file.size}\\u0000${file.type}`;\n}\n\n/**\n * Whether a file matches an `accept` list: an extension (`.pdf`, any case), a MIME type\n * (`image/png`) or a family (`image/*`). An empty list accepts everything.\n *\n * @internal\n * @claim \"An empty list accepts everything\" registry/ouro/components/ouro/file-field/file-field.test.tsx verify:testExists(registry/ouro/components/ouro/file-field/file-field.test.tsx::FileField > rejects files that do not match accept or exceed maxSize, and reports them)\n */\nfunction matchesAccept(file: File, accept: string | undefined): boolean {\n  const tokens = (accept ?? \"\")\n    .split(\",\")\n    .map((token) => token.trim().toLowerCase())\n    .filter(Boolean);\n  if (tokens.length === 0) return true;\n  const name = file.name.toLowerCase();\n  const type = file.type.toLowerCase();\n  return tokens.some((token) =>\n    token.startsWith(\".\") ? name.endsWith(token) : token.endsWith(\"/*\") ? type.startsWith(token.slice(0, -1)) : type === token,\n  );\n}\n\n/**\n * The first `accept` entry that is neither an extension nor a MIME type, such as `pdf`, or\n * undefined. Development only.\n *\n * @internal\n */\nfunction acceptProblem(accept: string | undefined): string | undefined {\n  return (accept ?? \"\")\n    .split(\",\")\n    .map((token) => token.trim())\n    .find((token) => token !== \"\" && !token.startsWith(\".\") && !token.includes(\"/\"));\n}\n\nconst units = [\"byte\", \"kilobyte\", \"megabyte\", \"gigabyte\"] as const;\n\n/**\n * A size in bytes for people: `2 kB`, `4.5 MB`, in the browser's language.\n *\n * @internal\n */\nfunction formatSize(bytes: number): string {\n  let value = bytes;\n  let unit = 0;\n  while (value >= 1024 && unit < units.length - 1) {\n    value /= 1024;\n    unit++;\n  }\n  return new Intl.NumberFormat(undefined, { style: \"unit\", unit: units[unit], unitDisplay: \"short\", maximumFractionDigits: 1 }).format(value);\n}\n",
      "type": "registry:ui",
      "target": "@components/ouro/file-field/file-field-styles.ts"
    },
    {
      "path": "registry/ouro/components/ouro/file-field/file-field.tsx",
      "content": "\"use client\";\n\nimport { useCallback, useEffect, useId, useRef, useState, type DragEvent, type JSX, type ReactNode, type Ref } from \"react\";\nimport { Button } from \"@/registry/ouro/components/ouro/button/button\";\nimport { Field } from \"@/registry/ouro/components/ouro/field/field\";\nimport { FieldControl } from \"@/registry/ouro/components/ouro/field/field-parts\";\nimport { contractWarnings, errorClass } from \"@/registry/ouro/components/ouro/field/field-styles\";\nimport { cn } from \"@/registry/ouro/lib/ouro/cn\";\nimport { useMergedRef } from \"@/registry/ouro/lib/ouro/refs\";\nimport { FieldOwnerContext, type ReadonlyErrorMessages } from \"@/registry/ouro/lib/ouro/use-field\";\nimport { useDevWarnings } from \"@/registry/ouro/lib/ouro/use-dev-messages\";\nimport {\n  acceptProblem,\n  fileKey,\n  formatSize,\n  listClass,\n  matchesAccept,\n  nameClass,\n  previewClass,\n  promptClass,\n  sizeClass,\n  zoneClass,\n} from \"@/registry/ouro/components/ouro/file-field/file-field-styles\";\n\n/** A file FileField left out, and why: it did not match `accept`, was larger than `maxSize`, or was one too many without `multiple`. */\nexport interface FileRejection {\n  /** The file that was left out. */\n  file: File;\n  /** `type`: it does not match `accept`. `size`: it is larger than `maxSize`. `count`: the field takes one file. */\n  reason: \"type\" | \"size\" | \"count\";\n}\n\n/** Props for {@link FileField}. */\nexport interface FileFieldProps {\n  /**\n   * What the files are for (\"Recipe photo\"), shown above the drop zone and read as the input's\n   * name. Required: every control needs a name. To hide it visually, keep it and add `hideLabel`.\n   * @claim \"Required: every control needs a name\" registry/ouro/components/ouro/file-field/file-field.test-d.ts verify:fileLine(registry/ouro/components/ouro/file-field/file-field.test-d.ts, /expectTypeOf<\\{\\saccept:\\s\"image\\/\\*\"\\s\\}>\\(\\)\\.not\\.toExtend<FileFieldProps>/)\n   */\n  label: string;\n  /** Hides the label visually; screen readers still read it. */\n  hideLabel?: boolean | undefined;\n  /**\n   * Supporting text under the label (\"PNG or JPG, up to 5 MB\"), read through `aria-describedby`.\n   *\n   * @claim \"), read through `aria-describedby`.\" registry/ouro/components/ouro/file-field/file-field.test.tsx verify:testExists(registry/ouro/components/ouro/file-field/file-field.test.tsx::FileField > is a labeled native file input inside a drop zone, on the Field contract)\n   */\n  description?: ReactNode | undefined;\n  /**\n   * What is wrong, from your server action or client check. It shows under the field, and\n   * the input gets `aria-invalid`. A message is text or a React node (one with a link); an empty string or array means valid.\n   */\n  error?: ReadonlyErrorMessages | undefined;\n  /** A file must be chosen before the form submits. */\n  required?: boolean | undefined;\n  /** Disables the input and the drop zone, and fades the field. */\n  disabled?: boolean | undefined;\n  /** The form field name the files submit under. */\n  name?: string | undefined;\n  /**\n   * The files it takes, as the input's `accept`: extensions and MIME types, comma-separated\n   * (`\".pdf,image/*\"`). Files that do not match are left out, with a message under the field,\n   * and reported to `onReject`.\n   */\n  accept?: string | undefined;\n  /**\n   * Takes several files; each new choice or drop adds to the list. Without it, a new file replaces the old one.\n   *\n   * @claim \"Takes several files; each new choice\" registry/ouro/components/ouro/file-field/file-field.test.tsx verify:testExists(registry/ouro/components/ouro/file-field/file-field.test.tsx::FileField > adds files to the list with multiple, and replaces the file without it)\n   */\n  multiple?: boolean | undefined;\n  /**\n   * The largest file it takes, in bytes: `5 * 1024 * 1024` for 5 MB. Larger files are left out,\n   * with a message under the field, and reported to `onReject`.\n   * @claim \"The largest file it takes, in\" registry/ouro/components/ouro/file-field/file-field.test.tsx verify:testExists(registry/ouro/components/ouro/file-field/file-field.test.tsx::FileField > says why a file was left out, under the field > for a file larger than maxSize, naming the limit)\n   */\n  maxSize?: number | undefined;\n  /** Called with the chosen files whenever the list changes: a choice, a drop, or a removal. */\n  onFilesChange?: ((files: File[]) => void) | undefined;\n  /**\n   * Called with the files that were left out, and why. The field already says why under\n   * itself; use this to log or count them.\n   */\n  onReject?: ((rejections: FileRejection[]) => void) | undefined;\n  /**\n   * The message under the field for each file that was left out, until the next choice takes\n   * every file, a removal or a form reset. It is announced to screen readers as a status, and\n   * shows next to `error` and a Form's error for this name, never instead of them. Translate it\n   * with your app.\n   * @default (rejection) => \"notes.heic is not an accepted file type.\", \"big.png is larger than 5 MB.\" or \"Only one file can be added, so b.png was left out.\"\n   * @claim \"The message under the field for\" registry/ouro/components/ouro/file-field/file-field.test.tsx verify:testExists(registry/ouro/components/ouro/file-field/file-field.test.tsx::FileField > says why a file was left out, under the field > next to the app's own error, in rejectMessage's words, until the next choice takes every file)\n   * @claim \"The message under the field for\" registry/ouro/components/ouro/file-field/file-field.test.tsx verify:testExists(registry/ouro/components/ouro/file-field/file-field.test.tsx::FileField > says why a file was left out, under the field > and drops the message when a file is removed or the form resets)\n   * @claim \"It is announced to screen readers\" registry/ouro/components/ouro/file-field/file-field.test.tsx verify:testExists(registry/ouro/components/ouro/file-field/file-field.test.tsx::FileField > says why a file was left out, under the field > next to a Form's error for its name, which it does not hide)\n   * @claim \"It is announced to screen readers\" registry/ouro/components/ouro/file-field/file-field.test.tsx verify:testExists(registry/ouro/components/ouro/file-field/file-field.test.tsx::FileField > says why a file was left out, under the field > in a polite status region, mounted before the rejection and emptied by the next valid pick)\n   */\n  rejectMessage?: ((rejection: FileRejection) => string) | undefined;\n  /**\n   * Which camera a phone opens instead of the file picker: `environment` (back) or `user` (front).\n   * Pass it with `accept=\"image/*\"`.\n   */\n  capture?: \"user\" | \"environment\" | undefined;\n  /**\n   * The text in the drop zone. Translate it with your app.\n   * @default \"Drag a file here, or choose one\" (\"Drag files here, or choose them\" with `multiple`)\n   */\n  prompt?: string | undefined;\n  /**\n   * The start of each file's remove button name, followed by the file name, as visually\n   * hidden text and not an `aria-label`, so a test's `getByLabel(\"Photo\")` finds the field and\n   * not \"Remove photo.jpg\". Translate it with your app.\n   * @default \"Remove\"\n   * @claim \"The start of each file's remove\" registry/ouro/components/ouro/file-field/file-field.test.tsx verify:testExists(registry/ouro/components/ouro/file-field/file-field.test.tsx::FileField > leaves a loose label lookup for the field on the input, not on a file's remove button)\n   */\n  removeLabel?: string | undefined;\n  /**\n   * Layout only: margins, width, grid placement (`mt-4`). Appearance classes warn in\n   * development; style fields in your theme.\n   */\n  className?: string | undefined;\n  /** The file input element. */\n  ref?: Ref<HTMLInputElement> | undefined;\n\n  /** Not a prop. Ouro UI uses `maxSize`, in bytes: `<FileField maxSize={5 * 1024 * 1024}>`. */\n  maxFileSize?: { 'Use <FileField maxSize={5 * 1024 * 1024}>': never };\n  /** Not a prop. Ouro UI uses `accept`, as the input does: `<FileField accept=\"image/*,.pdf\">`. */\n  acceptedFileTypes?: { 'Use <FileField accept=\"image/*,.pdf\">': never };\n  /** Not a prop. Ouro UI uses `onFilesChange`, which gets the files: `<FileField onFilesChange={(files) => ...}>`. */\n  onChange?: { 'Use <FileField onFilesChange={(files) => ...}>': never };\n  /** Not a prop. Dropped files arrive in `onFilesChange`: `<FileField onFilesChange={(files) => ...}>`. */\n  onDrop?: { 'Use <FileField onFilesChange={(files) => ...}>': never };\n  /** Not a prop. Ouro UI uses `error`: `<FileField error=\"Choose a photo.\">`. */\n  errorMessage?: { 'Use <FileField error=\"Choose a photo.\">': never };\n  /** Not a prop. Ouro UI uses `description`: `<FileField description=\"...\">`. */\n  helperText?: { 'Use <FileField description=\"...\">': never };\n  /** Not a prop. `error` marks the field invalid: `<FileField error=\"What is wrong\">`. */\n  isInvalid?: { 'Use <FileField error=\"What is wrong\">': never };\n  /** Not a prop. `error` marks the field invalid: `<FileField error=\"What is wrong\">`. */\n  invalid?: { 'Use <FileField error=\"What is wrong\">': never };\n  /** Not a prop. Ouro UI uses `required`: `<FileField required>`. */\n  isRequired?: { 'Use <FileField required>': never };\n  /** Not a prop. Ouro UI uses `disabled`: `<FileField disabled>`. */\n  isDisabled?: { 'Use <FileField disabled>': never };\n}\n\n/** Field's messages and root name FileField. */\nconst owner = { name: \"FileField\", data: \"file-field\" };\n\n/** Icons drawn in the text color, like the other Ouro icons. */\nfunction Icon({ children, className }: { children: ReactNode; className?: string }): JSX.Element {\n  return (\n    <svg\n      aria-hidden=\"true\"\n      viewBox=\"0 0 24 24\"\n      fill=\"none\"\n      stroke=\"currentColor\"\n      strokeWidth=\"1.5\"\n      strokeLinecap=\"round\"\n      strokeLinejoin=\"round\"\n      className={className}\n    >\n      {children}\n    </svg>\n  );\n}\n\n/**\n * An image file's thumbnail. Its object URL lives as long as the element: it is made when the\n * image is attached and released when it is removed.\n */\nfunction Thumbnail({ file }: { file: File }): JSX.Element {\n  const attach = useCallback(\n    (image: HTMLImageElement | null) => {\n      /* istanbul ignore if @preserve -- React 19 calls a ref that returns a cleanup with the element only */\n      if (!image) return;\n      const url = URL.createObjectURL(file);\n      image.src = url;\n      return () => URL.revokeObjectURL(url);\n    },\n    [file],\n  );\n  return <img ref={attach} alt=\"\" className={previewClass} />;\n}\n\n/** The English message for a file that was left out. */\nfunction defaultRejectMessage({ file, reason }: FileRejection, maxSize: number | undefined): string {\n  if (reason === \"type\") return `${file.name} is not an accepted file type.`;\n  if (reason === \"size\") return `${file.name} is larger than ${formatSize(maxSize!)}.`;\n  return `Only one file can be added, so ${file.name} was left out.`;\n}\n\n/** Puts files in the input, so the form submits exactly the listed ones. */\nfunction setInputFiles(input: HTMLInputElement, files: readonly File[]): void {\n  const data = new DataTransfer();\n  for (const file of files) data.items.add(file);\n  input.files = data.files;\n}\n\n/**\n * A labeled file input with a drop zone, on the Field contract. Files can be chosen with the\n * system picker (or a phone's camera, with `capture`) or dropped on the zone; the chosen ones\n * are listed with a thumbnail for images and a remove button, and they stay in the native\n * input, so a plain form submits them. `accept`, `maxSize` and `multiple` filter what comes\n * in; a file that is left out gets a message under the field (`rejectMessage` translates it),\n * and `onReject` reports it.\n *\n * Use `TextField type=\"url\"` instead to take a link to a file, and an upload service's own\n * widget when files go straight to storage without a form.\n *\n * @group Forms\n * @see https://ui.ouroboros.bot/docs/file-field\n *\n * @example\n * <FileField label=\"Recipe photo\" name=\"photo\" accept=\"image/*\" maxSize={5 * 1024 * 1024} error={errors?.photo} />\n * <FileField label=\"Attachments\" name=\"attachments\" multiple maxSize={10 * 1024 * 1024} onReject={(rejected) => logRejected(rejected)} />\n */\nexport function FileField(props: FileFieldProps): JSX.Element {\n  const {\n    label,\n    hideLabel,\n    description,\n    error,\n    required,\n    disabled,\n    name,\n    accept,\n    multiple,\n    maxSize,\n    onFilesChange,\n    onReject,\n    rejectMessage,\n    capture,\n    prompt,\n    removeLabel = \"Remove\",\n    className,\n    ref,\n    // Guard props (hint types), dropped here so they never reach the DOM.\n    maxFileSize,\n    acceptedFileTypes,\n    onChange,\n    onDrop,\n    errorMessage,\n    helperText,\n    isInvalid,\n    invalid,\n    isRequired,\n    isDisabled,\n  } = props;\n  useDevWarnings(\n    \"FileField\",\n    process.env.NODE_ENV !== \"production\"\n      ? () => {\n          const bad = acceptProblem(accept);\n          return [\n            bad !== undefined && [\n              `accept lists \"${bad}\", which is neither an extension nor a type`,\n              `<FileField accept=\"${accept!.replace(bad, `.${bad}`)}\">`,\n            ],\n            maxSize !== undefined &&\n              !(maxSize > 0) && [`maxSize={${String(maxSize)}} is not a positive number of bytes`, \"<FileField maxSize={5 * 1024 * 1024}>\"],\n            maxSize !== undefined &&\n              maxSize > 0 &&\n              maxSize < 1024 && [\n                `maxSize={${maxSize}} is ${maxSize} bytes; maxSize counts bytes`,\n                `<FileField maxSize={${maxSize} * 1024 * 1024}> for ${maxSize} MB`,\n              ],\n            ...contractWarnings(\"FileField\", { errorMessage, helperText, isInvalid, invalid, isRequired, isDisabled }),\n            maxFileSize !== undefined && [\"maxFileSize is not a prop\", `<FileField maxSize={${String(maxFileSize)}}>`],\n            acceptedFileTypes !== undefined && [\n              \"acceptedFileTypes is not a prop\",\n              `<FileField accept=\"${([] as unknown[]).concat(acceptedFileTypes).join(\",\")}\">`,\n            ],\n            onChange !== undefined && [\"onChange is not a prop\", \"<FileField onFilesChange={(files) => …}>\"],\n            onDrop !== undefined && [\"onDrop is not a prop; dropped files arrive in onFilesChange\", \"<FileField onFilesChange={(files) => …}>\"],\n          ];\n        }\n      : /* istanbul ignore next @preserve -- production only */ undefined,\n  );\n\n  const inputRef = useRef<HTMLInputElement | null>(null);\n  const setRef = useMergedRef(ref, inputRef);\n  const [files, setFiles] = useState<readonly File[]>([]);\n  const [dragging, setDragging] = useState(false);\n  // Why the last choice or drop left files out, shown under the field.\n  const [rejections, setRejections] = useState<readonly string[]>([]);\n  const statusId = useId();\n  const rejecting = rejections.length > 0;\n\n  // A form reset empties the input; empty the list and its messages with it.\n  useEffect(() => {\n    const form = inputRef.current!.form;\n    if (!form) return;\n    const onReset = () => {\n      setFiles([]);\n      setRejections([]);\n    };\n    form.addEventListener(\"reset\", onReset);\n    return () => form.removeEventListener(\"reset\", onReset);\n  }, []);\n\n  /** Shows a new list, puts it in the input and tells the app. */\n  const commit = (next: readonly File[]) => {\n    setInputFiles(inputRef.current!, next);\n    setFiles(next);\n    onFilesChange?.([...next]);\n  };\n\n  /** Takes files from the picker or a drop: filters them, then adds them or replaces the file. */\n  const take = (incoming: readonly File[]) => {\n    const rejected: FileRejection[] = [];\n    const accepted: File[] = [];\n    for (const file of incoming) {\n      if (!matchesAccept(file, accept)) rejected.push({ file, reason: \"type\" });\n      else if (maxSize !== undefined && maxSize > 0 && file.size > maxSize) rejected.push({ file, reason: \"size\" });\n      else if (!multiple && accepted.length > 0) rejected.push({ file, reason: \"count\" });\n      else accepted.push(file);\n    }\n    setRejections(rejected.map((rejection) => (rejectMessage ? rejectMessage(rejection) : defaultRejectMessage(rejection, maxSize))));\n    if (rejected.length > 0) onReject?.(rejected);\n    if (accepted.length === 0) {\n      // The picker put a rejected file in the input: put the listed ones back.\n      setInputFiles(inputRef.current!, files);\n      return;\n    }\n    if (!multiple) return commit(accepted);\n    const seen = new Set(files.map(fileKey));\n    commit([...files, ...accepted.filter((file) => !seen.has(fileKey(file)))]);\n  };\n\n  const remove = (file: File) => {\n    setRejections([]);\n    commit(files.filter((listed) => listed !== file));\n    inputRef.current!.focus();\n  };\n\n  // Dropping a file anywhere in the zone must never open it in the browser, so these always\n  // cancel the default; a disabled field ignores what is dropped.\n  const dragOver = (event: DragEvent<HTMLLabelElement>) => {\n    event.preventDefault();\n    if (!disabled) setDragging(true);\n  };\n  const dragLeave = (event: DragEvent<HTMLLabelElement>) => {\n    if (!event.currentTarget.contains(event.relatedTarget as Node | null)) setDragging(false);\n  };\n  const drop = (event: DragEvent<HTMLLabelElement>) => {\n    event.preventDefault();\n    setDragging(false);\n    if (!disabled) take([...event.dataTransfer.files]);\n  };\n\n  return (\n    <FieldOwnerContext.Provider value={owner}>\n      <Field\n        label={label}\n        hideLabel={hideLabel}\n        description={description}\n        error={error}\n        required={required}\n        disabled={disabled}\n        name={name}\n        className={className}\n      >\n        {/* The zone is a label around the input, so pressing anywhere in it opens the picker, and\n            its text counts as disabled with the input. The input's name stays the field's label\n            (aria-labelledby). */}\n        <label\n          data-ouro-drop-zone=\"\"\n          data-dragging={dragging ? \"\" : undefined}\n          data-disabled={disabled ? \"\" : undefined}\n          className={zoneClass}\n          onDragEnter={dragOver}\n          onDragOver={dragOver}\n          onDragLeave={dragLeave}\n          onDrop={drop}\n        >\n          <span className={promptClass}>\n            <Icon>\n              <path d=\"M12 15V4m0 0L7.5 8.5M12 4l4.5 4.5M4.5 15v3.5a1.5 1.5 0 0 0 1.5 1.5h12a1.5 1.5 0 0 0 1.5-1.5V15\" />\n            </Icon>\n            {prompt ?? (multiple ? \"Drag files here, or choose them\" : \"Drag a file here, or choose one\")}\n          </span>\n          <FieldControl\n            ref={setRef}\n            accept={accept}\n            multiple={multiple}\n            capture={capture}\n            onChange={(event) => take([...event.currentTarget.files!])}\n            {...(rejecting ? { \"aria-invalid\": true, \"aria-describedby\": statusId } : {})}\n            render={(controlProps) => <input {...controlProps} type=\"file\" data-ouro-control=\"file-field\" data-ouro-part=\"input\" className=\"sr-only\" />}\n          />\n        </label>\n        {files.length > 0 && (\n          <ul data-ouro-file-list=\"\" className={listClass}>\n            {files.map((file) => {\n              return (\n                <li key={fileKey(file)} className=\"m-0 flex min-w-0 items-center gap-3\">\n                  {file.type.startsWith(\"image/\") ? (\n                    <Thumbnail file={file} />\n                  ) : (\n                    <span aria-hidden=\"true\" className={previewClass}>\n                      <Icon>\n                        <path d=\"M14 3.5H7A1.5 1.5 0 0 0 5.5 5v14A1.5 1.5 0 0 0 7 20.5h10a1.5 1.5 0 0 0 1.5-1.5V8L14 3.5zM14 3.5V8h4.5\" />\n                      </Icon>\n                    </span>\n                  )}\n                  <span className=\"grid min-w-0 flex-1\">\n                    <span data-ouro-file-name=\"\" className={nameClass}>\n                      {file.name}\n                    </span>\n                    <span data-ouro-file-size=\"\" className={sizeClass}>\n                      {formatSize(file.size)}\n                    </span>\n                  </span>\n                  <Button\n                    variant=\"plain\"\n                    tone=\"secondary\"\n                    size=\"sm\"\n                    data-ouro-file-remove=\"\"\n                    data-ouro-control=\"file-field\"\n                    data-ouro-part=\"remove\"\n                    disabled={disabled}\n                    className=\"aspect-square px-0\"\n                    onClick={() => remove(file)}\n                  >\n                    <Icon className=\"size-4\">\n                      <path d=\"M7 7l10 10M17 7L7 17\" />\n                    </Icon>\n                    <span className=\"sr-only\">{`${removeLabel} ${file.name}`}</span>\n                  </Button>\n                </li>\n              );\n            })}\n          </ul>\n        )}\n        {/* Why files were left out: a polite status region from the first render, so screen\n            readers announce the message once when it appears; hidden while empty. It stays apart\n            from Field's error, so `error` and a Form's error still show. */}\n        <div id={statusId} role=\"status\" data-ouro-file-rejections=\"\" className={cn(errorClass, !rejecting && \"sr-only\")}>\n          {rejections.length > 1 ? (\n            <ul className=\"m-0 list-none p-0\">\n              {rejections.map((message, index) => (\n                // Two files can share a name, and so a message.\n                <li key={`${index}:${message}`}>{message}</li>\n              ))}\n            </ul>\n          ) : (\n            rejections[0]\n          )}\n        </div>\n      </Field>\n    </FieldOwnerContext.Provider>\n  );\n}\n",
      "type": "registry:ui",
      "target": "@components/ouro/file-field/file-field.tsx"
    }
  ],
  "docs": "A labeled file input with a drop zone, on the Field contract. Import: import { FileField } from \"@/components/ouro/file-field/file-field\", with @/components replaced by your components alias (aliases.components in components.json, such as ~/components). Also installed: button, field, the helpers they import in lib/ouro. Needs ouro-base in your stylesheet: add that item once per app, from the same place as this one, if you have not. Docs: https://ui.ouroboros.bot/docs/file-field.md Ouro UI v1.3.257.",
  "type": "registry:ui"
}