react-drag-and-drop-kit 0.0.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +181 -90
- package/dist/index.d.ts +7 -5
- package/dist/react-drag-and-drop-kit.es.js +69 -69
- package/dist/react-drag-and-drop-kit.umd.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
# Drag and Drop
|
|
1
|
+
# React Drag and Drop Kit
|
|
2
2
|
|
|
3
|
-
A lightweight, easy
|
|
3
|
+
A lightweight, easy-to-use React.js library for implementing drag-and-drop functionality. This library provides simple components that wrap the native HTML5 Drag and Drop API, making it straightforward to add drag-and-drop features to your React applications.
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/react-drag-and-drop-kit)
|
|
6
6
|
[](https://www.npmjs.com/package/react-drag-and-drop-kit)
|
|
@@ -9,9 +9,10 @@ A lightweight, easy to use React.js library for implementing react-drag-and-drop
|
|
|
9
9
|
## Features
|
|
10
10
|
|
|
11
11
|
✨ **Simple and Lightweight** - Minimal API with zero dependencies (besides React)
|
|
12
|
-
🎯 **Type-Safe** - Full TypeScript support
|
|
12
|
+
🎯 **Type-Safe** - Full TypeScript support with exported types
|
|
13
13
|
🎨 **Flexible** - Use with any React component
|
|
14
|
-
📦 **Reusable** -
|
|
14
|
+
📦 **Reusable** - Pass custom data during drag operations
|
|
15
|
+
🎨 **Styleable** - Built-in support for custom styling via `style` props
|
|
15
16
|
⚡ **Performance** - Efficient implementation using native browser APIs
|
|
16
17
|
|
|
17
18
|
## Installation
|
|
@@ -58,15 +59,26 @@ function App() {
|
|
|
58
59
|
<Draggable
|
|
59
60
|
handleDragStart={handleDragStart}
|
|
60
61
|
dataTransfer={{ id: "item-1", name: "My Item" }}
|
|
62
|
+
style={{
|
|
63
|
+
padding: "20px",
|
|
64
|
+
backgroundColor: "#3498db",
|
|
65
|
+
color: "#fff",
|
|
66
|
+
cursor: "grab",
|
|
67
|
+
}}
|
|
61
68
|
>
|
|
62
|
-
|
|
69
|
+
Drag me!
|
|
63
70
|
</Draggable>
|
|
64
71
|
</div>
|
|
65
72
|
|
|
66
|
-
<DropZone
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
73
|
+
<DropZone
|
|
74
|
+
handleDropItem={handleDropItem}
|
|
75
|
+
style={{
|
|
76
|
+
padding: "20px",
|
|
77
|
+
backgroundColor: "#2ecc71",
|
|
78
|
+
minHeight: "100%",
|
|
79
|
+
}}
|
|
80
|
+
>
|
|
81
|
+
{droppedData ? `Dropped: ${JSON.stringify(droppedData)}` : "Drop here!"}
|
|
70
82
|
</DropZone>
|
|
71
83
|
</div>
|
|
72
84
|
);
|
|
@@ -83,18 +95,25 @@ Wraps any React component to make it draggable.
|
|
|
83
95
|
|
|
84
96
|
#### Props
|
|
85
97
|
|
|
86
|
-
| Prop | Type | Description
|
|
87
|
-
| ----------------- | -------------------------------------------------- |
|
|
88
|
-
| `children` | `ReactNode` | The content to be dragged
|
|
89
|
-
| `handleDragStart` | `(event: React.DragEvent<HTMLDivElement>) => void` | Callback fired when drag starts
|
|
90
|
-
| `dataTransfer` | `DataTransferInterface` | Custom data object to be transferred during
|
|
98
|
+
| Prop | Type | Required | Description |
|
|
99
|
+
| ----------------- | -------------------------------------------------- | -------- | ------------------------------------------------ |
|
|
100
|
+
| `children` | `ReactNode` | No | The content to be dragged |
|
|
101
|
+
| `handleDragStart` | `(event: React.DragEvent<HTMLDivElement>) => void` | Yes | Callback fired when drag starts |
|
|
102
|
+
| `dataTransfer` | `DataTransferInterface` | No | Custom data object to be transferred during drag |
|
|
103
|
+
| `style` | `React.CSSProperties` | No | Inline CSS styles for the draggable element |
|
|
91
104
|
|
|
92
105
|
#### Example
|
|
93
106
|
|
|
94
107
|
```tsx
|
|
95
108
|
<Draggable
|
|
96
109
|
handleDragStart={(event) => console.log("Dragging...")}
|
|
97
|
-
dataTransfer={{ itemId: 123, type: "product" }}
|
|
110
|
+
dataTransfer={{ itemId: "123", type: "product" }}
|
|
111
|
+
style={{
|
|
112
|
+
padding: "10px",
|
|
113
|
+
backgroundColor: "#3498db",
|
|
114
|
+
cursor: "grab",
|
|
115
|
+
borderRadius: "4px",
|
|
116
|
+
}}
|
|
98
117
|
>
|
|
99
118
|
<div>Draggable Item</div>
|
|
100
119
|
</Draggable>
|
|
@@ -106,10 +125,11 @@ Creates a drop target that accepts dragged items.
|
|
|
106
125
|
|
|
107
126
|
#### Props
|
|
108
127
|
|
|
109
|
-
| Prop | Type | Description
|
|
110
|
-
| ---------------- | ----------------------------------------------------------------------------------- |
|
|
111
|
-
| `children` | `ReactNode` | The content of the drop zone
|
|
112
|
-
| `handleDropItem` | `(e: React.DragEvent<HTMLDivElement>, dataTransfer: DataTransferInterface) => void` | Callback fired when an item is dropped
|
|
128
|
+
| Prop | Type | Required | Description |
|
|
129
|
+
| ---------------- | ----------------------------------------------------------------------------------- | -------- | ------------------------------------------- |
|
|
130
|
+
| `children` | `ReactNode` | No | The content of the drop zone |
|
|
131
|
+
| `handleDropItem` | `(e: React.DragEvent<HTMLDivElement>, dataTransfer: DataTransferInterface) => void` | Yes | Callback fired when an item is dropped |
|
|
132
|
+
| `style` | `React.CSSProperties` | No | Inline CSS styles for the drop zone element |
|
|
113
133
|
|
|
114
134
|
#### Example
|
|
115
135
|
|
|
@@ -118,6 +138,12 @@ Creates a drop target that accepts dragged items.
|
|
|
118
138
|
handleDropItem={(event, dataTransfer) => {
|
|
119
139
|
console.log("Dropped data:", dataTransfer);
|
|
120
140
|
}}
|
|
141
|
+
style={{
|
|
142
|
+
border: "2px dashed #667eea",
|
|
143
|
+
padding: "20px",
|
|
144
|
+
minHeight: "300px",
|
|
145
|
+
backgroundColor: "#f0f4ff",
|
|
146
|
+
}}
|
|
121
147
|
>
|
|
122
148
|
<div>Drop Target</div>
|
|
123
149
|
</DropZone>
|
|
@@ -135,6 +161,27 @@ interface DataTransferInterface {
|
|
|
135
161
|
}
|
|
136
162
|
```
|
|
137
163
|
|
|
164
|
+
#### `DraggableProps`
|
|
165
|
+
|
|
166
|
+
```typescript
|
|
167
|
+
type DraggableProps = {
|
|
168
|
+
children?: ReactNode;
|
|
169
|
+
style?: React.CSSProperties;
|
|
170
|
+
handleDragStart: (event: React.DragEvent<HTMLDivElement>) => void;
|
|
171
|
+
dataTransfer?: DataTransferInterface;
|
|
172
|
+
};
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
#### `DropZoneProps`
|
|
176
|
+
|
|
177
|
+
```typescript
|
|
178
|
+
type DropZoneProps = {
|
|
179
|
+
children?: ReactNode;
|
|
180
|
+
style?: React.CSSProperties;
|
|
181
|
+
handleDropItem: (e: React.DragEvent<HTMLDivElement>, dataTransfer: DataTransferInterface) => void;
|
|
182
|
+
};
|
|
183
|
+
```
|
|
184
|
+
|
|
138
185
|
## Real-World Example
|
|
139
186
|
|
|
140
187
|
### Shopping Cart Demo
|
|
@@ -142,7 +189,6 @@ interface DataTransferInterface {
|
|
|
142
189
|
```tsx
|
|
143
190
|
import { useState } from "react";
|
|
144
191
|
import { Draggable, DropZone, type DataTransferInterface } from "react-drag-and-drop-kit";
|
|
145
|
-
import "./App.css";
|
|
146
192
|
|
|
147
193
|
function App() {
|
|
148
194
|
const products = [
|
|
@@ -166,42 +212,42 @@ function App() {
|
|
|
166
212
|
key={product.id}
|
|
167
213
|
dataTransfer={{ id: String(product.id), name: product.name }}
|
|
168
214
|
handleDragStart={() => console.log(`Dragging ${product.name}`)}
|
|
215
|
+
style={{
|
|
216
|
+
padding: "10px",
|
|
217
|
+
margin: "10px 0",
|
|
218
|
+
backgroundColor: "#3498db",
|
|
219
|
+
color: "#fff",
|
|
220
|
+
cursor: "grab",
|
|
221
|
+
borderRadius: "4px",
|
|
222
|
+
userSelect: "none",
|
|
223
|
+
}}
|
|
169
224
|
>
|
|
170
|
-
|
|
171
|
-
style={{
|
|
172
|
-
padding: "10px",
|
|
173
|
-
margin: "10px 0",
|
|
174
|
-
backgroundColor: "#3498db",
|
|
175
|
-
color: "#fff",
|
|
176
|
-
cursor: "grab",
|
|
177
|
-
}}
|
|
178
|
-
>
|
|
179
|
-
{product.name} - {product.price}
|
|
180
|
-
</div>
|
|
225
|
+
{product.name} - {product.price}
|
|
181
226
|
</Draggable>
|
|
182
227
|
))}
|
|
183
228
|
</div>
|
|
184
229
|
|
|
185
|
-
<DropZone
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
230
|
+
<DropZone
|
|
231
|
+
handleDropItem={handleAddToCart}
|
|
232
|
+
style={{
|
|
233
|
+
flex: 1,
|
|
234
|
+
backgroundColor: "#ecf0f1",
|
|
235
|
+
padding: "20px",
|
|
236
|
+
minHeight: "500px",
|
|
237
|
+
borderRadius: "4px",
|
|
238
|
+
border: "2px dashed #bdc3c7",
|
|
239
|
+
}}
|
|
240
|
+
>
|
|
241
|
+
<h2>Shopping Cart</h2>
|
|
242
|
+
{cart.length === 0 ? (
|
|
243
|
+
<p style={{ color: "#7f8c8d" }}>Drag items here to add to cart</p>
|
|
244
|
+
) : (
|
|
245
|
+
<ul>
|
|
246
|
+
{cart.map((item, idx) => (
|
|
247
|
+
<li key={idx}>{item.name}</li>
|
|
248
|
+
))}
|
|
249
|
+
</ul>
|
|
250
|
+
)}
|
|
205
251
|
</DropZone>
|
|
206
252
|
</div>
|
|
207
253
|
);
|
|
@@ -218,59 +264,82 @@ You can have multiple drop zones and draggable items on the same page:
|
|
|
218
264
|
|
|
219
265
|
```tsx
|
|
220
266
|
<div>
|
|
221
|
-
<Draggable
|
|
222
|
-
|
|
267
|
+
<Draggable
|
|
268
|
+
dataTransfer={{ id: "1", label: "Item 1" }}
|
|
269
|
+
handleDragStart={() => {}}
|
|
270
|
+
style={{
|
|
271
|
+
padding: "10px",
|
|
272
|
+
backgroundColor: "#3498db",
|
|
273
|
+
color: "white",
|
|
274
|
+
cursor: "grab",
|
|
275
|
+
marginBottom: "10px",
|
|
276
|
+
}}
|
|
277
|
+
>
|
|
278
|
+
Item 1
|
|
223
279
|
</Draggable>
|
|
224
280
|
|
|
225
|
-
<DropZone
|
|
226
|
-
|
|
281
|
+
<DropZone
|
|
282
|
+
handleDropItem={(e, data) => console.log("Zone 1:", data)}
|
|
283
|
+
style={{
|
|
284
|
+
padding: "20px",
|
|
285
|
+
backgroundColor: "#ecf0f1",
|
|
286
|
+
minHeight: "200px",
|
|
287
|
+
marginBottom: "10px",
|
|
288
|
+
borderRadius: "4px",
|
|
289
|
+
}}
|
|
290
|
+
>
|
|
291
|
+
Drop Zone 1
|
|
227
292
|
</DropZone>
|
|
228
293
|
|
|
229
|
-
<DropZone
|
|
230
|
-
|
|
294
|
+
<DropZone
|
|
295
|
+
handleDropItem={(e, data) => console.log("Zone 2:", data)}
|
|
296
|
+
style={{
|
|
297
|
+
padding: "20px",
|
|
298
|
+
backgroundColor: "#e8f8f5",
|
|
299
|
+
minHeight: "200px",
|
|
300
|
+
borderRadius: "4px",
|
|
301
|
+
}}
|
|
302
|
+
>
|
|
303
|
+
Drop Zone 2
|
|
231
304
|
</DropZone>
|
|
232
305
|
</div>
|
|
233
306
|
```
|
|
234
307
|
|
|
235
|
-
###
|
|
308
|
+
### Drag with Custom Styling
|
|
236
309
|
|
|
237
|
-
|
|
310
|
+
Use the `style` prop to create visually appealing drag-and-drop experiences:
|
|
238
311
|
|
|
239
312
|
```tsx
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
min-height: 300px;
|
|
260
|
-
background: rgba(102, 126, 234, 0.1);
|
|
261
|
-
}
|
|
262
|
-
`}</style>
|
|
313
|
+
const draggableStyle: React.CSSProperties = {
|
|
314
|
+
padding: '15px',
|
|
315
|
+
background: 'linear-gradient(135deg, #667eea 0%, #764ba2 100%)',
|
|
316
|
+
color: 'white',
|
|
317
|
+
cursor: 'grab',
|
|
318
|
+
borderRadius: '8px',
|
|
319
|
+
boxShadow: '0 2px 8px rgba(0,0,0,0.1)',
|
|
320
|
+
transition: 'transform 0.2s, boxShadow 0.2s',
|
|
321
|
+
userSelect: 'none'
|
|
322
|
+
};
|
|
323
|
+
|
|
324
|
+
const dropZoneStyle: React.CSSProperties = {
|
|
325
|
+
padding: '20px',
|
|
326
|
+
border: '2px dashed #667eea',
|
|
327
|
+
borderRadius: '8px',
|
|
328
|
+
minHeight: '300px',
|
|
329
|
+
backgroundColor: 'rgba(102, 126, 234, 0.1)',
|
|
330
|
+
transition: 'backgroundColor 0.3s'
|
|
331
|
+
};
|
|
263
332
|
|
|
264
333
|
<Draggable
|
|
265
334
|
dataTransfer={{ id: '1' }}
|
|
266
335
|
handleDragStart={() => {}}
|
|
267
|
-
|
|
336
|
+
style={draggableStyle}
|
|
268
337
|
>
|
|
269
|
-
|
|
338
|
+
Drag me with style!
|
|
270
339
|
</Draggable>
|
|
271
340
|
|
|
272
|
-
<DropZone handleDropItem={() => {}}
|
|
273
|
-
|
|
341
|
+
<DropZone handleDropItem={() => {}} style={dropZoneStyle}>
|
|
342
|
+
Styled Drop Zone
|
|
274
343
|
</DropZone>
|
|
275
344
|
```
|
|
276
345
|
|
|
@@ -290,6 +359,12 @@ import {
|
|
|
290
359
|
const handleDrop: DropZoneProps["handleDropItem"] = (event, dataTransfer) => {
|
|
291
360
|
console.log("Dropped:", dataTransfer);
|
|
292
361
|
};
|
|
362
|
+
|
|
363
|
+
const draggableConfig: DraggableProps = {
|
|
364
|
+
handleDragStart: (e) => console.log("Start"),
|
|
365
|
+
dataTransfer: { id: "1" },
|
|
366
|
+
style: { cursor: "grab" },
|
|
367
|
+
};
|
|
293
368
|
```
|
|
294
369
|
|
|
295
370
|
## Browser Support
|
|
@@ -307,6 +382,7 @@ This library uses the HTML5 Drag and Drop API, which is supported in all modern
|
|
|
307
382
|
- The library uses React's native event system for optimal performance
|
|
308
383
|
- Drag operations are handled efficiently with minimal re-renders
|
|
309
384
|
- Data transfer is serialized to JSON, so ensure your data is serializable
|
|
385
|
+
- Inline `style` props are recommended for better performance with frequent updates
|
|
310
386
|
|
|
311
387
|
## Contributing
|
|
312
388
|
|
|
@@ -327,10 +403,19 @@ This project is licensed under the MIT License - see the LICENSE file for detail
|
|
|
327
403
|
**Sanket Kakad**
|
|
328
404
|
|
|
329
405
|
- GitHub: [@sanketskakad](https://github.com/sanketskakad)
|
|
330
|
-
- Repository: [react-drag-and-drop-kit](https://github.com/sanketskakad/react-drag-and-drop
|
|
406
|
+
- Repository: [react-drag-and-drop-kit](https://github.com/sanketskakad/react-drag-and-drop)
|
|
331
407
|
|
|
332
408
|
## Changelog
|
|
333
409
|
|
|
410
|
+
### Version 1.0.0
|
|
411
|
+
|
|
412
|
+
- ✨ Added `style` prop to both `Draggable` and `DropZone` components
|
|
413
|
+
- ✨ Made `children` and `dataTransfer` optional in component props
|
|
414
|
+
- 🎨 Improved styling flexibility with built-in React CSS properties support
|
|
415
|
+
- 📦 Package renamed to `react-drag-and-drop-kit` for clarity
|
|
416
|
+
- 📝 Enhanced documentation with type definitions
|
|
417
|
+
- 🚀 First major stable release
|
|
418
|
+
|
|
334
419
|
### Version 0.0.0
|
|
335
420
|
|
|
336
421
|
Initial release with:
|
|
@@ -343,17 +428,23 @@ Initial release with:
|
|
|
343
428
|
## FAQ
|
|
344
429
|
|
|
345
430
|
**Q: Can I drag multiple items at once?**
|
|
346
|
-
A: The current version handles single-
|
|
431
|
+
A: The current version handles single-element dragging. However, you can transfer multiple item references through the `dataTransfer` object by encoding them as comma-separated strings or JSON.
|
|
347
432
|
|
|
348
433
|
**Q: Can I customize the drag ghost image?**
|
|
349
434
|
A: Yes, you can use the `setDragImage` method in the `handleDragStart` callback on the drag event.
|
|
350
435
|
|
|
436
|
+
**Q: How do I apply custom styles to draggable and drop zone elements?**
|
|
437
|
+
A: Use the `style` prop on both `Draggable` and `DropZone` components. It accepts standard React CSS properties (`React.CSSProperties`).
|
|
438
|
+
|
|
351
439
|
**Q: Is there any CSS required?**
|
|
352
|
-
A: No, the library requires no CSS.
|
|
440
|
+
A: No, the library requires no CSS. The `style` prop allows you to add all necessary visual feedback for better UX.
|
|
353
441
|
|
|
354
442
|
**Q: What data types can I transfer?**
|
|
355
443
|
A: The `dataTransfer` object should contain string values. Convert complex types to JSON strings if needed.
|
|
356
444
|
|
|
445
|
+
**Q: Can I use the style prop with CSS-in-JS libraries?**
|
|
446
|
+
A: Yes, the `style` prop accepts any valid `React.CSSProperties` object, making it compatible with styled-components, emotion, and other CSS-in-JS solutions.
|
|
447
|
+
|
|
357
448
|
## Support
|
|
358
449
|
|
|
359
|
-
If you have any questions or issues, please open an issue on the [GitHub repository](https://github.com/sanketskakad/react-drag-and-drop
|
|
450
|
+
If you have any questions or issues, please open an issue on the [GitHub repository](https://github.com/sanketskakad/react-drag-and-drop/issues).
|
package/dist/index.d.ts
CHANGED
|
@@ -5,18 +5,20 @@ export declare interface DataTransferInterface {
|
|
|
5
5
|
[key: string]: string;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
export declare function Draggable({ children, handleDragStart, dataTransfer }: DraggableProps): JSX.Element;
|
|
8
|
+
export declare function Draggable({ children, handleDragStart, dataTransfer, style }: DraggableProps): JSX.Element;
|
|
9
9
|
|
|
10
10
|
export declare type DraggableProps = {
|
|
11
|
-
children
|
|
11
|
+
children?: ReactNode;
|
|
12
|
+
style?: React.CSSProperties;
|
|
12
13
|
handleDragStart: (event: React.DragEvent<HTMLDivElement>) => void;
|
|
13
|
-
dataTransfer
|
|
14
|
+
dataTransfer?: DataTransferInterface;
|
|
14
15
|
};
|
|
15
16
|
|
|
16
|
-
export declare function DropZone({ children, handleDropItem }: DropZoneProps): JSX.Element;
|
|
17
|
+
export declare function DropZone({ children, handleDropItem, style }: DropZoneProps): JSX.Element;
|
|
17
18
|
|
|
18
19
|
export declare type DropZoneProps = {
|
|
19
|
-
children
|
|
20
|
+
children?: ReactNode;
|
|
21
|
+
style?: React.CSSProperties;
|
|
20
22
|
handleDropItem: (e: React.DragEvent<HTMLDivElement>, dataTransfer: DataTransferInterface) => void;
|
|
21
23
|
};
|
|
22
24
|
|
|
@@ -4,29 +4,29 @@ var Y;
|
|
|
4
4
|
function re() {
|
|
5
5
|
if (Y) return E;
|
|
6
6
|
Y = 1;
|
|
7
|
-
var
|
|
8
|
-
function c
|
|
9
|
-
var
|
|
10
|
-
if (
|
|
11
|
-
|
|
12
|
-
for (var m in
|
|
13
|
-
m !== "key" && (
|
|
14
|
-
} else
|
|
15
|
-
return
|
|
16
|
-
$$typeof:
|
|
17
|
-
type:
|
|
18
|
-
key:
|
|
19
|
-
ref:
|
|
20
|
-
props:
|
|
7
|
+
var u = /* @__PURE__ */ Symbol.for("react.transitional.element"), i = /* @__PURE__ */ Symbol.for("react.fragment");
|
|
8
|
+
function l(c, a, s) {
|
|
9
|
+
var f = null;
|
|
10
|
+
if (s !== void 0 && (f = "" + s), a.key !== void 0 && (f = "" + a.key), "key" in a) {
|
|
11
|
+
s = {};
|
|
12
|
+
for (var m in a)
|
|
13
|
+
m !== "key" && (s[m] = a[m]);
|
|
14
|
+
} else s = a;
|
|
15
|
+
return a = s.ref, {
|
|
16
|
+
$$typeof: u,
|
|
17
|
+
type: c,
|
|
18
|
+
key: f,
|
|
19
|
+
ref: a !== void 0 ? a : null,
|
|
20
|
+
props: s
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
|
-
return E.Fragment = i, E.jsx =
|
|
23
|
+
return E.Fragment = i, E.jsx = l, E.jsxs = l, E;
|
|
24
24
|
}
|
|
25
25
|
var _ = {};
|
|
26
26
|
var $;
|
|
27
27
|
function te() {
|
|
28
28
|
return $ || ($ = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
29
|
-
function
|
|
29
|
+
function u(e) {
|
|
30
30
|
if (e == null) return null;
|
|
31
31
|
if (typeof e == "function")
|
|
32
32
|
return e.$$typeof === H ? null : e.displayName || e.name || null;
|
|
@@ -59,11 +59,11 @@ function te() {
|
|
|
59
59
|
var r = e.render;
|
|
60
60
|
return e = e.displayName, e || (e = r.displayName || r.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
|
|
61
61
|
case Z:
|
|
62
|
-
return r = e.displayName || null, r !== null ? r :
|
|
62
|
+
return r = e.displayName || null, r !== null ? r : u(e.type) || "Memo";
|
|
63
63
|
case T:
|
|
64
64
|
r = e._payload, e = e._init;
|
|
65
65
|
try {
|
|
66
|
-
return
|
|
66
|
+
return u(e(r));
|
|
67
67
|
} catch {
|
|
68
68
|
}
|
|
69
69
|
}
|
|
@@ -72,7 +72,7 @@ function te() {
|
|
|
72
72
|
function i(e) {
|
|
73
73
|
return "" + e;
|
|
74
74
|
}
|
|
75
|
-
function
|
|
75
|
+
function l(e) {
|
|
76
76
|
try {
|
|
77
77
|
i(e);
|
|
78
78
|
var r = !1;
|
|
@@ -81,33 +81,33 @@ function te() {
|
|
|
81
81
|
}
|
|
82
82
|
if (r) {
|
|
83
83
|
r = console;
|
|
84
|
-
var t = r.error,
|
|
84
|
+
var t = r.error, n = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
|
|
85
85
|
return t.call(
|
|
86
86
|
r,
|
|
87
87
|
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
88
|
-
|
|
88
|
+
n
|
|
89
89
|
), i(e);
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
|
-
function
|
|
92
|
+
function c(e) {
|
|
93
93
|
if (e === b) return "<>";
|
|
94
94
|
if (typeof e == "object" && e !== null && e.$$typeof === T)
|
|
95
95
|
return "<...>";
|
|
96
96
|
try {
|
|
97
|
-
var r =
|
|
97
|
+
var r = u(e);
|
|
98
98
|
return r ? "<" + r + ">" : "<...>";
|
|
99
99
|
} catch {
|
|
100
100
|
return "<...>";
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
|
-
function
|
|
103
|
+
function a() {
|
|
104
104
|
var e = k.A;
|
|
105
105
|
return e === null ? null : e.getOwner();
|
|
106
106
|
}
|
|
107
|
-
function
|
|
107
|
+
function s() {
|
|
108
108
|
return Error("react-stack-top-frame");
|
|
109
109
|
}
|
|
110
|
-
function
|
|
110
|
+
function f(e) {
|
|
111
111
|
if (j.call(e, "key")) {
|
|
112
112
|
var r = Object.getOwnPropertyDescriptor(e, "key").get;
|
|
113
113
|
if (r && r.isReactWarning) return !1;
|
|
@@ -127,20 +127,20 @@ function te() {
|
|
|
127
127
|
});
|
|
128
128
|
}
|
|
129
129
|
function L() {
|
|
130
|
-
var e =
|
|
130
|
+
var e = u(this.type);
|
|
131
131
|
return h[e] || (h[e] = !0, console.error(
|
|
132
132
|
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
|
|
133
133
|
)), e = this.props.ref, e !== void 0 ? e : null;
|
|
134
134
|
}
|
|
135
|
-
function M(e, r, t,
|
|
136
|
-
var
|
|
135
|
+
function M(e, r, t, n, R, S) {
|
|
136
|
+
var o = t.ref;
|
|
137
137
|
return e = {
|
|
138
138
|
$$typeof: y,
|
|
139
139
|
type: e,
|
|
140
140
|
key: r,
|
|
141
141
|
props: t,
|
|
142
|
-
_owner:
|
|
143
|
-
}, (
|
|
142
|
+
_owner: n
|
|
143
|
+
}, (o !== void 0 ? o : null) !== null ? Object.defineProperty(e, "ref", {
|
|
144
144
|
enumerable: !1,
|
|
145
145
|
get: L
|
|
146
146
|
}) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", {
|
|
@@ -165,50 +165,50 @@ function te() {
|
|
|
165
165
|
value: S
|
|
166
166
|
}), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
|
|
167
167
|
}
|
|
168
|
-
function A(e, r, t,
|
|
169
|
-
var
|
|
170
|
-
if (
|
|
171
|
-
if (
|
|
172
|
-
if (Q(
|
|
173
|
-
for (
|
|
174
|
-
P(n
|
|
175
|
-
Object.freeze && Object.freeze(
|
|
168
|
+
function A(e, r, t, n, R, S) {
|
|
169
|
+
var o = r.children;
|
|
170
|
+
if (o !== void 0)
|
|
171
|
+
if (n)
|
|
172
|
+
if (Q(o)) {
|
|
173
|
+
for (n = 0; n < o.length; n++)
|
|
174
|
+
P(o[n]);
|
|
175
|
+
Object.freeze && Object.freeze(o);
|
|
176
176
|
} else
|
|
177
177
|
console.error(
|
|
178
178
|
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
|
179
179
|
);
|
|
180
|
-
else P(
|
|
180
|
+
else P(o);
|
|
181
181
|
if (j.call(r, "key")) {
|
|
182
|
-
|
|
183
|
-
var
|
|
182
|
+
o = u(e);
|
|
183
|
+
var d = Object.keys(r).filter(function(K) {
|
|
184
184
|
return K !== "key";
|
|
185
185
|
});
|
|
186
|
-
|
|
186
|
+
n = 0 < d.length ? "{key: someKey, " + d.join(": ..., ") + ": ...}" : "{key: someKey}", C[o + n] || (d = 0 < d.length ? "{" + d.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
187
187
|
`A props object containing a "key" prop is being spread into JSX:
|
|
188
188
|
let props = %s;
|
|
189
189
|
<%s {...props} />
|
|
190
190
|
React keys must be passed directly to JSX without using spread:
|
|
191
191
|
let props = %s;
|
|
192
192
|
<%s key={someKey} {...props} />`,
|
|
193
|
-
a,
|
|
194
193
|
n,
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
194
|
+
o,
|
|
195
|
+
d,
|
|
196
|
+
o
|
|
197
|
+
), C[o + n] = !0);
|
|
198
198
|
}
|
|
199
|
-
if (
|
|
199
|
+
if (o = null, t !== void 0 && (l(t), o = "" + t), f(r) && (l(r.key), o = "" + r.key), "key" in r) {
|
|
200
200
|
t = {};
|
|
201
201
|
for (var g in r)
|
|
202
202
|
g !== "key" && (t[g] = r[g]);
|
|
203
203
|
} else t = r;
|
|
204
|
-
return
|
|
204
|
+
return o && m(
|
|
205
205
|
t,
|
|
206
206
|
typeof e == "function" ? e.displayName || e.name || "Unknown" : e
|
|
207
207
|
), M(
|
|
208
208
|
e,
|
|
209
|
-
|
|
209
|
+
o,
|
|
210
210
|
t,
|
|
211
|
-
|
|
211
|
+
a(),
|
|
212
212
|
R,
|
|
213
213
|
S
|
|
214
214
|
);
|
|
@@ -229,27 +229,27 @@ React keys must be passed directly to JSX without using spread:
|
|
|
229
229
|
};
|
|
230
230
|
var w, h = {}, N = v.react_stack_bottom_frame.bind(
|
|
231
231
|
v,
|
|
232
|
-
|
|
233
|
-
)(), D = O(s
|
|
232
|
+
s
|
|
233
|
+
)(), D = O(c(s)), C = {};
|
|
234
234
|
_.Fragment = b, _.jsx = function(e, r, t) {
|
|
235
|
-
var
|
|
235
|
+
var n = 1e4 > k.recentlyCreatedOwnerStacks++;
|
|
236
236
|
return A(
|
|
237
237
|
e,
|
|
238
238
|
r,
|
|
239
239
|
t,
|
|
240
240
|
!1,
|
|
241
|
-
|
|
242
|
-
|
|
241
|
+
n ? Error("react-stack-top-frame") : N,
|
|
242
|
+
n ? O(c(e)) : D
|
|
243
243
|
);
|
|
244
244
|
}, _.jsxs = function(e, r, t) {
|
|
245
|
-
var
|
|
245
|
+
var n = 1e4 > k.recentlyCreatedOwnerStacks++;
|
|
246
246
|
return A(
|
|
247
247
|
e,
|
|
248
248
|
r,
|
|
249
249
|
t,
|
|
250
250
|
!0,
|
|
251
|
-
|
|
252
|
-
|
|
251
|
+
n ? Error("react-stack-top-frame") : N,
|
|
252
|
+
n ? O(c(e)) : D
|
|
253
253
|
);
|
|
254
254
|
};
|
|
255
255
|
})()), _;
|
|
@@ -259,19 +259,19 @@ function ae() {
|
|
|
259
259
|
return I || (I = 1, process.env.NODE_ENV === "production" ? p.exports = re() : p.exports = te()), p.exports;
|
|
260
260
|
}
|
|
261
261
|
var F = ae();
|
|
262
|
-
function oe({ children:
|
|
263
|
-
const
|
|
264
|
-
|
|
262
|
+
function oe({ children: u, handleDragStart: i, dataTransfer: l, style: c }) {
|
|
263
|
+
const a = (s) => {
|
|
264
|
+
s.dataTransfer.setData("dataTransfer", JSON.stringify(l)), i(s);
|
|
265
265
|
};
|
|
266
|
-
return /* @__PURE__ */ F.jsx("div", { draggable: "true", onDragStart:
|
|
266
|
+
return /* @__PURE__ */ F.jsx("div", { style: c, draggable: "true", onDragStart: a, children: u });
|
|
267
267
|
}
|
|
268
|
-
function se({ children:
|
|
269
|
-
const c = (
|
|
270
|
-
|
|
271
|
-
const
|
|
272
|
-
i(
|
|
268
|
+
function se({ children: u, handleDropItem: i, style: l }) {
|
|
269
|
+
const c = (a) => {
|
|
270
|
+
a.preventDefault();
|
|
271
|
+
const s = a.dataTransfer.getData("dataTransfer"), f = JSON.parse(s);
|
|
272
|
+
i(a, f);
|
|
273
273
|
};
|
|
274
|
-
return /* @__PURE__ */ F.jsx("div", { onDragOver: (
|
|
274
|
+
return /* @__PURE__ */ F.jsx("div", { style: l, onDragOver: (a) => a.preventDefault(), onDrop: c, children: u });
|
|
275
275
|
}
|
|
276
276
|
export {
|
|
277
277
|
oe as Draggable,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
(function(i,
|
|
1
|
+
(function(i,E){typeof exports=="object"&&typeof module<"u"?E(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],E):(i=typeof globalThis<"u"?globalThis:i||self,E(i.DragAndDropKit={},i.React))})(this,(function(i,E){"use strict";var v={exports:{}},_={};var P;function W(){if(P)return _;P=1;var u=Symbol.for("react.transitional.element"),f=Symbol.for("react.fragment");function l(c,n,s){var d=null;if(s!==void 0&&(d=""+s),n.key!==void 0&&(d=""+n.key),"key"in n){s={};for(var b in n)b!=="key"&&(s[b]=n[b])}else s=n;return n=s.ref,{$$typeof:u,type:c,key:d,ref:n!==void 0?n:null,props:s}}return _.Fragment=f,_.jsx=l,_.jsxs=l,_}var p={};var j;function J(){return j||(j=1,process.env.NODE_ENV!=="production"&&(function(){function u(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===ae?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case g:return"Fragment";case B:return"Profiler";case Z:return"StrictMode";case ee:return"Suspense";case re:return"SuspenseList";case ne:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case X:return"Portal";case Q:return e.displayName||"Context";case H:return(e._context.displayName||"Context")+".Consumer";case K:var r=e.render;return e=e.displayName,e||(e=r.displayName||r.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case te:return r=e.displayName||null,r!==null?r:u(e.type)||"Memo";case k:r=e._payload,e=e._init;try{return u(e(r))}catch{}}return null}function f(e){return""+e}function l(e){try{f(e);var r=!1}catch{r=!0}if(r){r=console;var t=r.error,a=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return t.call(r,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",a),f(e)}}function c(e){if(e===g)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===k)return"<...>";try{var r=u(e);return r?"<"+r+">":"<...>"}catch{return"<...>"}}function n(){var e=O.A;return e===null?null:e.getOwner()}function s(){return Error("react-stack-top-frame")}function d(e){if(Y.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function b(e,r){function t(){I||(I=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",r))}t.isReactWarning=!0,Object.defineProperty(e,"key",{get:t,configurable:!0})}function z(){var e=u(this.type);return $[e]||($[e]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),e=this.props.ref,e!==void 0?e:null}function G(e,r,t,a,T,y){var o=t.ref;return e={$$typeof:C,type:e,key:r,props:t,_owner:a},(o!==void 0?o:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:z}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:T}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:y}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function w(e,r,t,a,T,y){var o=r.children;if(o!==void 0)if(a)if(oe(o)){for(a=0;a<o.length;a++)N(o[a]);Object.freeze&&Object.freeze(o)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else N(o);if(Y.call(r,"key")){o=u(e);var m=Object.keys(r).filter(function(se){return se!=="key"});a=0<m.length?"{key: someKey, "+m.join(": ..., ")+": ...}":"{key: someKey}",L[o+a]||(m=0<m.length?"{"+m.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
2
2
|
let props = %s;
|
|
3
3
|
<%s {...props} />
|
|
4
4
|
React keys must be passed directly to JSX without using spread:
|
|
5
5
|
let props = %s;
|
|
6
|
-
<%s key={someKey} {...props} />`,
|
|
6
|
+
<%s key={someKey} {...props} />`,a,o,m,o),L[o+a]=!0)}if(o=null,t!==void 0&&(l(t),o=""+t),d(r)&&(l(r.key),o=""+r.key),"key"in r){t={};for(var A in r)A!=="key"&&(t[A]=r[A])}else t=r;return o&&b(t,typeof e=="function"?e.displayName||e.name||"Unknown":e),G(e,o,t,n(),T,y)}function N(e){D(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===k&&(e._payload.status==="fulfilled"?D(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function D(e){return typeof e=="object"&&e!==null&&e.$$typeof===C}var R=E,C=Symbol.for("react.transitional.element"),X=Symbol.for("react.portal"),g=Symbol.for("react.fragment"),Z=Symbol.for("react.strict_mode"),B=Symbol.for("react.profiler"),H=Symbol.for("react.consumer"),Q=Symbol.for("react.context"),K=Symbol.for("react.forward_ref"),ee=Symbol.for("react.suspense"),re=Symbol.for("react.suspense_list"),te=Symbol.for("react.memo"),k=Symbol.for("react.lazy"),ne=Symbol.for("react.activity"),ae=Symbol.for("react.client.reference"),O=R.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Y=Object.prototype.hasOwnProperty,oe=Array.isArray,S=console.createTask?console.createTask:function(){return null};R={react_stack_bottom_frame:function(e){return e()}};var I,$={},F=R.react_stack_bottom_frame.bind(R,s)(),M=S(c(s)),L={};p.Fragment=g,p.jsx=function(e,r,t){var a=1e4>O.recentlyCreatedOwnerStacks++;return w(e,r,t,!1,a?Error("react-stack-top-frame"):F,a?S(c(e)):M)},p.jsxs=function(e,r,t){var a=1e4>O.recentlyCreatedOwnerStacks++;return w(e,r,t,!0,a?Error("react-stack-top-frame"):F,a?S(c(e)):M)}})()),p}var h;function U(){return h||(h=1,process.env.NODE_ENV==="production"?v.exports=W():v.exports=J()),v.exports}var x=U();function q({children:u,handleDragStart:f,dataTransfer:l,style:c}){const n=s=>{s.dataTransfer.setData("dataTransfer",JSON.stringify(l)),f(s)};return x.jsx("div",{style:c,draggable:"true",onDragStart:n,children:u})}function V({children:u,handleDropItem:f,style:l}){const c=n=>{n.preventDefault();const s=n.dataTransfer.getData("dataTransfer"),d=JSON.parse(s);f(n,d)};return x.jsx("div",{style:l,onDragOver:n=>n.preventDefault(),onDrop:c,children:u})}i.Draggable=q,i.DropZone=V,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})}));
|
package/package.json
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
"url": "https://github.com/sanketskakad/react-drag-and-drop"
|
|
8
8
|
},
|
|
9
9
|
"private": false,
|
|
10
|
-
"version": "
|
|
10
|
+
"version": "1.0.0",
|
|
11
11
|
"description": "An open source, lightweight React.js library for implementing simple and flexible react-drag-and-drop functionality.",
|
|
12
12
|
"keywords": [
|
|
13
13
|
"react",
|