import { AfterContentInit, ChangeDetectorRef, ElementRef, EventEmitter, OnChanges, OnDestroy, OnInit, SimpleChanges } from '@angular/core';
import { FormControl } from '@angular/forms';
import { TsDocumentService } from '@terminus/ngx-tools/browser';
import { TsReactiveFormBaseComponent, TsStyleThemeTypes } from '@terminus/ui/utilities';
import { TsDropProtectionService } from './drop-protection.service';
import { TsFileImageDimensionConstraints } from './image-dimension-constraints';
import { TsFileAcceptedMimeTypes } from './mime-types';
import { TsSelectedFile } from './selected-file';
export interface ImageRatio {
widthRatio: number;
heightRatio: number;
}
export declare type TsFileUploadDragEvent = DragEvent;
/**
* This is the file-upload UI Component
*
* @example
*
*
* https://getterminus.github.io/ui-demos-release/components/file-upload
*/
export declare class TsFileUploadComponent extends TsReactiveFormBaseComponent implements OnInit, OnChanges, OnDestroy, AfterContentInit {
private documentService;
private elementRef;
private changeDetectorRef;
private dropProtectionService;
/**
* Define the default component ID
*/
protected uid: string;
/**
* A flag that represents an in-progress drag movement
*/
dragInProgress: boolean;
/**
* Store the selected file
*/
file: TsSelectedFile | undefined;
/**
* Define the flexbox layout gap
*/
layoutGap: string;
/**
* Store reference to the generated file input
*/
private readonly virtualFileInput;
/**
* Provide access to the file preview element
*/
preview: ElementRef;
/**
* Get the file select button text
*/
get buttonMessage(): string;
/**
* Compose and expose all hints to the template
*
* @returns An array of hints
*/
get hints(): string[];
/**
* Compose supported image dimensions as a string
*
* @returns A string containing all allowed image dimensions
*/
private get supportedImageDimensions();
/**
* Define the accepted mime types
*
* @param value
*/
set accept(value: TsFileAcceptedMimeTypes | TsFileAcceptedMimeTypes[] | undefined);
get acceptedTypes(): TsFileAcceptedMimeTypes[];
private _acceptedTypes;
/**
* Define maximum and minimum pixel dimensions for images
*
* @param value
*/
set dimensionConstraints(value: TsFileImageDimensionConstraints | undefined);
get dimensionConstraints(): TsFileImageDimensionConstraints | undefined;
private _sizeConstraints;
/**
* Create a form control to manage validation messages
*
* @param ctrl
*/
set formControl(ctrl: FormControl);
get formControl(): FormControl;
private _formControl;
/**
* Define if the 'select files' button should be visible. DO NOT USE.
*/
hideButton: boolean;
/**
* Define an ID for the component
*
* @param value
*/
set id(value: string);
get id(): string;
private _id;
/**
* Define if the component is disabled
*/
isDisabled: boolean;
/**
* Define the maximum file size in kilobytes
*
* @param value
*/
set maximumKilobytesPerFile(value: number);
get maximumKilobytesPerFile(): number;
private _maximumKilobytesPerFile;
/**
* Define if multiple files may be uploaded
*/
multiple: boolean;
/**
* Define the upload progress
*
* @param value
*/
set progress(value: number);
get progress(): number;
private _progress;
/**
* Define supported ratio for images
*
* @param values
*/
set ratioConstraints(values: Array | undefined);
get ratioConstraints(): Array | undefined;
private _ratioConstraints;
/**
* Seed an existing file (used for multiple upload hack)
*
* @param file
*/
set seedFile(file: File | undefined);
get seedFile(): File | undefined;
private _seedFile;
/**
* Define the theme. See {@link TsStyleThemeTypes}.
*/
theme: TsStyleThemeTypes;
/**
* Event emitted when the user clears a loaded file
*/
readonly cleared: EventEmitter;
/**
* Event emitted when the user's cursor enters the field while dragging a file
*/
readonly enter: EventEmitter;
/**
* Event emitted when the user's cursor exits the field while dragging a file
*/
readonly exit: EventEmitter;
/**
* Event emitted when the user drops or selects a file
*/
readonly selected: EventEmitter;
/**
* Event emitted when the user drops or selects multiple files
*/
readonly selectedMultiple: EventEmitter;
/**
* HostListeners
*
* @param event
*/
handleDragover(event: TsFileUploadDragEvent): void;
handleDragleave(event: TsFileUploadDragEvent): void;
handleDrop(event: TsFileUploadDragEvent): void;
handleClick(): void;
constructor(documentService: TsDocumentService, elementRef: ElementRef, changeDetectorRef: ChangeDetectorRef, dropProtectionService: TsDropProtectionService);
/**
* Update the inner value when the formControl value is updated
*
* @param value - The value to set
*/
updateInnerValue: (value: string) => void;
/**
* Enable drop protection
*/
ngOnInit(): void;
/**
* Update the virtual file input when the change event is fired
*/
ngAfterContentInit(): void;
/**
* Update the virtual file input's attrs when specific inputs change
*
* @param changes - The changed inputs
*/
ngOnChanges(changes: SimpleChanges): void;
/**
* Remove event listener when the component is destroyed
*/
ngOnDestroy(): void;
/**
* Handle the 'enter' keydown event
*
* @param event - The keyboard event
*/
handleKeydown(event: KeyboardEvent): void;
/**
* Open the file selection window when the user interacts
*/
promptForFiles(): void;
/**
* Remove a loaded file, clear validation and emit event
*
* @param event - The event
*/
removeFile(event?: Event): void;
/**
* Create a virtual file input
*
* @returns The HTMLInputElement for file collection
*/
private createFileInput;
/**
* Get all selected files from an event
*
* @param event - The event
*/
private collectFilesFromEvent;
/**
* Register our custom onChange function
*
* @param fn - The onChange function
*/
private registerOnChangeFn;
/**
* Set file and set up preview and validations
*
* @param file - The file
*/
private setUpNewFile;
/**
* Listen for changes to the virtual input
*
* @param event - The event
*/
private onVirtualInputElementChange;
private preventAndStopEventPropagation;
/**
* Update the attributes of the virtual file input based on @Inputs
*
* @param input - The HTML input element
*/
private updateVirtualFileInputAttrs;
/**
* Set validation messages
*
* @param file - The file
*/
private setValidationMessages;
/**
* Clear all validation messages
*/
private clearValidationMessages;
/**
* Parse ratio from Array of string to Array of ImageRatio
*
* @param ratios - Array of string
* @returns - Array of ImageRatio
*/
private parseRatioStringToObject;
/**
* Parse ratio from Array of ImageRatio to Array of string
*
* @param ratios - Array of ImageRatio
* @returns - Array of string
*/
private parseRatioToString;
/**
* Function for tracking for-loops changes
*
* @param index - The item index
* @returns The unique ID
*/
trackByFn(index: any): number;
}