JSPM

  • Created
  • Published
  • Downloads 13640
  • Score
    100M100P100Q158802F
  • License MIT

Package Exports

  • @rpldy/upload-drop-zone

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@rpldy/upload-drop-zone) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

npm version circleci status codecov status bundlephobia badge rpldy storybook

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')

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
children React.Node undefined child element(s) to render inside the container

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.

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={grouped}
                        maxGroupSize={groupSize}>
            <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.