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

file-uploader-js

v0.3.1

Published

React JS File uploader handler component with loading process and error management. Returns local uploaded file contents via callback

Downloads

39

Readme

npm npm npm

file-uploader

React JS File Uploader Component

Description

Simple react file upload component with loading throbber. Abstracts the FE loading functionality and invokes a callback function once the file has been already loaded with the appropriate data. This was originally thought for text files. Can accept specific file types if needed

How to thank me? Just click on ⭐️ button :)

Installation

Install it from npm and include it in your React build process (using Webpack, Browserify, etc).

npm i file-uploader-js

Usage

Import FileUploader in your react component.

import FileUploader from 'file-uploader';

and specify the callback function you want to call when the file is loaded.

While the file is loading, you'll see a loading throbber.

For example:

<FileUploader
  accept=".csv"
  title="Please upload a CSV file"
  titleCss={{ color: "#000", fontFamily: "arial" }}
  uploadedFileCallback={e => {
    this.uploadedCsv(e);
  }}
/>

And then define the callback function

uploadedCsv(fileData) {
    console.log(fileData);
    //Do stuff with the loaded file data
}

Props

Props available:

  • title (title that will have the upload component section as a label)
  • uploadedFileCallback (callback function that will be invoked)
  • accept (Types you want to filter and accept for uploads e.g ".csv")

Optionally you can handle errors with the following props:

  • onErrorCallback (Error uploading and reading the file)
  • onAbortCallback (Operation aborted)

| Name | Type | Mandatory | Description
| ------------- |:-------------:| -----:|:-----| | title | String | N | Title you want to have in the uploader | | uploadedFileCallback | Function callback | Y| Function to call on loaded data | | accept | String | N| Filter to determine what file types you want to upload | | onErrorCallback | Function callback | N| Function to call on loading error | | onAbortCallback | Function callback | N| Function to call on loading abort | | titleCss | Object | N| Styling for title | | isBinary | present? | N| Is the file binary? Text file as default | customLimitTextCSS | Object | N| Object to customize error title | byteLimit | Number | N| Number in bytes to determine file size limit

Changelog

v0.3.1

  • Package size optimizations

v0.3.0

  • Dependencies updated
  • Overall package size optimized

v0.2.7

  • Added props to have a hard file size limit byteLimit
  • Added new error message if the file exceeds the limit, can be configured with customLimitTextCSS prop

v0.2.2

  • Bug fixes typecheck added

v0.2.1

  • Read binary files

v0.2.0

  • Added accept prop
  • Added styling prop for title

License

Licensed under the MIT License © jciccio