@vue-dnd-kit/core 0.0.13 → 0.0.14
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 +149 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Vue Drag & Drop
|
|
1
|
+
# Vue Drag & Drop Library - Core Package
|
|
2
2
|
|
|
3
3
|
<p align="center">
|
|
4
4
|
<a href="https://zizigy.github.io/vue-dnd-hooks/">
|
|
@@ -20,9 +20,9 @@
|
|
|
20
20
|
Inspired by the popular <a href="https://dndkit.com/" target="_blank">React DnD Kit</a> library, adapted for Vue.js
|
|
21
21
|
</p>
|
|
22
22
|
|
|
23
|
-
##
|
|
23
|
+
## Features
|
|
24
24
|
|
|
25
|
-
###
|
|
25
|
+
### Core Capabilities
|
|
26
26
|
|
|
27
27
|
- 🎯 **Simple Composables API**
|
|
28
28
|
|
|
@@ -75,6 +75,37 @@
|
|
|
75
75
|
- Responsive design ready
|
|
76
76
|
- Dynamic constraints
|
|
77
77
|
|
|
78
|
+
### Advanced Features
|
|
79
|
+
|
|
80
|
+
- 🎯 **Smart Grouping**
|
|
81
|
+
|
|
82
|
+
- Element groups
|
|
83
|
+
- Zone filtering
|
|
84
|
+
- Nested groups
|
|
85
|
+
- Dynamic group validation
|
|
86
|
+
|
|
87
|
+
- 📊 **Rich Events System**
|
|
88
|
+
|
|
89
|
+
- Comprehensive lifecycle events
|
|
90
|
+
- Custom event handlers
|
|
91
|
+
- Drag state tracking
|
|
92
|
+
- Position coordinates
|
|
93
|
+
|
|
94
|
+
- 🛡️ **Built-in Utilities**
|
|
95
|
+
|
|
96
|
+
- Geometry calculations
|
|
97
|
+
- Bounding box tracking
|
|
98
|
+
- Position management
|
|
99
|
+
- Intersection detection
|
|
100
|
+
|
|
101
|
+
### Integration
|
|
102
|
+
|
|
103
|
+
- 🔌 **Framework Integration**
|
|
104
|
+
- Vue 3 Composition API
|
|
105
|
+
- Nuxt.js compatible
|
|
106
|
+
- Works with SSR
|
|
107
|
+
- Plugin ecosystem ready
|
|
108
|
+
|
|
78
109
|
## Installation
|
|
79
110
|
|
|
80
111
|
Choose your preferred package manager:
|
|
@@ -91,10 +122,124 @@ yarn add @vue-dnd-hooks/core
|
|
|
91
122
|
pnpm install @vue-dnd-hooks/core
|
|
92
123
|
```
|
|
93
124
|
|
|
125
|
+
## Basic Usage
|
|
126
|
+
|
|
127
|
+
### App.vue
|
|
128
|
+
|
|
129
|
+
<sup>📄 Root Application Component</sup>
|
|
130
|
+
|
|
131
|
+
```vue
|
|
132
|
+
<script setup lang="ts">
|
|
133
|
+
import { ref } from 'vue';
|
|
134
|
+
import { DragOverlay } from '@vue-dnd-hooks/core';
|
|
135
|
+
import Draggable from './components/Draggable.vue';
|
|
136
|
+
import Droppable from './components/Droppable.vue';
|
|
137
|
+
|
|
138
|
+
const handleDrop = () => (elementInDropZone.value = true);
|
|
139
|
+
|
|
140
|
+
const handleEnd = () => (elementInDropZone.value = false);
|
|
141
|
+
|
|
142
|
+
const elementInDropZone = ref<boolean>(false);
|
|
143
|
+
</script>
|
|
144
|
+
|
|
145
|
+
<template>
|
|
146
|
+
<div>
|
|
147
|
+
<Draggable v-if="!elementInDropZone"> drag me </Draggable>
|
|
148
|
+
<Droppable @drop="handleDrop">
|
|
149
|
+
<Draggable
|
|
150
|
+
v-if="elementInDropZone"
|
|
151
|
+
@end="handleEnd"
|
|
152
|
+
>
|
|
153
|
+
im in drop zone
|
|
154
|
+
</Draggable>
|
|
155
|
+
</Droppable>
|
|
156
|
+
|
|
157
|
+
<DragOverlay />
|
|
158
|
+
</div>
|
|
159
|
+
</template>
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### Draggable.vue
|
|
163
|
+
|
|
164
|
+
<sup>🧩 components/Draggable.vue</sup>
|
|
165
|
+
|
|
166
|
+
```vue
|
|
167
|
+
<script setup lang="ts">
|
|
168
|
+
import { useDraggable } from '@vue-dnd-hooks/core';
|
|
169
|
+
|
|
170
|
+
const emit = defineEmits<{
|
|
171
|
+
(e: 'end'): void;
|
|
172
|
+
}>();
|
|
173
|
+
|
|
174
|
+
const { elementRef, handleDragStart, isDragging } = useDraggable({
|
|
175
|
+
events: { onEnd: () => emit('end') },
|
|
176
|
+
});
|
|
177
|
+
</script>
|
|
178
|
+
|
|
179
|
+
<template>
|
|
180
|
+
<div
|
|
181
|
+
ref="elementRef"
|
|
182
|
+
@pointerdown="handleDragStart"
|
|
183
|
+
:class="{ dragging: isDragging }"
|
|
184
|
+
>
|
|
185
|
+
<slot />
|
|
186
|
+
</div>
|
|
187
|
+
</template>
|
|
188
|
+
|
|
189
|
+
<style scoped>
|
|
190
|
+
.dragging {
|
|
191
|
+
opacity: 0.5;
|
|
192
|
+
}
|
|
193
|
+
</style>
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### Droppable.vue
|
|
197
|
+
|
|
198
|
+
<sup>🧩 components/Droppable.vue</sup>
|
|
199
|
+
|
|
200
|
+
```vue
|
|
201
|
+
<script setup lang="ts">
|
|
202
|
+
import { useDroppable } from '@vue-dnd-hooks/core';
|
|
203
|
+
|
|
204
|
+
const emit = defineEmits<{
|
|
205
|
+
(e: 'drop'): void;
|
|
206
|
+
}>();
|
|
207
|
+
|
|
208
|
+
const { elementRef, isOvered } = useDroppable({
|
|
209
|
+
events: { onDrop: () => emit('drop') },
|
|
210
|
+
});
|
|
211
|
+
</script>
|
|
212
|
+
|
|
213
|
+
<template>
|
|
214
|
+
<div
|
|
215
|
+
ref="elementRef"
|
|
216
|
+
:class="{
|
|
217
|
+
droppable: true,
|
|
218
|
+
'is-overed': isOvered,
|
|
219
|
+
}"
|
|
220
|
+
>
|
|
221
|
+
drop here
|
|
222
|
+
<slot />
|
|
223
|
+
</div>
|
|
224
|
+
</template>
|
|
225
|
+
|
|
226
|
+
<style scoped>
|
|
227
|
+
.droppable {
|
|
228
|
+
width: 100px;
|
|
229
|
+
height: 100px;
|
|
230
|
+
border: 1px solid black;
|
|
231
|
+
}
|
|
232
|
+
.is-overed {
|
|
233
|
+
background-color: #f0f0f0;
|
|
234
|
+
border: 1px dashed red;
|
|
235
|
+
}
|
|
236
|
+
</style>
|
|
237
|
+
```
|
|
238
|
+
|
|
94
239
|
## 📄 License
|
|
95
240
|
|
|
96
241
|
[MIT](LICENSE) © [ZiZiGY](https://github.com/ZiZiGY)
|
|
97
242
|
|
|
98
243
|
---
|
|
99
244
|
|
|
100
|
-
<p align="center">Made with ❤️ for the Vue.js community</p>
|
|
245
|
+
<p align="center">Made with ❤️ for the Vue.js community</p>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue-dnd-kit/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.14",
|
|
4
4
|
"description": "Core functionality for Vue DnD Kit - a lightweight Vue 3 library for building performant and accessible drag and drop interfaces",
|
|
5
5
|
"author": "ZiZIGY",
|
|
6
6
|
"license": "MIT",
|