@vue-dnd-kit/core 1.3.3 → 1.4.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/LICENSE +21 -21
- package/README.md +305 -305
- package/dist/index.d.ts +19 -11
- package/dist/vue-dnd-kit-core.cjs.js +1 -1
- package/dist/vue-dnd-kit-core.cjs.js.map +1 -1
- package/dist/vue-dnd-kit-core.es.js +412 -398
- package/dist/vue-dnd-kit-core.es.js.map +1 -1
- package/package.json +73 -73
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2024 ZiZiGY
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 ZiZiGY
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,305 +1,305 @@
|
|
|
1
|
-
# Vue Drag & Drop Library - Core Package
|
|
2
|
-
|
|
3
|
-
[](https://github.com/zizigy/vue-dnd-kit)
|
|
4
|
-
|
|
5
|
-
<p align="center">
|
|
6
|
-
<a href="https://zizigy.github.io/vue-dnd-kit/">
|
|
7
|
-
<img src="https://raw.githubusercontent.com/ZiZiGY/vue-dnd-kit/master/public/logo.svg" width="400" alt="Vue Drag & Drop Logo">
|
|
8
|
-
</a>
|
|
9
|
-
</p>
|
|
10
|
-
|
|
11
|
-
<p align="center">
|
|
12
|
-
Core package of the Vue Drag & Drop library with essential hooks and functionality.
|
|
13
|
-
</p>
|
|
14
|
-
|
|
15
|
-
<p align="center">
|
|
16
|
-
<a href="https://zizigy.github.io/vue-dnd-kit/" target="_blank">
|
|
17
|
-
<img src="https://img.shields.io/badge/Documentation-Visit-blue?style=flat-square" alt="Documentation">
|
|
18
|
-
</a>
|
|
19
|
-
</p>
|
|
20
|
-
|
|
21
|
-
<p align="center">
|
|
22
|
-
Inspired by the popular <a href="https://dndkit.com/" target="_blank">React DnD Kit</a> library, adapted for Vue.js
|
|
23
|
-
</p>
|
|
24
|
-
|
|
25
|
-
## Lightweight & High Performance
|
|
26
|
-
|
|
27
|
-
Vue DnD Kit is designed to be extremely lightweight while delivering exceptional performance. The library has been optimized for:
|
|
28
|
-
|
|
29
|
-
- 🚀 **Minimal bundle size** - keep your application fast and responsive
|
|
30
|
-
- ⚡ **Efficient DOM operations** - optimized for handling large lists and complex interactions
|
|
31
|
-
- 🔄 **Smart rendering** - prevents unnecessary re-renders during drag operations
|
|
32
|
-
- 📱 **Smooth experience** - even on mobile and low-powered devices
|
|
33
|
-
|
|
34
|
-
## Unlimited Flexibility
|
|
35
|
-
|
|
36
|
-
The library is built with flexibility as a core principle, allowing you to implement virtually any drag and drop scenario:
|
|
37
|
-
|
|
38
|
-
- 🎯 **Any UI pattern** - sortable lists, kanban boards, calendars, file uploads, and more
|
|
39
|
-
- 🎨 **Any design system** - works with any UI library or custom components
|
|
40
|
-
- 📐 **Any layout** - grid, flex, or custom positioning systems
|
|
41
|
-
- 🔄 **Any interaction model** - simple drag and drop, multi-select, nested containers
|
|
42
|
-
|
|
43
|
-
## Features
|
|
44
|
-
|
|
45
|
-
### Core Capabilities
|
|
46
|
-
|
|
47
|
-
- 🎯 **Simple Composables API**
|
|
48
|
-
|
|
49
|
-
- Intuitive hooks-based approach
|
|
50
|
-
- Clean and declarative syntax
|
|
51
|
-
- Minimal boilerplate code
|
|
52
|
-
|
|
53
|
-
- 🎨 **Full Customization**
|
|
54
|
-
|
|
55
|
-
- Custom drag overlays
|
|
56
|
-
- Flexible styling system
|
|
57
|
-
- Animation support
|
|
58
|
-
- Custom drag handles
|
|
59
|
-
|
|
60
|
-
- 📱 **Advanced Input Support**
|
|
61
|
-
|
|
62
|
-
- Touch devices support
|
|
63
|
-
- Mouse events
|
|
64
|
-
- Multi-touch gestures
|
|
65
|
-
- **Full keyboard navigation** - complete drag and drop operations using only keyboard
|
|
66
|
-
|
|
67
|
-
### Accessibility
|
|
68
|
-
|
|
69
|
-
- ♿ **Keyboard Navigation**
|
|
70
|
-
|
|
71
|
-
- Start and control drag operations with keyboard
|
|
72
|
-
- Arrow keys for movement
|
|
73
|
-
- Space/Enter for selection and dropping
|
|
74
|
-
- Escape to cancel drag operations
|
|
75
|
-
- Tab navigation between draggable elements
|
|
76
|
-
|
|
77
|
-
- 🔍 **Screen Reader Support**
|
|
78
|
-
|
|
79
|
-
- ARIA attributes for drag and drop operations
|
|
80
|
-
- Descriptive announcements during interactions
|
|
81
|
-
- Semantic HTML structure
|
|
82
|
-
|
|
83
|
-
### Performance
|
|
84
|
-
|
|
85
|
-
- ⚡ **Optimized Rendering**
|
|
86
|
-
|
|
87
|
-
- Virtual DOM friendly
|
|
88
|
-
- Minimal re-renders
|
|
89
|
-
- Efficient DOM updates
|
|
90
|
-
- Memory leak prevention
|
|
91
|
-
|
|
92
|
-
- 🔄 **Smart Auto-scrolling**
|
|
93
|
-
|
|
94
|
-
- Smooth scroll animations
|
|
95
|
-
- Configurable thresholds
|
|
96
|
-
- Performance-optimized
|
|
97
|
-
- Works with nested scrollable containers
|
|
98
|
-
|
|
99
|
-
### Developer Experience
|
|
100
|
-
|
|
101
|
-
- 🔍 **TypeScript Ready**
|
|
102
|
-
|
|
103
|
-
- Full type coverage
|
|
104
|
-
- Type inference
|
|
105
|
-
- IDE autocompletion
|
|
106
|
-
- Type-safe events
|
|
107
|
-
|
|
108
|
-
- 📐 **Layout Features**
|
|
109
|
-
|
|
110
|
-
- Grid system support
|
|
111
|
-
- Flex layout compatible
|
|
112
|
-
- Responsive design ready
|
|
113
|
-
- Dynamic constraints
|
|
114
|
-
|
|
115
|
-
### Advanced Features
|
|
116
|
-
|
|
117
|
-
- 🎯 **Smart Grouping**
|
|
118
|
-
|
|
119
|
-
- Element groups
|
|
120
|
-
- Zone filtering
|
|
121
|
-
- Nested groups
|
|
122
|
-
- Dynamic group validation
|
|
123
|
-
|
|
124
|
-
- 📊 **Rich Events System**
|
|
125
|
-
|
|
126
|
-
- Comprehensive lifecycle events
|
|
127
|
-
- Custom event handlers
|
|
128
|
-
- Drag state tracking
|
|
129
|
-
- Position coordinates
|
|
130
|
-
|
|
131
|
-
- 🛡️ **Built-in Utilities**
|
|
132
|
-
|
|
133
|
-
- Geometry calculations
|
|
134
|
-
- Bounding box tracking
|
|
135
|
-
- Position management
|
|
136
|
-
- Intersection detection
|
|
137
|
-
|
|
138
|
-
### Integration
|
|
139
|
-
|
|
140
|
-
- 🔌 **Framework Integration**
|
|
141
|
-
- Vue 3 Composition API
|
|
142
|
-
- Nuxt.js compatible
|
|
143
|
-
- Works with SSR
|
|
144
|
-
- Plugin ecosystem ready
|
|
145
|
-
|
|
146
|
-
## Installation
|
|
147
|
-
|
|
148
|
-
Choose your preferred package manager:
|
|
149
|
-
|
|
150
|
-
```bash
|
|
151
|
-
npm install @vue-dnd-kit/core @vueuse/core
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
```bash
|
|
155
|
-
yarn add @vue-dnd-kit/core @vueuse/core
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
```bash
|
|
159
|
-
pnpm install @vue-dnd-kit/core @vueuse/core
|
|
160
|
-
```
|
|
161
|
-
|
|
162
|
-
## Setup as a Plugin
|
|
163
|
-
|
|
164
|
-
You can register the library as a Vue plugin in your main.ts/js file:
|
|
165
|
-
|
|
166
|
-
```typescript
|
|
167
|
-
import { createApp } from 'vue';
|
|
168
|
-
import App from './App.vue';
|
|
169
|
-
import VueDnDKitPlugin from '@vue-dnd-kit/core';
|
|
170
|
-
|
|
171
|
-
const app = createApp(App);
|
|
172
|
-
|
|
173
|
-
// Register the plugin
|
|
174
|
-
app.use(VueDnDKitPlugin);
|
|
175
|
-
|
|
176
|
-
app.mount('#app');
|
|
177
|
-
```
|
|
178
|
-
|
|
179
|
-
This will make all the components and composables globally available in your application.
|
|
180
|
-
|
|
181
|
-
## Basic Usage
|
|
182
|
-
|
|
183
|
-
### App.vue
|
|
184
|
-
|
|
185
|
-
<sup>📄 Root Application Component</sup>
|
|
186
|
-
|
|
187
|
-
```vue
|
|
188
|
-
<script setup lang="ts">
|
|
189
|
-
import { ref } from 'vue';
|
|
190
|
-
import Draggable from './components/Draggable.vue';
|
|
191
|
-
import Droppable from './components/Droppable.vue';
|
|
192
|
-
|
|
193
|
-
const handleDrop = () => (elementInDropZone.value = true);
|
|
194
|
-
|
|
195
|
-
const handleEnd = () => (elementInDropZone.value = false);
|
|
196
|
-
|
|
197
|
-
const elementInDropZone = ref<boolean>(false);
|
|
198
|
-
</script>
|
|
199
|
-
|
|
200
|
-
<template>
|
|
201
|
-
<div>
|
|
202
|
-
<Draggable v-if="!elementInDropZone"> drag me </Draggable>
|
|
203
|
-
<Droppable @drop="handleDrop">
|
|
204
|
-
<Draggable
|
|
205
|
-
v-if="elementInDropZone"
|
|
206
|
-
@end="handleEnd"
|
|
207
|
-
>
|
|
208
|
-
im in drop zone
|
|
209
|
-
</Draggable>
|
|
210
|
-
</Droppable>
|
|
211
|
-
</div>
|
|
212
|
-
</template>
|
|
213
|
-
```
|
|
214
|
-
|
|
215
|
-
### Draggable.vue
|
|
216
|
-
|
|
217
|
-
<sup>🧩 components/Draggable.vue</sup>
|
|
218
|
-
|
|
219
|
-
```vue
|
|
220
|
-
<script setup lang="ts">
|
|
221
|
-
import { useDraggable } from '@vue-dnd-kit/core';
|
|
222
|
-
|
|
223
|
-
const emit = defineEmits<{
|
|
224
|
-
(e: 'end'): void;
|
|
225
|
-
}>();
|
|
226
|
-
|
|
227
|
-
const { elementRef, handleDragStart, isDragging } = useDraggable({
|
|
228
|
-
events: { onEnd: () => emit('end') },
|
|
229
|
-
});
|
|
230
|
-
</script>
|
|
231
|
-
|
|
232
|
-
<template>
|
|
233
|
-
<div
|
|
234
|
-
ref="elementRef"
|
|
235
|
-
@pointerdown="handleDragStart"
|
|
236
|
-
:class="{ dragging: isDragging }"
|
|
237
|
-
tabindex="0"
|
|
238
|
-
role="button"
|
|
239
|
-
aria-grabbed="false"
|
|
240
|
-
:aria-pressed="isDragging"
|
|
241
|
-
>
|
|
242
|
-
<slot />
|
|
243
|
-
</div>
|
|
244
|
-
</template>
|
|
245
|
-
|
|
246
|
-
<style scoped>
|
|
247
|
-
.dragging {
|
|
248
|
-
opacity: 0.5;
|
|
249
|
-
}
|
|
250
|
-
</style>
|
|
251
|
-
```
|
|
252
|
-
|
|
253
|
-
### Droppable.vue
|
|
254
|
-
|
|
255
|
-
<sup>🧩 components/Droppable.vue</sup>
|
|
256
|
-
|
|
257
|
-
```vue
|
|
258
|
-
<script setup lang="ts">
|
|
259
|
-
import { useDroppable } from '@vue-dnd-kit/core';
|
|
260
|
-
|
|
261
|
-
const emit = defineEmits<{
|
|
262
|
-
(e: 'drop'): void;
|
|
263
|
-
}>();
|
|
264
|
-
|
|
265
|
-
const { elementRef, isOvered } = useDroppable({
|
|
266
|
-
events: { onDrop: () => emit('drop') },
|
|
267
|
-
});
|
|
268
|
-
</script>
|
|
269
|
-
|
|
270
|
-
<template>
|
|
271
|
-
<div
|
|
272
|
-
ref="elementRef"
|
|
273
|
-
:class="{
|
|
274
|
-
droppable: true,
|
|
275
|
-
'is-overed': isOvered,
|
|
276
|
-
}"
|
|
277
|
-
role="region"
|
|
278
|
-
aria-dropeffect="move"
|
|
279
|
-
>
|
|
280
|
-
drop here
|
|
281
|
-
<slot />
|
|
282
|
-
</div>
|
|
283
|
-
</template>
|
|
284
|
-
|
|
285
|
-
<style scoped>
|
|
286
|
-
.droppable {
|
|
287
|
-
width: 100px;
|
|
288
|
-
height: 100px;
|
|
289
|
-
border: 1px solid black;
|
|
290
|
-
}
|
|
291
|
-
.is-overed {
|
|
292
|
-
background-color: #f0f0f0;
|
|
293
|
-
border: 1px dashed red;
|
|
294
|
-
}
|
|
295
|
-
</style>
|
|
296
|
-
```
|
|
297
|
-
|
|
298
|
-
## 📄 License
|
|
299
|
-
|
|
300
|
-
[MIT](LICENSE) © [ZiZiGY](https://github.com/ZiZiGY)
|
|
301
|
-
|
|
302
|
-
---
|
|
303
|
-
|
|
304
|
-
<p align="center">🎉 Congratulations on the official release! 🎉</p>
|
|
305
|
-
<p align="center">Made with ❤️ for the Vue.js community</p>
|
|
1
|
+
# Vue Drag & Drop Library - Core Package
|
|
2
|
+
|
|
3
|
+
[](https://github.com/zizigy/vue-dnd-kit)
|
|
4
|
+
|
|
5
|
+
<p align="center">
|
|
6
|
+
<a href="https://zizigy.github.io/vue-dnd-kit/">
|
|
7
|
+
<img src="https://raw.githubusercontent.com/ZiZiGY/vue-dnd-kit/master/public/logo.svg" width="400" alt="Vue Drag & Drop Logo">
|
|
8
|
+
</a>
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
Core package of the Vue Drag & Drop library with essential hooks and functionality.
|
|
13
|
+
</p>
|
|
14
|
+
|
|
15
|
+
<p align="center">
|
|
16
|
+
<a href="https://zizigy.github.io/vue-dnd-kit/" target="_blank">
|
|
17
|
+
<img src="https://img.shields.io/badge/Documentation-Visit-blue?style=flat-square" alt="Documentation">
|
|
18
|
+
</a>
|
|
19
|
+
</p>
|
|
20
|
+
|
|
21
|
+
<p align="center">
|
|
22
|
+
Inspired by the popular <a href="https://dndkit.com/" target="_blank">React DnD Kit</a> library, adapted for Vue.js
|
|
23
|
+
</p>
|
|
24
|
+
|
|
25
|
+
## Lightweight & High Performance
|
|
26
|
+
|
|
27
|
+
Vue DnD Kit is designed to be extremely lightweight while delivering exceptional performance. The library has been optimized for:
|
|
28
|
+
|
|
29
|
+
- 🚀 **Minimal bundle size** - keep your application fast and responsive
|
|
30
|
+
- ⚡ **Efficient DOM operations** - optimized for handling large lists and complex interactions
|
|
31
|
+
- 🔄 **Smart rendering** - prevents unnecessary re-renders during drag operations
|
|
32
|
+
- 📱 **Smooth experience** - even on mobile and low-powered devices
|
|
33
|
+
|
|
34
|
+
## Unlimited Flexibility
|
|
35
|
+
|
|
36
|
+
The library is built with flexibility as a core principle, allowing you to implement virtually any drag and drop scenario:
|
|
37
|
+
|
|
38
|
+
- 🎯 **Any UI pattern** - sortable lists, kanban boards, calendars, file uploads, and more
|
|
39
|
+
- 🎨 **Any design system** - works with any UI library or custom components
|
|
40
|
+
- 📐 **Any layout** - grid, flex, or custom positioning systems
|
|
41
|
+
- 🔄 **Any interaction model** - simple drag and drop, multi-select, nested containers
|
|
42
|
+
|
|
43
|
+
## Features
|
|
44
|
+
|
|
45
|
+
### Core Capabilities
|
|
46
|
+
|
|
47
|
+
- 🎯 **Simple Composables API**
|
|
48
|
+
|
|
49
|
+
- Intuitive hooks-based approach
|
|
50
|
+
- Clean and declarative syntax
|
|
51
|
+
- Minimal boilerplate code
|
|
52
|
+
|
|
53
|
+
- 🎨 **Full Customization**
|
|
54
|
+
|
|
55
|
+
- Custom drag overlays
|
|
56
|
+
- Flexible styling system
|
|
57
|
+
- Animation support
|
|
58
|
+
- Custom drag handles
|
|
59
|
+
|
|
60
|
+
- 📱 **Advanced Input Support**
|
|
61
|
+
|
|
62
|
+
- Touch devices support
|
|
63
|
+
- Mouse events
|
|
64
|
+
- Multi-touch gestures
|
|
65
|
+
- **Full keyboard navigation** - complete drag and drop operations using only keyboard
|
|
66
|
+
|
|
67
|
+
### Accessibility
|
|
68
|
+
|
|
69
|
+
- ♿ **Keyboard Navigation**
|
|
70
|
+
|
|
71
|
+
- Start and control drag operations with keyboard
|
|
72
|
+
- Arrow keys for movement
|
|
73
|
+
- Space/Enter for selection and dropping
|
|
74
|
+
- Escape to cancel drag operations
|
|
75
|
+
- Tab navigation between draggable elements
|
|
76
|
+
|
|
77
|
+
- 🔍 **Screen Reader Support**
|
|
78
|
+
|
|
79
|
+
- ARIA attributes for drag and drop operations
|
|
80
|
+
- Descriptive announcements during interactions
|
|
81
|
+
- Semantic HTML structure
|
|
82
|
+
|
|
83
|
+
### Performance
|
|
84
|
+
|
|
85
|
+
- ⚡ **Optimized Rendering**
|
|
86
|
+
|
|
87
|
+
- Virtual DOM friendly
|
|
88
|
+
- Minimal re-renders
|
|
89
|
+
- Efficient DOM updates
|
|
90
|
+
- Memory leak prevention
|
|
91
|
+
|
|
92
|
+
- 🔄 **Smart Auto-scrolling**
|
|
93
|
+
|
|
94
|
+
- Smooth scroll animations
|
|
95
|
+
- Configurable thresholds
|
|
96
|
+
- Performance-optimized
|
|
97
|
+
- Works with nested scrollable containers
|
|
98
|
+
|
|
99
|
+
### Developer Experience
|
|
100
|
+
|
|
101
|
+
- 🔍 **TypeScript Ready**
|
|
102
|
+
|
|
103
|
+
- Full type coverage
|
|
104
|
+
- Type inference
|
|
105
|
+
- IDE autocompletion
|
|
106
|
+
- Type-safe events
|
|
107
|
+
|
|
108
|
+
- 📐 **Layout Features**
|
|
109
|
+
|
|
110
|
+
- Grid system support
|
|
111
|
+
- Flex layout compatible
|
|
112
|
+
- Responsive design ready
|
|
113
|
+
- Dynamic constraints
|
|
114
|
+
|
|
115
|
+
### Advanced Features
|
|
116
|
+
|
|
117
|
+
- 🎯 **Smart Grouping**
|
|
118
|
+
|
|
119
|
+
- Element groups
|
|
120
|
+
- Zone filtering
|
|
121
|
+
- Nested groups
|
|
122
|
+
- Dynamic group validation
|
|
123
|
+
|
|
124
|
+
- 📊 **Rich Events System**
|
|
125
|
+
|
|
126
|
+
- Comprehensive lifecycle events
|
|
127
|
+
- Custom event handlers
|
|
128
|
+
- Drag state tracking
|
|
129
|
+
- Position coordinates
|
|
130
|
+
|
|
131
|
+
- 🛡️ **Built-in Utilities**
|
|
132
|
+
|
|
133
|
+
- Geometry calculations
|
|
134
|
+
- Bounding box tracking
|
|
135
|
+
- Position management
|
|
136
|
+
- Intersection detection
|
|
137
|
+
|
|
138
|
+
### Integration
|
|
139
|
+
|
|
140
|
+
- 🔌 **Framework Integration**
|
|
141
|
+
- Vue 3 Composition API
|
|
142
|
+
- Nuxt.js compatible
|
|
143
|
+
- Works with SSR
|
|
144
|
+
- Plugin ecosystem ready
|
|
145
|
+
|
|
146
|
+
## Installation
|
|
147
|
+
|
|
148
|
+
Choose your preferred package manager:
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
npm install @vue-dnd-kit/core @vueuse/core
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
yarn add @vue-dnd-kit/core @vueuse/core
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
pnpm install @vue-dnd-kit/core @vueuse/core
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
## Setup as a Plugin
|
|
163
|
+
|
|
164
|
+
You can register the library as a Vue plugin in your main.ts/js file:
|
|
165
|
+
|
|
166
|
+
```typescript
|
|
167
|
+
import { createApp } from 'vue';
|
|
168
|
+
import App from './App.vue';
|
|
169
|
+
import VueDnDKitPlugin from '@vue-dnd-kit/core';
|
|
170
|
+
|
|
171
|
+
const app = createApp(App);
|
|
172
|
+
|
|
173
|
+
// Register the plugin
|
|
174
|
+
app.use(VueDnDKitPlugin);
|
|
175
|
+
|
|
176
|
+
app.mount('#app');
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
This will make all the components and composables globally available in your application.
|
|
180
|
+
|
|
181
|
+
## Basic Usage
|
|
182
|
+
|
|
183
|
+
### App.vue
|
|
184
|
+
|
|
185
|
+
<sup>📄 Root Application Component</sup>
|
|
186
|
+
|
|
187
|
+
```vue
|
|
188
|
+
<script setup lang="ts">
|
|
189
|
+
import { ref } from 'vue';
|
|
190
|
+
import Draggable from './components/Draggable.vue';
|
|
191
|
+
import Droppable from './components/Droppable.vue';
|
|
192
|
+
|
|
193
|
+
const handleDrop = () => (elementInDropZone.value = true);
|
|
194
|
+
|
|
195
|
+
const handleEnd = () => (elementInDropZone.value = false);
|
|
196
|
+
|
|
197
|
+
const elementInDropZone = ref<boolean>(false);
|
|
198
|
+
</script>
|
|
199
|
+
|
|
200
|
+
<template>
|
|
201
|
+
<div>
|
|
202
|
+
<Draggable v-if="!elementInDropZone"> drag me </Draggable>
|
|
203
|
+
<Droppable @drop="handleDrop">
|
|
204
|
+
<Draggable
|
|
205
|
+
v-if="elementInDropZone"
|
|
206
|
+
@end="handleEnd"
|
|
207
|
+
>
|
|
208
|
+
im in drop zone
|
|
209
|
+
</Draggable>
|
|
210
|
+
</Droppable>
|
|
211
|
+
</div>
|
|
212
|
+
</template>
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
### Draggable.vue
|
|
216
|
+
|
|
217
|
+
<sup>🧩 components/Draggable.vue</sup>
|
|
218
|
+
|
|
219
|
+
```vue
|
|
220
|
+
<script setup lang="ts">
|
|
221
|
+
import { useDraggable } from '@vue-dnd-kit/core';
|
|
222
|
+
|
|
223
|
+
const emit = defineEmits<{
|
|
224
|
+
(e: 'end'): void;
|
|
225
|
+
}>();
|
|
226
|
+
|
|
227
|
+
const { elementRef, handleDragStart, isDragging } = useDraggable({
|
|
228
|
+
events: { onEnd: () => emit('end') },
|
|
229
|
+
});
|
|
230
|
+
</script>
|
|
231
|
+
|
|
232
|
+
<template>
|
|
233
|
+
<div
|
|
234
|
+
ref="elementRef"
|
|
235
|
+
@pointerdown="handleDragStart"
|
|
236
|
+
:class="{ dragging: isDragging }"
|
|
237
|
+
tabindex="0"
|
|
238
|
+
role="button"
|
|
239
|
+
aria-grabbed="false"
|
|
240
|
+
:aria-pressed="isDragging"
|
|
241
|
+
>
|
|
242
|
+
<slot />
|
|
243
|
+
</div>
|
|
244
|
+
</template>
|
|
245
|
+
|
|
246
|
+
<style scoped>
|
|
247
|
+
.dragging {
|
|
248
|
+
opacity: 0.5;
|
|
249
|
+
}
|
|
250
|
+
</style>
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
### Droppable.vue
|
|
254
|
+
|
|
255
|
+
<sup>🧩 components/Droppable.vue</sup>
|
|
256
|
+
|
|
257
|
+
```vue
|
|
258
|
+
<script setup lang="ts">
|
|
259
|
+
import { useDroppable } from '@vue-dnd-kit/core';
|
|
260
|
+
|
|
261
|
+
const emit = defineEmits<{
|
|
262
|
+
(e: 'drop'): void;
|
|
263
|
+
}>();
|
|
264
|
+
|
|
265
|
+
const { elementRef, isOvered } = useDroppable({
|
|
266
|
+
events: { onDrop: () => emit('drop') },
|
|
267
|
+
});
|
|
268
|
+
</script>
|
|
269
|
+
|
|
270
|
+
<template>
|
|
271
|
+
<div
|
|
272
|
+
ref="elementRef"
|
|
273
|
+
:class="{
|
|
274
|
+
droppable: true,
|
|
275
|
+
'is-overed': isOvered,
|
|
276
|
+
}"
|
|
277
|
+
role="region"
|
|
278
|
+
aria-dropeffect="move"
|
|
279
|
+
>
|
|
280
|
+
drop here
|
|
281
|
+
<slot />
|
|
282
|
+
</div>
|
|
283
|
+
</template>
|
|
284
|
+
|
|
285
|
+
<style scoped>
|
|
286
|
+
.droppable {
|
|
287
|
+
width: 100px;
|
|
288
|
+
height: 100px;
|
|
289
|
+
border: 1px solid black;
|
|
290
|
+
}
|
|
291
|
+
.is-overed {
|
|
292
|
+
background-color: #f0f0f0;
|
|
293
|
+
border: 1px dashed red;
|
|
294
|
+
}
|
|
295
|
+
</style>
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
## 📄 License
|
|
299
|
+
|
|
300
|
+
[MIT](LICENSE) © [ZiZiGY](https://github.com/ZiZiGY)
|
|
301
|
+
|
|
302
|
+
---
|
|
303
|
+
|
|
304
|
+
<p align="center">🎉 Congratulations on the official release! 🎉</p>
|
|
305
|
+
<p align="center">Made with ❤️ for the Vue.js community</p>
|