npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@manufosela/rich-inputfile

v2.0.0

Published

Enhanced file input web component with preview and validation

Readme

@manufosela/rich-inputfile

Enhanced file input web component with preview and validation. Built with Lit.

Installation

npm install @manufosela/rich-inputfile

Usage

import '@manufosela/rich-inputfile';
<rich-inputfile label="Upload File"></rich-inputfile>

Features

  • Drag and drop support
  • Image preview thumbnails
  • File type validation
  • File size validation
  • Clear button
  • Programmatic file access
  • CSS custom properties for theming

Attributes

| Attribute | Type | Default | Description | | -------------------- | ------- | ------- | ---------------------------------- | | name | String | '' | Input name attribute | | label | String | '' | Label text | | allowed-extensions | String | '' | Comma-separated allowed extensions | | accept | String | '' | HTML accept attribute value | | max-size | Number | 0 | Maximum file size in bytes (0=no limit) | | show-preview | Boolean | true | Show image thumbnail preview | | preview-size | Number | 60 | Preview thumbnail size in pixels | | dropzone | Boolean | true | Enable drag and drop | | disabled | Boolean | false | Disable the input |

Methods

| Method | Returns | Description | | ----------------------- | ---------------------- | -------------------------- | | getFile() | File \| null | Get selected file | | getFileArrayBuffer() | Promise<ArrayBuffer> | Get file as ArrayBuffer | | getFileUint8Array() | Promise<Uint8Array> | Get file as Uint8Array | | getFileDataURL() | Promise<string> | Get file as Data URL | | setFile(file) | void | Set file programmatically | | clear() | void | Clear selected file |

Events

| Event | Detail | Description | | ------------- | ----------------------------- | ------------------------- | | file-change | {file, name, size, type} | Fired on file selection | | file-clear | - | Fired when file is cleared| | file-error | {message, file} | Fired on validation error |

Examples

Basic

<rich-inputfile label="Upload File"></rich-inputfile>

Image Upload

<rich-inputfile
  label="Upload Image"
  allowed-extensions="jpg,jpeg,png,gif,webp"
></rich-inputfile>

Document Upload

<rich-inputfile
  label="Upload Document"
  allowed-extensions="pdf,doc,docx"
  max-size="5242880"
></rich-inputfile>

Size Limit

<rich-inputfile
  label="Max 1MB"
  max-size="1048576"
></rich-inputfile>

No Preview

<rich-inputfile
  label="Upload"
  .showPreview="${false}"
></rich-inputfile>

Disabled

<rich-inputfile
  label="Disabled"
  disabled
></rich-inputfile>

Click Only (No Drag)

<rich-inputfile
  label="Click to Upload"
  .dropzone="${false}"
></rich-inputfile>

Handle Events

const input = document.querySelector('rich-inputfile');

input.addEventListener('file-change', (e) => {
  console.log('File:', e.detail.name);
  console.log('Size:', e.detail.size);
  console.log('Type:', e.detail.type);
});

input.addEventListener('file-error', (e) => {
  console.log('Error:', e.detail.message);
});

input.addEventListener('file-clear', () => {
  console.log('File cleared');
});

Programmatic Access

const input = document.querySelector('rich-inputfile');

// Get file
const file = input.getFile();

// Get as ArrayBuffer
const buffer = await input.getFileArrayBuffer();

// Get as Uint8Array
const uint8 = await input.getFileUint8Array();

// Get as Data URL (for images)
const dataUrl = await input.getFileDataURL();

// Clear file
input.clear();

CSS Custom Properties

| Property | Default | Description | | --------------------- | ---------- | ------------------- | | --input-border | #d1d5db | Border color | | --input-border-focus| #3b82f6 | Focus border color | | --input-bg | #fff | Background color | | --input-radius | 8px | Border radius |

Styling Example

rich-inputfile {
  --input-border: #e5e7eb;
  --input-border-focus: #8b5cf6;
  --input-radius: 12px;
}

Compared to Original

| Feature | Original | New | | ------- | -------- | --- | | Lit version | Lit 2.x | Lit 3.x | | Drag & drop | Manual | Built-in | | Validation | Extension only | Extension + size | | Preview | Basic | Improved | | Methods | Limited | Full API | | Tests | Basic | Comprehensive |

License

Apache-2.0