1.8.0 • Published 2 months ago

@rpldy/upload-drop-zone v1.8.0

Weekly downloads
794
License
MIT
Repository
github
Last release
2 months ago

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)TypeDefaultDescription
idstringundefinedid attribute to pass to the container element
classNamestringundefinedthe class attribute to pass to the container element
onDragOverClassNamestringundefinedclass name to add to the container when dragged over
dropHandlerDropHandlerMethodundefinedoverride default handler that returns the drop result (ex: files). May return a promise
htmlDirContentParamsObjectundefinedwill be passed as is to html-dir-content. See docs
shouldRemoveDragOverShouldRemoveDragOverMethodundefinedcallback to help identify when to remove the onDragOverClassName. Receives the dragleave event
shouldHandleDragboolean or ShuoldHandleDragMethodundefinedWhether drag&drop should be handled, either boolean or method returning boolean
enableOnContainsbooleantrueBy default will handle drag-enter for children of the container and not just the container itself
childrenReact.Nodeundefinedchild element(s) to render inside the container
extraPropsObjectundefinedany 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.

1.8.0

2 months ago

1.8.0-rc.0

2 months ago

1.7.1

4 months ago

1.7.0

5 months ago

1.7.0-rc.1

5 months ago

1.7.0-rc.0

5 months ago

1.6.1

6 months ago

1.6.0

7 months ago

1.6.0-rc.0

7 months ago

1.5.0-rc.0

8 months ago

1.5.0-rc.1

8 months ago

1.5.0-rc.2

8 months ago

1.5.0-rc.3

8 months ago

1.5.0-rc.4

8 months ago

1.5.0-rc.5

8 months ago

1.5.0

8 months ago

1.6.1-rc.2

6 months ago

1.6.1-rc.0

6 months ago

1.6.1-rc.1

6 months ago

1.4.2-alpha.0

1 year ago

1.4.1

1 year ago

1.4.1-rc.0

1 year ago

1.4.0

1 year ago

1.4.0-rc.0

1 year ago

1.4.0-rc.1

1 year ago

1.3.1

1 year ago

1.2.0

2 years ago

1.3.0-rc.2

1 year ago

1.3.0-rc.3

1 year ago

1.3.0-rc.0

1 year ago

1.3.0-rc.1

1 year ago

1.3.0

1 year ago

1.1.0

2 years ago

1.0.1

2 years ago

1.1.0-rc.1

2 years ago

1.1.0-rc.0

2 years ago

1.0.0

2 years ago

0.18.3

2 years ago

0.18.1

2 years ago

0.18.2

2 years ago

0.18.0

2 years ago

0.17.2

2 years ago

0.17.3

2 years ago

0.17.4

2 years ago

0.17.5

2 years ago

0.17.0

2 years ago

0.17.1

2 years ago

0.16.1

2 years ago

0.16.2

2 years ago

0.15.0

2 years ago

0.16.0

2 years ago

0.14.2

2 years ago

0.14.0

3 years ago

0.14.1

3 years ago

0.13.6

3 years ago

0.13.5

3 years ago

0.13.4

3 years ago

0.13.3

3 years ago

0.13.1

3 years ago

0.13.2

3 years ago

0.13.0

3 years ago

0.12.1

3 years ago

0.12.0

3 years ago

0.11.5

3 years ago

0.11.6

3 years ago

0.11.4

3 years ago

0.11.2

3 years ago

0.11.3

3 years ago

0.11.3-alpha.0

3 years ago

0.11.2-alpha.0

3 years ago

0.11.0

3 years ago

0.11.1

3 years ago

0.10.0

3 years ago

0.9.0

3 years ago

0.8.3

3 years ago

0.8.2

3 years ago

0.8.1

3 years ago

0.8.0

3 years ago

0.7.4

3 years ago

0.7.3

3 years ago

0.7.2

3 years ago

0.7.1

4 years ago

0.7.0

4 years ago

0.6.0

4 years ago

0.5.0

4 years ago

0.4.1

4 years ago

0.4.0

4 years ago

0.3.2

4 years ago

0.3.0

4 years ago

0.3.1

4 years ago

0.2.4

4 years ago

0.2.3

4 years ago

0.2.2

4 years ago

0.2.1

4 years ago

0.2.0

4 years ago

0.1.12

4 years ago

0.1.11

4 years ago

0.1.10

4 years ago

0.1.9

4 years ago

0.1.8

4 years ago

0.1.7

4 years ago

0.1.6

4 years ago

0.1.5

4 years ago