/** * @fileoverview File helpers shared by the upload components: size formatting, * extension parsing and file-type icon resolution. */ import type { IconName } from '../components/nv-icon/nv-icons'; /** Icon shown when the file type has no dedicated glyph. */ export declare const DEFAULT_FILE_ICON: `${IconName}`; /** Icon shown for a file rejected by validation. */ export declare const INVALID_FILE_ICON: `${IconName}`; /** * Returns the lowercase extension of a file name, without the dot. * * @param {string} [fileName] - The file name, e.g. "report.PDF". * @returns {string} The extension ("pdf"), or an empty string when there is none. */ export declare function getFileExtension(fileName?: string): string; /** * Normalizes a file type to an extension. Accepts an extension ("pdf", * ".pdf") or a MIME type ("application/pdf"). * * @param {string} [fileType] - The extension or MIME type. * @returns {string} The lowercase extension, or an empty string. */ export declare function normalizeFileType(fileType?: string): string; /** * Resolves the icon for a file. The explicit type wins over the file name; * when the type has no dedicated icon, the extension of the name is used. * * @param {string} [fileName] - The file name, used when the type gives no icon. * @param {string} [fileType] - An extension or MIME type. * @returns {IconName} The matching `file-type-*` icon, or the generic file icon. */ export declare function getFileTypeIcon(fileName?: string, fileType?: string): `${IconName}`; /** * Formats a size in bytes for display, using binary multiples (1 MB = * 1 048 576 bytes) and the units of the given locale ("1.2 MB", "1,2 Mo"). * * @param {number} bytes - The size in bytes. * @param {string} [locale] - Locale override. Defaults to the browser locale. * @returns {string} The formatted size, or an empty string for an invalid value. */ export declare function formatFileSize(bytes: number, locale?: string): string; /** * Reads the files carried by a drag-and-drop or clipboard transfer. Dropped * folders are skipped: only real files are returned. * * @param {DataTransfer | null} [transfer] - The `dataTransfer` or `clipboardData` of the event. * @returns {File[]} The files, in the order they were provided. */ export declare function getTransferFiles(transfer?: DataTransfer | null): File[]; /** Number of bytes in one megabyte, as used by `maxFileSize` (binary). */ export declare const BYTES_PER_MEGABYTE: number; /** * Splits an `accept` value into its lowercase tokens. * * @param {string} [accept] - Comma-separated MIME types and extensions. * @returns {string[]} The tokens, without empty entries. */ export declare function parseAccept(accept?: string): string[]; /** * What `matchesAccept` needs to know about a file. A browser `File` fits. */ export interface AcceptCandidate { /** Name of the file, extension included. */ name: string; /** MIME type reported by the browser, when it knows it. */ type?: string; } /** * Tells whether a file matches an `accept` value, with the same rules as the * native file input: extensions (".pdf"), exact MIME types * ("application/pdf") and wildcards ("image/*"). When the browser reports no * MIME type, the extension of the file name is used instead. * * @param {AcceptCandidate} file - The file to check. * @param {string} [accept] - Comma-separated MIME types and extensions. * @returns {boolean} True when the file is accepted, or when `accept` is empty. */ export declare function matchesAccept(file: AcceptCandidate, accept?: string): boolean; /** * Lists the file types of an `accept` value in a form fit for display: * uppercase extensions ("PDF", "JPG") and, for wildcards, the category * followed by "/*" ("image/*"). Duplicates such as ".jpg" and "image/jpeg" * are merged. * * @param {string} [accept] - Comma-separated MIME types and extensions. * @returns {string[]} The display labels, in the order they were declared. */ export declare function getAcceptLabels(accept?: string): string[];