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

@rpldy/upload-drop-zone

v1.8.0

Published

drop zone (container) component to initiate file and folder content uploads

Downloads

26,341

Readme

Upload Drop Zone

Drop zone (container) component to initiate file and folder content uploads Supports individual files as well as recursively iterating over a dropped directory to upload its contents.

Uses html-dir-content to process the files/directories in the DnD events (DataTransferItem).

Can easily be combined with other D&D solutions.

Drop Zones can use different configuration overrides that supersede the options passed to the parent Uploady.

Note: Some options cannot be overriden by the button. For example, any prop that influences the file input directly (such as 'multiple')

The best place to get started is at our: React-Uploady Documentation Website

Installation

#Yarn: 
   $ yarn add @rpldy/uploady @rpldy/upload-drop-zone 

#NPM:
   $ npm i @rpldy/uploady @rpldy/upload-drop-zone 

Props

| Name (* = mandatory) | Type | Default | Description | |----------------------|-----------------------------------------------------|-----------|----------------------------------------------------------------------------------------------------------| | id | string | undefined | id attribute to pass to the container element | | className | string | undefined | the class attribute to pass to the container element | | onDragOverClassName | string | undefined | class name to add to the container when dragged over | | dropHandler | DropHandlerMethod | undefined | override default handler that returns the drop result (ex: files). May return a promise | | htmlDirContentParams | Object | undefined | will be passed as is to html-dir-content. See docs | | shouldRemoveDragOver | ShouldRemoveDragOverMethod | undefined | callback to help identify when to remove the onDragOverClassName. Receives the dragleave event | | shouldHandleDrag | boolean or ShuoldHandleDragMethod | undefined | Whether drag&drop should be handled, either boolean or method returning boolean | | enableOnContains | boolean | true | By default will handle drag-enter for children of the container and not just the container itself | | children | React.Node | undefined | child element(s) to render inside the container | | extraProps | Object | undefined | any other props to pass to the div component (with spread) |

In addition, most UploadOptions props can be passed to UploadDropZone. In order to override configuration passed to the parent Uploady component. See Uploady documentation for detailed list of upload options.

shouldHandleDrag

Can be a boolean or a method returning a boolean. In case of a method, the drag event will be provided as a param.

In case shouldHandleDrag === false, the drag&drop flow will not be handled by this component. In case you want to enable logic to determine whether drag&drop will be enabled, pass a callback for this prop. Returning a Falsy value will disable DnD, returning Truthy will keep it enabled.

dropHandler

By default, handles Drop event by calling getFilesFromDragEvent from html-dir-content.

In case you want to provide your own logic that will calculate the items(files) passed to the uploader from the drop event, pass in a custom handler.

You can still get the files as the internal method does, by calling getFiles passed to the custom dropHandler as the second param.

shouldRemoveDragOver

Gives more control over when to recognize drag-over is done and indicator should be cleared

See further explanation on our doc site

Example

Simple example, shows how upload options can be passed to the drop-zone (grouped, maxGroupSize).


import Uploady from "@rpldy/uploady";
import UploadDropZone from "@rpldy/upload-drop-zone";

const App = () => (
    <Uploady destination={destination}>
        <UploadDropZone onDragOverClassName="drag-over"
                        grouped
                        maxGroupSize={3}
        >
            <span>Drag&Drop File(s) Here</span>            
        </UploadDropZone>
    </Uploady>);

See story showing how to use a 3rd library: react-dnd together with @rpldy/upload-drop-zone.