UNPKG

@avoraui/av-file-picker

Version:

A customizable Angular file picker component for images and PDFs with preview support.

60 lines (57 loc) 2.53 kB
import * as i0 from '@angular/core'; import { OnDestroy } from '@angular/core'; import { ControlValueAccessor } from '@angular/forms'; declare class AvFilePicker implements ControlValueAccessor, OnDestroy { defaultImage: any; showPdfDetails: boolean; imageURL: any; pdfFileName: string; isPDF: boolean; viewPdf: boolean; private convertValue; private decodeValue; pdfUrl: any; private readonly MAX_FILE_SIZE; constructor(); private onChange; private onTouched; private disabled; /** * Handles the selection of an image or PDF file from an input event and processes the file accordingly. * It validates the file size, checks its format, and reads the file to produce a base64-encoded string. * Updates the relevant properties depending on whether the file is an image or a PDF. * * @param {any} event - The event triggered by the input file selection. * @return {void} This method does not return a value. */ selectImage(event: any): void; /** * Resets the image-related properties to their default states. * Sets the imageURL to the default image, marks the object as not a PDF, * disables the PDF viewer, and triggers an update with the encoded imageURL. * * @return {void} Does not return a value. */ clearImage(): void; /** * Processes and decodes a provided Base64-encoded value, determining if it is an image or a PDF. * Updates the relevant properties based on the decoded content or handles errors gracefully. * * @param {any} value - The Base64-encoded string to process. If null, undefined, or an empty string, it defaults to a predefined image. * @return {void} No return value. */ writeValue(value: any): void; registerOnChange(fn: any): void; registerOnTouched(fn: any): void; setDisabledState?(isDisabled: boolean): void; /** * Performs cleanup and resource deallocation before the component is destroyed. * Specifically, it revokes any created Object URLs to prevent memory leaks. * * @return {void} Does not return a value. */ ngOnDestroy(): void; static ɵfac: i0.ɵɵFactoryDeclaration<AvFilePicker, never>; static ɵcmp: i0.ɵɵComponentDeclaration<AvFilePicker, "av-file-picker", never, { "defaultImage": { "alias": "defaultImage"; "required": false; }; "showPdfDetails": { "alias": "showPdfDetails"; "required": false; }; }, {}, never, never, true, never>; } export { AvFilePicker };