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

react-drag-drop-browser

v3.0.3

Published

Simple, customizable components for selecting files, with drag and drop.

Downloads

128

Readme

react-drag-drop-browser

Simple, customizable react drag and drop component. Also comes with a file browser.

Coverage Status

NPM page | Run example app on codesandbox

Installation

Installation can be done with yarn or npm

# yarn
yarn add react-drag-drop-browser

# npm
npm install react-drag-drop-browser

‼️ Important

The maximum allowed file size is set to 1MB by default and can be changed as required. This is worth mentiontioning because there is no feedback provided. If you need to do that you should do the check yourself. I only included it as a sensible default to prevent the inadvertent upload of very large files.

Usage

<DragAndDrop /> props

| Prop | Default value | Description | | --------------------------------------------- | --------------- | ---------------------------------------------------------------------------------------------------------------------------------------- | | zoneId (optional, string) | hot-zone | A unique id to identify the hot zone | | dataTestId (optional, string) | hot-zone | data-testid of the hot zone | | maxSizeInMB (optional, number) | 1 | maximum allowed file size | | children (optional, string, ReactElement) | Drop files here | | | zoneClassName (optional, string) | hot-zone | Class to style the section element | | inZoneClassName (optional, string) | inside-hot-zone | This class is applied when the dragged file is within the hot zone | | render (optional, ReactElement) | undefinded | If this is defined, it takes precedence. In that case you have to attach the event handlers defined in the DragAndDropRenderProps prop | | onDropFiles (required, function) | | A callback function that receives the array of files dropped into the hot zone |

<FileBrowser /> props

| Prop | Default value | Description | | ----------------------------------------- | ----------------------------------- | ---------------------------------------------------------------------------------------------------- | | dataTestId (optional, string) | file-browser | data-testid of the trigger button | | maxSizeInMB (optional, number) | 1 | maximum allowed file size | | inputId (optional, string) | input-id | id of the input element | | multiple (optional, boolean) | false | Whether to allow selecting multiple files | | allowedFileTypes (optional, string[]) | [".pdf", ".jpeg", ".png", ".jpg"] | The kinds of files to select | | pickerBtnText (optional, string) | Click here to browse files | Text of the file picker trigger button | | pickerBtnClassName (optional, string) | file-browser-button | Class to style the trigger button | | render (optional, ReactElement) | undefined | If this is defined, then the button is not rendered. It accepts an object with an onClick property | | onSelectFiles (required, function) | | A callback function that receives the array of files dropped in the hot zone |

Contributing

  1. Clone the repository
  2. Open a terminal and cd into the dev-app/ folder and package/ folder and run yarn install in both separately
  3. Linking for development. Inside package/ run npm link. Then navigate to the dev-app/ folder and run yarn link react-drag-drop-browser

Credits

  1. Publish a react component as npm module
  2. This inspired me to take a closer look at the implementation of the dragenter and dragleave events