import { type ComponentPropsWithRef } from 'react'; /** * Something attached — a document or an image — drawn as a card. * * Peek's two attachment components, class for class (UIG-27, Katerina's ruling * of 14 September that both apps draw one): `FileAttachmentCard`, the card on * something already posted, and `PendingAttachmentChip`, the card in a composer * waiting to go. The card is told the result — a `src`, an `href`, a `state` — * and hands a click back through `onOpen`, `onDownload` and `onRemove`. * * **It now does the rest of the job too** (UIG-35, Katerina 20 September): * given a `remoteSrc` and the app's `fetchImage`, it fetches a file the reader * needs permission for and draws the wait and the refusal; it opens a picture * full screen in the package's `Lightbox`; and with `download` it saves the * file. Peek and Ship had each written those three around it, 174 and 181 lines * that did the same things differently — Ship's pictures never opened at all. * What stays an app's is the one thing only it knows: how to fetch with its own * authorization. * * Two shapes, decided by the file: an **image** with a picture is a 180px * thumbnail you can open; anything else is a 240px **row** — a type tile, the * name, and what it is. Waiting to be sent (`pending`) it is a 200px row with a * remove control on its corner. * * One change from Peek, by ruling: a file that could not be read has a dashed * hairline, as every card that cannot be read does. */ export type AttachmentCardState = 'ready' | 'loading' | 'unreadable' | 'uploading' | 'failed' | 'warning'; export interface AttachmentCardProps extends Omit, 'children'> { /** The name it was attached under, extension included: it decides the icon and the type label. */ name: string; /** In bytes. */ size?: number; /** Its MIME type, where known: an `image/…` type is an image whatever its name. */ contentType?: string; /** Where a document opens, in a new tab. Without it the row is dimmed and opens nothing. */ href?: string; /** The picture an image card draws. Without it an image is drawn as a row. */ src?: string; /** * What the picture shows, where the sender said — Ship carries one on every * `imeta`. It is what a screen reader reads and what the viewer is named * with; `name` is still the file's name, under the thumbnail. Without it the * name does both jobs. */ alt?: string; /** * A file the app has to *fetch* before it can be used — one on a relay, where * reading it needs the reader's own authorization (UIG-35). Give `fetchImage` * with it. For a picture the card waits, draws it, and says so if it cannot * be read, so no app writes that state machine again; for a document the * result is where the row opens, and until it lands the row is dimmed rather * than pretending to open. Ignored when `src` is set. */ remoteSrc?: string; /** * The full-size picture, fetched only when someone opens it. A thread of * screenshots would otherwise pull every original at full size to draw them * at 112px. Until it arrives the viewer shows the thumbnail. */ remoteFullSrc?: string; /** How this app fetches a picture it is allowed to read: a URL in, a URL the * browser can draw out (an object URL, usually). */ fetchImage?: (url: string) => Promise; /** * What a click on an image's picture does. Without it the card **opens the * picture itself**, full screen, in the package's `Lightbox` — which is what * both apps wanted and one of them had written by hand. */ onOpen?: () => void; /** Shows a download control on hover or focus, and calls this. */ onDownload?: () => void; /** * Shows the download control and **saves the file itself**, under `name`: * the original where there is one (`remoteFullSrc`), otherwise what the card * is drawing. Use `onDownload` instead when the app must do it another way. */ download?: boolean; /** Waiting to be sent: the composer's 200px row, with a remove control on its corner. */ pending?: boolean; /** Removes a pending card. */ onRemove?: () => void; /** * `ready` · `loading` (an image on its way) · `unreadable` (it could not be read) · * `uploading`, `failed`, `warning` (while pending). Default `ready`. */ state?: AttachmentCardState; /** The line under the name, in place of its type and size — why it failed, or what the warning is. */ note?: string; /** The note's full words, on hover, where the line is short. */ noteHint?: string; } export declare function AttachmentCard({ name, size, contentType, href, src, alt, remoteSrc, remoteFullSrc, fetchImage, onOpen, onDownload, download, pending, onRemove, state, note, noteHint, className, ...props }: AttachmentCardProps): import("react").JSX.Element; //# sourceMappingURL=AttachmentCard.d.ts.map