import { JudoRestResponse } from '@judo/actions'; import { CustomDialogProps } from '@judo/feedback'; /** * Return type of the {@link useFileHandling} hook. */ export interface FileHandling { /** * Download a binary attribute's file. * * Reads the download token from `data[attributeName]` and triggers * either a browser download (`attachment`) or an inline preview dialog (`inline`). */ downloadFile: (data: Record, attributeName: string, disposition: "inline" | "attachment") => Promise; /** * Upload a file to a binary attribute via the two-step upload flow. * Returns the server response data (upload metadata). */ uploadFile: (attributePath: string, file: File) => Promise; /** * Extract the original filename from a JUDO binary download token (JWT). * Returns `fallbackText` when the token is missing or cannot be decoded. */ extractFileNameFromToken: (token?: string | null, fallbackText?: string) => string; /** * Trigger a browser file download from a REST API response that contains a Blob. * Reads filename from the `Content-Disposition` header, falling back to `"download"`. */ exportFile: (response: JudoRestResponse) => void; } /** @internal Props for the inline preview dialog rendered by `downloadFile`. */ export interface InlinePreviewDialogProps extends CustomDialogProps { url: string; fileName: string; } /** * Dialog component that previews a binary file in an iframe. * Opened by `useFileHandling().downloadFile(…, "inline")`. * * @internal */ export declare function InlinePreviewDialog({ onClose, url, fileName }: InlinePreviewDialogProps): import("react/jsx-runtime").JSX.Element; /** * Hook providing file handling operations: download, upload, * filename extraction from JWT tokens, and export-to-file. * * Adapted from the legacy `fileHandling` hook. Uses the JUDO REST * API client for upload/download and the feedback dialog service * for inline binary previews. * * @example * ```tsx * const { downloadFile, uploadFile, extractFileNameFromToken, exportFile } = useFileHandling(); * * // Download as attachment * await downloadFile(transfer, "document", "attachment"); * * // Preview inline * await downloadFile(transfer, "preview", "inline"); * * // Upload a file * const result = await uploadFile("/admin/Issue/avatar", selectedFile); * * // Get display name from stored token * const name = extractFileNameFromToken(transfer.document, "Unnamed file"); * ``` */ export declare function useFileHandling(): FileHandling; //# sourceMappingURL=use-file-handling.d.ts.map