import { HttpClient } from '@angular/common/http'; import { Subject, Observable } from 'rxjs'; import * as i0 from '@angular/core'; import { EventEmitter, OnDestroy, ElementRef, ChangeDetectorRef, AfterContentInit, OnChanges, DoCheck, OnInit, AfterViewInit, QueryList, TemplateRef } from '@angular/core'; import { FocusMonitor } from '@angular/cdk/a11y'; import { BooleanInput, NumberInput } from '@angular/cdk/coercion'; import { ValidatorFn, ControlValueAccessor, NgControl, NgForm, FormGroupDirective } from '@angular/forms'; import * as i14 from '@aposin/ng-aquila/base'; import { NxLabelComponent, NxErrorComponent } from '@aposin/ng-aquila/base'; import { ErrorStateMatcher } from '@aposin/ng-aquila/utils'; import * as i1 from '@angular/common'; import * as i2 from '@aposin/ng-aquila/icon'; import * as i3 from '@aposin/ng-aquila/button'; import * as i4 from '@aposin/ng-aquila/spinner'; /** * Class used to keep track of the current states of the file. */ declare class FileItem { /** The actual file data. */ file: File | null; /** Sets the name of the file. */ name: string; private readonly _size; private readonly _type; /** Whether the file is being uploaded at the moment. */ isUploading: boolean; /** Whether the file was successfully uploaded. */ isUploaded: boolean; /** Whether an error occured when uploading the file. */ isError: boolean; /** Sets the index of the file. */ index: number; /** * Emits the FileItem on changed. */ readonly onChange: EventEmitter; constructor(file: File, index?: number); /** Returns the file size in bytes */ get size(): number; /** Returns the file type */ get type(): string; /** * Sets the file to a uploaded state. */ setUploadedState(): void; /** * Sets the file to a 'upload-in-progress' state. */ setUploadingState(): void; /** * Sets the file to an error state. */ setErrorState(): void; } interface NxFileUploadConfig { /** Sets the url for uploading requests. */ requestUrl: string; /** Sets the options for http upload requests. HttpParams */ options?: object; /** Whether the files should be uploaded separately. Default: false. */ uploadSeparately?: boolean; } declare class NxFileUploadSuccess { /** The files that were successfully uploaded. */ readonly files: FileItem[]; /** The results of the request(s). */ readonly requests: object[]; constructor( /** The files that were successfully uploaded. */ files: FileItem[], /** The results of the request(s). */ requests: object[]); } declare class NxFileUploadError { /** The files that had an error while uploading. */ readonly files: FileItem[]; /** The returned errors of the request(s). */ readonly requests: object[]; constructor( /** The files that had an error while uploading. */ files: FileItem[], /** The returned errors of the request(s). */ requests: object[]); } interface NxFileUploadResult { /** Whether all files were successfully uploaded. */ allSucessful?: boolean; /** All successfully uploaded results. */ success?: NxFileUploadSuccess; /** All results with errors. */ error?: NxFileUploadError; } declare class NxFileUploader { private _config; private readonly _httpClient; /** Stream that emits the result of an upload request. */ readonly response: Subject; /** Sets the config options for http requests for uploading the files. */ set config(options: NxFileUploadConfig); get config(): NxFileUploadConfig; constructor(config: NxFileUploadConfig, http: HttpClient); /** Uploads the files to the url specified in config. */ uploadFiles(files: FileItem[]): void; /** Uploads all files with a POST request to the url specified in config. */ private _uploadFilesCollectively; /** * Uploads all files with a POST request to the url specified in config. * * Each file is uploaded with an individual request. */ private _uploadFilesSeparately; /** Uploads one file with a POST request to the url specified in config. */ private _uploadFile; } /** * Verifies the file type against the accepted types. */ declare function isFileTypeValid(file: File, accept: string, strict: boolean): boolean; /** * Verifies the file size against the max file size allow. */ declare function isMaxFileSizeValid(file: File, maxFileSize: number): boolean; /** Returns the file extension including the dot or empty string if filename has no extension */ declare function getFileExtension(filename: string): string; declare function isMaxFileNumberValid(numFile: number, max: number | undefined): boolean; /** * Provides a set of file uploader validators that can be used by form controls. * * Currently `maxFileSize` and `fileType` are available. * @dynamic */ declare class NxFileUploaderValidators { /** The form control validator for the max file size. */ static maxFileSize(max: number | undefined, file: File): ValidatorFn; /** The form control validator for the accepted file type. */ static fileType(file: File, accept: string | undefined, strict: boolean): ValidatorFn; /** The form control validator for the max file number that is accepted. */ static maxFileNumber(filesNum: number, max: number | undefined): ValidatorFn; } interface BaseFileUploadError { filename: string; } type FileUploadError = NxFileTypeError | NxFileSizeError | NxFileNumberError | NxFileUploadTypeError; interface NxFileTypeError extends BaseFileUploadError { type: 'fileType'; extension: string; actual: string; } interface NxFileSizeError extends BaseFileUploadError { type: 'fileNumber'; max: number; actual: number; } interface NxFileNumberError extends BaseFileUploadError { type: 'fileSize'; max: number; actual: number; } interface NxFileUploadTypeError extends BaseFileUploadError { type: 'upload'; reason: string; } declare class NxFileUploaderButtonDirective implements OnDestroy { private readonly _cdr; readonly elemetRef: ElementRef; /** Whether the file uploader is disabled */ set disabled(value: boolean); get disabled(): boolean; private _disabled; readonly _clicked: Subject; _ariaDescribedby?: string; constructor(_cdr: ChangeDetectorRef, elemetRef: ElementRef); /** @docs-private */ setDescribedByIds(ids: string[]): void; /** @docs-private */ onClick(): void; ngOnDestroy(): void; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵdir: i0.ɵɵDirectiveDeclaration; } declare class NxFileUploaderDropZoneComponent { private readonly _cdr; /** Whether the file uploader is disabled. */ set disabled(value: boolean); get disabled(): boolean; private _disabled; private _active; /** An event emitted when files were dropped. */ readonly fileDropped: EventEmitter; constructor(_cdr: ChangeDetectorRef); /** @docs-private */ onDrop(event: DragEvent): void; /** @docs-private */ onDragOver(event: DragEvent): void; /** @docs-private */ onDragLeave(event: DragEvent): void; /** @docs-private */ onDragEnd(event: DragEvent): void; /** @docs-private */ onDragStart(event: DragEvent): void; /** @docs-private */ get active(): boolean; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵcmp: i0.ɵɵComponentDeclaration; } declare class NxFileUploaderHintDirective { /** Sets the id of the file upload hint. */ id: string; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵdir: i0.ɵɵDirectiveDeclaration; } /** File uploader data that requires internationalization. */ declare class NxFileUploaderIntl { /** * Stream that emits whenever the labels here are changed. Use this to notify * components if the labels have changed after initialization. */ readonly changes: Subject; /** A label for the uploading state used in the queue. */ uploadingLabel: string; /** Aria-label for the delete icon. */ deleteLabel: string; /** Aria-label for the 'successfully-uploaded' icon. */ uploadedStateLabel: string; /** Aria-label for the uploaded files list. */ uploadedListLabel: string; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; } declare class NxFileUploaderComponent implements ControlValueAccessor, AfterContentInit, OnChanges, OnDestroy, DoCheck, OnInit, AfterViewInit { private readonly _cdr; private readonly _errorStateMatcher; readonly _intl: NxFileUploaderIntl; private readonly _parentForm; private readonly _parentFormGroup; /** @docs-private */ readonly ngControl: NgControl | null; private readonly _focusMonitor; /** @docs-private */ button?: NxFileUploaderButtonDirective; /** @docs-private */ _dropZone: NxFileUploaderDropZoneComponent; /** @docs-private */ nativeInputFile: ElementRef; /** @docs-private */ _label?: NxLabelComponent; /** @docs-private */ _hintChildren: QueryList; /** @docs-private */ _errorList: QueryList; _fileRowElements: QueryList; /** Preserves the current value of the _fileRowElements ViewChildren in case _fileRowElements changes. */ private _fileRowElementsPrevious; private _filesSubscriptions; /** * An event emitted when queue is changed. * * Emits the changed array of FileItems. * @docs-private */ readonly valueChange: EventEmitter; /** * An event emitted when a file is deleted from the queue. * * Emits the deleted FileItem. */ readonly fileDeleted: EventEmitter; /** * An event emitted when one or more files were added to the file input. * * Emits the selected `FileItem | FileItem[]`. */ readonly filesSelected: EventEmitter; private _controlValidators; _templateContext: this; /** @docs-private */ errorState: boolean; /** List of errors */ errors: FileUploadError[]; /** Whether the file uploader use common validators (file type, file size). */ set noBlockingValidators(value: BooleanInput); get noBlockingValidators(): boolean; private _noBlockingValidators; /** @docs-private */ readonly stateChanges: Subject; /** @docs-private */ validatorFnArray: any[]; /** aria-describedby ids that will be applied to the inner controls */ ariaDescribedBy: i0.InputSignal; /** Sets the id of the file uploader. */ set id(value: string); get id(): string; private _id; _inputId: string; _labelId: string; /** Whether the file uploader is required. */ set required(value: BooleanInput); get required(): boolean; private _required; /** The value of the file upload. */ set value(value: FileItem[] | undefined); get value(): FileItem[] | undefined; private _value; /** Name that is used for accessibility. */ set name(value: string); get name(): string; private _name; /** Whether the file uploader is disabled. */ set disabled(value: BooleanInput); get disabled(): boolean; private _disabled; /** Whether the file uploader accepts multiple files to be added. */ set multiple(value: BooleanInput); get multiple(): boolean; private _multiple; /** The accepted file types */ set accept(value: string); get accept(): string; private _accept; /** Whether to validate files that don't have provide a file type. Disabled by default. */ strictAcceptValidation: boolean; /** The max file size in bytes used for validation */ set maxFileSize(value: NumberInput); get maxFileSize(): number; private _maxFileSize; /** Sets the file uploader for the component. */ set uploader(newUploader: NxFileUploader); get uploader(): NxFileUploader; private _uploader; /** The max number of files that is accepted. */ set maxFileNumber(value: NumberInput); get maxFileNumber(): number; private _maxFileNumber; /** Sets the template for the file items. */ set itemTemplate(template: TemplateRef); get itemTemplate(): TemplateRef; _itemTemplate: TemplateRef; private readonly _destroyed; /** Event emitted when the file picker dialog has been toggled. */ readonly openedChange: EventEmitter; /** Event emitted when the file picker dialog has been opened. */ readonly _openedStream: Observable; /** Event emitted when the file picker dialog has been closed. */ readonly _closedStream: Observable; constructor(_cdr: ChangeDetectorRef, _errorStateMatcher: ErrorStateMatcher, _intl: NxFileUploaderIntl, _parentForm: NgForm | null, _parentFormGroup: FormGroupDirective | null, /** @docs-private */ ngControl: NgControl | null, _focusMonitor: FocusMonitor); ngOnInit(): void; ngAfterViewInit(): void; ngOnChanges(): void; ngOnDestroy(): void; /** @docs-private */ updateErrorState(): void; /** @docs-private */ onChangeCallback: (_: any) => void; /** @docs-private */ onTouchedCallback: () => void; registerOnChange(callback: any): void; registerOnTouched(callback: any): void; writeValue(value: FileItem[]): void; _resetValidators(clear?: boolean): void; ngAfterContentInit(): void; _addFilesToQueue(files: File[]): void; _setFileListFromValue(files: File[]): void; /** Removes a file from the value list of the file upload input. */ removeFile(file: any): void; /** Uploads the files via the defined uploader. */ uploadFiles(): void; ngDoCheck(): void; /** * The label for the uploading state used in the queue. * @docs-private */ get uploadingLabel(): string; /** * The label for the uploading state used in the queue. * @docs-private */ get deleteLabel(): string; /** * The label for the uploading state used in the queue. * @docs-private */ get uploadedLabel(): string; /** * The label for the uploaded files in the queue. * @docs-private */ get uploadedListLabel(): string; /** * Sets the list of element IDs that describe the child control. This allows the trigger element (button) to update * its `aria-describedby` attribute accordingly. */ private _syncDescribedByIds; _handleKeydownListRow(event: KeyboardEvent): void; /** * Triggered when the `input[type=file]` is changed. */ _onFileChange(event: any): void; /** Listens to changes in each file. */ _subscribeToFileChanges(): void; private setMaxFileNumberError; private setFileSizeError; private setFileTypeError; private setFileUploadError; /** weather all files is uplaoded */ get allFilesUploaded(): boolean; setDisabledState?(isDisabled: boolean): void; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵcmp: i0.ɵɵComponentDeclaration; } declare class NxFileUploaderTriggerDirective { /** References the file upload component instance that the trigger is associated with. */ set fileUpload(value: NxFileUploaderComponent); get fileUpload(): NxFileUploaderComponent; _fileUpload: NxFileUploaderComponent; _onClick(): void; get visibility(): "hidden" | "unset"; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵdir: i0.ɵɵDirectiveDeclaration; } /** Shows the file name. */ declare class NxFileUploaderItemName implements OnInit { /** The filename.*/ name: string; iconColor: { [key: string]: string; }; extension: string; ngOnInit(): void; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵcmp: i0.ɵɵComponentDeclaration; } /** Shows a file size in Megabyte (MB) or an alternative label while the file is uploading. */ declare class NxFileUploaderItemSize { /** The size of the file in bytes.*/ size: number; /** Whether the file is uploading at the moment. Default: false.*/ isUploading: boolean; /** The label that is shown while uploading the file.*/ uploadingLabel: string; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵcmp: i0.ɵɵComponentDeclaration; } /** Shows the current uploading status of a file. */ declare class NxFileUploaderItemStatus { /** Whether the file is uploading at the moment. If this is true, a spinner is shown. Default: false.*/ isUploading: boolean; /** Whether the file was uploaded. If this is true, a `check-circle` icon is shown. Default: false.*/ isUploaded: boolean; /** The label that is used once the file has been uploaded (used by screen readers).*/ uploadedLabel: string; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵcmp: i0.ɵɵComponentDeclaration; } /** Shows a delete button. */ declare class NxFileUploaderItemDelete { /** Whether the file is uploading at the moment. If true, the button is disabled. Default: false.*/ isUploading: boolean; /** The label that is used for the delete button (used by screen readers). */ deleteLabel: string; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵcmp: i0.ɵɵComponentDeclaration; } declare class NxFileUploaderModule { static ɵfac: i0.ɵɵFactoryDeclaration; static ɵmod: i0.ɵɵNgModuleDeclaration; static ɵinj: i0.ɵɵInjectorDeclaration; } export { FileItem, NxFileUploadError, NxFileUploadSuccess, NxFileUploader, NxFileUploaderButtonDirective, NxFileUploaderComponent, NxFileUploaderDropZoneComponent, NxFileUploaderHintDirective, NxFileUploaderIntl, NxFileUploaderItemDelete, NxFileUploaderItemName, NxFileUploaderItemSize, NxFileUploaderItemStatus, NxFileUploaderModule, NxFileUploaderTriggerDirective, NxFileUploaderValidators, getFileExtension, isFileTypeValid, isMaxFileNumberValid, isMaxFileSizeValid }; export type { BaseFileUploadError, FileUploadError, NxFileNumberError, NxFileSizeError, NxFileTypeError, NxFileUploadConfig, NxFileUploadResult, NxFileUploadTypeError };