@masteratm/ngx-dropzone
Version:
A highly configurable dropzone component for Angular.
162 lines (152 loc) • 8.41 kB
TypeScript
import * as i0 from '@angular/core';
import { EventEmitter, QueryList, ElementRef, OnInit, OnDestroy } from '@angular/core';
import { DomSanitizer, SafeStyle, SafeUrl } from '@angular/platform-browser';
import * as i7 from '@angular/common';
interface FileSelectResult {
/** The added files, emitted in the filesAdded event. */
addedFiles: File[];
/** The rejected files, emitted in the filesRejected event. */
rejectedFiles: RejectedFile[];
}
interface RejectedFile extends File {
/** The reason the file was rejected. */
reason?: RejectReason;
}
type RejectReason = 'type' | 'size' | 'no_multiple';
/**
* This service contains the filtering logic to be applied to
* any dropped or selected file. If a file matches all criteria
* like maximum size or accept type, it will be emitted in the
* addedFiles array, otherwise in the rejectedFiles array.
*/
declare class NgxDropzoneService {
parseFileList(files: FileList, accept: string, maxFileSize: number, multiple: boolean): FileSelectResult;
private isAccepted;
private rejectFile;
static ɵfac: i0.ɵɵFactoryDeclaration<NgxDropzoneService, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<NgxDropzoneService>;
}
declare class NgxDropzonePreviewComponent {
protected sanitizer: DomSanitizer;
constructor(sanitizer: DomSanitizer);
protected _file: File;
/** The file to preview. */
set file(value: File);
get file(): File;
/** Allow the user to remove files. */
get removable(): boolean;
set removable(value: boolean);
protected _removable: boolean;
/** Emitted when the element should be removed. */
readonly removed: EventEmitter<File>;
keyEvent(event: KeyboardEvent): void;
/** We use the HostBinding to pass these common styles to child components. */
get hostStyle(): SafeStyle;
/** Make the preview item focusable using the tab key. */
tabIndex: number;
/** Remove method to be used from the template. */
_remove(event: any): void;
/** Remove the preview item (use from component code). */
remove(): void;
protected readFile(): Promise<string | ArrayBuffer>;
static ɵfac: i0.ɵɵFactoryDeclaration<NgxDropzonePreviewComponent, never>;
static ɵcmp: i0.ɵɵComponentDeclaration<NgxDropzonePreviewComponent, "ngx-dropzone-preview", never, { "file": { "alias": "file"; "required": false; }; "removable": { "alias": "removable"; "required": false; }; }, { "removed": "removed"; }, never, ["ngx-dropzone-label"], false, never>;
}
interface NgxDropzoneChangeEvent {
source: NgxDropzoneComponent;
addedFiles: File[];
rejectedFiles: RejectedFile[];
}
declare class NgxDropzoneComponent {
private service;
constructor(service: NgxDropzoneService);
/** A list of the content-projected preview children. */
_previewChildren: QueryList<NgxDropzonePreviewComponent>;
get _hasPreviews(): boolean;
/** A template reference to the native file input element. */
_fileInput: ElementRef;
/** Emitted when any files were added or rejected. */
readonly change: EventEmitter<NgxDropzoneChangeEvent>;
/** Set the accepted file types. Defaults to '*'. */
accept: string;
/** Disable any user interaction with the component. */
get disabled(): boolean;
set disabled(value: boolean);
private _disabled;
/** Allow the selection of multiple files. */
get multiple(): boolean;
set multiple(value: boolean);
private _multiple;
/** Set the maximum size a single file may have. */
get maxFileSize(): number;
set maxFileSize(value: number);
private _maxFileSize;
/** Allow the dropzone container to expand vertically. */
get expandable(): boolean;
set expandable(value: boolean);
private _expandable;
/** Open the file selector on click. */
get disableClick(): boolean;
set disableClick(value: boolean);
private _disableClick;
/** Allow dropping directories. */
get processDirectoryDrop(): boolean;
set processDirectoryDrop(value: boolean);
private _processDirectoryDrop;
/** Expose the id, aria-label, aria-labelledby and aria-describedby of the native file input for proper accessibility. */
id: string;
ariaLabel: string;
ariaLabelledby: string;
ariaDescribedBy: string;
_isHovered: boolean;
/** Show the native OS file explorer to select files. */
_onClick(): void;
_onDragOver(event: any): void;
_onDragLeave(): void;
_onDrop(event: any): void;
private extractFilesFromDirectory;
showFileSelector(): void;
_onFilesSelected(event: any): void;
private handleFileDrop;
private preventDefault;
static ɵfac: i0.ɵɵFactoryDeclaration<NgxDropzoneComponent, [{ self: true; }]>;
static ɵcmp: i0.ɵɵComponentDeclaration<NgxDropzoneComponent, "ngx-dropzone, [ngx-dropzone]", never, { "accept": { "alias": "accept"; "required": false; }; "disabled": { "alias": "disabled"; "required": false; }; "multiple": { "alias": "multiple"; "required": false; }; "maxFileSize": { "alias": "maxFileSize"; "required": false; }; "expandable": { "alias": "expandable"; "required": false; }; "disableClick": { "alias": "disableClick"; "required": false; }; "processDirectoryDrop": { "alias": "processDirectoryDrop"; "required": false; }; "id": { "alias": "id"; "required": false; }; "ariaLabel": { "alias": "aria-label"; "required": false; }; "ariaLabelledby": { "alias": "aria-labelledby"; "required": false; }; "ariaDescribedBy": { "alias": "aria-describedby"; "required": false; }; }, { "change": "change"; }, ["_previewChildren"], ["ngx-dropzone-label", "ngx-dropzone-preview", "*"], false, never>;
}
declare class NgxDropzoneLabelDirective {
static ɵfac: i0.ɵɵFactoryDeclaration<NgxDropzoneLabelDirective, never>;
static ɵdir: i0.ɵɵDirectiveDeclaration<NgxDropzoneLabelDirective, "ngx-dropzone-label", never, {}, {}, never, never, false, never>;
}
declare class NgxDropzoneImagePreviewComponent extends NgxDropzonePreviewComponent implements OnInit {
constructor(sanitizer: DomSanitizer);
/** The file to preview. */
set file(value: File);
get file(): File;
/** The image data source. */
defaultImgLoading: string;
imageSrc: any;
ngOnInit(): void;
private renderImage;
static ɵfac: i0.ɵɵFactoryDeclaration<NgxDropzoneImagePreviewComponent, never>;
static ɵcmp: i0.ɵɵComponentDeclaration<NgxDropzoneImagePreviewComponent, "ngx-dropzone-image-preview", never, { "file": { "alias": "file"; "required": false; }; }, {}, never, ["ngx-dropzone-label"], false, never>;
}
declare class NgxDropzoneRemoveBadgeComponent {
static ɵfac: i0.ɵɵFactoryDeclaration<NgxDropzoneRemoveBadgeComponent, never>;
static ɵcmp: i0.ɵɵComponentDeclaration<NgxDropzoneRemoveBadgeComponent, "ngx-dropzone-remove-badge", never, {}, {}, never, never, false, never>;
}
declare class NgxDropzoneVideoPreviewComponent extends NgxDropzonePreviewComponent implements OnInit, OnDestroy {
constructor(sanitizer: DomSanitizer);
/** The video data source. */
sanitizedVideoSrc: SafeUrl;
private videoSrc;
ngOnInit(): void;
ngOnDestroy(): void;
static ɵfac: i0.ɵɵFactoryDeclaration<NgxDropzoneVideoPreviewComponent, never>;
static ɵcmp: i0.ɵɵComponentDeclaration<NgxDropzoneVideoPreviewComponent, "ngx-dropzone-video-preview", never, {}, {}, never, ["ngx-dropzone-label"], false, never>;
}
declare class NgxDropzoneModule {
static ɵfac: i0.ɵɵFactoryDeclaration<NgxDropzoneModule, never>;
static ɵmod: i0.ɵɵNgModuleDeclaration<NgxDropzoneModule, [typeof NgxDropzoneComponent, typeof NgxDropzoneLabelDirective, typeof NgxDropzonePreviewComponent, typeof NgxDropzoneImagePreviewComponent, typeof NgxDropzoneRemoveBadgeComponent, typeof NgxDropzoneVideoPreviewComponent], [typeof i7.CommonModule], [typeof NgxDropzoneComponent, typeof NgxDropzoneLabelDirective, typeof NgxDropzonePreviewComponent, typeof NgxDropzoneImagePreviewComponent, typeof NgxDropzoneRemoveBadgeComponent, typeof NgxDropzoneVideoPreviewComponent]>;
static ɵinj: i0.ɵɵInjectorDeclaration<NgxDropzoneModule>;
}
export { NgxDropzoneComponent, NgxDropzoneImagePreviewComponent, NgxDropzoneLabelDirective, NgxDropzoneModule, NgxDropzonePreviewComponent, NgxDropzoneRemoveBadgeComponent, NgxDropzoneVideoPreviewComponent };
export type { NgxDropzoneChangeEvent };