{
  "$schema": "https://rift-ds.com/schema/component.schema.json",
  "version": "1.40.0",
  "kind": "component",
  "name": "AttachmentViewer",
  "label": "Attachment viewer",
  "slug": "attachment-viewer",
  "category": "ai",
  "description": "A preview dialog for a message's files, with download, stepping, and plain states for files it cannot show.",
  "client": true,
  "importPath": "rift-ds/components/Attachment/AttachmentViewer",
  "barrel": "main",
  "docsUrl": "https://rift-ds.com/components/attachment-viewer",
  "markdownUrl": "https://rift-ds.com/components/attachment-viewer.md",
  "exports": [
    {
      "component": "AttachmentViewer",
      "props": [
        {
          "name": "open",
          "type": "boolean",
          "typeKind": "primitive",
          "required": true,
          "description": "Whether the viewer is open."
        },
        {
          "name": "onOpenChange",
          "type": "(open: boolean) => void",
          "typeKind": "function",
          "required": true,
          "description": "Fires when the viewer asks to close: the close button, Escape, or the backdrop."
        },
        {
          "name": "items",
          "type": "AttachmentItem[]",
          "typeKind": "array",
          "required": true,
          "description": "The files the viewer steps through, in order.",
          "typeRefs": [
            "AttachmentItem"
          ]
        },
        {
          "name": "activeId",
          "type": "string",
          "typeKind": "primitive",
          "required": false,
          "description": "Id of the file on show, for controlled use. Pair with `onActiveChange`."
        },
        {
          "name": "defaultActiveId",
          "type": "string",
          "typeKind": "primitive",
          "required": false,
          "description": "Id of the file shown first, for uncontrolled use. Defaults to the first item."
        },
        {
          "name": "onActiveChange",
          "type": "((id: string) => void)",
          "typeKind": "function",
          "required": false,
          "description": "Fires with the id of the file stepped to."
        },
        {
          "name": "renderPreview",
          "type": "((item: AttachmentItem) => ReactNode)",
          "typeKind": "function",
          "required": false,
          "description": "Draws a file the viewer cannot: the pages of a PDF, a media player, a\nrendered spreadsheet. Return nothing to fall back to the built-in view.",
          "typeRefs": [
            "AttachmentItem"
          ]
        },
        {
          "name": "onDownload",
          "type": "((item: AttachmentItem) => void)",
          "typeKind": "function",
          "required": false,
          "description": "Fires with the file on show when Download is pressed. Its presence renders the buttons.",
          "typeRefs": [
            "AttachmentItem"
          ]
        },
        {
          "name": "onRetry",
          "type": "((item: AttachmentItem) => void)",
          "typeKind": "function",
          "required": false,
          "description": "Fires with a file that failed to load when \"Try again\" is pressed. Its presence renders the button.",
          "typeRefs": [
            "AttachmentItem"
          ]
        },
        {
          "name": "dismissible",
          "type": "boolean",
          "typeKind": "primitive",
          "required": false,
          "description": "Whether Escape, the backdrop and the close button dismiss the viewer.",
          "default": true
        },
        {
          "name": "downloadLabel",
          "type": "string",
          "typeKind": "primitive",
          "required": false,
          "description": "Text of the Download buttons.",
          "default": "Download"
        },
        {
          "name": "closeLabel",
          "type": "string",
          "typeKind": "primitive",
          "required": false,
          "description": "Accessible label for the close button.",
          "default": "Close"
        },
        {
          "name": "previousLabel",
          "type": "string",
          "typeKind": "primitive",
          "required": false,
          "description": "Accessible label for the previous-file button.",
          "default": "Previous file"
        },
        {
          "name": "nextLabel",
          "type": "string",
          "typeKind": "primitive",
          "required": false,
          "description": "Accessible label for the next-file button.",
          "default": "Next file"
        },
        {
          "name": "retryLabel",
          "type": "string",
          "typeKind": "primitive",
          "required": false,
          "description": "Text of the retry button.",
          "default": "Try again"
        },
        {
          "name": "noPreviewLabel",
          "type": "string",
          "typeKind": "primitive",
          "required": false,
          "description": "Headline when a file has nothing the viewer can draw.",
          "default": "No preview for this file type"
        },
        {
          "name": "failedLabel",
          "type": "string",
          "typeKind": "primitive",
          "required": false,
          "description": "Headline when a file failed to load or is no longer available.",
          "default": "Couldn’t load this file"
        },
        {
          "name": "failedDescription",
          "type": "string",
          "typeKind": "primitive",
          "required": false,
          "description": "Sentence under `failedLabel`, when the file carries no error message of its own.",
          "default": "The link may have expired."
        },
        {
          "name": "formatPosition",
          "type": "((position: number, total: number) => string)",
          "typeKind": "function",
          "required": false,
          "description": "Builds the position text, e.g. \"2 of 5\", from a one-based index and the total.",
          "defaultExpression": "(position, total) => `${position} of ${total}`"
        },
        {
          "name": "locale",
          "type": "string",
          "typeKind": "primitive",
          "required": false,
          "description": "The BCP 47 locale file sizes are written in, such as `de-DE` (`1,5 MB`). Defaults to the nearest LocaleProvider's, else `en-US`."
        },
        {
          "name": "className",
          "type": "string",
          "typeKind": "primitive",
          "required": false,
          "description": "Additional CSS classes — applied to the portal container, not the panel.",
          "default": ""
        }
      ]
    }
  ],
  "types": {
    "AttachmentItem": {
      "kind": "interface",
      "definition": "interface AttachmentItem {\n  /** Stable identity, unique within its list. */\n  id: string;\n  /** File name, extension included. */\n  name: string;\n  /** What kind of file it is. */\n  kind: FileKind;\n  /**\n   * Short label on the file's type mark, replacing the one derived from its\n   * kind and extension (`getFileTypeLabel`: \"PDF\", \"DOC\", the extension, or\n   * \"FILE\"), wherever the family draws the mark: the tile, a lone picture's\n   * badge, the viewer and a composer's queue. Set it to localise the mark or\n   * to name a format the derivation does not know.\n   */\n  typeLabel?: string;\n  /** Size in bytes. */\n  size?: number;\n  /** Mime type, when the source reported one. */\n  mimeType?: string;\n  /** Where the file is in its life. */\n  status: AttachmentStatus;\n  /** Upload progress, 0 to 100, while `status` is `uploading`. */\n  progress?: number;\n  /** Why it failed, while `status` is `error`. */\n  error?: string;\n  /** Image that fills the tile: an object URL for a picture, or a\n      host-rendered first page for a document. */\n  previewSrc?: string;\n  /** Alt text for the preview. Defaults to the name. */\n  previewAlt?: string;\n  /** Full-size image for the viewer, when the preview is a thumbnail.\n      Defaults to `previewSrc`. */\n  src?: string;\n  /** The file itself, for the viewer to show a PDF or a text file in place\n      (through DocumentViewer) and for a picture with no `src`. Distinct\n      from `src`, which is always an image. */\n  fileUrl?: string;\n  /** Intrinsic width of the preview, to reserve its shape before it loads. */\n  width?: number;\n  /** Intrinsic height of the preview. */\n  height?: number;\n  /** First lines of a pasted block, drawn as the tile's excerpt. */\n  excerpt?: string;\n}",
      "description": "One attachment as the family passes it around: what a tile draws, what a\ngroup lays out, and what `useAttachments` keeps. Plain data, so it\nserialises and crosses the server boundary; the `File` itself stays with\nwhoever owns the upload.",
      "refs": [
        "AttachmentStatus",
        "FileKind"
      ]
    },
    "AttachmentStatus": {
      "kind": "type",
      "definition": "type AttachmentStatus = 'ready' | 'uploading' | 'error' | 'unavailable';",
      "description": "Where an attachment is in its life: usable, on its way, failed, or gone."
    },
    "FileKind": {
      "kind": "type",
      "definition": "type FileKind =\n  | 'pdf'\n  | 'document'\n  | 'spreadsheet'\n  | 'presentation'\n  | 'image'\n  | 'audio'\n  | 'video'\n  | 'archive'\n  | 'code'\n  | 'text'\n  | 'pasted'\n  | 'generic';"
    }
  },
  "externalTypes": {
    "ReactNode": "react"
  },
  "keyboard": [
    {
      "pattern": "dialog",
      "label": "Dialog",
      "apg": "https://www.w3.org/WAI/ARIA/apg/patterns/dialog-modal/",
      "rows": [
        {
          "keys": [],
          "when": "On open",
          "text": "Opening moves focus inside."
        },
        {
          "keys": [
            "Tab"
          ],
          "text": "Moves to the next control inside, and from the last back to the first. Focus never reaches the page behind."
        },
        {
          "keys": [
            "Shift",
            "Tab"
          ],
          "text": "Moves to the previous control inside, and from the first to the last."
        },
        {
          "keys": [
            "Escape"
          ],
          "text": "Closes it and returns focus to what opened it."
        }
      ]
    }
  ],
  "size": {
    "gzip": 11462
  }
}
