@dnd-kit/vue 0.2.3 → 0.3.0-beta-20260210032016
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/composables.cjs +15 -39
- package/composables.js +7 -6
- package/index.cjs +80 -144
- package/index.js +46 -100
- package/package.json +4 -4
- package/sortable.cjs +55 -80
- package/sortable.js +10 -18
- package/utilities.cjs +11 -43
- package/utilities.js +6 -13
package/composables.cjs
CHANGED
|
@@ -1,47 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1
|
+
'use strict';
|
|
19
2
|
|
|
20
|
-
|
|
21
|
-
var
|
|
22
|
-
__export(composables_exports, {
|
|
23
|
-
useDeepSignal: () => useDeepSignal
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(composables_exports);
|
|
3
|
+
var state = require('@dnd-kit/state');
|
|
4
|
+
var vue = require('vue');
|
|
26
5
|
|
|
27
6
|
// src/composables/useDeepSignal.ts
|
|
28
|
-
var import_state = require("@dnd-kit/state");
|
|
29
|
-
var import_vue = require("vue");
|
|
30
7
|
function useDeepSignal(target) {
|
|
31
8
|
const tracked = /* @__PURE__ */ new Map();
|
|
32
|
-
const dirty =
|
|
33
|
-
|
|
34
|
-
const _target =
|
|
9
|
+
const dirty = vue.ref(0);
|
|
10
|
+
vue.watchEffect(() => {
|
|
11
|
+
const _target = vue.toValue(target);
|
|
35
12
|
if (!_target) {
|
|
36
13
|
tracked.clear();
|
|
37
14
|
return;
|
|
38
15
|
}
|
|
39
|
-
|
|
40
|
-
|
|
16
|
+
vue.onWatcherCleanup(
|
|
17
|
+
state.effect(() => {
|
|
41
18
|
let stale = false;
|
|
42
19
|
for (const entry of tracked) {
|
|
43
20
|
const [key] = entry;
|
|
44
|
-
const value =
|
|
21
|
+
const value = state.untracked(() => entry[1]);
|
|
45
22
|
const latestValue = _target[key];
|
|
46
23
|
if (value !== latestValue) {
|
|
47
24
|
stale = true;
|
|
@@ -53,9 +30,9 @@ function useDeepSignal(target) {
|
|
|
53
30
|
}
|
|
54
31
|
})
|
|
55
32
|
);
|
|
56
|
-
});
|
|
57
|
-
return
|
|
58
|
-
const _target =
|
|
33
|
+
}, { flush: "post" });
|
|
34
|
+
return vue.computed(() => {
|
|
35
|
+
const _target = vue.toValue(target);
|
|
59
36
|
void dirty.value;
|
|
60
37
|
return _target ? new Proxy(_target, {
|
|
61
38
|
get(target2, key) {
|
|
@@ -66,8 +43,7 @@ function useDeepSignal(target) {
|
|
|
66
43
|
}) : _target;
|
|
67
44
|
});
|
|
68
45
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
});
|
|
46
|
+
|
|
47
|
+
exports.useDeepSignal = useDeepSignal;
|
|
48
|
+
//# sourceMappingURL=composables.cjs.map
|
|
73
49
|
//# sourceMappingURL=composables.cjs.map
|
package/composables.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { effect, untracked } from '@dnd-kit/state';
|
|
2
|
+
import { ref, watchEffect, toValue, onWatcherCleanup, computed } from 'vue';
|
|
3
|
+
|
|
1
4
|
// src/composables/useDeepSignal.ts
|
|
2
|
-
import { effect, untracked } from "@dnd-kit/state";
|
|
3
|
-
import { computed, onWatcherCleanup, ref, toValue, watchEffect } from "vue";
|
|
4
5
|
function useDeepSignal(target) {
|
|
5
6
|
const tracked = /* @__PURE__ */ new Map();
|
|
6
7
|
const dirty = ref(0);
|
|
@@ -27,7 +28,7 @@ function useDeepSignal(target) {
|
|
|
27
28
|
}
|
|
28
29
|
})
|
|
29
30
|
);
|
|
30
|
-
});
|
|
31
|
+
}, { flush: "post" });
|
|
31
32
|
return computed(() => {
|
|
32
33
|
const _target = toValue(target);
|
|
33
34
|
void dirty.value;
|
|
@@ -40,7 +41,7 @@ function useDeepSignal(target) {
|
|
|
40
41
|
}) : _target;
|
|
41
42
|
});
|
|
42
43
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
|
|
45
|
+
export { useDeepSignal };
|
|
46
|
+
//# sourceMappingURL=composables.js.map
|
|
46
47
|
//# sourceMappingURL=composables.js.map
|
package/index.cjs
CHANGED
|
@@ -1,49 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1
|
+
'use strict';
|
|
19
2
|
|
|
20
|
-
|
|
21
|
-
var
|
|
22
|
-
|
|
23
|
-
DragDropProvider: () => DragDropProvider_default,
|
|
24
|
-
KeyboardSensor: () => import_dom5.KeyboardSensor,
|
|
25
|
-
PointerSensor: () => import_dom5.PointerSensor,
|
|
26
|
-
useDragDropManager: () => useDragDropManager,
|
|
27
|
-
useDragDropMonitor: () => useDragDropMonitor,
|
|
28
|
-
useDragOperation: () => useDragOperation,
|
|
29
|
-
useDraggable: () => useDraggable,
|
|
30
|
-
useDroppable: () => useDroppable,
|
|
31
|
-
useInstance: () => useInstance
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(core_exports);
|
|
3
|
+
var dom = require('@dnd-kit/dom');
|
|
4
|
+
var vue = require('vue');
|
|
5
|
+
var state = require('@dnd-kit/state');
|
|
34
6
|
|
|
35
7
|
// src/core/context/DragDropProvider.ts
|
|
36
|
-
var import_dom = require("@dnd-kit/dom");
|
|
37
|
-
var import_dom2 = require("@dnd-kit/dom");
|
|
38
|
-
var import_vue5 = require("vue");
|
|
39
|
-
|
|
40
|
-
// src/core/context/renderer.ts
|
|
41
|
-
var import_vue = require("vue");
|
|
42
8
|
function useRenderer() {
|
|
43
|
-
const transitionCount =
|
|
44
|
-
const rendering =
|
|
9
|
+
const transitionCount = vue.ref(0);
|
|
10
|
+
const rendering = vue.ref(null);
|
|
45
11
|
let resolver = null;
|
|
46
|
-
|
|
12
|
+
vue.watch(
|
|
47
13
|
transitionCount,
|
|
48
14
|
() => {
|
|
49
15
|
resolver?.();
|
|
@@ -65,7 +31,7 @@ function useRenderer() {
|
|
|
65
31
|
});
|
|
66
32
|
}
|
|
67
33
|
callback();
|
|
68
|
-
|
|
34
|
+
vue.nextTick(() => {
|
|
69
35
|
transitionCount.value++;
|
|
70
36
|
});
|
|
71
37
|
}
|
|
@@ -74,16 +40,13 @@ function useRenderer() {
|
|
|
74
40
|
trackRendering
|
|
75
41
|
};
|
|
76
42
|
}
|
|
77
|
-
|
|
78
|
-
// src/utilities/context.ts
|
|
79
|
-
var import_vue2 = require("vue");
|
|
80
43
|
function createContext(componentName) {
|
|
81
44
|
const injectionKey = Symbol(
|
|
82
45
|
`${componentName}Context`
|
|
83
46
|
);
|
|
84
47
|
return [injectContext, provideContext];
|
|
85
48
|
function injectContext(fallback) {
|
|
86
|
-
const context =
|
|
49
|
+
const context = vue.inject(injectionKey, fallback);
|
|
87
50
|
if (context) return context;
|
|
88
51
|
if (context === null) return context;
|
|
89
52
|
throw new Error(
|
|
@@ -91,23 +54,17 @@ function createContext(componentName) {
|
|
|
91
54
|
);
|
|
92
55
|
}
|
|
93
56
|
function provideContext(contextValue) {
|
|
94
|
-
|
|
57
|
+
vue.provide(injectionKey, contextValue);
|
|
95
58
|
return contextValue;
|
|
96
59
|
}
|
|
97
60
|
}
|
|
98
|
-
|
|
99
|
-
// src/utilities/element.ts
|
|
100
|
-
var import_vue3 = require("vue");
|
|
101
61
|
function unrefElement(elRef) {
|
|
102
|
-
const plain =
|
|
62
|
+
const plain = vue.toValue(elRef);
|
|
103
63
|
return plain?.$el ?? plain ?? void 0;
|
|
104
64
|
}
|
|
105
|
-
|
|
106
|
-
// src/utilities/ref.ts
|
|
107
|
-
var import_vue4 = require("vue");
|
|
108
65
|
function toValueDeep(input) {
|
|
109
66
|
return Object.fromEntries(
|
|
110
|
-
Object.entries(input).map(([key, value]) => [key,
|
|
67
|
+
Object.entries(input).map(([key, value]) => [key, vue.toValue(value)])
|
|
111
68
|
);
|
|
112
69
|
}
|
|
113
70
|
|
|
@@ -115,7 +72,7 @@ function toValueDeep(input) {
|
|
|
115
72
|
var [injectDragDropContext, provideDragDropContext] = createContext("DragDropProvider");
|
|
116
73
|
|
|
117
74
|
// src/core/context/DragDropProvider.ts
|
|
118
|
-
var DragDropProvider_default = /* @__PURE__ */
|
|
75
|
+
var DragDropProvider_default = /* @__PURE__ */ vue.defineComponent({
|
|
119
76
|
props: [
|
|
120
77
|
"manager",
|
|
121
78
|
"plugins",
|
|
@@ -132,11 +89,11 @@ var DragDropProvider_default = /* @__PURE__ */ (0, import_vue5.defineComponent)(
|
|
|
132
89
|
],
|
|
133
90
|
setup(props, { emit, slots }) {
|
|
134
91
|
const { renderer, trackRendering } = useRenderer();
|
|
135
|
-
const manager =
|
|
136
|
-
|
|
92
|
+
const manager = vue.shallowRef(props.manager ?? new dom.DragDropManager(props));
|
|
93
|
+
vue.watch(
|
|
137
94
|
[() => props.manager],
|
|
138
95
|
() => {
|
|
139
|
-
const _manager = props.manager ?? new
|
|
96
|
+
const _manager = props.manager ?? new dom.DragDropManager(props);
|
|
140
97
|
const cleanupFns = [];
|
|
141
98
|
_manager.renderer = renderer;
|
|
142
99
|
cleanupFns.push(
|
|
@@ -176,19 +133,19 @@ var DragDropProvider_default = /* @__PURE__ */ (0, import_vue5.defineComponent)(
|
|
|
176
133
|
)
|
|
177
134
|
);
|
|
178
135
|
manager.value = _manager;
|
|
179
|
-
|
|
136
|
+
vue.onWatcherCleanup(() => cleanupFns.forEach((fn) => fn()));
|
|
180
137
|
},
|
|
181
138
|
{
|
|
182
139
|
immediate: true
|
|
183
140
|
}
|
|
184
141
|
);
|
|
185
|
-
|
|
186
|
-
manager.value.plugins = props.plugins ??
|
|
187
|
-
manager.value.sensors = props.sensors ??
|
|
188
|
-
manager.value.modifiers = props.modifiers ??
|
|
142
|
+
vue.watchEffect(() => {
|
|
143
|
+
manager.value.plugins = props.plugins ?? dom.defaultPreset.plugins;
|
|
144
|
+
manager.value.sensors = props.sensors ?? dom.defaultPreset.sensors;
|
|
145
|
+
manager.value.modifiers = props.modifiers ?? dom.defaultPreset.modifiers;
|
|
189
146
|
});
|
|
190
|
-
provideDragDropContext(
|
|
191
|
-
|
|
147
|
+
provideDragDropContext(vue.computed(() => manager.value));
|
|
148
|
+
vue.onUnmounted(() => {
|
|
192
149
|
if (!props.manager) {
|
|
193
150
|
manager.value.destroy();
|
|
194
151
|
}
|
|
@@ -196,28 +153,21 @@ var DragDropProvider_default = /* @__PURE__ */ (0, import_vue5.defineComponent)(
|
|
|
196
153
|
return () => slots.default?.();
|
|
197
154
|
}
|
|
198
155
|
});
|
|
199
|
-
|
|
200
|
-
// src/core/draggable/useDraggable.ts
|
|
201
|
-
var import_dom3 = require("@dnd-kit/dom");
|
|
202
|
-
|
|
203
|
-
// src/composables/useDeepSignal.ts
|
|
204
|
-
var import_state = require("@dnd-kit/state");
|
|
205
|
-
var import_vue6 = require("vue");
|
|
206
156
|
function useDeepSignal(target) {
|
|
207
157
|
const tracked = /* @__PURE__ */ new Map();
|
|
208
|
-
const dirty =
|
|
209
|
-
|
|
210
|
-
const _target =
|
|
158
|
+
const dirty = vue.ref(0);
|
|
159
|
+
vue.watchEffect(() => {
|
|
160
|
+
const _target = vue.toValue(target);
|
|
211
161
|
if (!_target) {
|
|
212
162
|
tracked.clear();
|
|
213
163
|
return;
|
|
214
164
|
}
|
|
215
|
-
|
|
216
|
-
|
|
165
|
+
vue.onWatcherCleanup(
|
|
166
|
+
state.effect(() => {
|
|
217
167
|
let stale = false;
|
|
218
168
|
for (const entry of tracked) {
|
|
219
169
|
const [key] = entry;
|
|
220
|
-
const value =
|
|
170
|
+
const value = state.untracked(() => entry[1]);
|
|
221
171
|
const latestValue = _target[key];
|
|
222
172
|
if (value !== latestValue) {
|
|
223
173
|
stale = true;
|
|
@@ -229,9 +179,9 @@ function useDeepSignal(target) {
|
|
|
229
179
|
}
|
|
230
180
|
})
|
|
231
181
|
);
|
|
232
|
-
});
|
|
233
|
-
return
|
|
234
|
-
const _target =
|
|
182
|
+
}, { flush: "post" });
|
|
183
|
+
return vue.computed(() => {
|
|
184
|
+
const _target = vue.toValue(target);
|
|
235
185
|
void dirty.value;
|
|
236
186
|
return _target ? new Proxy(_target, {
|
|
237
187
|
get(target2, key) {
|
|
@@ -243,12 +193,6 @@ function useDeepSignal(target) {
|
|
|
243
193
|
});
|
|
244
194
|
}
|
|
245
195
|
|
|
246
|
-
// src/core/draggable/useDraggable.ts
|
|
247
|
-
var import_vue8 = require("vue");
|
|
248
|
-
|
|
249
|
-
// src/core/hooks/useInstance.ts
|
|
250
|
-
var import_vue7 = require("vue");
|
|
251
|
-
|
|
252
196
|
// src/core/hooks/useDragDropManager.ts
|
|
253
197
|
function useDragDropManager() {
|
|
254
198
|
return injectDragDropContext();
|
|
@@ -257,18 +201,18 @@ function useDragDropManager() {
|
|
|
257
201
|
// src/core/hooks/useInstance.ts
|
|
258
202
|
function useInstance(initializer) {
|
|
259
203
|
const manager = useDragDropManager();
|
|
260
|
-
const instance =
|
|
261
|
-
|
|
204
|
+
const instance = vue.shallowRef(initializer(manager.value));
|
|
205
|
+
vue.watchEffect(() => {
|
|
262
206
|
instance.value.manager = manager.value;
|
|
263
|
-
|
|
207
|
+
vue.onWatcherCleanup(instance.value.register());
|
|
264
208
|
});
|
|
265
|
-
return
|
|
209
|
+
return vue.computed(() => instance.value);
|
|
266
210
|
}
|
|
267
211
|
|
|
268
212
|
// src/core/draggable/useDraggable.ts
|
|
269
213
|
function useDraggable(input) {
|
|
270
214
|
const draggable = useInstance(
|
|
271
|
-
(manager) => new
|
|
215
|
+
(manager) => new dom.Draggable(
|
|
272
216
|
{
|
|
273
217
|
...toValueDeep(input),
|
|
274
218
|
register: false,
|
|
@@ -279,33 +223,29 @@ function useDraggable(input) {
|
|
|
279
223
|
)
|
|
280
224
|
);
|
|
281
225
|
const trackedDraggable = useDeepSignal(draggable);
|
|
282
|
-
|
|
226
|
+
vue.watchEffect(() => {
|
|
283
227
|
draggable.value.element = unrefElement(input.element) ?? void 0;
|
|
284
228
|
draggable.value.handle = unrefElement(input.handle) ?? void 0;
|
|
285
|
-
draggable.value.id =
|
|
286
|
-
draggable.value.disabled =
|
|
287
|
-
draggable.value.feedback =
|
|
288
|
-
draggable.value.alignment =
|
|
289
|
-
draggable.value.modifiers =
|
|
290
|
-
draggable.value.sensors =
|
|
291
|
-
if (
|
|
292
|
-
draggable.value.data =
|
|
229
|
+
draggable.value.id = vue.toValue(input.id);
|
|
230
|
+
draggable.value.disabled = vue.toValue(input.disabled) ?? false;
|
|
231
|
+
draggable.value.feedback = vue.toValue(input.feedback) ?? "default";
|
|
232
|
+
draggable.value.alignment = vue.toValue(input.alignment);
|
|
233
|
+
draggable.value.modifiers = vue.toValue(input.modifiers);
|
|
234
|
+
draggable.value.sensors = vue.toValue(input.sensors);
|
|
235
|
+
if (vue.toValue(input.data)) {
|
|
236
|
+
draggable.value.data = vue.toValue(input.data);
|
|
293
237
|
}
|
|
294
238
|
});
|
|
295
239
|
return {
|
|
296
|
-
draggable:
|
|
297
|
-
isDragging:
|
|
298
|
-
isDropping:
|
|
299
|
-
isDragSource:
|
|
240
|
+
draggable: vue.shallowReadonly(draggable),
|
|
241
|
+
isDragging: vue.computed(() => trackedDraggable.value.isDragging),
|
|
242
|
+
isDropping: vue.computed(() => trackedDraggable.value.isDropping),
|
|
243
|
+
isDragSource: vue.computed(() => trackedDraggable.value.isDragSource)
|
|
300
244
|
};
|
|
301
245
|
}
|
|
302
|
-
|
|
303
|
-
// src/core/droppable/useDroppable.ts
|
|
304
|
-
var import_dom4 = require("@dnd-kit/dom");
|
|
305
|
-
var import_vue9 = require("vue");
|
|
306
246
|
function useDroppable(input) {
|
|
307
247
|
const droppable = useInstance(
|
|
308
|
-
(manager) => new
|
|
248
|
+
(manager) => new dom.Droppable(
|
|
309
249
|
{
|
|
310
250
|
...toValueDeep(input),
|
|
311
251
|
register: false,
|
|
@@ -315,30 +255,27 @@ function useDroppable(input) {
|
|
|
315
255
|
)
|
|
316
256
|
);
|
|
317
257
|
const trackedDroppable = useDeepSignal(droppable);
|
|
318
|
-
|
|
258
|
+
vue.watchEffect(() => {
|
|
319
259
|
droppable.value.element = unrefElement(input.element) ?? void 0;
|
|
320
|
-
droppable.value.id =
|
|
321
|
-
droppable.value.accept =
|
|
322
|
-
droppable.value.type =
|
|
323
|
-
droppable.value.disabled =
|
|
324
|
-
if (
|
|
325
|
-
droppable.value.collisionDetector =
|
|
260
|
+
droppable.value.id = vue.toValue(input.id);
|
|
261
|
+
droppable.value.accept = vue.toValue(input.accept);
|
|
262
|
+
droppable.value.type = vue.toValue(input.type);
|
|
263
|
+
droppable.value.disabled = vue.toValue(input.disabled) ?? false;
|
|
264
|
+
if (vue.toValue(input.collisionDetector)) {
|
|
265
|
+
droppable.value.collisionDetector = vue.toValue(input.collisionDetector);
|
|
326
266
|
}
|
|
327
|
-
if (
|
|
328
|
-
droppable.value.data =
|
|
267
|
+
if (vue.toValue(input.data)) {
|
|
268
|
+
droppable.value.data = vue.toValue(input.data);
|
|
329
269
|
}
|
|
330
270
|
});
|
|
331
271
|
return {
|
|
332
|
-
droppable:
|
|
333
|
-
isDropTarget:
|
|
272
|
+
droppable: vue.shallowReadonly(droppable),
|
|
273
|
+
isDropTarget: vue.computed(() => trackedDroppable.value.isDropTarget)
|
|
334
274
|
};
|
|
335
275
|
}
|
|
336
|
-
|
|
337
|
-
// src/core/hooks/useDragDropMonitor.ts
|
|
338
|
-
var import_vue10 = require("vue");
|
|
339
276
|
function useDragDropMonitor(handlers) {
|
|
340
277
|
const manager = useDragDropManager();
|
|
341
|
-
|
|
278
|
+
vue.watchEffect(() => {
|
|
342
279
|
if (!manager) {
|
|
343
280
|
if (process.env.NODE_ENV !== "production") {
|
|
344
281
|
console.warn(
|
|
@@ -361,16 +298,13 @@ function useDragDropMonitor(handlers) {
|
|
|
361
298
|
},
|
|
362
299
|
[]
|
|
363
300
|
);
|
|
364
|
-
|
|
301
|
+
vue.onWatcherCleanup(() => cleanupFns.forEach((cleanup) => cleanup()));
|
|
365
302
|
});
|
|
366
303
|
}
|
|
367
|
-
|
|
368
|
-
// src/core/hooks/useDragOperation.ts
|
|
369
|
-
var import_vue11 = require("vue");
|
|
370
304
|
function useDragOperation() {
|
|
371
305
|
const manager = useDragDropManager();
|
|
372
306
|
const trackedDragOperation = useDeepSignal(
|
|
373
|
-
|
|
307
|
+
vue.computed(() => manager.value.dragOperation)
|
|
374
308
|
);
|
|
375
309
|
return {
|
|
376
310
|
get source() {
|
|
@@ -385,18 +319,20 @@ function useDragOperation() {
|
|
|
385
319
|
};
|
|
386
320
|
}
|
|
387
321
|
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
PointerSensor
|
|
395
|
-
useDragDropManager,
|
|
396
|
-
useDragDropMonitor,
|
|
397
|
-
useDragOperation,
|
|
398
|
-
useDraggable,
|
|
399
|
-
useDroppable,
|
|
400
|
-
useInstance
|
|
322
|
+
Object.defineProperty(exports, "KeyboardSensor", {
|
|
323
|
+
enumerable: true,
|
|
324
|
+
get: function () { return dom.KeyboardSensor; }
|
|
325
|
+
});
|
|
326
|
+
Object.defineProperty(exports, "PointerSensor", {
|
|
327
|
+
enumerable: true,
|
|
328
|
+
get: function () { return dom.PointerSensor; }
|
|
401
329
|
});
|
|
330
|
+
exports.DragDropProvider = DragDropProvider_default;
|
|
331
|
+
exports.useDragDropManager = useDragDropManager;
|
|
332
|
+
exports.useDragDropMonitor = useDragDropMonitor;
|
|
333
|
+
exports.useDragOperation = useDragOperation;
|
|
334
|
+
exports.useDraggable = useDraggable;
|
|
335
|
+
exports.useDroppable = useDroppable;
|
|
336
|
+
exports.useInstance = useInstance;
|
|
337
|
+
//# sourceMappingURL=index.cjs.map
|
|
402
338
|
//# sourceMappingURL=index.cjs.map
|
package/index.js
CHANGED
|
@@ -1,20 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
} from
|
|
5
|
-
import { DragDropManager } from "@dnd-kit/dom";
|
|
6
|
-
import {
|
|
7
|
-
computed,
|
|
8
|
-
defineComponent,
|
|
9
|
-
onUnmounted,
|
|
10
|
-
onWatcherCleanup,
|
|
11
|
-
shallowRef,
|
|
12
|
-
watch as watch2,
|
|
13
|
-
watchEffect
|
|
14
|
-
} from "vue";
|
|
1
|
+
import { DragDropManager, defaultPreset, Draggable, Droppable } from '@dnd-kit/dom';
|
|
2
|
+
export { KeyboardSensor, PointerSensor } from '@dnd-kit/dom';
|
|
3
|
+
import { inject, provide, defineComponent, shallowRef, watch, onWatcherCleanup, watchEffect, computed, onUnmounted, toValue, shallowReadonly, ref, nextTick } from 'vue';
|
|
4
|
+
import { effect, untracked } from '@dnd-kit/state';
|
|
15
5
|
|
|
16
|
-
// src/core/context/
|
|
17
|
-
import { nextTick, ref, watch } from "vue";
|
|
6
|
+
// src/core/context/DragDropProvider.ts
|
|
18
7
|
function useRenderer() {
|
|
19
8
|
const transitionCount = ref(0);
|
|
20
9
|
const rendering = ref(null);
|
|
@@ -50,9 +39,6 @@ function useRenderer() {
|
|
|
50
39
|
trackRendering
|
|
51
40
|
};
|
|
52
41
|
}
|
|
53
|
-
|
|
54
|
-
// src/utilities/context.ts
|
|
55
|
-
import { inject, provide } from "vue";
|
|
56
42
|
function createContext(componentName) {
|
|
57
43
|
const injectionKey = Symbol(
|
|
58
44
|
`${componentName}Context`
|
|
@@ -71,19 +57,13 @@ function createContext(componentName) {
|
|
|
71
57
|
return contextValue;
|
|
72
58
|
}
|
|
73
59
|
}
|
|
74
|
-
|
|
75
|
-
// src/utilities/element.ts
|
|
76
|
-
import { toValue } from "vue";
|
|
77
60
|
function unrefElement(elRef) {
|
|
78
61
|
const plain = toValue(elRef);
|
|
79
62
|
return plain?.$el ?? plain ?? void 0;
|
|
80
63
|
}
|
|
81
|
-
|
|
82
|
-
// src/utilities/ref.ts
|
|
83
|
-
import { toValue as toValue2 } from "vue";
|
|
84
64
|
function toValueDeep(input) {
|
|
85
65
|
return Object.fromEntries(
|
|
86
|
-
Object.entries(input).map(([key, value]) => [key,
|
|
66
|
+
Object.entries(input).map(([key, value]) => [key, toValue(value)])
|
|
87
67
|
);
|
|
88
68
|
}
|
|
89
69
|
|
|
@@ -109,7 +89,7 @@ var DragDropProvider_default = /* @__PURE__ */ defineComponent({
|
|
|
109
89
|
setup(props, { emit, slots }) {
|
|
110
90
|
const { renderer, trackRendering } = useRenderer();
|
|
111
91
|
const manager = shallowRef(props.manager ?? new DragDropManager(props));
|
|
112
|
-
|
|
92
|
+
watch(
|
|
113
93
|
[() => props.manager],
|
|
114
94
|
() => {
|
|
115
95
|
const _manager = props.manager ?? new DragDropManager(props);
|
|
@@ -172,23 +152,16 @@ var DragDropProvider_default = /* @__PURE__ */ defineComponent({
|
|
|
172
152
|
return () => slots.default?.();
|
|
173
153
|
}
|
|
174
154
|
});
|
|
175
|
-
|
|
176
|
-
// src/core/draggable/useDraggable.ts
|
|
177
|
-
import { Draggable } from "@dnd-kit/dom";
|
|
178
|
-
|
|
179
|
-
// src/composables/useDeepSignal.ts
|
|
180
|
-
import { effect, untracked } from "@dnd-kit/state";
|
|
181
|
-
import { computed as computed2, onWatcherCleanup as onWatcherCleanup2, ref as ref2, toValue as toValue3, watchEffect as watchEffect2 } from "vue";
|
|
182
155
|
function useDeepSignal(target) {
|
|
183
156
|
const tracked = /* @__PURE__ */ new Map();
|
|
184
|
-
const dirty =
|
|
185
|
-
|
|
186
|
-
const _target =
|
|
157
|
+
const dirty = ref(0);
|
|
158
|
+
watchEffect(() => {
|
|
159
|
+
const _target = toValue(target);
|
|
187
160
|
if (!_target) {
|
|
188
161
|
tracked.clear();
|
|
189
162
|
return;
|
|
190
163
|
}
|
|
191
|
-
|
|
164
|
+
onWatcherCleanup(
|
|
192
165
|
effect(() => {
|
|
193
166
|
let stale = false;
|
|
194
167
|
for (const entry of tracked) {
|
|
@@ -205,9 +178,9 @@ function useDeepSignal(target) {
|
|
|
205
178
|
}
|
|
206
179
|
})
|
|
207
180
|
);
|
|
208
|
-
});
|
|
209
|
-
return
|
|
210
|
-
const _target =
|
|
181
|
+
}, { flush: "post" });
|
|
182
|
+
return computed(() => {
|
|
183
|
+
const _target = toValue(target);
|
|
211
184
|
void dirty.value;
|
|
212
185
|
return _target ? new Proxy(_target, {
|
|
213
186
|
get(target2, key) {
|
|
@@ -219,12 +192,6 @@ function useDeepSignal(target) {
|
|
|
219
192
|
});
|
|
220
193
|
}
|
|
221
194
|
|
|
222
|
-
// src/core/draggable/useDraggable.ts
|
|
223
|
-
import { computed as computed4, shallowReadonly, toValue as toValue4, watchEffect as watchEffect4 } from "vue";
|
|
224
|
-
|
|
225
|
-
// src/core/hooks/useInstance.ts
|
|
226
|
-
import { computed as computed3, onWatcherCleanup as onWatcherCleanup3, shallowRef as shallowRef2, watchEffect as watchEffect3 } from "vue";
|
|
227
|
-
|
|
228
195
|
// src/core/hooks/useDragDropManager.ts
|
|
229
196
|
function useDragDropManager() {
|
|
230
197
|
return injectDragDropContext();
|
|
@@ -233,12 +200,12 @@ function useDragDropManager() {
|
|
|
233
200
|
// src/core/hooks/useInstance.ts
|
|
234
201
|
function useInstance(initializer) {
|
|
235
202
|
const manager = useDragDropManager();
|
|
236
|
-
const instance =
|
|
237
|
-
|
|
203
|
+
const instance = shallowRef(initializer(manager.value));
|
|
204
|
+
watchEffect(() => {
|
|
238
205
|
instance.value.manager = manager.value;
|
|
239
|
-
|
|
206
|
+
onWatcherCleanup(instance.value.register());
|
|
240
207
|
});
|
|
241
|
-
return
|
|
208
|
+
return computed(() => instance.value);
|
|
242
209
|
}
|
|
243
210
|
|
|
244
211
|
// src/core/draggable/useDraggable.ts
|
|
@@ -255,30 +222,26 @@ function useDraggable(input) {
|
|
|
255
222
|
)
|
|
256
223
|
);
|
|
257
224
|
const trackedDraggable = useDeepSignal(draggable);
|
|
258
|
-
|
|
225
|
+
watchEffect(() => {
|
|
259
226
|
draggable.value.element = unrefElement(input.element) ?? void 0;
|
|
260
227
|
draggable.value.handle = unrefElement(input.handle) ?? void 0;
|
|
261
|
-
draggable.value.id =
|
|
262
|
-
draggable.value.disabled =
|
|
263
|
-
draggable.value.feedback =
|
|
264
|
-
draggable.value.alignment =
|
|
265
|
-
draggable.value.modifiers =
|
|
266
|
-
draggable.value.sensors =
|
|
267
|
-
if (
|
|
268
|
-
draggable.value.data =
|
|
228
|
+
draggable.value.id = toValue(input.id);
|
|
229
|
+
draggable.value.disabled = toValue(input.disabled) ?? false;
|
|
230
|
+
draggable.value.feedback = toValue(input.feedback) ?? "default";
|
|
231
|
+
draggable.value.alignment = toValue(input.alignment);
|
|
232
|
+
draggable.value.modifiers = toValue(input.modifiers);
|
|
233
|
+
draggable.value.sensors = toValue(input.sensors);
|
|
234
|
+
if (toValue(input.data)) {
|
|
235
|
+
draggable.value.data = toValue(input.data);
|
|
269
236
|
}
|
|
270
237
|
});
|
|
271
238
|
return {
|
|
272
239
|
draggable: shallowReadonly(draggable),
|
|
273
|
-
isDragging:
|
|
274
|
-
isDropping:
|
|
275
|
-
isDragSource:
|
|
240
|
+
isDragging: computed(() => trackedDraggable.value.isDragging),
|
|
241
|
+
isDropping: computed(() => trackedDraggable.value.isDropping),
|
|
242
|
+
isDragSource: computed(() => trackedDraggable.value.isDragSource)
|
|
276
243
|
};
|
|
277
244
|
}
|
|
278
|
-
|
|
279
|
-
// src/core/droppable/useDroppable.ts
|
|
280
|
-
import { Droppable } from "@dnd-kit/dom";
|
|
281
|
-
import { computed as computed5, shallowReadonly as shallowReadonly2, toValue as toValue5, watchEffect as watchEffect5 } from "vue";
|
|
282
245
|
function useDroppable(input) {
|
|
283
246
|
const droppable = useInstance(
|
|
284
247
|
(manager) => new Droppable(
|
|
@@ -291,30 +254,27 @@ function useDroppable(input) {
|
|
|
291
254
|
)
|
|
292
255
|
);
|
|
293
256
|
const trackedDroppable = useDeepSignal(droppable);
|
|
294
|
-
|
|
257
|
+
watchEffect(() => {
|
|
295
258
|
droppable.value.element = unrefElement(input.element) ?? void 0;
|
|
296
|
-
droppable.value.id =
|
|
297
|
-
droppable.value.accept =
|
|
298
|
-
droppable.value.type =
|
|
299
|
-
droppable.value.disabled =
|
|
300
|
-
if (
|
|
301
|
-
droppable.value.collisionDetector =
|
|
259
|
+
droppable.value.id = toValue(input.id);
|
|
260
|
+
droppable.value.accept = toValue(input.accept);
|
|
261
|
+
droppable.value.type = toValue(input.type);
|
|
262
|
+
droppable.value.disabled = toValue(input.disabled) ?? false;
|
|
263
|
+
if (toValue(input.collisionDetector)) {
|
|
264
|
+
droppable.value.collisionDetector = toValue(input.collisionDetector);
|
|
302
265
|
}
|
|
303
|
-
if (
|
|
304
|
-
droppable.value.data =
|
|
266
|
+
if (toValue(input.data)) {
|
|
267
|
+
droppable.value.data = toValue(input.data);
|
|
305
268
|
}
|
|
306
269
|
});
|
|
307
270
|
return {
|
|
308
|
-
droppable:
|
|
309
|
-
isDropTarget:
|
|
271
|
+
droppable: shallowReadonly(droppable),
|
|
272
|
+
isDropTarget: computed(() => trackedDroppable.value.isDropTarget)
|
|
310
273
|
};
|
|
311
274
|
}
|
|
312
|
-
|
|
313
|
-
// src/core/hooks/useDragDropMonitor.ts
|
|
314
|
-
import { onWatcherCleanup as onWatcherCleanup4, watchEffect as watchEffect6 } from "vue";
|
|
315
275
|
function useDragDropMonitor(handlers) {
|
|
316
276
|
const manager = useDragDropManager();
|
|
317
|
-
|
|
277
|
+
watchEffect(() => {
|
|
318
278
|
if (!manager) {
|
|
319
279
|
if (process.env.NODE_ENV !== "production") {
|
|
320
280
|
console.warn(
|
|
@@ -337,16 +297,13 @@ function useDragDropMonitor(handlers) {
|
|
|
337
297
|
},
|
|
338
298
|
[]
|
|
339
299
|
);
|
|
340
|
-
|
|
300
|
+
onWatcherCleanup(() => cleanupFns.forEach((cleanup) => cleanup()));
|
|
341
301
|
});
|
|
342
302
|
}
|
|
343
|
-
|
|
344
|
-
// src/core/hooks/useDragOperation.ts
|
|
345
|
-
import { computed as computed6 } from "vue";
|
|
346
303
|
function useDragOperation() {
|
|
347
304
|
const manager = useDragDropManager();
|
|
348
305
|
const trackedDragOperation = useDeepSignal(
|
|
349
|
-
|
|
306
|
+
computed(() => manager.value.dragOperation)
|
|
350
307
|
);
|
|
351
308
|
return {
|
|
352
309
|
get source() {
|
|
@@ -361,17 +318,6 @@ function useDragOperation() {
|
|
|
361
318
|
};
|
|
362
319
|
}
|
|
363
320
|
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
export {
|
|
367
|
-
DragDropProvider_default as DragDropProvider,
|
|
368
|
-
KeyboardSensor,
|
|
369
|
-
PointerSensor,
|
|
370
|
-
useDragDropManager,
|
|
371
|
-
useDragDropMonitor,
|
|
372
|
-
useDragOperation,
|
|
373
|
-
useDraggable,
|
|
374
|
-
useDroppable,
|
|
375
|
-
useInstance
|
|
376
|
-
};
|
|
321
|
+
export { DragDropProvider_default as DragDropProvider, useDragDropManager, useDragDropMonitor, useDragOperation, useDraggable, useDroppable, useInstance };
|
|
322
|
+
//# sourceMappingURL=index.js.map
|
|
377
323
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dnd-kit/vue",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0-beta-20260210032016",
|
|
4
4
|
"main": "./index.cjs",
|
|
5
5
|
"module": "./index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -55,9 +55,9 @@
|
|
|
55
55
|
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist"
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"@dnd-kit/abstract": "
|
|
59
|
-
"@dnd-kit/dom": "
|
|
60
|
-
"@dnd-kit/state": "
|
|
58
|
+
"@dnd-kit/abstract": "0.3.0-beta-20260210032016",
|
|
59
|
+
"@dnd-kit/dom": "0.3.0-beta-20260210032016",
|
|
60
|
+
"@dnd-kit/state": "0.3.0-beta-20260210032016",
|
|
61
61
|
"tslib": "^2.6.2"
|
|
62
62
|
},
|
|
63
63
|
"peerDependencies": {
|
package/sortable.cjs
CHANGED
|
@@ -1,112 +1,87 @@
|
|
|
1
|
-
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1
|
+
'use strict';
|
|
19
2
|
|
|
20
|
-
|
|
21
|
-
var
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
module.exports = __toCommonJS(sortable_exports);
|
|
3
|
+
var sortable = require('@dnd-kit/dom/sortable');
|
|
4
|
+
var state = require('@dnd-kit/state');
|
|
5
|
+
var composables = require('@dnd-kit/vue/composables');
|
|
6
|
+
var utilities = require('@dnd-kit/vue/utilities');
|
|
7
|
+
var vue$1 = require('@dnd-kit/vue');
|
|
8
|
+
var vue = require('vue');
|
|
27
9
|
|
|
28
10
|
// src/sortable/useSortable.ts
|
|
29
|
-
var import_sortable = require("@dnd-kit/dom/sortable");
|
|
30
|
-
var import_state = require("@dnd-kit/state");
|
|
31
|
-
var import_composables = require("@dnd-kit/vue/composables");
|
|
32
|
-
var import_utilities = require("@dnd-kit/vue/utilities");
|
|
33
|
-
var import_vue = require("@dnd-kit/vue");
|
|
34
|
-
var import_vue2 = require("vue");
|
|
35
11
|
function useSortable(input) {
|
|
36
|
-
const transition =
|
|
37
|
-
...
|
|
38
|
-
...
|
|
12
|
+
const transition = vue.computed(() => ({
|
|
13
|
+
...sortable.defaultSortableTransition,
|
|
14
|
+
...vue.toValue(input.transition)
|
|
39
15
|
}));
|
|
40
|
-
const sortable =
|
|
41
|
-
const _input =
|
|
42
|
-
return new
|
|
16
|
+
const sortable$1 = vue$1.useInstance((manager) => {
|
|
17
|
+
const _input = utilities.toValueDeep(input);
|
|
18
|
+
return new sortable.Sortable(
|
|
43
19
|
{
|
|
44
20
|
..._input,
|
|
45
21
|
register: false,
|
|
46
22
|
transition: transition.value,
|
|
47
|
-
element:
|
|
48
|
-
handle:
|
|
49
|
-
target:
|
|
23
|
+
element: utilities.unrefElement(input.element),
|
|
24
|
+
handle: utilities.unrefElement(input.handle),
|
|
25
|
+
target: utilities.unrefElement(input.target)
|
|
50
26
|
},
|
|
51
27
|
manager
|
|
52
28
|
);
|
|
53
29
|
});
|
|
54
|
-
const trackedSortable =
|
|
55
|
-
|
|
56
|
-
sortable.value.element =
|
|
57
|
-
sortable.value.handle =
|
|
58
|
-
if (
|
|
59
|
-
sortable.value.source =
|
|
30
|
+
const trackedSortable = composables.useDeepSignal(sortable$1);
|
|
31
|
+
vue.watchEffect(() => {
|
|
32
|
+
sortable$1.value.element = utilities.unrefElement(input.element);
|
|
33
|
+
sortable$1.value.handle = utilities.unrefElement(input.handle);
|
|
34
|
+
if (utilities.unrefElement(input.source)) {
|
|
35
|
+
sortable$1.value.source = utilities.unrefElement(input.source);
|
|
60
36
|
}
|
|
61
|
-
if (
|
|
62
|
-
sortable.value.target =
|
|
37
|
+
if (utilities.unrefElement(input.target)) {
|
|
38
|
+
sortable$1.value.target = utilities.unrefElement(input.target);
|
|
63
39
|
}
|
|
64
|
-
sortable.value.id =
|
|
65
|
-
sortable.value.disabled =
|
|
66
|
-
sortable.value.feedback =
|
|
67
|
-
sortable.value.alignment =
|
|
68
|
-
sortable.value.modifiers =
|
|
69
|
-
sortable.value.sensors =
|
|
70
|
-
sortable.value.accept =
|
|
71
|
-
sortable.value.type =
|
|
72
|
-
sortable.value.collisionPriority =
|
|
73
|
-
sortable.value.transition = transition.value;
|
|
74
|
-
if (
|
|
75
|
-
sortable.value.data =
|
|
40
|
+
sortable$1.value.id = vue.toValue(input.id);
|
|
41
|
+
sortable$1.value.disabled = vue.toValue(input.disabled) ?? false;
|
|
42
|
+
sortable$1.value.feedback = vue.toValue(input.feedback) ?? "default";
|
|
43
|
+
sortable$1.value.alignment = vue.toValue(input.alignment);
|
|
44
|
+
sortable$1.value.modifiers = vue.toValue(input.modifiers);
|
|
45
|
+
sortable$1.value.sensors = vue.toValue(input.sensors);
|
|
46
|
+
sortable$1.value.accept = vue.toValue(input.accept);
|
|
47
|
+
sortable$1.value.type = vue.toValue(input.type);
|
|
48
|
+
sortable$1.value.collisionPriority = vue.toValue(input.collisionPriority);
|
|
49
|
+
sortable$1.value.transition = transition.value;
|
|
50
|
+
if (vue.toValue(input.data)) {
|
|
51
|
+
sortable$1.value.data = vue.toValue(input.data);
|
|
76
52
|
}
|
|
77
53
|
});
|
|
78
|
-
|
|
79
|
-
[() =>
|
|
54
|
+
vue.watch(
|
|
55
|
+
[() => vue.toValue(input.group), () => vue.toValue(input.index)],
|
|
80
56
|
() => {
|
|
81
|
-
|
|
82
|
-
sortable.value.group =
|
|
83
|
-
sortable.value.index =
|
|
57
|
+
state.batch(() => {
|
|
58
|
+
sortable$1.value.group = vue.toValue(input.group);
|
|
59
|
+
sortable$1.value.index = vue.toValue(input.index);
|
|
84
60
|
});
|
|
85
61
|
},
|
|
86
62
|
{ flush: "sync" }
|
|
87
63
|
);
|
|
88
|
-
|
|
89
|
-
() =>
|
|
64
|
+
vue.watch(
|
|
65
|
+
() => vue.toValue(input.index),
|
|
90
66
|
() => {
|
|
91
|
-
if (sortable.value.manager?.dragOperation.status.idle && sortable.value.transition?.idle) {
|
|
92
|
-
sortable.value.refreshShape();
|
|
67
|
+
if (sortable$1.value.manager?.dragOperation.status.idle && sortable$1.value.transition?.idle) {
|
|
68
|
+
sortable$1.value.refreshShape();
|
|
93
69
|
}
|
|
94
70
|
}
|
|
95
71
|
);
|
|
96
72
|
return {
|
|
97
|
-
sortable:
|
|
98
|
-
isDragging:
|
|
99
|
-
isDropping:
|
|
100
|
-
isDragSource:
|
|
101
|
-
isDropTarget:
|
|
73
|
+
sortable: vue.shallowReadonly(sortable$1),
|
|
74
|
+
isDragging: vue.computed(() => trackedSortable.value.isDragging),
|
|
75
|
+
isDropping: vue.computed(() => trackedSortable.value.isDropping),
|
|
76
|
+
isDragSource: vue.computed(() => trackedSortable.value.isDragSource),
|
|
77
|
+
isDropTarget: vue.computed(() => trackedSortable.value.isDropTarget)
|
|
102
78
|
};
|
|
103
79
|
}
|
|
104
80
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
0 && (module.exports = {
|
|
109
|
-
isSortable,
|
|
110
|
-
useSortable
|
|
81
|
+
Object.defineProperty(exports, "isSortable", {
|
|
82
|
+
enumerable: true,
|
|
83
|
+
get: function () { return sortable.isSortable; }
|
|
111
84
|
});
|
|
85
|
+
exports.useSortable = useSortable;
|
|
86
|
+
//# sourceMappingURL=sortable.cjs.map
|
|
112
87
|
//# sourceMappingURL=sortable.cjs.map
|
package/sortable.js
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
|
+
import { defaultSortableTransition, Sortable } from '@dnd-kit/dom/sortable';
|
|
2
|
+
export { isSortable } from '@dnd-kit/dom/sortable';
|
|
3
|
+
import { batch } from '@dnd-kit/state';
|
|
4
|
+
import { useDeepSignal } from '@dnd-kit/vue/composables';
|
|
5
|
+
import { toValueDeep, unrefElement } from '@dnd-kit/vue/utilities';
|
|
6
|
+
import { useInstance } from '@dnd-kit/vue';
|
|
7
|
+
import { computed, toValue, watchEffect, watch, shallowReadonly } from 'vue';
|
|
8
|
+
|
|
1
9
|
// src/sortable/useSortable.ts
|
|
2
|
-
import { defaultSortableTransition, Sortable } from "@dnd-kit/dom/sortable";
|
|
3
|
-
import { batch } from "@dnd-kit/state";
|
|
4
|
-
import { useDeepSignal } from "@dnd-kit/vue/composables";
|
|
5
|
-
import { toValueDeep, unrefElement } from "@dnd-kit/vue/utilities";
|
|
6
|
-
import { useInstance } from "@dnd-kit/vue";
|
|
7
|
-
import {
|
|
8
|
-
computed,
|
|
9
|
-
shallowReadonly,
|
|
10
|
-
toValue,
|
|
11
|
-
watch,
|
|
12
|
-
watchEffect
|
|
13
|
-
} from "vue";
|
|
14
10
|
function useSortable(input) {
|
|
15
11
|
const transition = computed(() => ({
|
|
16
12
|
...defaultSortableTransition,
|
|
@@ -81,10 +77,6 @@ function useSortable(input) {
|
|
|
81
77
|
};
|
|
82
78
|
}
|
|
83
79
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
export {
|
|
87
|
-
isSortable,
|
|
88
|
-
useSortable
|
|
89
|
-
};
|
|
80
|
+
export { useSortable };
|
|
81
|
+
//# sourceMappingURL=sortable.js.map
|
|
90
82
|
//# sourceMappingURL=sortable.js.map
|
package/utilities.cjs
CHANGED
|
@@ -1,40 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1
|
+
'use strict';
|
|
19
2
|
|
|
20
|
-
|
|
21
|
-
var utilities_exports = {};
|
|
22
|
-
__export(utilities_exports, {
|
|
23
|
-
createContext: () => createContext,
|
|
24
|
-
toValueDeep: () => toValueDeep,
|
|
25
|
-
unrefElement: () => unrefElement
|
|
26
|
-
});
|
|
27
|
-
module.exports = __toCommonJS(utilities_exports);
|
|
3
|
+
var vue = require('vue');
|
|
28
4
|
|
|
29
5
|
// src/utilities/context.ts
|
|
30
|
-
var import_vue = require("vue");
|
|
31
6
|
function createContext(componentName) {
|
|
32
7
|
const injectionKey = Symbol(
|
|
33
8
|
`${componentName}Context`
|
|
34
9
|
);
|
|
35
10
|
return [injectContext, provideContext];
|
|
36
11
|
function injectContext(fallback) {
|
|
37
|
-
const context =
|
|
12
|
+
const context = vue.inject(injectionKey, fallback);
|
|
38
13
|
if (context) return context;
|
|
39
14
|
if (context === null) return context;
|
|
40
15
|
throw new Error(
|
|
@@ -42,29 +17,22 @@ function createContext(componentName) {
|
|
|
42
17
|
);
|
|
43
18
|
}
|
|
44
19
|
function provideContext(contextValue) {
|
|
45
|
-
|
|
20
|
+
vue.provide(injectionKey, contextValue);
|
|
46
21
|
return contextValue;
|
|
47
22
|
}
|
|
48
23
|
}
|
|
49
|
-
|
|
50
|
-
// src/utilities/element.ts
|
|
51
|
-
var import_vue2 = require("vue");
|
|
52
24
|
function unrefElement(elRef) {
|
|
53
|
-
const plain =
|
|
25
|
+
const plain = vue.toValue(elRef);
|
|
54
26
|
return plain?.$el ?? plain ?? void 0;
|
|
55
27
|
}
|
|
56
|
-
|
|
57
|
-
// src/utilities/ref.ts
|
|
58
|
-
var import_vue3 = require("vue");
|
|
59
28
|
function toValueDeep(input) {
|
|
60
29
|
return Object.fromEntries(
|
|
61
|
-
Object.entries(input).map(([key, value]) => [key,
|
|
30
|
+
Object.entries(input).map(([key, value]) => [key, vue.toValue(value)])
|
|
62
31
|
);
|
|
63
32
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
});
|
|
33
|
+
|
|
34
|
+
exports.createContext = createContext;
|
|
35
|
+
exports.toValueDeep = toValueDeep;
|
|
36
|
+
exports.unrefElement = unrefElement;
|
|
37
|
+
//# sourceMappingURL=utilities.cjs.map
|
|
70
38
|
//# sourceMappingURL=utilities.cjs.map
|
package/utilities.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { inject, provide, toValue } from 'vue';
|
|
2
|
+
|
|
1
3
|
// src/utilities/context.ts
|
|
2
|
-
import { inject, provide } from "vue";
|
|
3
4
|
function createContext(componentName) {
|
|
4
5
|
const injectionKey = Symbol(
|
|
5
6
|
`${componentName}Context`
|
|
@@ -18,24 +19,16 @@ function createContext(componentName) {
|
|
|
18
19
|
return contextValue;
|
|
19
20
|
}
|
|
20
21
|
}
|
|
21
|
-
|
|
22
|
-
// src/utilities/element.ts
|
|
23
|
-
import { toValue } from "vue";
|
|
24
22
|
function unrefElement(elRef) {
|
|
25
23
|
const plain = toValue(elRef);
|
|
26
24
|
return plain?.$el ?? plain ?? void 0;
|
|
27
25
|
}
|
|
28
|
-
|
|
29
|
-
// src/utilities/ref.ts
|
|
30
|
-
import { toValue as toValue2 } from "vue";
|
|
31
26
|
function toValueDeep(input) {
|
|
32
27
|
return Object.fromEntries(
|
|
33
|
-
Object.entries(input).map(([key, value]) => [key,
|
|
28
|
+
Object.entries(input).map(([key, value]) => [key, toValue(value)])
|
|
34
29
|
);
|
|
35
30
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
unrefElement
|
|
40
|
-
};
|
|
31
|
+
|
|
32
|
+
export { createContext, toValueDeep, unrefElement };
|
|
33
|
+
//# sourceMappingURL=utilities.js.map
|
|
41
34
|
//# sourceMappingURL=utilities.js.map
|