@nghacks/uploader
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

Uploader

Picks image or file.

Live Preview

How to use

Install package

npm install @nghacks/uploader

Import UploaderModule to your consumer module like ConsumerModule

import { NgModule } from '@angular/core';
...
...
import { UploaderModule } from '@nghacks/uploader';

@NgModule({
  declarations: [
    ...
  ],
  imports: [
    ...
    UploaderModule
  ]
})
export class ConsumerModule { }

Use component on html template

<img-uploader (fileInputChange)="imageInputChange($event)"></img-uploader>

<file-uploader (fileInputChange)="fileInputChange($event)"></file-uploader>

Inputs

/**
 * @description Picker label
 * @default 'Drag image, or Choose' for image uploader
 * @default 'Drag file, or Choose' for file uploader
 * @example 'Drag your funny video, or Choose'
 */
@Input() pickerLabel: string;

/**
 * @description Hint is used to guide user
 * @example 'Max file size: 5mb'
 */
@Input() hint: string;

/**
 * @description acceptable file types
 * @default ['.jpg', '.png', '.jpeg'] for image uploader
 * @default ['.pdf', '.csv', '.doc', '.docx','.docx', '.xlsx', '.cer'] for file uploader
 * @example ['.gif'] for only gif files
 */
@Input() accept: string[];

/**
 * @description maximum file size in kb (kilobyte)
 * @default 5000 (5mb)
 */
@Input() maxSize = 5000;

/**
 * @description disables the picker
 */
@Input() disabled: boolean;

/**
 * @description min-height of the picker
 * @default 48 (in pixel)
 */
@Input() minHeight = 48;

/**
 * @description max-height of the image previewer
 * @memberof ImgUploaderComponent only
 * @default 250 (in pixel)
 */
@Input() maxHeight = 250;

Inputs

@Output() fileInputChange = new EventEmitter<FileInputChange>();

Types

export interface UploaderError {
  maxSizeExceeded: boolean;
  wrongFileType: boolean;
}

export interface FileInputChange {
  hasFile: boolean;
  fileName: string;
  base64Image: string[];
  errors: UploaderError;
}

Package Sidebar

Install

npm i @nghacks/uploader

Weekly Downloads

0

Version

0.1.1

License

MIT

Unpacked Size

189 kB

Total Files

25

Last publish

Collaborators

  • abdunnahid