import { Component, Input, Output, EventEmitter, HostBinding, HostListener } from '@angular/core'; import { coerceBooleanProperty } from '../helpers'; import { DomSanitizer } from '@angular/platform-browser'; import * as i0 from "@angular/core"; import * as i1 from "@angular/platform-browser"; import * as i2 from "./ngx-dropzone-remove-badge/ngx-dropzone-remove-badge.component"; import * as i3 from "@angular/common"; var KEY_CODE; (function (KEY_CODE) { KEY_CODE[KEY_CODE["BACKSPACE"] = 8] = "BACKSPACE"; KEY_CODE[KEY_CODE["DELETE"] = 46] = "DELETE"; })(KEY_CODE || (KEY_CODE = {})); export class NgxDropzonePreviewComponent { constructor(sanitizer) { this.sanitizer = sanitizer; this._removable = false; /** Emitted when the element should be removed. */ this.removed = new EventEmitter(); /** Make the preview item focusable using the tab key. */ this.tabIndex = 0; } /** The file to preview. */ set file(value) { this._file = value; } get file() { return this._file; } /** Allow the user to remove files. */ get removable() { return this._removable; } set removable(value) { this._removable = coerceBooleanProperty(value); } keyEvent(event) { switch (event.keyCode) { case KEY_CODE.BACKSPACE: case KEY_CODE.DELETE: this.remove(); break; default: break; } } /** We use the HostBinding to pass these common styles to child components. */ get hostStyle() { const styles = ` display: flex; height: 140px; min-height: 140px; min-width: 180px; max-width: 180px; justify-content: center; align-items: center; padding: 0 20px; margin: 10px; border-radius: 5px; position: relative; `; return this.sanitizer.bypassSecurityTrustStyle(styles); } /** Remove method to be used from the template. */ _remove(event) { event.stopPropagation(); this.remove(); } /** Remove the preview item (use from component code). */ remove() { if (this._removable) { this.removed.next(this.file); } } async readFile() { return new Promise((resolve, reject) => { const reader = new FileReader(); reader.onload = e => { resolve(e.target.result); }; reader.onerror = e => { console.error(`FileReader failed on file ${this.file.name}.`); reject(e); }; if (!this.file) { return reject('No file to read. Please provide a file using the [file] Input property.'); } reader.readAsDataURL(this.file); }); } } NgxDropzonePreviewComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: NgxDropzonePreviewComponent, deps: [{ token: i1.DomSanitizer }], target: i0.ɵɵFactoryTarget.Component }); NgxDropzonePreviewComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.2", type: NgxDropzonePreviewComponent, selector: "ngx-dropzone-preview", inputs: { file: "file", removable: "removable" }, outputs: { removed: "removed" }, host: { listeners: { "keyup": "keyEvent($event)" }, properties: { "style": "this.hostStyle", "tabindex": "this.tabIndex" } }, ngImport: i0, template: ` `, isInline: true, styles: [":host{background-image:linear-gradient(to top,#ededed,#efefef,#f1f1f1,#f4f4f4,#f6f6f6)}:host:hover,:host:focus{background-image:linear-gradient(to top,#e3e3e3,#ebeaea,#e8e7e7,#ebeaea,#f4f4f4);outline:0}:host:hover ngx-dropzone-remove-badge,:host:focus ngx-dropzone-remove-badge{opacity:1}:host ngx-dropzone-remove-badge{opacity:0}:host ::ng-deep ngx-dropzone-label{overflow-wrap:break-word}\n"], components: [{ type: i2.NgxDropzoneRemoveBadgeComponent, selector: "ngx-dropzone-remove-badge" }], directives: [{ type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] }); i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: NgxDropzonePreviewComponent, decorators: [{ type: Component, args: [{ selector: 'ngx-dropzone-preview', template: ` `, styles: [":host{background-image:linear-gradient(to top,#ededed,#efefef,#f1f1f1,#f4f4f4,#f6f6f6)}:host:hover,:host:focus{background-image:linear-gradient(to top,#e3e3e3,#ebeaea,#e8e7e7,#ebeaea,#f4f4f4);outline:0}:host:hover ngx-dropzone-remove-badge,:host:focus ngx-dropzone-remove-badge{opacity:1}:host ngx-dropzone-remove-badge{opacity:0}:host ::ng-deep ngx-dropzone-label{overflow-wrap:break-word}\n"] }] }], ctorParameters: function () { return [{ type: i1.DomSanitizer }]; }, propDecorators: { file: [{ type: Input }], removable: [{ type: Input }], removed: [{ type: Output }], keyEvent: [{ type: HostListener, args: ['keyup', ['$event']] }], hostStyle: [{ type: HostBinding, args: ['style'] }], tabIndex: [{ type: HostBinding, args: ['tabindex'] }] } }); //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibmd4LWRyb3B6b25lLXByZXZpZXcuY29tcG9uZW50LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vcHJvamVjdHMvbmd4LWRyb3B6b25lL3NyYy9saWIvbmd4LWRyb3B6b25lLXByZXZpZXcvbmd4LWRyb3B6b25lLXByZXZpZXcuY29tcG9uZW50LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxTQUFTLEVBQUUsS0FBSyxFQUFFLE1BQU0sRUFBRSxZQUFZLEVBQUUsV0FBVyxFQUFFLFlBQVksRUFBRSxNQUFNLGVBQWUsQ0FBQztBQUNsRyxPQUFPLEVBQUUscUJBQXFCLEVBQUUsTUFBTSxZQUFZLENBQUM7QUFDbkQsT0FBTyxFQUFhLFlBQVksRUFBRSxNQUFNLDJCQUEyQixDQUFDOzs7OztBQUVwRSxJQUFLLFFBR0o7QUFIRCxXQUFLLFFBQVE7SUFDWixpREFBYSxDQUFBO0lBQ2IsNENBQVcsQ0FBQTtBQUNaLENBQUMsRUFISSxRQUFRLEtBQVIsUUFBUSxRQUdaO0FBV0QsTUFBTSxPQUFPLDJCQUEyQjtJQUV2QyxZQUNXLFNBQXVCO1FBQXZCLGNBQVMsR0FBVCxTQUFTLENBQWM7UUFrQnhCLGVBQVUsR0FBRyxLQUFLLENBQUM7UUFFN0Isa0RBQWtEO1FBQy9CLFlBQU8sR0FBRyxJQUFJLFlBQVksRUFBUSxDQUFDO1FBa0N0RCx5REFBeUQ7UUFDaEMsYUFBUSxHQUFHLENBQUMsQ0FBQztJQXZEbEMsQ0FBQztJQUlMLDJCQUEyQjtJQUMzQixJQUNJLElBQUksQ0FBQyxLQUFXLElBQUksSUFBSSxDQUFDLEtBQUssR0FB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