import * as _siemens_element_translate_ng_translate from '@siemens/element-translate-ng/translate'; import { TranslatableString } from '@siemens/element-translate-ng/translate'; import * as _angular_core from '@angular/core'; import { HttpHeaders, HttpRequest, HttpEvent, HttpResponse } from '@angular/common/http'; import { Observable, Subscription } from 'rxjs'; /** * Copyright (c) Siemens 2016 - 2026 * SPDX-License-Identifier: MIT */ /** */ interface UploadFile { status: 'added' | 'invalid' | 'queued' | 'uploading' | 'success' | 'error'; file: File; fileName: string; size: string; errorText?: TranslatableString; errorParams?: Record; progress: number; } interface FileUploadError extends UploadFile { status: 'invalid'; errorText: TranslatableString; } /** * Directive for handling file uploads with validation for file type and size. * * @example * ```html * * ``` */ declare class SiFileUploadDirective { /** * Text or translation key of message title if incorrect file type is dragged / dropped. * * @defaultValue * ``` * t(() => $localize`:@@SI_FILE_UPLOADER.ERROR_FILE_TYPE:Invalid file type`) * ``` */ readonly errorTextFileType: _angular_core.InputSignal; /** * Message or translation key if file exceeds the maximum file size limit. * * @defaultValue * ``` * t(() => $localize`:@@SI_FILE_UPLOADER.ERROR_FILE_SIZE_EXCEEDED:Max. {{maxFileSize}}`) * ``` */ readonly errorTextFileMaxSize: _angular_core.InputSignal; /** * Define which file types are suggested in file browser. * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#attr-accept */ readonly accept: _angular_core.InputSignal; /** * Define maximal allowed file size in bytes. */ readonly maxFileSize: _angular_core.InputSignal; /** * Defines whether the file input allows selecting multiple files. * When {@link directoryUpload} is enabled, this will have no effect. * * @defaultValue false */ readonly multiple: _angular_core.InputSignalWithTransform; /** * Enable directory upload. * * @defaultValue false */ readonly directoryUpload: _angular_core.InputSignalWithTransform; /** * Event emitted when valid files are added. * Invalid files (due to size or type) will be ignored and instead the {@link fileError} event will be emitted. */ readonly validFiles: _angular_core.OutputEmitterRef; /** * Event emitted when valid files are added. * Also includes invalid files, but with status 'invalid' and an errorText describing why they were ignored. */ readonly filesAdded: _angular_core.OutputEmitterRef; /** * Event emitted when file validation errors occur, including files that were ignored due to size or type. */ readonly fileError: _angular_core.OutputEmitterRef; private readonly elementRef; private locale; private numberFormat; protected onInputChange(event: Event): void; /** * Handle files from input or drag and drop */ handleFiles(files: FileList | null): void; /** * Handle directory entries for drag and drop */ handleItems(items: DataTransferItemList): void; /** * Reset the file input value */ reset(): void; /** * Trigger the file input click */ triggerClick(): void; private makeUploadFile; private verifyFileSize; private verifyFileType; fileSizeToString(num: number): string; static formatFileSize(num: number, formatter?: Intl.NumberFormat): string; static ɵfac: _angular_core.ɵɵFactoryDeclaration; static ɵdir: _angular_core.ɵɵDirectiveDeclaration; } declare class SiFileDropzoneComponent { /** * Text or translation key of the drag&drop field. * * @defaultValue * ``` * t(() => $localize`:@@SI_FILE_UPLOADER.DROP:Drop files here or click to upload`) * ``` */ readonly uploadDropText: _angular_core.InputSignal<_siemens_element_translate_ng_translate.TranslatableString>; /** * Text or translation key for max file size. * * @defaultValue * ``` * t(() => $localize`:@@SI_FILE_UPLOADER.MAX_SIZE:Upload max. {{maxFileSize}}`) * ``` */ readonly maxFileSizeText: _angular_core.InputSignal<_siemens_element_translate_ng_translate.TranslatableString>; /** * Text or translation key for accepted types. * * @defaultValue * ``` * t(() => $localize`:@@SI_FILE_UPLOADER.ACCEPTED_FILE_TYPES:Accepted file types: {{accept}}.`) * ``` */ readonly acceptText: _angular_core.InputSignal<_siemens_element_translate_ng_translate.TranslatableString>; /** * Text or translation key of message title if incorrect file type is dragged / dropped. * * @defaultValue * ``` * t(() => $localize`:@@SI_FILE_UPLOADER.ERROR_FILE_TYPE:Invalid file type`) * ``` */ readonly errorTextFileType: _angular_core.InputSignal<_siemens_element_translate_ng_translate.TranslatableString>; /** * Message or translation key if file exceeds the maximum file size limit. * * @defaultValue * ``` * t(() => $localize`:@@SI_FILE_UPLOADER.ERROR_FILE_SIZE_EXCEEDED:Max. {{maxFileSize}}`) * ``` */ readonly errorTextFileMaxSize: _angular_core.InputSignal<_siemens_element_translate_ng_translate.TranslatableString>; /** * Define which file types are suggested in file browser. * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#attr-accept */ readonly accept: _angular_core.InputSignal; /** * Define maximal allowed file size in bytes. */ readonly maxFileSize: _angular_core.InputSignal; /** * Defines whether the file input allows selecting multiple files. * When {@link directoryUpload} is enabled, this will have no effect. * * @defaultValue false */ readonly multiple: _angular_core.InputSignalWithTransform; /** * Event emitted when valid files are added. * Invalid files are also included here, but with status 'invalid' and an errorText describing why they were ignored. */ readonly filesAdded: _angular_core.OutputEmitterRef; /** * Event emitted when file validation errors occur, including files that were ignored due to size or type. */ readonly fileError: _angular_core.OutputEmitterRef; /** * Enable directory upload. * * @defaultValue false */ readonly directoryUpload: _angular_core.InputSignalWithTransform; protected readonly maxFileSizeString: _angular_core.Signal; protected readonly icons: Record<"elementUpload", string>; protected dragOver: boolean; private readonly fileUploadDirective; protected dropHandler(event: DragEvent): void; protected dragOverHandler(event: DragEvent): void; protected triggerFileSelect(): void; protected onFilesAdded(files: UploadFile[]): void; protected onFileError(error: FileUploadError): void; /** * Reset all the files inside the native file input (and therefore the dropzone). */ reset(): void; static ɵfac: _angular_core.ɵɵFactoryDeclaration; static ɵcmp: _angular_core.ɵɵComponentDeclaration; } /** * The FileUploadResult is emitted at completion of the file uploading * via the `uploadCompleted` emitter. On success the Http `response` from * the backend is provided and on failure, the `error` object is available. */ interface FileUploadResult { file: string; response?: HttpResponse; error?: Error; } interface FileUploadConfig { headers: HttpHeaders | string | Record | Headers; method: 'POST' | 'PUT' | 'PATCH'; url: string; /** Form field name for the uploaded file. */ fieldName: string; /** * Additional form fields added in the HTTP request. * * @example * ```json * { upload_user: 'Reiner Zufall', expiry_date: ' 21.12.2012' } * ``` */ additionalFields?: Record; /** Specify the server response type */ responseType?: 'arraybuffer' | 'blob' | 'json' | 'text'; /** A function to modify the HTTP request sent on the consumer side. */ handler?: (req: HttpRequest) => Observable>; /** * When `true`, the file will be sent directly w/o the use of `FormData`. * You will also need to set the `Content-Type` header when sending binary. See: {@link headers} */ sendBinary?: boolean; } interface ExtUploadFile extends UploadFile { httpErrorText?: string; subscription?: Subscription; successResponse?: HttpResponse; fadeOut?: boolean; } declare class SiFileUploaderComponent { /** * Text instructing a user to drop the files inside the dropzone. * * @defaultValue * ``` * t(() => $localize`:@@SI_FILE_UPLOADER.DROP:Drop files here or click to upload`) * ``` */ readonly uploadDropText: _angular_core.InputSignal<_siemens_element_translate_ng_translate.TranslatableString>; /** * Text to describe the maximum file size. * * @defaultValue * ``` * t(() => $localize`:@@SI_FILE_UPLOADER.MAX_SIZE:Upload max. {{maxFileSize}}`) * ``` */ readonly maxFileSizeText: _angular_core.InputSignal<_siemens_element_translate_ng_translate.TranslatableString>; /** * Error message shown when the maximum number of files are reached. * * @defaultValue * ``` * t(() => $localize`:@@SI_FILE_UPLOADER.MAX_FILE_REACHED:Max. {{maxFiles}} files`) * ``` */ readonly maxFilesReachedText: _angular_core.InputSignal<_siemens_element_translate_ng_translate.TranslatableString>; /** * Text for the accepted file types. * * @defaultValue * ``` * t(() => $localize`:@@SI_FILE_UPLOADER.ACCEPTED_FILE_TYPES:Accepted file types: {{accept}}.`) * ``` */ readonly acceptText: _angular_core.InputSignal<_siemens_element_translate_ng_translate.TranslatableString>; /** * Text used inside the upload button. * * @defaultValue * ``` * t(() => $localize`:@@SI_FILE_UPLOADER.UPLOAD:Upload`) * ``` */ readonly uploadButtonText: _angular_core.InputSignal<_siemens_element_translate_ng_translate.TranslatableString>; /** * Text used inside the clear button. * * @defaultValue * ``` * t(() => $localize`:@@SI_FILE_UPLOADER.CLEAR:Clear`) * ``` */ readonly clearButtonText: _angular_core.InputSignal<_siemens_element_translate_ng_translate.TranslatableString>; /** * Text shown during the file upload. * * @defaultValue * ``` * t(() => $localize`:@@SI_FILE_UPLOADER.UPLOADING:Uploading`) * ``` */ readonly uploadingText: _angular_core.InputSignal<_siemens_element_translate_ng_translate.TranslatableString>; /** * Text shown to remove a file from the file list. Required for a11y. * * @defaultValue * ``` * t(() => $localize`:@@SI_FILE_UPLOADER.REMOVE:Remove`) * ``` */ readonly removeButtonText: _angular_core.InputSignal<_siemens_element_translate_ng_translate.TranslatableString>; /** * Text of cancel button. Shown during upload. Required for a11y. * * @defaultValue * ``` * t(() => $localize`:@@SI_FILE_UPLOADER.CANCEL:Cancel`) * ``` */ readonly cancelButtonText: _angular_core.InputSignal<_siemens_element_translate_ng_translate.TranslatableString>; /** * Text shown if the upload was successful. * * @defaultValue * ``` * t(() => $localize`:@@SI_FILE_UPLOADER.UPLOAD_COMPLETED:Upload completed`) * ``` */ readonly successTextTitle: _angular_core.InputSignal<_siemens_element_translate_ng_translate.TranslatableString>; /** * Text shown if the upload failed. * * @defaultValue * ``` * t(() => $localize`:@@SI_FILE_UPLOADER.UPLOAD_FAILED:Upload failed`) * ``` */ readonly errorUploadFailed: _angular_core.InputSignal<_siemens_element_translate_ng_translate.TranslatableString>; /** * On failed upload, show the error received from the server. * * @defaultValue false */ readonly showHttpError: _angular_core.InputSignalWithTransform; /** * Text shown to indicate that an incorrect file type was added to file list. * * @defaultValue * ``` * t(() => $localize`:@@SI_FILE_UPLOADER.ERROR_FILE_TYPE:Invalid file type`) * ``` */ readonly errorTextFileType: _angular_core.InputSignal<_siemens_element_translate_ng_translate.TranslatableString>; /** * Message or translation key if file exceeds the maximum file size limit. * * @defaultValue * ``` * t(() => $localize`:@@SI_FILE_UPLOADER.ERROR_FILE_SIZE_EXCEEDED:Max. {{maxFileSize}}`) * ``` */ readonly errorTextFileMaxSize: _angular_core.InputSignal<_siemens_element_translate_ng_translate.TranslatableString>; /** * Config for HTTP request to upload file. * * @defaultValue * ``` * { * headers: new HttpHeaders({ 'Accept': 'application/json' }), * method: 'POST', * url: '', * fieldName: 'upload_file', * responseType: 'json' * } * ``` */ readonly uploadConfig: _angular_core.InputSignal; /** * Define which file types are suggested in file browser. * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#attr-accept */ readonly accept: _angular_core.InputSignal; /** * Define maximal allowed file size in bytes. * * @defaultValue undefined */ readonly maxFileSize: _angular_core.InputSignalWithTransform; /** * Define maximal allowed number of files. * When {@link directoryUpload} is enabled, this will have no effect. * @defaultValue 10 */ readonly maxFiles: _angular_core.InputSignalWithTransform; /** * Maximum number of concurrent uploads. * * @defaultValue 3 */ readonly maxConcurrentUploads: _angular_core.InputSignalWithTransform; /** * Numbers of retries for failed uploads. * * @defaultValue 0 */ readonly retries: _angular_core.InputSignalWithTransform; /** * Auto-upload mode - automatically start upload once files are added. * * @defaultValue false */ readonly autoUpload: _angular_core.InputSignalWithTransform; /** * Disable the upload button. * * @defaultValue false */ readonly disableUpload: _angular_core.InputSignalWithTransform; /** * Enable directory upload mode. * When enabled, the file input will accept directories and upload all files within as a flat list. * The hierarchy of the directory will not be preserved. * The `maxFiles` property will have no effect when `directoryUpload` is enabled. * * **Note:** This feature is not yet available for safari (iOS) * * @defaultValue false */ readonly directoryUpload: _angular_core.InputSignalWithTransform; /** * Emits when a user press cancel during upload. The event provides the file details. */ readonly uploadCanceled: _angular_core.OutputEmitterRef; /** * Output callback event will provide you if upload is finished. If an error * occurred it will be emitted. */ readonly uploadCompleted: _angular_core.OutputEmitterRef; /** * Output which fires whenever new files are added to or removed from the uploader. */ readonly filesChanges: _angular_core.OutputEmitterRef; protected readonly icons: Record<"elementCancel" | "elementDelete" | "elementDocument" | "elementRedo", string>; protected readonly files: _angular_core.WritableSignal; protected pending: number; private uploading; protected readonly uploadEnabled: _angular_core.WritableSignal; protected readonly maxFilesReached: _angular_core.WritableSignal; private readonly dropZone; private http?; constructor(); protected handleFiles(files: UploadFile[]): void; protected removeFile(index: number): void; protected cancelUpload(file: ExtUploadFile): void; protected retryUpload(file: UploadFile): void; /** * Reset the state. */ reset(emit?: boolean): void; /** * Uploads the file */ fileUpload(doRetry?: boolean): void; private doUpload; private processQueue; private uploadOneFile; private isDuplicate; private handleUploadEvent; private handleUploadError; private handleUploadComplete; private oneUploadDone; private fadeOut; private updateStates; private countValid; static ɵfac: _angular_core.ɵɵFactoryDeclaration; static ɵcmp: _angular_core.ɵɵComponentDeclaration; } declare class SiFileUploaderModule { static ɵfac: _angular_core.ɵɵFactoryDeclaration; static ɵmod: _angular_core.ɵɵNgModuleDeclaration; static ɵinj: _angular_core.ɵɵInjectorDeclaration; } export { SiFileDropzoneComponent, SiFileUploadDirective, SiFileUploaderComponent, SiFileUploaderModule }; export type { FileUploadConfig, FileUploadError, FileUploadResult, UploadFile };