# react-draggable-wrapper

> HTML5 Draggable wrapper for React

Latest version **1.0.1** (published 2020-06-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-draggable-wrapper
pnpm add react-draggable-wrapper
yarn add react-draggable-wrapper
bun add react-draggable-wrapper
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2020-06-06 |
| First published | 2020-06-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 12.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Theekshana Wijesinghe |
| Maintainers | theekshanawj |
| Keywords | React, HTML5, WebAPIs, DragNDrop |

## Links

- npm: https://www.npmjs.com/package/react-draggable-wrapper
- Repository: https://github.com/theekshanawj/react-draggable-wrapper
- Homepage: https://github.com/theekshanawj/react-draggable-wrapper#readme
- Issues: https://github.com/theekshanawj/react-draggable-wrapper/issues
- npm.io page: https://npm.io/package/react-draggable-wrapper

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2020-06-06
- 1.0.0 — 2020-06-06
- 0.0.2 — 2020-06-06
- 0.0.1 — 2020-06-06

## README

# react-draggable-wrapper
React draggable wrapper component encapsulating the HTML5 Drag and Drop APIs.

## HTML5 Drag and Drop

Refer: https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API

## How to use

Import the module from [here](https://www.npmjs.com/package/react-draggable-wrapper)

```javascript
import DraggableWrapper from 'react-draggable-wrapper';
```

Wrap any React component which requires Drag and Drop feature by `DraggableWrapper`.

```javascript
<DraggableWrapper
      id={...}
      handleDragStart={...}
      handleDrop={...}
      handleDragOver={...}
    >
    <div> drag me </div>
 </DraggableWrapper>

```

## API reference 

### Props

Following props main props are accepted 

|Prop|Type|Usage|Default|
|---|---|---|---|
id|`any`| Uniquely identify a dragging element| `0` |
isDraggable|`boolean`| Allow drag and drop| `true` |
handleDragStart|`function: (event, id) => {...}`| Will trigger at `onDragStart` | - |
handleDrop|`function: (event, id) => {...}`| Will trigger at `onDrop` | - |
handleDragOver|`function: (event, id) => {...}`| Will trigger at `onDragOver` | - |
handleDragEnter|`function: (event, id) => {...}`| Will trigger at `onDragEnter` | - |
handleDragLeave|`function: (event, id) => {...}`| Will trigger at `onDragLeave` | - |
handleDragExit|`function: (event, id) => {...}`| Will trigger at `onDragExit` | - |
handleDragEnd|`function: (event, id) => {...}`| Will trigger at `onDragEnd` | - |

Other than above main props, additional props such as `style`, `data-id` can be passed to the wrapper.

### Example

A reference implementation of a row drag and drop is provided [here](https://github.com/theekshanawj/react-draggable-wrapper/blob/master/sample/App.js). Below is a screen casting of the application.

![Row and Drop](https://github.com/theekshanawj/react-draggable-wrapper/blob/read-me/sample/row-drag-n-drop.gif)

---
_Source: https://npm.io/package/react-draggable-wrapper · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
