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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@invisionag/iris-react-file-input

v3.6.2

Published

```js import FileInput from '@invisionag/iris-react-file-input'; ```

Downloads

139

Readme

import FileInput from '@invisionag/iris-react-file-input';

FileInput is a generalized Component to handle file selections made by the user. To this end, we make use of the "dropzone" pattern, wherein a file can simply be dragged into the designated zone to fill an <input type="file" /> element with a filepath.

Usage:

<FileInput />

isLoading

Can be passed to indicate that the selected files are currently being processed. It will cause:

  • Any interactivity with the dropzone to be disabled
  • A spinner to be displayed in the dropzone instead of the regular logic
  • The remove-buttons in the FileList to be hidden, so no files can be added or removed while isLoading is true

onChange

onChange is called on any state change, including when a file is removed.

onDrop

Callback that is invoked every time a file is selected, either via drop or traditional file explorer selection. First (and only) argument is an array of selected files:

handleDrop = files => {
  files.forEach(file =>console.log("file", file))
}

render() {
  return <FileInput onDrop={handleDrop} />
}

multiple

By default, only one file can be selected. If you want the user to be able to select multiple files, you can provide the multiple prop like so:

<FileInput multiple />

accept

Mime-Type-String or Array of Mime-Type-Strings. If set, the file input will only accept files with the matching mime-type. Other files will simply be ignored; this is also true if multiple and accept is set: if a user drops multiple files with different mime-types, those with the correct type will be accepted whereas the others will simply be ignored.

<FileInput accept="text/csv" />

localeUtils

Via this prop all customizable texts can be set. It should be a polyglot object following the implementataion in e.g. forecast-ui.

Following text items can be customized in the FileInput by implementing the corresponding key. If the key is not provided, a default text will be displayed.

| Description | key | default | |---------------------------------------|----------------------------------------------|------------------- | | message in initial screen for multiple| file_input.description.multiple | Drag your files here | | message in initial screen | file_input.description.single | Drag your file here | | conjunction before file explorer link | file_input.joiner | or | | displayed in zone when isLoading is passed | file_input.loading | Uploading... | | file explorer link | file_input.link | choose files | | dragging with valid files | file_input.active_description.valid | Drop files here | | dragging with invalid files | file_input.active_description.invalid | Cannot select this file type | | when file limit is reached | file_input.file_limit_warning | 1 of 1 file selected |

className

Provides a class name for the react Dropzone.

validate

With the validate prop, a custom validator can be passed to the component.

The component will run the validator function for each file that was added, passing the file as the only argument.

The file will only be added to the selection if the validator function returns true.

<FileInput validate={(file: File): boolean => file.name === 'my-special-name.txt'} />