import "./file_preview.css"; import { useRender } from "@base-ui/react/use-render"; import type { DisplayFile } from "./file_thumbnail"; import { type StyleProps } from "./style_props"; /** Caption/error strings, from the `gallery` slice with `labels` overriding. */ export interface PreviewLabels { notAvailable: string; loadFailed: string; download: string; passwordProtected: string; } export interface FilePreviewProps extends StyleProps { file: DisplayFile; /** Override any subset of the English default labels. */ labels?: Partial; /** Reported on a render/parse failure — the package stays analytics-free. */ onError?: (error: unknown, meta: { fileId: string; mimeType: string; }) => void; /** View rotation in degrees (0/90/180/270) — applied to image previews only. */ rotation?: number; /** Credentials for the PDF / Word / spreadsheet byte fetches: `"include"` for an * auth-gated cross-origin proxy, omitted for a presigned URL, where it would * trip the bucket's CORS. */ credentials?: RequestCredentials; testID?: string; ref?: React.Ref; render?: useRender.RenderProp; } /** Strings for the full-screen `FileGalleryDialog` chrome, on top of the inner * {@link PreviewLabels}. */ export interface GalleryLabels extends PreviewLabels { close: string; previous: string; next: string; /** Accessibility label for the per-row ⋯ menu in `FileRows`. */ actions: string; openExternal: string; /** The removal's VERB AND NOUN — the ⋯ row, the toolbar act and the confirm's * commit, said one way wherever it is offered. */ remove: string; /** The confirm's QUESTION, naming the file. A function, because word order is * not shared between languages; the rest of the dialog is `locale.confirm`'s. */ removeQuestion: (filename: string) => string; rotateLeft: string; rotateRight: string; saveRotation: string; } /** * Universal inline file preview (web), by MIME type: browser-native elements for * media, `pdfjs-dist` for PDF, `@lotics/docx` for Word, `@lotics/xlsx` for * Excel/CSV. Heavy engines are dynamic-imported. * * PDF renders bytes to a canvas rather than a native `