import { EventEmitter } from '../../stencil-public-runtime'; import { FileUploadSize } from '../../utils/constants'; /** * @slot label - Content of the field label, as an alternative to the `label` prop. * @slot description - Content of the description, as an alternative to the `description` prop. */ export declare class NvFileupload { el: HTMLNvFileuploadElement; internals: ElementInternals; private readonly uid; private readonly labelId; private readonly descriptionId; /** Raw files of the items added through this component, by item id. */ private readonly fileStore; private fileCounter; /****************************************************************************/ /** * Density of the dropzone and of the file tiles. Use `sm` in dense layouts * and narrow containers. */ readonly size: `${FileUploadSize}`; /** * Accepted file types, as a comma-separated list of MIME types, wildcards * and extensions, for example "application/pdf,image/*,.docx". It filters * the file picker, is listed in the helper text and is checked on every * dropped, picked or pasted file. */ readonly accept?: string; /** * Maximum size of one file, in megabytes (1 MB = 1 048 576 bytes). Decimals * are allowed. Larger files are added to the list as rejected. */ readonly maxFileSize?: number; /** * Maximum number of files when `multiple` is set. Files beyond the limit * are not added, and the dropzone is disabled once the limit is reached. */ readonly maxFiles?: number; /** * Lets the user add several files. Without it the upload holds one file, * and a new file replaces the current one. */ readonly multiple: boolean; /** * Prevents the user from adding files and from acting on the listed ones. */ readonly disabled: boolean; /** * Shows the files without the dropzone and without any action, for forms * that can no longer be changed. */ readonly readonly: boolean; /** * Marks the upload as required: its form is invalid until at least one * file is in the `complete` state. Also shows the required marker on the * label. */ readonly required: boolean; /** * Ignores files pasted from the clipboard. Paste is on by default while the * focus is inside the dropzone. */ readonly disablePaste: boolean; /** * Language of the built-in texts and of the file sizes, for example "fr" or * "nl-BE". It covers the dropzone, the tiles, the rejection messages and the * summary. If not provided, the browser language is used. */ readonly locale?: string; /** * Label of the field. Leave it empty when the surrounding form already * labels the upload. */ readonly label?: string; /** * Text shown under the label to guide the user. */ readonly description?: string; /** * Instruction line of the dropzone. `{browse}` is replaced by the browse * link. Defaults to a text in the language set by `locale`. */ readonly instruction?: string; /** * Text of the browse link inserted in the instruction. Defaults to a text * in the user's language. */ readonly browseLabel?: string; /** * Instruction of the dropzone while files are dragged over it. Defaults to * a text in the language set by `locale`. */ readonly dropInstruction?: string; /** * Constraint line of the dropzone. By default it is generated from * `accept`, `maxFileSize` and `maxFiles` in the language set by `locale`. */ readonly helperText?: string; /** * The files of the upload. The component adds an item for every file the * user provides and removes it on cancel or remove. The consumer uploads * the files and writes `state`, `progress` and `message` back into the * items to report how each upload is going. */ files: { /** Identifier of the file, created by the component. Use it to match the events. */ id: string; /** Name of the file, extension included. */ name: string; /** Size of the file in bytes. */ size: number; /** MIME type reported by the browser. */ type: string; /** Where the file stands: queued, uploading, processing, complete, error or invalid. */ state: string; /** Upload progress between 0 and 100, shown while the state is uploading. */ progress?: number; /** Text shown under the file name, such as the reason of an error. */ message?: string; }[]; /** * Number of files left out by the last addition because of `maxFiles`. */ overflowCount: number; /** * Whether the form disables the upload, through a disabled fieldset. Kept * apart from `disabled`: writing that reflected prop would put a `disabled` * attribute on the host, and the upload would stay disabled once the * fieldset is enabled again. */ formDisabled: boolean; /****************************************************************************/ /** * Emitted whenever the list changes: files added, removed, cancelled or * retried. * @bind files */ filesChanged: EventEmitter<{ /** Identifier of the file, created by the component. Use it to match the events. */ id: string; /** Name of the file, extension included. */ name: string; /** Size of the file in bytes. */ size: number; /** MIME type reported by the browser. */ type: string; /** Where the file stands: queued, uploading, processing, complete, error or invalid. */ state: string; /** Upload progress between 0 and 100, shown while the state is uploading. */ progress?: number; /** Text shown under the file name, such as the reason of an error. */ message?: string; }[]>; /** * Emitted with the files that passed validation and are ready to be * uploaded. Start one request per file and report its progress through * `files`. */ filesAdded: EventEmitter<{ /** The accepted files, each with the identifier of its item in `files`. */ files: { /** Identifier of the item in `files`. */ id: string; /** The file to upload. */ file: File; }[]; }>; /** * Emitted when the user cancels an upload in progress. Abort the request * of that file. */ fileCancelled: EventEmitter<{ /** Identifier of the cancelled file. */ id: string; }>; /** * Emitted when the user removes a file from the list. */ fileRemoved: EventEmitter<{ /** Identifier of the removed file. */ id: string; }>; /** * Emitted when the user retries a failed upload. The file goes back to the * `queued` state; start a new request for it. */ fileRetried: EventEmitter<{ /** Identifier of the retried file. */ id: string; /** The file to upload again, when it was added through this component. */ file?: File; }>; /****************************************************************************/ handleFilesChange(): void; handleRequiredChange(): void; /****************************************************************************/ /** * Returns the list as an array, whatever was assigned to the prop. * @returns {NvFileupload['files']} The file items. */ private getFiles; /** * Creates an identifier that is unique on the page. * @returns {string} The identifier. */ private createId; /** * Replaces the list and notifies the consumer. * @param {NvFileupload['files']} files - The new list. */ private commit; /** * Counts the files that hold a place in the list. Rejected files do not. * @returns {number} The number of files that are not `invalid`. */ private countValidFiles; /** * Tells whether the user is kept from acting on the upload. * @returns {boolean} True when `disabled` is set or the form disables it. */ private isDisabled; /** * Tells whether the list is full and no more file can be added. * @returns {boolean} True when `maxFiles` is reached in multiple mode. */ private isLimitReached; /** * Resolves the file limit that applies to the list. * @returns {number} `maxFiles` in multiple mode, or 0 when there is no limit. */ private getMaxFiles; /** * Converts `maxFileSize` to bytes. * @returns {number} The size limit in bytes, or 0 when there is no limit. */ private getMaxBytes; /** * Checks a file against `accept` and `maxFileSize`. * @param {File} file - The file to check. * @returns {string | undefined} The rejection message, or undefined when the file is valid. */ private validate; /** * Keeps the form validity in sync: a required upload is invalid until one * file is complete. */ private updateValidity; /** * Builds the constraint line of the dropzone from the constraints. * @returns {string} The helper text, or an empty string without constraints. */ private getHelperText; /** * Builds the summary line. It is only shown when something went wrong. * @returns {string} The summary, or an empty string when nothing failed. */ private getSummary; private handleFilesSelected; /** * Removes an item from the list. * @param {string} id - Identifier of the item. */ private removeItem; private handleCancel; private handleRemove; private handleRetry; /****************************************************************************/ componentWillLoad(): void; /** * Called by the browser when the form is reset: the list is emptied. */ formResetCallback(): void; /** * Called by the browser when an ancestor fieldset is disabled or enabled. * Reads the current state rather than the argument: Stencil replays a call * made before the element loaded once it is ready, and the element may have * been enabled again in between. */ formDisabledCallback(): void; /****************************************************************************/ render(): any; }