{"id":29313019,"url":"https://github.com/sanjib-kumar-mandal/ng-files-input","last_synced_at":"2025-07-07T09:13:59.072Z","repository":{"id":300735142,"uuid":"1006533637","full_name":"sanjib-kumar-mandal/ng-files-input","owner":"sanjib-kumar-mandal","description":"Angular file input component with live preview support for images, PDFs, text files, and upload progress tracking.","archived":false,"fork":false,"pushed_at":"2025-06-23T09:34:08.000Z","size":131,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-06-23T10:33:13.794Z","etag":null,"topics":["angular","angular-components","angular-library","file-input","file-preview","file-upload","file-uploader","ng-files","upload-progress"],"latest_commit_sha":null,"homepage":"","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sanjib-kumar-mandal.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-06-22T13:39:53.000Z","updated_at":"2025-06-23T09:34:11.000Z","dependencies_parsed_at":"2025-06-23T10:44:06.469Z","dependency_job_id":null,"html_url":"https://github.com/sanjib-kumar-mandal/ng-files-input","commit_stats":null,"previous_names":["sanjib-kumar-mandal/ng-files-input"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/sanjib-kumar-mandal/ng-files-input","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sanjib-kumar-mandal%2Fng-files-input","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sanjib-kumar-mandal%2Fng-files-input/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sanjib-kumar-mandal%2Fng-files-input/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sanjib-kumar-mandal%2Fng-files-input/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sanjib-kumar-mandal","download_url":"https://codeload.github.com/sanjib-kumar-mandal/ng-files-input/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sanjib-kumar-mandal%2Fng-files-input/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264049080,"owners_count":23549405,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["angular","angular-components","angular-library","file-input","file-preview","file-upload","file-uploader","ng-files","upload-progress"],"created_at":"2025-07-07T09:13:58.281Z","updated_at":"2025-07-07T09:13:59.060Z","avatar_url":"https://github.com/sanjib-kumar-mandal.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"![npm](https://img.shields.io/npm/v/ng-files-input)\n![downloads](https://img.shields.io/npm/dm/ng-files-input)\n![license](https://img.shields.io/npm/l/ng-files-input)\n\n# ng-files-input 📁🖼️\n\n**ng-files-input** is an Angular library for previewing uploaded files with support for images, PDFs, plain text, and more — all wrapped in a highly customizable and developer-friendly file input component.\n\n---\n\n## ✨ Features\n\n- 📸 Image preview\n- 📄 PDF viewer with embedded preview\n- ❓ Graceful fallback for unsupported file types\n- 🧠 Automatic file-type detection\n- 🎨 Fully customizable UI\n- 🔌 Works with `ngModel` and `FormControl`\n- 🧩 Designed for modern Angular (v19+)\n\n---\n\n## 📦 Installation\n\n```bash\nnpm install ng-files-input\n```\n\n## ⚙️ Usage\n\n- Import the module\n\n```ts\nimport { NgFilesInput, UploadType } from \"ng-files-input\";\n\n@Component({\n  imports: [NgFilesInput],\n})\nexport class ExampleComponent {\n  uploadType = UploadType.IMAGE;\n}\n```\n\n- Template Usage\n\n```html\n\u003cng-files-input [uploadType]=\"uploadType\" [accept]=\"'.png,.jpg'\" [(ngModel)]=\"file\" [disabled]=\"false\" [showPreview]=\"true\"\u003e Please select image \u003c/ng-files-input\u003e\n```\n\n- Style modification\n\n```scss\n--ng-files-area-width: 200px;\n--ng-files-area-height: 180px;\n--ng-files-border-width: 2px;\n--ng-files-border-style: solid;\n--ng-files-border-color: #9e9e9e;\n--ng-files-background: #f5f5f5;\n--ng-files-icon-size: 40;\n--ng-files-icon-color: green; // This may or may not work\n--ng-files-placeholder-color: #292826;\n--ng-files-placeholder-font-size: 12px;\n--ng-files-placeholder-gap: 5px;\n--ng-files-progress-bar-color: green;\n```\n\n## 🚀 Advanced Usage: Custom Upload Function with Progress\n\nTS\n\n```ts\nimport { HttpClient, HttpRequest } from \"@angular/common/http\";\nimport { Component, inject } from \"@angular/core\";\n\n@Component({\n  selector: \"app-file-upload\",\n  templateUrl: \"./file-upload.component.html\",\n})\nexport class FileUploadComponent {\n  private http = inject(HttpClient);\n\n  // Upload function passed to ng-files-input\n  uploadFile = (file: File) =\u003e {\n    const formData = new FormData();\n    formData.append(\"file\", file);\n\n    const req = new HttpRequest(\"POST\", \"https://your.api/upload\", formData, {\n      reportProgress: true, // enables progress events\n    });\n\n    return this.http.request(req); // returns Observable\u003cHttpEvent\u003cany\u003e\u003e\n  };\n}\n```\n\nHTML\n\n```html\n\u003cng-files-input [(ngModel)]=\"selectedFile\" [uploadFn]=\"uploadFile\"\u003e\u003c/ng-files-input\u003e\n```\n\n## ✅ What ng-files-input handles:\n\n- Automatically calls your `uploadFn(file)`\n- Tracks `HttpEventType.UploadProgress`\n- Emits upload status (optional: via `(uploadProgress)` or `(uploadComplete)` outputs)\n\n## 🧩 Expected Behavior in Library\n\nInternally, your component might do something like:\n\n```ts\nuploadFn(file).subscribe((event) =\u003e {\n  if (event.type === HttpEventType.UploadProgress) {\n    const percent = Math.round((100 * event.loaded) / (event.total ?? 1));\n    this.progress = percent;\n  } else if (event.type === HttpEventType.Response) {\n    this.uploadComplete.emit(event.body);\n  }\n});\n```\n\n## 🗂️ Supported File Types\n\n| File Type                     | Preview Method                |\n| ----------------------------- | ----------------------------- |\n| Images (`.png`, `.jpg`, etc.) | `\u003cimg\u003e` tag                   |\n| PDFs                          | `\u003ciframe\u003e` or `\u003cembed\u003e`       |\n| Text files                    | `\u003cpre\u003e` element               |\n| Others                        | ⚠️ Fallback message displayed |\n\n## 🔧 Inputs\n\n| Input                 | Type     | Description                       |\n| --------------------- | -------- | --------------------------------- |\n| accept                | string   | Accepted MIME types or extensions |\n| disabled              | boolean  | Disable file input                |\n| ngModel / formControl | `Base64` | `null`                            |\n\n## 🚀 Roadmap\n\n- Drag-and-drop upload\n- Multiple file preview\n- File validation (type/size)\n- Custom preview template slots\n\n## 📄 License\n\nMIT\n\n## 👨‍💻 Author\n\nMade with ❤️ by [Sanjib Kumar Mandal](https://github.com/sanjib-kumar-mandal)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsanjib-kumar-mandal%2Fng-files-input","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsanjib-kumar-mandal%2Fng-files-input","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsanjib-kumar-mandal%2Fng-files-input/lists"}