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

@dojo-ng/file-input

v0.1.0

Published

Dojo NG file-input web component

Readme

@dojo-ng/file-input

<dj-file-input> — A form-associated file selector with a button (opens the OS picker) and a focusable drop zone.

Part of Dojo NG, a framework-agnostic web component library built on Lit. BSD-3-Clause.

A form-associated file selector with a button (opens the OS picker) and a focusable drop zone. Files arrive by picker, drop, paste (a screenshot pasted while the drop zone has focus), or the public addFiles method; all four route through one intake that applies accept + multiple + max-size. Selected files are copied into component state, shown as a removable list; the element only SELECTS files (no upload/preview). Form value: a single File normally, or a FormData with one entry per file (under name) when multiple. Parts: button, dropzone, list, item, remove. Event: dj-change ({ files }) on add and remove.

A form-associated file selector: a dj-button opens the OS picker and the host doubles as a drop zone. Selected files are copied into component state and listed with their size and a remove button; the component only SELECTS files — it does no uploading or preview. accept filters both the picker and drops (extension, exact MIME, or type/*); multiple allows more than one (otherwise a new pick replaces the current file); max-size (bytes, per file) rejects an oversize file and sets a fileTooLarge validity error, cleared on the next change; required with no files reports valueMissing. Form value is a single File, or a FormData with one entry per file under name when multiple. Read files (read-only) for the current selection; call clear() to empty it. Emits dj-change ({ files }) on add and remove. Files arrive four ways, all through one intake (which applies accept + multiple + max-size): the picker, a drop, a paste, and the public addFiles(files: File[] | FileList) method — the app-integration seam for forwarding files captured elsewhere (a paste into a compose body, a drop on a whole pane). The drop zone is focusable and shows a focus ring; pasting a file (e.g. a screenshot) while it has focus adds the file. Parts: button, dropzone, list, item, remove.

Install

npm install @dojo-ng/file-input

Usage

Import the package to register the custom element, then use the tag.

Set accept and multiple; read the selection from dj-change or the files property.

<dj-file-input id="files" label="Attachments" accept="image/*" multiple max-size="5000000"></dj-file-input>
<script type="module">
  import "@dojo-ng/file-input";
  document.getElementById("files").addEventListener("dj-change", (e) => console.log(e.detail.files));
</script>

Properties

↻ marks an attribute reflected to the DOM; a dash means the property is set in JavaScript only.

| Property | Attribute | Type | Default | |---|---|---|---| | accept | accept | string | — | | multiple | multiple | boolean | false | | required | required ↻ | boolean | false | | maxSize | max-size | number | — | | label | label | string | — | | name | name ↻ | string | — | | disabled | disabled ↻ | boolean | false |

Parts: button, dropzone, list, item, remove, label

Events: dj-change ({ files })

Methods: checkValidity(): boolean, reportValidity(): boolean, focus(options: FocusOptions), clear() (Remove all selected files (no dj-change).), addFiles(incoming: File[] | FileList) (Add files from any source, applying accept + multiple + max-size; appends, or replaces when not multiple. Emits dj-change. This is the single intake path — the picker, drop, and paste all route through it, and the app can call it to forward files captured elsewhere (e.g. a paste into the compose body or a drop on the whole pane).)

Examples

Forward files from elsewhere with addFiles

The app can push files the control did not capture — e.g. a paste or drop on a surrounding compose pane. addFiles runs the same accept / multiple / max-size filtering as the picker and emits dj-change. (The control also handles a paste directly onto its focused drop zone.)

<dj-file-input id="attach" label="Attachments" accept="image/*" multiple></dj-file-input>
<script type="module">
  import "@dojo-ng/file-input";
  const input = document.getElementById("attach");
  // A paste anywhere in the compose pane forwards its files to the control.
  document.querySelector(".compose").addEventListener("paste", (e) => {
    if (e.clipboardData?.files.length) input.addFiles(e.clipboardData.files);
  });
</script>

Theming

Styled with Dojo NG --dj-* design tokens and exposes ::part() hooks for targeted overrides.

Accessibility and i18n

Follows the project's WCAG 2.2 AA and localization conventions.

More

Live, interactive examples are in the playground (playground/index.html). For the full API reference, theming, accessibility, and localization guides, see the Dojo NG documentation.