@vue-dnd-kit/core 0.3.0-beta → 0.5.1
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/dist/composables/useDnDStore.d.ts +11 -29
- package/dist/composables/useDragContainer.d.ts +4 -28
- package/dist/composables/useDraggable.d.ts +5 -29
- package/dist/composables/useKeyboard.d.ts +10 -0
- package/dist/composables/useSelection.d.ts +0 -5
- package/dist/composables/useSensor.d.ts +5 -5
- package/dist/index.d.ts +3 -2
- package/dist/managers/useElementManager.d.ts +0 -8
- package/dist/managers/useEventManager.d.ts +6 -0
- package/dist/types/index.d.ts +11 -6
- package/dist/utils/dom.d.ts +1 -1
- package/dist/vue-dnd-kit-core.cjs.js +1 -1
- package/dist/vue-dnd-kit-core.es.js +370 -317
- package/package.json +1 -1
- package/dist/managers/useInteractionManager.d.ts +0 -4
|
@@ -236,7 +236,7 @@ export declare const useDnDStore: () => {
|
|
|
236
236
|
__file?: string | undefined;
|
|
237
237
|
__name?: string | undefined;
|
|
238
238
|
} | null>;
|
|
239
|
-
ref: import('vue').
|
|
239
|
+
ref: import('vue').ShallowRef<HTMLElement | null, HTMLElement | null>;
|
|
240
240
|
};
|
|
241
241
|
elements: import('vue').Ref<{
|
|
242
242
|
node: HTMLElement | Element | null;
|
|
@@ -2283,35 +2283,17 @@ export declare const useDnDStore: () => {
|
|
|
2283
2283
|
} | null>;
|
|
2284
2284
|
};
|
|
2285
2285
|
pointerPosition: {
|
|
2286
|
-
current: import('vue').
|
|
2287
|
-
|
|
2288
|
-
y: number;
|
|
2289
|
-
} | null, IPoint | {
|
|
2290
|
-
x: number;
|
|
2291
|
-
y: number;
|
|
2292
|
-
} | null>;
|
|
2293
|
-
start: import('vue').Ref<{
|
|
2294
|
-
x: number;
|
|
2295
|
-
y: number;
|
|
2296
|
-
} | null, IPoint | {
|
|
2297
|
-
x: number;
|
|
2298
|
-
y: number;
|
|
2299
|
-
} | null>;
|
|
2286
|
+
current: import('vue').ShallowRef<IPoint | null, IPoint | null>;
|
|
2287
|
+
start: import('vue').ShallowRef<IPoint | null, IPoint | null>;
|
|
2300
2288
|
offset: {
|
|
2301
|
-
percent: import('vue').
|
|
2302
|
-
|
|
2303
|
-
y: number;
|
|
2304
|
-
} | null, IPoint | {
|
|
2305
|
-
x: number;
|
|
2306
|
-
y: number;
|
|
2307
|
-
} | null>;
|
|
2308
|
-
pixel: import('vue').Ref<{
|
|
2309
|
-
x: number;
|
|
2310
|
-
y: number;
|
|
2311
|
-
} | null, IPoint | {
|
|
2312
|
-
x: number;
|
|
2313
|
-
y: number;
|
|
2314
|
-
} | null>;
|
|
2289
|
+
percent: import('vue').ShallowRef<IPoint | null, IPoint | null>;
|
|
2290
|
+
pixel: import('vue').ShallowRef<IPoint | null, IPoint | null>;
|
|
2315
2291
|
};
|
|
2316
2292
|
};
|
|
2293
|
+
keyboard: {
|
|
2294
|
+
w: import('vue').ShallowRef<boolean, boolean>;
|
|
2295
|
+
s: import('vue').ShallowRef<boolean, boolean>;
|
|
2296
|
+
a: import('vue').ShallowRef<boolean, boolean>;
|
|
2297
|
+
d: import('vue').ShallowRef<boolean, boolean>;
|
|
2298
|
+
};
|
|
2317
2299
|
};
|
|
@@ -587,35 +587,11 @@ export declare const useDragContainer: () => {
|
|
|
587
587
|
};
|
|
588
588
|
}[]>;
|
|
589
589
|
pointerPosition: {
|
|
590
|
-
current: import('vue').
|
|
591
|
-
|
|
592
|
-
y: number;
|
|
593
|
-
} | null, import('../types').IPoint | {
|
|
594
|
-
x: number;
|
|
595
|
-
y: number;
|
|
596
|
-
} | null>;
|
|
597
|
-
start: import('vue').Ref<{
|
|
598
|
-
x: number;
|
|
599
|
-
y: number;
|
|
600
|
-
} | null, import('../types').IPoint | {
|
|
601
|
-
x: number;
|
|
602
|
-
y: number;
|
|
603
|
-
} | null>;
|
|
590
|
+
current: import('vue').ShallowRef<import('..').IPoint | null, import('..').IPoint | null>;
|
|
591
|
+
start: import('vue').ShallowRef<import('..').IPoint | null, import('..').IPoint | null>;
|
|
604
592
|
offset: {
|
|
605
|
-
percent: import('vue').
|
|
606
|
-
|
|
607
|
-
y: number;
|
|
608
|
-
} | null, import('../types').IPoint | {
|
|
609
|
-
x: number;
|
|
610
|
-
y: number;
|
|
611
|
-
} | null>;
|
|
612
|
-
pixel: import('vue').Ref<{
|
|
613
|
-
x: number;
|
|
614
|
-
y: number;
|
|
615
|
-
} | null, import('../types').IPoint | {
|
|
616
|
-
x: number;
|
|
617
|
-
y: number;
|
|
618
|
-
} | null>;
|
|
593
|
+
percent: import('vue').ShallowRef<import('..').IPoint | null, import('..').IPoint | null>;
|
|
594
|
+
pixel: import('vue').ShallowRef<import('..').IPoint | null, import('..').IPoint | null>;
|
|
619
595
|
};
|
|
620
596
|
};
|
|
621
597
|
isDragging: import('vue').ComputedRef<boolean>;
|
|
@@ -2,40 +2,16 @@ import { IUseDragOptions } from "../types";
|
|
|
2
2
|
|
|
3
3
|
export declare const useDraggable: (options?: IUseDragOptions) => {
|
|
4
4
|
pointerPosition: {
|
|
5
|
-
current: import('vue').
|
|
6
|
-
|
|
7
|
-
y: number;
|
|
8
|
-
} | null, import('../types').IPoint | {
|
|
9
|
-
x: number;
|
|
10
|
-
y: number;
|
|
11
|
-
} | null>;
|
|
12
|
-
start: import('vue').Ref<{
|
|
13
|
-
x: number;
|
|
14
|
-
y: number;
|
|
15
|
-
} | null, import('../types').IPoint | {
|
|
16
|
-
x: number;
|
|
17
|
-
y: number;
|
|
18
|
-
} | null>;
|
|
5
|
+
current: import('vue').ShallowRef<import('../types').IPoint | null, import('../types').IPoint | null>;
|
|
6
|
+
start: import('vue').ShallowRef<import('../types').IPoint | null, import('../types').IPoint | null>;
|
|
19
7
|
offset: {
|
|
20
|
-
percent: import('vue').
|
|
21
|
-
|
|
22
|
-
y: number;
|
|
23
|
-
} | null, import('../types').IPoint | {
|
|
24
|
-
x: number;
|
|
25
|
-
y: number;
|
|
26
|
-
} | null>;
|
|
27
|
-
pixel: import('vue').Ref<{
|
|
28
|
-
x: number;
|
|
29
|
-
y: number;
|
|
30
|
-
} | null, import('../types').IPoint | {
|
|
31
|
-
x: number;
|
|
32
|
-
y: number;
|
|
33
|
-
} | null>;
|
|
8
|
+
percent: import('vue').ShallowRef<import('../types').IPoint | null, import('../types').IPoint | null>;
|
|
9
|
+
pixel: import('vue').ShallowRef<import('../types').IPoint | null, import('../types').IPoint | null>;
|
|
34
10
|
};
|
|
35
11
|
};
|
|
36
12
|
elementRef: import('vue').Ref<HTMLElement | null, HTMLElement | null>;
|
|
37
13
|
isDragging: import('vue').ComputedRef<boolean>;
|
|
38
14
|
isOvered: import('vue').ComputedRef<boolean>;
|
|
39
15
|
isAllowed: import('vue').ComputedRef<boolean>;
|
|
40
|
-
handleDragStart: (event: PointerEvent) => void;
|
|
16
|
+
handleDragStart: (event: PointerEvent | KeyboardEvent) => void;
|
|
41
17
|
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Ref } from 'vue';
|
|
2
|
+
|
|
3
|
+
export interface IKeyboardOptions {
|
|
4
|
+
moveStep?: number;
|
|
5
|
+
}
|
|
6
|
+
export declare const useKeyboard: (elementRef: Ref<HTMLElement | null>, options?: IKeyboardOptions) => {
|
|
7
|
+
onKeyboardStart: (event: KeyboardEvent) => void;
|
|
8
|
+
onKeyboardMove: () => void;
|
|
9
|
+
onKeyboardEnd: () => void;
|
|
10
|
+
};
|
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
import { Ref } from 'vue';
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* Hook for managing element selection in drag and drop interface
|
|
5
|
-
* @param elementRef - Reference to the HTML element that can be selected
|
|
6
|
-
* @returns Object containing selection state and handlers
|
|
7
|
-
*/
|
|
8
3
|
export declare const useSelection: (elementRef: Ref<HTMLElement | null>) => {
|
|
9
4
|
handleUnselect: () => void;
|
|
10
5
|
handleSelect: () => void;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IUseDragOptions } from "../types";
|
|
2
2
|
import { Ref } from 'vue';
|
|
3
3
|
|
|
4
|
-
export declare const useSensor: (elementRef: Ref<HTMLElement | null>, options?:
|
|
5
|
-
activate: (event: PointerEvent) => void;
|
|
6
|
-
track: (event: PointerEvent | WheelEvent) => void;
|
|
7
|
-
deactivate: () => void;
|
|
4
|
+
export declare const useSensor: (elementRef: Ref<HTMLElement | null>, options?: IUseDragOptions) => {
|
|
5
|
+
activate: (event: PointerEvent | KeyboardEvent) => void;
|
|
6
|
+
track: (event: PointerEvent | WheelEvent | KeyboardEvent) => void;
|
|
7
|
+
deactivate: (triggerEvents?: boolean) => void;
|
|
8
8
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { VueDndKitPlugin } from './plugin';
|
|
2
|
+
import { getBoundingBox } from './utils/geometry';
|
|
2
3
|
import { useDnDStore } from './composables/useDnDStore';
|
|
3
4
|
import { useDraggable } from './composables/useDraggable';
|
|
4
5
|
import { useDroppable } from './composables/useDroppable';
|
|
5
6
|
import { useSelection } from './composables/useSelection';
|
|
6
7
|
|
|
7
8
|
export default VueDndKitPlugin;
|
|
8
|
-
export { useDraggable, useDroppable, useDnDStore, useSelection };
|
|
9
|
-
export type { IDnDStore, IActiveContainer, IDragElement, IDraggingElement, IDropZone, } from './types';
|
|
9
|
+
export { useDraggable, useDroppable, useDnDStore, useSelection, getBoundingBox, };
|
|
10
|
+
export type { IDnDStore, IActiveContainer, IDragElement, IDraggingElement, IDropZone, IPoint, IBoundingBox, } from './types';
|
|
@@ -1,13 +1,5 @@
|
|
|
1
1
|
import { IUseDragOptions } from "../types";
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* Hook for managing draggable elements and their interactions.
|
|
5
|
-
* Provides methods for registering, unregistering elements,
|
|
6
|
-
* checking if an element is being dragged, and determining if it can be dropped.
|
|
7
|
-
*
|
|
8
|
-
* @param options - Optional configuration object for element management
|
|
9
|
-
* @returns Object containing element management state and methods
|
|
10
|
-
*/
|
|
11
3
|
export declare const useElementManager: (options?: IUseDragOptions) => {
|
|
12
4
|
elementRef: import('vue').Ref<HTMLElement | null, HTMLElement | null>;
|
|
13
5
|
registerElement: () => void;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -72,7 +72,7 @@ export interface IUseDropOptions {
|
|
|
72
72
|
};
|
|
73
73
|
data?: any;
|
|
74
74
|
}
|
|
75
|
-
export interface IUseDragOptions {
|
|
75
|
+
export interface IUseDragOptions extends IUseSensorOptions {
|
|
76
76
|
groups?: string[];
|
|
77
77
|
events?: {
|
|
78
78
|
onEnd?: (store: IDnDStore) => void;
|
|
@@ -81,14 +81,17 @@ export interface IUseDragOptions {
|
|
|
81
81
|
onHover?: (store: IDnDStore) => void;
|
|
82
82
|
onLeave?: (store: IDnDStore) => void;
|
|
83
83
|
};
|
|
84
|
+
keyboard?: {
|
|
85
|
+
moveStep?: number;
|
|
86
|
+
};
|
|
84
87
|
data?: any;
|
|
85
88
|
layer?: Component | null;
|
|
86
89
|
container?: Component;
|
|
87
|
-
throttle?: number;
|
|
88
|
-
sensor?: ISensor;
|
|
89
90
|
}
|
|
90
91
|
|
|
91
|
-
export type ISensor = (
|
|
92
|
+
export type ISensor = (
|
|
93
|
+
store: IDnDStore
|
|
94
|
+
) => HTMLElement | HTMLElement[] | Element | Element[] | null;
|
|
92
95
|
|
|
93
96
|
export interface IBoundingBox {
|
|
94
97
|
x: number;
|
|
@@ -102,8 +105,10 @@ export interface IBoundingBox {
|
|
|
102
105
|
}
|
|
103
106
|
|
|
104
107
|
export interface IUseSensorOptions {
|
|
105
|
-
|
|
106
|
-
|
|
108
|
+
sensor?: {
|
|
109
|
+
throttle?: number;
|
|
110
|
+
setup?: ISensor;
|
|
111
|
+
};
|
|
107
112
|
}
|
|
108
113
|
|
|
109
114
|
interface ICollisionDetectionResult {
|
package/dist/utils/dom.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const isDescendant: (element: HTMLElement | null, container: HTMLElement) => boolean;
|
|
1
|
+
export declare const isDescendant: (element: HTMLElement | Element | null, container: HTMLElement | Element) => boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("vue");function Y(e){let t=!1,n;const s=o.effectScope(!0);return(...u)=>(t||(n=s.run(()=>e(...u)),t=!0),n)}typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const z=()=>{};function F(e,t){function n(...s){return new Promise((u,l)=>{Promise.resolve(e(()=>t.apply(this,s),{fn:t,thisArg:this,args:s})).then(u).catch(l)})}return n}function N(...e){let t=0,n,s=!0,u=z,l,a,v,f,E;!o.isRef(e[0])&&typeof e[0]=="object"?{delay:a,trailing:v=!0,leading:f=!0,rejectOnCancel:E=!1}=e[0]:[a,v=!0,f=!0,E=!1]=e;const c=()=>{n&&(clearTimeout(n),n=void 0,u(),u=z)};return r=>{const i=o.toValue(a),m=Date.now()-t,p=()=>l=r();return c(),i<=0?(t=Date.now(),p()):(m>i&&(f||!s)?(t=Date.now(),p()):v&&(l=new Promise((w,x)=>{u=E?x:w,n=setTimeout(()=>{t=Date.now(),s=!0,w(p()),c()},Math.max(0,i-m))})),!f&&!n&&(n=setTimeout(()=>s=!0,i)),s=!1,l)}}function Z(e,t=200,n=!1,s=!0,u=!1){return F(N(t,n,s,u),e)}const M=Y(()=>{const e=o.ref([]),t=o.computed(()=>e.value.length>0),n={component:o.ref(null),ref:o.ref(null)},s=o.ref([]),u=o.ref([]),l=o.ref([]),a={zone:o.ref(null),element:o.ref(null)},v={current:o.ref(null),start:o.ref(null),offset:{percent:o.ref(null),pixel:o.ref(null)}};return{isDragging:t,activeContainer:n,elements:s,draggingElements:e,selectedElements:u,zones:l,hovered:a,pointerPosition:v}}),B=()=>{const e=o.ref(null),{draggingElements:t,pointerPosition:n,isDragging:s,activeContainer:u}=M();return o.onMounted(()=>{u.ref=e}),o.onBeforeUnmount(()=>{u.ref.value=null}),{elementRef:e,draggingElements:t,pointerPosition:n,isDragging:s}},q=["innerHTML"],K=o.defineComponent({__name:"DefaultOverlay",setup(e){const{elementRef:t,pointerPosition:n,isDragging:s,draggingElements:u}=B(),l=o.computed(()=>{var a,v,f,E;return{transform:`translate3d(${(((a=n.current.value)==null?void 0:a.x)??0)-(((v=n.offset.pixel.value)==null?void 0:v.x)??0)}px, ${(((f=n.current.value)==null?void 0:f.y)??0)-(((E=n.offset.pixel.value)==null?void 0:E.y)??0)}px, 0)`,zIndex:1e3,position:"fixed",top:0,left:0,transition:"0.3s cubic-bezier(0.165, 0.84, 0.44, 1)"}});return(a,v)=>o.unref(s)?(o.openBlock(),o.createElementBlock("div",{key:0,ref_key:"elementRef",ref:t,style:o.normalizeStyle(l.value)},[(o.openBlock(!0),o.createElementBlock(o.Fragment,null,o.renderList(o.unref(u),(f,E)=>{var c,y;return o.openBlock(),o.createElementBlock("div",{key:E,innerHTML:f.initialHTML,style:o.normalizeStyle({width:`${(c=f.initialRect)==null?void 0:c.width}px`,height:`${(y=f.initialRect)==null?void 0:y.height}px`})},null,12,q)}),128))],4)):o.createCommentVNode("",!0)}}),R=o.defineComponent({__name:"DragOverlay",setup(e){const{activeContainer:t}=M(),n=o.computed(()=>t.component.value??K);return(s,u)=>(o.openBlock(),o.createBlock(o.resolveDynamicComponent(n.value)))}}),X={install(e){e.component("DragOverlay",R);const t=e.mount;e.mount=function(s){const u=t.call(this,s),l=typeof s=="string"?document.querySelector(s):s;if(l&&l instanceof Element&&!l.querySelector("#vue-dnd-kit-overlay")){const a=document.createElement("div");a.id="vue-dnd-kit-overlay",a.style.pointerEvents="none",l.appendChild(a);const v=o.createVNode(R);o.render(v,a),e.__VUE_DND_KIT_OVERLAY__={container:a,vnode:v}}return u};const n=e.unmount;e.unmount=function(){return e.__VUE_DND_KIT_OVERLAY__&&(o.render(null,e.__VUE_DND_KIT_OVERLAY__.container),delete e.__VUE_DND_KIT_OVERLAY__),n.call(this)}}},A="data-vue-dnd-kit-draggable",L=e=>{e.preventDefault()},$=e=>{const{elements:t,draggingElements:n,hovered:s,selectedElements:u,isDragging:l}=M(),a=o.ref(null),v=o.computed(()=>{var r;return((r=s.element.value)==null?void 0:r.node)===a.value}),f=o.computed(()=>n.value.some(r=>r.node===a.value)),E=o.computed(()=>{if(!a.value||!l.value)return!1;const r=t.value.find(i=>i.node===a.value);return r!=null&&r.groups.length?!n.value.some(i=>i.groups.length?!i.groups.some(m=>r.groups.includes(m)):!1):!0});return{elementRef:a,registerElement:()=>{if(!a.value)throw new Error("ElementRef is not set");t.value.push({node:a.value,groups:(e==null?void 0:e.groups)??[],layer:(e==null?void 0:e.layer)??null,defaultLayer:(e==null?void 0:e.layer)??null,events:(e==null?void 0:e.events)??{},data:(e==null?void 0:e.data)??void 0}),a.value.addEventListener("dragstart",L),a.value.addEventListener("drag",L),a.value.setAttribute(A,"true"),a.value.setAttribute("draggable","false"),a.value.style.touchAction="none"},unregisterElement:()=>{var m,p,w,x;const r=t.value.findIndex(d=>d.node===a.value);r!==-1&&t.value.splice(r,1);const i=u.value.findIndex(d=>d.node===a.value);i!==-1&&u.value.splice(i,1),(m=a.value)==null||m.removeEventListener("dragstart",L),(p=a.value)==null||p.removeEventListener("drag",L),(w=a.value)==null||w.removeAttribute(A),(x=a.value)==null||x.removeAttribute("draggable")},isDragging:f,isOvered:v,isAllowed:E}},j=()=>{let e="",t="",n="";return{disableInteractions:()=>{const l=document.body;e=l.style.userSelect,l.style.userSelect="none",window.addEventListener("contextmenu",L),window.addEventListener("selectstart",L),window.addEventListener("touchstart",L),window.addEventListener("touchmove",L)},enableInteractions:()=>{const l=document.body;l.style.userSelect=e,l.style.touchAction=t,l.style.overscrollBehavior=n,window.removeEventListener("contextmenu",L),window.removeEventListener("selectstart",L),window.removeEventListener("touchstart",L),window.removeEventListener("touchmove",L)}}},V=(e,t)=>e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y,T=e=>{if(!e)return{x:0,y:0,width:0,height:0,bottom:0,left:0,right:0,top:0};const t=e.getBoundingClientRect();return{bottom:t.bottom,left:t.left,right:t.right,top:t.top,x:t.x,y:t.y,width:t.width,height:t.height}},O=e=>({x:e.x+e.width/2,y:e.y+e.height/2}),G=(e,t)=>{const n=T(e);return{pixel:{x:t.x-n.x,y:t.y-n.y},percent:{x:(t.x-n.x)/n.width*100,y:(t.y-n.y)/n.height*100}}},U=(e,t)=>{const n=t.x-e.x,s=t.y-e.y;return Math.sqrt(n*n+s*s)},H=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),s=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y)),u=n*s,l=e.width*e.height,a=t.width*t.height;return(u/l*100+u/a*100)/2},C=(e,t)=>e?t.contains(e):!1,W=e=>{var c,y;const t=T(e.activeContainer.ref.value),n=O(t),s=((c=e.pointerPosition.current.value)==null?void 0:c.x)??0,u=((y=e.pointerPosition.current.value)==null?void 0:y.y)??0,a=!(t&&s>=t.x&&s<=t.x+t.width&&u>=t.y&&u<=t.y+t.height),v=e.draggingElements.value.map(r=>r.node),f=e.elements.value.filter(r=>{if(!r.node||v.some(m=>m&&C(r.node,m)))return!1;const i=T(r.node);return i&&t&&V(i,t)}).map(r=>{const i=T(r.node),m=O(i),p=s>=i.x&&s<=i.x+i.width&&u>=i.y&&u<=i.y+i.height,w=H(i,t),x=U(n,m),d=e.elements.value.filter(g=>g!==r&&g.node&&r.node&&C(r.node,g.node)).length;return{element:r,node:r.node,isPointerInElement:p,overlapPercent:w,depth:d,centerDistance:x}}).sort((r,i)=>{if(!a){if(r.isPointerInElement&&i.isPointerInElement)return i.depth-r.depth;if(r.isPointerInElement!==i.isPointerInElement)return r.isPointerInElement?-1:1}return Math.abs(r.overlapPercent-i.overlapPercent)<=1?r.centerDistance-i.centerDistance:i.overlapPercent-r.overlapPercent}),E=e.zones.value.filter(r=>{if(!r.node||v.some(m=>m&&C(r.node,m)))return!1;const i=T(r.node);return i&&t&&V(i,t)}).map(r=>{const i=T(r.node),m=O(i),p=s>=i.x&&s<=i.x+i.width&&u>=i.y&&u<=i.y+i.height,w=H(i,t),x=U(n,m),d=e.zones.value.filter(g=>g!==r&&g.node&&r.node&&C(r.node,g.node)).length;return{zone:r,node:r.node,isPointerInElement:p,overlapPercent:w,depth:d,centerDistance:x}}).sort((r,i)=>{if(!a){if(r.isPointerInElement&&i.isPointerInElement)return i.depth-r.depth;if(r.isPointerInElement!==i.isPointerInElement)return r.isPointerInElement?-1:1}return Math.abs(r.overlapPercent-i.overlapPercent)<=1?r.centerDistance-i.centerDistance:i.overlapPercent-r.overlapPercent});return[...f.map(r=>r.node),...E.map(r=>r.node)]},J=e=>{const t=M();return{onPointerStart:l=>{t.pointerPosition.start.value={x:l.clientX,y:l.clientY},t.pointerPosition.current.value={x:l.clientX,y:l.clientY};const{pixel:a,percent:v}=G(e.value,{x:l.clientX,y:l.clientY});t.pointerPosition.offset.pixel.value=a,t.pointerPosition.offset.percent.value=v},onPointerMove:l=>{t.pointerPosition.current.value={x:l.clientX,y:l.clientY}},onPointerEnd:()=>{t.pointerPosition.current.value=null,t.pointerPosition.start.value=null,t.pointerPosition.offset.pixel.value=null,t.pointerPosition.offset.percent.value=null}}},Q=(e,t)=>{const n=M(),{onPointerStart:s,onPointerMove:u,onPointerEnd:l}=J(e);let a=null;const v=d=>{var S,I;const g=n.selectedElements.value.some(h=>h.node===d);if(n.selectedElements.value.length&&g)return n.selectedElements.value.map(h=>{var _,D;return{...h,initialHTML:((_=h.node)==null?void 0:_.outerHTML)??"",initialRect:(D=h.node)==null?void 0:D.getBoundingClientRect()}});n.selectedElements.value=[];const P=n.elements.value.find(h=>h.node===d);return P?[{...P,initialHTML:((S=P.node)==null?void 0:S.outerHTML)??"",initialRect:(I=P.node)==null?void 0:I.getBoundingClientRect()}]:[]},f=d=>{if(!d)return{element:null,zone:null};const g=Array.isArray(d)?d:[d],P=n.draggingElements.value.map(h=>h.node),[S]=g.map(h=>n.elements.value.find(_=>_.node===h)).filter(h=>h?h.groups.length?!n.draggingElements.value.some(D=>D.groups.length?!D.groups.some(k=>h.groups.includes(k)):!1):!0:!1),[I]=g.map(h=>{const _=n.zones.value.find(D=>D.node===h);return!_||P.some(D=>D&&C(h,D))||_.groups.length&&!!n.draggingElements.value.some(k=>k.groups.length?!k.groups.some(b=>_.groups.includes(b)):!1)?null:_});return{element:S??null,zone:I??null}},E=(t==null?void 0:t.sensor)||W,c=d=>{var S,I,h,_,D,k;const g=n.hovered.element.value,P=n.hovered.zone.value;n.hovered.element.value=d.element,n.hovered.zone.value=d.zone,n.hovered.element.value!==g&&((S=g==null?void 0:g.events)!=null&&S.onLeave&&g.events.onLeave(n),(h=(I=n.hovered.element.value)==null?void 0:I.events)!=null&&h.onHover&&n.hovered.element.value.events.onHover(n)),n.hovered.zone.value!==P&&((_=P==null?void 0:P.events)!=null&&_.onLeave&&P.events.onLeave(n),(k=(D=n.hovered.zone.value)==null?void 0:D.events)!=null&&k.onHover&&n.hovered.zone.value.events.onHover(n))},y=Z(()=>{const d=E(n),g=f(d);c(g)},(t==null?void 0:t.throttle)??0),r=()=>{y(),a=requestAnimationFrame(r)},i=()=>r(),m=()=>{a!==null&&(cancelAnimationFrame(a),a=null)};return{activate:d=>{n.draggingElements.value=v(e.value),s(d),i()},track:d=>{u(d)},deactivate:()=>{var d,g;l(),n.hovered.zone.value?(g=(d=n.hovered.zone.value.events).onDrop)==null||g.call(d,n):n.draggingElements.value.forEach(P=>{var S,I;return(I=(S=P.events).onEnd)==null?void 0:I.call(S,n)}),n.draggingElements.value=[],n.selectedElements.value=[],n.hovered.zone.value=null,n.hovered.element.value=null,m()}}},ee=e=>{const{elementRef:t,registerElement:n,unregisterElement:s,isDragging:u,isOvered:l,isAllowed:a}=$(e),{disableInteractions:v,enableInteractions:f}=j(),{activeContainer:E,pointerPosition:c}=M(),{activate:y,track:r,deactivate:i}=Q(t,{throttle:e==null?void 0:e.throttle,sensor:e==null?void 0:e.sensor}),m=d=>{e!=null&&e.container&&(E.component.value=o.markRaw(e.container)),v(),y(d),document.addEventListener("pointermove",p),document.addEventListener("pointerup",x),document.addEventListener("wheel",w)},p=d=>r(d),w=d=>r(d),x=()=>{E.component.value=null,f(),i(),document.removeEventListener("pointermove",p),document.removeEventListener("pointerup",x),document.removeEventListener("wheel",w)};return o.onMounted(n),o.onBeforeUnmount(s),{pointerPosition:c,elementRef:t,isDragging:u,isOvered:l,isAllowed:a,handleDragStart:m}},te=e=>{const{zones:t,hovered:n,draggingElements:s,isDragging:u}=M(),l=o.ref(null),a=o.computed(()=>{var c;return((c=n.zone.value)==null?void 0:c.node)===l.value}),v=o.computed(()=>{if(!l.value||!u.value)return!1;const c=t.value.find(y=>y.node===l.value);return c!=null&&c.groups.length?!s.value.some(y=>y.groups.length?!y.groups.some(r=>c.groups.includes(r)):!1):!0});return{elementRef:l,registerZone:()=>{if(!l.value)throw new Error("elementRef is not set");t.value.push({node:l.value,groups:(e==null?void 0:e.groups)??[],events:(e==null?void 0:e.events)??{},data:(e==null?void 0:e.data)??void 0}),l.value.setAttribute("data-dnd-droppable","true")},unregisterZone:()=>{if(!l.value)throw new Error("elementRef is not set");const c=t.value.findIndex(y=>y.node===l.value);c!==-1&&t.value.splice(c,1)},isOvered:a,isAllowed:v}},ne=e=>{const{elementRef:t,registerZone:n,unregisterZone:s,isOvered:u,isAllowed:l}=te(e);return o.onMounted(n),o.onBeforeUnmount(s),{elementRef:t,isOvered:u,isAllowed:l}},re=e=>{const{selectedElements:t,elements:n}=M(),s=o.computed(()=>n.value.find(c=>c.node===e.value)),u=o.computed(()=>t.value.some(c=>c.node===e.value)),l=o.computed(()=>e.value?t.value.some(c=>c.node&&C(c.node,e.value)):!1),a=o.computed(()=>e.value?t.value.some(c=>c.node&&C(e.value,c.node)):!1),v=()=>{s.value&&(t.value=t.value.filter(c=>c.node!==e.value))},f=()=>{s.value&&(l.value&&(t.value=t.value.filter(c=>c.node&&!C(c.node,e.value))),a.value&&(t.value=t.value.filter(c=>c.node&&!C(e.value,c.node))),t.value.push(s.value))};return{handleUnselect:v,handleSelect:f,handleToggleSelect:()=>{s.value&&(t.value.some(c=>c.node===e.value)?v():f())},isSelected:u,isParentOfSelected:l}};exports.default=X;exports.useDnDStore=M;exports.useDraggable=ee;exports.useDroppable=ne;exports.useSelection=re;
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const s=require("vue");function H(e){let t=!1,n;const o=s.effectScope(!0);return(...l)=>(t||(n=o.run(()=>e(...l)),t=!0),n)}typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const V=()=>{};function Z(e,t){function n(...o){return new Promise((l,u)=>{Promise.resolve(e(()=>t.apply(this,o),{fn:t,thisArg:this,args:o})).then(l).catch(u)})}return n}function q(...e){let t=0,n,o=!0,l=V,u,a,f,d,v;!s.isRef(e[0])&&typeof e[0]=="object"?{delay:a,trailing:f=!0,leading:d=!0,rejectOnCancel:v=!1}=e[0]:[a,f=!0,d=!0,v=!1]=e;const c=()=>{n&&(clearTimeout(n),n=void 0,l(),l=V)};return r=>{const i=s.toValue(a),g=Date.now()-t,p=()=>u=r();return c(),i<=0?(t=Date.now(),p()):(g>i&&(d||!o)?(t=Date.now(),p()):f&&(u=new Promise((w,L)=>{l=v?L:w,n=setTimeout(()=>{t=Date.now(),o=!0,w(p()),c()},Math.max(0,i-g))})),!d&&!n&&(n=setTimeout(()=>o=!0,i)),o=!1,u)}}function N(e,t=200,n=!1,o=!0,l=!1){return Z(q(t,n,o,l),e)}const M=H(()=>{const e=s.ref([]),t=s.computed(()=>e.value.length>0),n={component:s.ref(null),ref:s.shallowRef(null)},o=s.ref([]),l=s.ref([]),u=s.ref([]),a={zone:s.ref(null),element:s.ref(null)},f={current:s.shallowRef(null),start:s.shallowRef(null),offset:{percent:s.shallowRef(null),pixel:s.shallowRef(null)}},d={w:s.shallowRef(!1),s:s.shallowRef(!1),a:s.shallowRef(!1),d:s.shallowRef(!1)};return{isDragging:t,activeContainer:n,elements:o,draggingElements:e,selectedElements:l,zones:u,hovered:a,pointerPosition:f,keyboard:d}}),$=()=>{const e=s.ref(null),{draggingElements:t,pointerPosition:n,isDragging:o,activeContainer:l}=M();return s.onMounted(()=>{l.ref=e}),s.onBeforeUnmount(()=>{l.ref.value=null}),{elementRef:e,draggingElements:t,pointerPosition:n,isDragging:o}},j=["innerHTML"],W=s.defineComponent({__name:"DefaultOverlay",setup(e){const{elementRef:t,pointerPosition:n,isDragging:o,draggingElements:l}=$(),u=s.computed(()=>{var a,f,d,v;return{transform:`translate3d(${(((a=n.current.value)==null?void 0:a.x)??0)-(((f=n.offset.pixel.value)==null?void 0:f.x)??0)}px, ${(((d=n.current.value)==null?void 0:d.y)??0)-(((v=n.offset.pixel.value)==null?void 0:v.y)??0)}px, 0)`,zIndex:1e3,position:"fixed",top:0,left:0,transition:"0.3s cubic-bezier(0.165, 0.84, 0.44, 1)"}});return(a,f)=>s.unref(o)?(s.openBlock(),s.createElementBlock("div",{key:0,ref_key:"elementRef",ref:t,style:s.normalizeStyle(u.value)},[(s.openBlock(!0),s.createElementBlock(s.Fragment,null,s.renderList(s.unref(l),(d,v)=>{var c,h;return s.openBlock(),s.createElementBlock("div",{key:v,innerHTML:d.initialHTML,style:s.normalizeStyle({width:`${(c=d.initialRect)==null?void 0:c.width}px`,height:`${(h=d.initialRect)==null?void 0:h.height}px`})},null,12,j)}),128))],4)):s.createCommentVNode("",!0)}}),U=s.defineComponent({__name:"DragOverlay",setup(e){const{activeContainer:t}=M(),n=s.computed(()=>t.component.value??W);return(o,l)=>(s.openBlock(),s.createBlock(s.resolveDynamicComponent(n.value)))}}),G={install(e){e.component("DragOverlay",U);const t=e.mount;e.mount=function(o){const l=t.call(this,o),u=typeof o=="string"?document.querySelector(o):o;if(u&&u instanceof Element&&!u.querySelector("#vue-dnd-kit-overlay")){const a=document.createElement("div");a.id="vue-dnd-kit-overlay",a.style.pointerEvents="none",u.appendChild(a);const f=s.createVNode(U);s.render(f,a),e.__VUE_DND_KIT_OVERLAY__={container:a,vnode:f}}return l};const n=e.unmount;e.unmount=function(){return e.__VUE_DND_KIT_OVERLAY__&&(s.render(null,e.__VUE_DND_KIT_OVERLAY__.container),delete e.__VUE_DND_KIT_OVERLAY__),n.call(this)}}},Y=(e,t)=>e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y,T=e=>{if(!e)return{x:0,y:0,width:0,height:0,bottom:0,left:0,right:0,top:0};const t=e.getBoundingClientRect();return{bottom:t.bottom,left:t.left,right:t.right,top:t.top,x:t.x,y:t.y,width:t.width,height:t.height}},K=e=>({x:e.x+e.width/2,y:e.y+e.height/2}),J=(e,t)=>{const n=T(e);return{pixel:{x:t.x-n.x,y:t.y-n.y},percent:{x:(t.x-n.x)/n.width*100,y:(t.y-n.y)/n.height*100}}},B=(e,t)=>{const n=t.x-e.x,o=t.y-e.y;return Math.sqrt(n*n+o*o)},X=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),o=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y)),l=n*o,u=e.width*e.height,a=t.width*t.height;return(l/u*100+l/a*100)/2},F="data-vue-dnd-kit-draggable",_=e=>{e.preventDefault()},Q=e=>{const{elements:t,draggingElements:n,hovered:o,selectedElements:l,isDragging:u}=M(),a=s.ref(null),f=s.computed(()=>{var r;return((r=o.element.value)==null?void 0:r.node)===a.value}),d=s.computed(()=>n.value.some(r=>r.node===a.value)),v=s.computed(()=>{if(!a.value||!u.value)return!1;const r=t.value.find(i=>i.node===a.value);return r!=null&&r.groups.length?!n.value.some(i=>i.groups.length?!i.groups.some(g=>r.groups.includes(g)):!1):!0});return{elementRef:a,registerElement:()=>{if(!a.value)throw new Error("ElementRef is not set");t.value.push({node:a.value,groups:(e==null?void 0:e.groups)??[],layer:(e==null?void 0:e.layer)??null,defaultLayer:(e==null?void 0:e.layer)??null,events:(e==null?void 0:e.events)??{},data:(e==null?void 0:e.data)??void 0}),a.value.addEventListener("dragstart",_),a.value.addEventListener("drag",_),a.value.setAttribute(F,"true"),a.value.setAttribute("draggable","false")},unregisterElement:()=>{var g,p,w,L;const r=t.value.findIndex(S=>S.node===a.value);r!==-1&&t.value.splice(r,1);const i=l.value.findIndex(S=>S.node===a.value);i!==-1&&l.value.splice(i,1),(g=a.value)==null||g.removeEventListener("dragstart",_),(p=a.value)==null||p.removeEventListener("drag",_),(w=a.value)==null||w.removeAttribute(F),(L=a.value)==null||L.removeAttribute("draggable")},isDragging:d,isOvered:f,isAllowed:v}},b=(e,t)=>e?t.contains(e):!1,ee=e=>{var c,h;const t=T(e.activeContainer.ref.value),n=K(t),o=((c=e.pointerPosition.current.value)==null?void 0:c.x)??0,l=((h=e.pointerPosition.current.value)==null?void 0:h.y)??0,a=!(t&&o>=t.x&&o<=t.x+t.width&&l>=t.y&&l<=t.y+t.height),f=e.draggingElements.value.map(r=>r.node),d=e.elements.value.filter(r=>{if(!r.node)return!1;const i=T(r.node);return i&&t&&Y(i,t)}).map(r=>{const i=T(r.node),g=K(i),p=o>=i.x&&o<=i.x+i.width&&l>=i.y&&l<=i.y+i.height,w=X(i,t),L=B(n,g),S=e.elements.value.filter(C=>C!==r&&C.node&&r.node&&b(r.node,C.node)).length;return{element:r,node:r.node,isPointerInElement:p,overlapPercent:w,depth:S,centerDistance:L}}).sort((r,i)=>{if(!a){if(r.isPointerInElement&&i.isPointerInElement)return i.depth-r.depth;if(r.isPointerInElement!==i.isPointerInElement)return r.isPointerInElement?-1:1}return Math.abs(r.overlapPercent-i.overlapPercent)<=1?r.centerDistance-i.centerDistance:i.overlapPercent-r.overlapPercent}),v=e.zones.value.filter(r=>{if(!r.node||f.some(g=>g&&b(r.node,g)))return!1;const i=T(r.node);return i&&t&&Y(i,t)}).map(r=>{const i=T(r.node),g=K(i),p=o>=i.x&&o<=i.x+i.width&&l>=i.y&&l<=i.y+i.height,w=X(i,t),L=B(n,g),S=e.zones.value.filter(C=>C!==r&&C.node&&r.node&&b(r.node,C.node)).length;return{zone:r,node:r.node,isPointerInElement:p,overlapPercent:w,depth:S,centerDistance:L}}).sort((r,i)=>{if(!a){if(r.isPointerInElement&&i.isPointerInElement)return i.depth-r.depth;if(r.isPointerInElement!==i.isPointerInElement)return r.isPointerInElement?-1:1}return Math.abs(r.overlapPercent-i.overlapPercent)<=1?r.centerDistance-i.centerDistance:i.overlapPercent-r.overlapPercent});return[...d.map(r=>r.node),...v.map(r=>r.node)]},te=(e,t)=>{const{pointerPosition:n,keyboard:o}=M(),l=(t==null?void 0:t.moveStep)||10;return{onKeyboardStart:d=>{var r;_(d);const v=T(e.value);(r=e.value)==null||r.blur();const c=v.x+v.width/2,h=v.y+v.height/2;n.start.value={x:c,y:h},n.current.value={x:c,y:h},n.offset.pixel.value={x:v.width/2,y:v.height/2},n.offset.percent.value={x:50,y:50}},onKeyboardMove:()=>{if(!n.current.value)return;const d=n.current.value.x,v=n.current.value.y;let c=d,h=v;o.w.value&&(h-=l),o.s.value&&(h+=l),o.a.value&&(c-=l),o.d.value&&(c+=l),n.current.value={x:c,y:h}},onKeyboardEnd:()=>{n.current.value=null,n.start.value=null,n.offset.pixel.value=null,n.offset.percent.value=null}}},ne=e=>{const t=M();return{onPointerStart:u=>{t.pointerPosition.start.value={x:u.clientX,y:u.clientY},t.pointerPosition.current.value={x:u.clientX,y:u.clientY};const{pixel:a,percent:f}=J(e.value,{x:u.clientX,y:u.clientY});t.pointerPosition.offset.pixel.value=a,t.pointerPosition.offset.percent.value=f},onPointerMove:u=>{t.pointerPosition.current.value={x:u.clientX,y:u.clientY}},onPointerEnd:()=>{t.pointerPosition.current.value=null,t.pointerPosition.start.value=null,t.pointerPosition.offset.pixel.value=null,t.pointerPosition.offset.percent.value=null}}},re=(e,t)=>{var A,z;const n=M(),{onPointerStart:o,onPointerMove:l,onPointerEnd:u}=ne(e),{onKeyboardStart:a,onKeyboardMove:f,onKeyboardEnd:d}=te(e,t==null?void 0:t.keyboard);let v=null;const c=y=>{var R,I;const x=n.selectedElements.value.some(m=>m.node===y);if(n.selectedElements.value.length&&x)return n.selectedElements.value.map(m=>{var E,k;return{...m,initialHTML:((E=m.node)==null?void 0:E.outerHTML)??"",initialRect:(k=m.node)==null?void 0:k.getBoundingClientRect()}});n.selectedElements.value=[];const D=n.elements.value.find(m=>m.node===y);return D?[{...D,initialHTML:((R=D.node)==null?void 0:R.outerHTML)??"",initialRect:(I=D.node)==null?void 0:I.getBoundingClientRect()}]:[]},h=y=>{if(!y)return{element:null,zone:null};const x=Array.isArray(y)?y:[y],D=n.draggingElements.value.map(m=>m.node),R=x.map(m=>n.elements.value.find(E=>E.node===m)).filter(m=>!m||D.some(E=>E&&(E===m.node||b(m.node,E)))?!1:m.groups.length?!n.draggingElements.value.some(k=>k.groups.length?!k.groups.some(O=>m.groups.includes(O)):!1):!0),I=x.map(m=>n.zones.value.find(E=>E.node===m)).filter(m=>!m||D.some(E=>E&&(E===m.node||b(m.node,E)))?!1:m.groups.length&&!!n.draggingElements.value.some(k=>k.groups.length?!k.groups.some(O=>m.groups.includes(O)):!1)?null:!0);return{element:R[0]??null,zone:I[0]??null}},r=((A=t==null?void 0:t.sensor)==null?void 0:A.setup)||ee,i=y=>{var R,I,m,E,k,O;const x=n.hovered.element.value,D=n.hovered.zone.value;n.hovered.element.value=y.element,n.hovered.zone.value=y.zone,n.hovered.element.value!==x&&((R=x==null?void 0:x.events)!=null&&R.onLeave&&x.events.onLeave(n),(m=(I=n.hovered.element.value)==null?void 0:I.events)!=null&&m.onHover&&n.hovered.element.value.events.onHover(n)),n.hovered.zone.value!==D&&((E=D==null?void 0:D.events)!=null&&E.onLeave&&D.events.onLeave(n),(O=(k=n.hovered.zone.value)==null?void 0:k.events)!=null&&O.onHover&&n.hovered.zone.value.events.onHover(n))},g=N(()=>{const y=r(n),x=h(y);i(x)},((z=t==null?void 0:t.sensor)==null?void 0:z.throttle)??0),p=()=>{g(),v=requestAnimationFrame(p)},w=()=>p(),L=()=>{v!==null&&(cancelAnimationFrame(v),v=null)};return{activate:y=>{n.draggingElements.value=c(e.value),y instanceof PointerEvent?o(y):a(y),w()},track:y=>{y instanceof KeyboardEvent?f():l(y)},deactivate:(y=!0)=>{var x,D;u(),d(),y&&(n.hovered.zone.value?(D=(x=n.hovered.zone.value.events).onDrop)==null||D.call(x,n):n.draggingElements.value.forEach(R=>{var I,m;return(m=(I=R.events).onEnd)==null?void 0:m.call(I,n)}),n.selectedElements.value=[]),n.draggingElements.value=[],n.hovered.zone.value=null,n.hovered.element.value=null,L()}}},le=H(()=>{let e="",t="",n="",o=null,l=null,u=null,a=null;const{activeContainer:f,keyboard:d}=M(),v=()=>{const g=document.body;e=g.style.userSelect,g.style.userSelect="none",window.addEventListener("contextmenu",_),window.addEventListener("selectstart",_),window.addEventListener("touchstart",_),window.addEventListener("touchmove",_)},c=()=>{const g=document.body;g.style.userSelect=e,g.style.touchAction=t,g.style.overscrollBehavior=n,window.removeEventListener("contextmenu",_),window.removeEventListener("selectstart",_),window.removeEventListener("touchstart",_),window.removeEventListener("touchmove",_)},h=()=>{o&&(document.removeEventListener("pointermove",o),o=null),l&&(document.removeEventListener("pointerup",()=>l==null?void 0:l()),l=null),u&&(document.removeEventListener("wheel",u),u=null),a&&(document.removeEventListener("keydown",a),document.removeEventListener("keypress",a),document.removeEventListener("keyup",a),a=null)},r=(g,p,w)=>{h(),g.target.blur(),w!=null&&w.container&&(f.component.value=s.markRaw(w.container));const{activate:L,track:S,deactivate:C}=re(p,w);l=(P=!0)=>{f.component.value=null,c(),C(P),h()},o=P=>S(P),u=P=>S(P),a=P=>{P.type==="keydown"&&i(P,!0),P.type==="keypress"&&i(P,!0),P.type==="keyup"&&(P.code==="Escape"&&(l==null||l(!1)),P.code==="Enter"&&(l==null||l()),i(P,!1)),S(P)},v(),L(g),document.addEventListener("pointermove",o),document.addEventListener("pointerup",()=>l==null?void 0:l()),document.addEventListener("wheel",u),document.addEventListener("keydown",a),document.addEventListener("keypress",a),document.addEventListener("keyup",a)},i=(g,p=!0)=>{g.code==="KeyW"&&(d.w.value=p),g.code==="KeyA"&&(d.a.value=p),g.code==="KeyS"&&(d.s.value=p),g.code==="KeyD"&&(d.d.value=p)};return{handleDragStart:r}}),oe=e=>{const{elementRef:t,registerElement:n,unregisterElement:o,isDragging:l,isOvered:u,isAllowed:a}=Q(e),{pointerPosition:f}=M(),{handleDragStart:d}=le(),v=c=>d(c,t,e);return s.onMounted(n),s.onBeforeUnmount(o),{pointerPosition:f,elementRef:t,isDragging:l,isOvered:u,isAllowed:a,handleDragStart:v}},se=e=>{const{zones:t,hovered:n,draggingElements:o,isDragging:l}=M(),u=s.ref(null),a=s.computed(()=>{var c;return((c=n.zone.value)==null?void 0:c.node)===u.value}),f=s.computed(()=>{if(!u.value||!l.value)return!1;const c=t.value.find(h=>h.node===u.value);return c!=null&&c.groups.length?!o.value.some(h=>h.groups.length?!h.groups.some(r=>c.groups.includes(r)):!1):!0});return{elementRef:u,registerZone:()=>{if(!u.value)throw new Error("elementRef is not set");t.value.push({node:u.value,groups:(e==null?void 0:e.groups)??[],events:(e==null?void 0:e.events)??{},data:(e==null?void 0:e.data)??void 0}),u.value.setAttribute("data-dnd-droppable","true")},unregisterZone:()=>{if(!u.value)throw new Error("elementRef is not set");const c=t.value.findIndex(h=>h.node===u.value);c!==-1&&t.value.splice(c,1)},isOvered:a,isAllowed:f}},ae=e=>{const{elementRef:t,registerZone:n,unregisterZone:o,isOvered:l,isAllowed:u}=se(e);return s.onMounted(n),s.onBeforeUnmount(o),{elementRef:t,isOvered:l,isAllowed:u}},ie=e=>{const{selectedElements:t,elements:n}=M(),o=s.computed(()=>n.value.find(c=>c.node===e.value)),l=s.computed(()=>t.value.some(c=>c.node===e.value)),u=s.computed(()=>e.value?t.value.some(c=>c.node&&b(c.node,e.value)):!1),a=s.computed(()=>e.value?t.value.some(c=>c.node&&b(e.value,c.node)):!1),f=()=>{o.value&&(t.value=t.value.filter(c=>c.node!==e.value))},d=()=>{o.value&&(u.value&&(t.value=t.value.filter(c=>c.node&&!b(c.node,e.value))),a.value&&(t.value=t.value.filter(c=>c.node&&!b(e.value,c.node))),t.value.push(o.value))};return{handleUnselect:f,handleSelect:d,handleToggleSelect:()=>{o.value&&(t.value.some(c=>c.node===e.value)?f():d())},isSelected:l,isParentOfSelected:u}};exports.default=G;exports.getBoundingBox=T;exports.useDnDStore=M;exports.useDraggable=oe;exports.useDroppable=ae;exports.useSelection=ie;
|
|
@@ -1,85 +1,91 @@
|
|
|
1
|
-
import { effectScope as
|
|
2
|
-
function
|
|
1
|
+
import { effectScope as te, isRef as ne, toValue as re, ref as I, computed as S, shallowRef as O, onMounted as U, onBeforeUnmount as X, defineComponent as B, createElementBlock as z, createCommentVNode as le, unref as Z, openBlock as V, normalizeStyle as N, Fragment as oe, renderList as se, createBlock as ae, resolveDynamicComponent as ie, createVNode as ue, render as $, markRaw as ce } from "vue";
|
|
2
|
+
function ee(e) {
|
|
3
3
|
let t = !1, n;
|
|
4
|
-
const
|
|
5
|
-
return (...
|
|
4
|
+
const o = te(!0);
|
|
5
|
+
return (...l) => (t || (n = o.run(() => e(...l)), t = !0), n);
|
|
6
6
|
}
|
|
7
7
|
typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
|
|
8
|
-
const
|
|
8
|
+
const q = () => {
|
|
9
9
|
};
|
|
10
|
-
function
|
|
11
|
-
function n(...
|
|
12
|
-
return new Promise((
|
|
13
|
-
Promise.resolve(e(() => t.apply(this,
|
|
10
|
+
function de(e, t) {
|
|
11
|
+
function n(...o) {
|
|
12
|
+
return new Promise((l, i) => {
|
|
13
|
+
Promise.resolve(e(() => t.apply(this, o), { fn: t, thisArg: this, args: o })).then(l).catch(i);
|
|
14
14
|
});
|
|
15
15
|
}
|
|
16
16
|
return n;
|
|
17
17
|
}
|
|
18
|
-
function
|
|
19
|
-
let t = 0, n,
|
|
20
|
-
!
|
|
18
|
+
function ve(...e) {
|
|
19
|
+
let t = 0, n, o = !0, l = q, i, s, v, c, d;
|
|
20
|
+
!ne(e[0]) && typeof e[0] == "object" ? { delay: s, trailing: v = !0, leading: c = !0, rejectOnCancel: d = !1 } = e[0] : [s, v = !0, c = !0, d = !1] = e;
|
|
21
21
|
const u = () => {
|
|
22
|
-
n && (clearTimeout(n), n = void 0,
|
|
22
|
+
n && (clearTimeout(n), n = void 0, l(), l = q);
|
|
23
23
|
};
|
|
24
24
|
return (r) => {
|
|
25
|
-
const
|
|
26
|
-
return u(),
|
|
27
|
-
|
|
28
|
-
t = Date.now(),
|
|
29
|
-
}, Math.max(0,
|
|
30
|
-
})), !
|
|
25
|
+
const a = re(s), f = Date.now() - t, y = () => i = r();
|
|
26
|
+
return u(), a <= 0 ? (t = Date.now(), y()) : (f > a && (c || !o) ? (t = Date.now(), y()) : v && (i = new Promise((p, _) => {
|
|
27
|
+
l = d ? _ : p, n = setTimeout(() => {
|
|
28
|
+
t = Date.now(), o = !0, p(y()), u();
|
|
29
|
+
}, Math.max(0, a - f));
|
|
30
|
+
})), !c && !n && (n = setTimeout(() => o = !0, a)), o = !1, i);
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
|
-
function
|
|
34
|
-
return
|
|
35
|
-
|
|
33
|
+
function fe(e, t = 200, n = !1, o = !0, l = !1) {
|
|
34
|
+
return de(
|
|
35
|
+
ve(t, n, o, l),
|
|
36
36
|
e
|
|
37
37
|
);
|
|
38
38
|
}
|
|
39
|
-
const T =
|
|
40
|
-
const e =
|
|
41
|
-
component:
|
|
42
|
-
ref:
|
|
43
|
-
},
|
|
44
|
-
zone:
|
|
45
|
-
element:
|
|
46
|
-
},
|
|
47
|
-
current:
|
|
48
|
-
start:
|
|
39
|
+
const T = ee(() => {
|
|
40
|
+
const e = I([]), t = S(() => e.value.length > 0), n = {
|
|
41
|
+
component: I(null),
|
|
42
|
+
ref: O(null)
|
|
43
|
+
}, o = I([]), l = I([]), i = I([]), s = {
|
|
44
|
+
zone: I(null),
|
|
45
|
+
element: I(null)
|
|
46
|
+
}, v = {
|
|
47
|
+
current: O(null),
|
|
48
|
+
start: O(null),
|
|
49
49
|
offset: {
|
|
50
|
-
percent:
|
|
51
|
-
pixel:
|
|
50
|
+
percent: O(null),
|
|
51
|
+
pixel: O(null)
|
|
52
52
|
}
|
|
53
|
+
}, c = {
|
|
54
|
+
w: O(!1),
|
|
55
|
+
s: O(!1),
|
|
56
|
+
a: O(!1),
|
|
57
|
+
d: O(!1)
|
|
53
58
|
};
|
|
54
59
|
return {
|
|
55
60
|
isDragging: t,
|
|
56
61
|
activeContainer: n,
|
|
57
|
-
elements:
|
|
62
|
+
elements: o,
|
|
58
63
|
draggingElements: e,
|
|
59
|
-
selectedElements:
|
|
60
|
-
zones:
|
|
64
|
+
selectedElements: l,
|
|
65
|
+
zones: i,
|
|
61
66
|
hovered: s,
|
|
62
|
-
pointerPosition:
|
|
67
|
+
pointerPosition: v,
|
|
68
|
+
keyboard: c
|
|
63
69
|
};
|
|
64
|
-
}),
|
|
65
|
-
const e =
|
|
66
|
-
return
|
|
67
|
-
|
|
68
|
-
}),
|
|
69
|
-
|
|
70
|
+
}), ge = () => {
|
|
71
|
+
const e = I(null), { draggingElements: t, pointerPosition: n, isDragging: o, activeContainer: l } = T();
|
|
72
|
+
return U(() => {
|
|
73
|
+
l.ref = e;
|
|
74
|
+
}), X(() => {
|
|
75
|
+
l.ref.value = null;
|
|
70
76
|
}), {
|
|
71
77
|
elementRef: e,
|
|
72
78
|
draggingElements: t,
|
|
73
79
|
pointerPosition: n,
|
|
74
|
-
isDragging:
|
|
80
|
+
isDragging: o
|
|
75
81
|
};
|
|
76
|
-
},
|
|
82
|
+
}, me = ["innerHTML"], he = /* @__PURE__ */ B({
|
|
77
83
|
__name: "DefaultOverlay",
|
|
78
84
|
setup(e) {
|
|
79
|
-
const { elementRef: t, pointerPosition: n, isDragging:
|
|
80
|
-
var s,
|
|
85
|
+
const { elementRef: t, pointerPosition: n, isDragging: o, draggingElements: l } = ge(), i = S(() => {
|
|
86
|
+
var s, v, c, d;
|
|
81
87
|
return {
|
|
82
|
-
transform: `translate3d(${(((s = n.current.value) == null ? void 0 : s.x) ?? 0) - (((
|
|
88
|
+
transform: `translate3d(${(((s = n.current.value) == null ? void 0 : s.x) ?? 0) - (((v = n.offset.pixel.value) == null ? void 0 : v.x) ?? 0)}px, ${(((c = n.current.value) == null ? void 0 : c.y) ?? 0) - (((d = n.offset.pixel.value) == null ? void 0 : d.y) ?? 0)}px, 0)`,
|
|
83
89
|
zIndex: 1e3,
|
|
84
90
|
position: "fixed",
|
|
85
91
|
top: 0,
|
|
@@ -87,121 +93,56 @@ const T = oe(() => {
|
|
|
87
93
|
transition: "0.3s cubic-bezier(0.165, 0.84, 0.44, 1)"
|
|
88
94
|
};
|
|
89
95
|
});
|
|
90
|
-
return (s,
|
|
96
|
+
return (s, v) => Z(o) ? (V(), z("div", {
|
|
91
97
|
key: 0,
|
|
92
98
|
ref_key: "elementRef",
|
|
93
99
|
ref: t,
|
|
94
|
-
style:
|
|
100
|
+
style: N(i.value)
|
|
95
101
|
}, [
|
|
96
|
-
(
|
|
97
|
-
var u,
|
|
98
|
-
return
|
|
99
|
-
key:
|
|
100
|
-
innerHTML:
|
|
101
|
-
style:
|
|
102
|
-
width: `${(u =
|
|
103
|
-
height: `${(
|
|
102
|
+
(V(!0), z(oe, null, se(Z(l), (c, d) => {
|
|
103
|
+
var u, m;
|
|
104
|
+
return V(), z("div", {
|
|
105
|
+
key: d,
|
|
106
|
+
innerHTML: c.initialHTML,
|
|
107
|
+
style: N({
|
|
108
|
+
width: `${(u = c.initialRect) == null ? void 0 : u.width}px`,
|
|
109
|
+
height: `${(m = c.initialRect) == null ? void 0 : m.height}px`
|
|
104
110
|
})
|
|
105
|
-
}, null, 12,
|
|
111
|
+
}, null, 12, me);
|
|
106
112
|
}), 128))
|
|
107
|
-
], 4)) :
|
|
113
|
+
], 4)) : le("", !0);
|
|
108
114
|
}
|
|
109
|
-
}),
|
|
115
|
+
}), W = /* @__PURE__ */ B({
|
|
110
116
|
__name: "DragOverlay",
|
|
111
117
|
setup(e) {
|
|
112
|
-
const { activeContainer: t } = T(), n =
|
|
113
|
-
() => t.component.value ??
|
|
118
|
+
const { activeContainer: t } = T(), n = S(
|
|
119
|
+
() => t.component.value ?? he
|
|
114
120
|
);
|
|
115
|
-
return (
|
|
121
|
+
return (o, l) => (V(), ae(ie(n.value)));
|
|
116
122
|
}
|
|
117
|
-
}),
|
|
123
|
+
}), Se = {
|
|
118
124
|
install(e) {
|
|
119
|
-
e.component("DragOverlay",
|
|
125
|
+
e.component("DragOverlay", W);
|
|
120
126
|
const t = e.mount;
|
|
121
|
-
e.mount = function(
|
|
122
|
-
const
|
|
123
|
-
if (
|
|
127
|
+
e.mount = function(o) {
|
|
128
|
+
const l = t.call(this, o), i = typeof o == "string" ? document.querySelector(o) : o;
|
|
129
|
+
if (i && i instanceof Element && !i.querySelector("#vue-dnd-kit-overlay")) {
|
|
124
130
|
const s = document.createElement("div");
|
|
125
|
-
s.id = "vue-dnd-kit-overlay", s.style.pointerEvents = "none",
|
|
126
|
-
const
|
|
127
|
-
|
|
131
|
+
s.id = "vue-dnd-kit-overlay", s.style.pointerEvents = "none", i.appendChild(s);
|
|
132
|
+
const v = ue(W);
|
|
133
|
+
$(v, s), e.__VUE_DND_KIT_OVERLAY__ = {
|
|
128
134
|
container: s,
|
|
129
|
-
vnode:
|
|
135
|
+
vnode: v
|
|
130
136
|
};
|
|
131
137
|
}
|
|
132
|
-
return
|
|
138
|
+
return l;
|
|
133
139
|
};
|
|
134
140
|
const n = e.unmount;
|
|
135
141
|
e.unmount = function() {
|
|
136
|
-
return e.__VUE_DND_KIT_OVERLAY__ && (
|
|
142
|
+
return e.__VUE_DND_KIT_OVERLAY__ && ($(null, e.__VUE_DND_KIT_OVERLAY__.container), delete e.__VUE_DND_KIT_OVERLAY__), n.call(this);
|
|
137
143
|
};
|
|
138
144
|
}
|
|
139
|
-
},
|
|
140
|
-
e.preventDefault();
|
|
141
|
-
}, ve = (e) => {
|
|
142
|
-
const {
|
|
143
|
-
elements: t,
|
|
144
|
-
draggingElements: n,
|
|
145
|
-
hovered: i,
|
|
146
|
-
selectedElements: a,
|
|
147
|
-
isDragging: l
|
|
148
|
-
} = T(), s = y(null), d = I(
|
|
149
|
-
() => {
|
|
150
|
-
var r;
|
|
151
|
-
return ((r = i.element.value) == null ? void 0 : r.node) === s.value;
|
|
152
|
-
}
|
|
153
|
-
), v = I(
|
|
154
|
-
() => n.value.some((r) => r.node === s.value)
|
|
155
|
-
), h = I(() => {
|
|
156
|
-
if (!s.value || !l.value) return !1;
|
|
157
|
-
const r = t.value.find(
|
|
158
|
-
(o) => o.node === s.value
|
|
159
|
-
);
|
|
160
|
-
return r != null && r.groups.length ? !n.value.some((o) => o.groups.length ? !o.groups.some(
|
|
161
|
-
(f) => r.groups.includes(f)
|
|
162
|
-
) : !1) : !0;
|
|
163
|
-
});
|
|
164
|
-
return {
|
|
165
|
-
elementRef: s,
|
|
166
|
-
registerElement: () => {
|
|
167
|
-
if (!s.value) throw new Error("ElementRef is not set");
|
|
168
|
-
t.value.push({
|
|
169
|
-
node: s.value,
|
|
170
|
-
groups: (e == null ? void 0 : e.groups) ?? [],
|
|
171
|
-
layer: (e == null ? void 0 : e.layer) ?? null,
|
|
172
|
-
defaultLayer: (e == null ? void 0 : e.layer) ?? null,
|
|
173
|
-
events: (e == null ? void 0 : e.events) ?? {},
|
|
174
|
-
data: (e == null ? void 0 : e.data) ?? void 0
|
|
175
|
-
}), s.value.addEventListener("dragstart", L), s.value.addEventListener("drag", L), s.value.setAttribute(b, "true"), s.value.setAttribute("draggable", "false"), s.value.style.touchAction = "none";
|
|
176
|
-
},
|
|
177
|
-
unregisterElement: () => {
|
|
178
|
-
var f, p, D, x;
|
|
179
|
-
const r = t.value.findIndex(
|
|
180
|
-
(c) => c.node === s.value
|
|
181
|
-
);
|
|
182
|
-
r !== -1 && t.value.splice(r, 1);
|
|
183
|
-
const o = a.value.findIndex(
|
|
184
|
-
(c) => c.node === s.value
|
|
185
|
-
);
|
|
186
|
-
o !== -1 && a.value.splice(o, 1), (f = s.value) == null || f.removeEventListener("dragstart", L), (p = s.value) == null || p.removeEventListener("drag", L), (D = s.value) == null || D.removeAttribute(b), (x = s.value) == null || x.removeAttribute("draggable");
|
|
187
|
-
},
|
|
188
|
-
isDragging: v,
|
|
189
|
-
isOvered: d,
|
|
190
|
-
isAllowed: h
|
|
191
|
-
};
|
|
192
|
-
}, ge = () => {
|
|
193
|
-
let e = "", t = "", n = "";
|
|
194
|
-
return {
|
|
195
|
-
disableInteractions: () => {
|
|
196
|
-
const l = document.body;
|
|
197
|
-
e = l.style.userSelect, l.style.userSelect = "none", window.addEventListener("contextmenu", L), window.addEventListener("selectstart", L), window.addEventListener("touchstart", L), window.addEventListener("touchmove", L);
|
|
198
|
-
},
|
|
199
|
-
enableInteractions: () => {
|
|
200
|
-
const l = document.body;
|
|
201
|
-
l.style.userSelect = e, l.style.touchAction = t, l.style.overscrollBehavior = n, window.removeEventListener("contextmenu", L), window.removeEventListener("selectstart", L), window.removeEventListener("touchstart", L), window.removeEventListener("touchmove", L);
|
|
202
|
-
}
|
|
203
|
-
};
|
|
204
|
-
}, K = (e, t) => e.x < t.x + t.width && e.x + e.width > t.x && e.y < t.y + t.height && e.y + e.height > t.y, R = (e) => {
|
|
145
|
+
}, j = (e, t) => e.x < t.x + t.width && e.x + e.width > t.x && e.y < t.y + t.height && e.y + e.height > t.y, b = (e) => {
|
|
205
146
|
if (!e)
|
|
206
147
|
return {
|
|
207
148
|
x: 0,
|
|
@@ -224,11 +165,11 @@ const T = oe(() => {
|
|
|
224
165
|
width: t.width,
|
|
225
166
|
height: t.height
|
|
226
167
|
};
|
|
227
|
-
},
|
|
168
|
+
}, Y = (e) => ({
|
|
228
169
|
x: e.x + e.width / 2,
|
|
229
170
|
y: e.y + e.height / 2
|
|
230
|
-
}),
|
|
231
|
-
const n =
|
|
171
|
+
}), ye = (e, t) => {
|
|
172
|
+
const n = b(e);
|
|
232
173
|
return {
|
|
233
174
|
pixel: {
|
|
234
175
|
x: t.x - n.x,
|
|
@@ -239,282 +180,394 @@ const T = oe(() => {
|
|
|
239
180
|
y: (t.y - n.y) / n.height * 100
|
|
240
181
|
}
|
|
241
182
|
};
|
|
242
|
-
},
|
|
243
|
-
const n = t.x - e.x,
|
|
244
|
-
return Math.sqrt(n * n +
|
|
245
|
-
},
|
|
183
|
+
}, G = (e, t) => {
|
|
184
|
+
const n = t.x - e.x, o = t.y - e.y;
|
|
185
|
+
return Math.sqrt(n * n + o * o);
|
|
186
|
+
}, J = (e, t) => {
|
|
246
187
|
const n = Math.max(
|
|
247
188
|
0,
|
|
248
189
|
Math.min(e.x + e.width, t.x + t.width) - Math.max(e.x, t.x)
|
|
249
|
-
),
|
|
190
|
+
), o = Math.max(
|
|
250
191
|
0,
|
|
251
192
|
Math.min(e.y + e.height, t.y + t.height) - Math.max(e.y, t.y)
|
|
252
|
-
),
|
|
253
|
-
return (
|
|
254
|
-
},
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
193
|
+
), l = n * o, i = e.width * e.height, s = t.width * t.height;
|
|
194
|
+
return (l / i * 100 + l / s * 100) / 2;
|
|
195
|
+
}, Q = "data-vue-dnd-kit-draggable", D = (e) => {
|
|
196
|
+
e.preventDefault();
|
|
197
|
+
}, Ee = (e) => {
|
|
198
|
+
const {
|
|
199
|
+
elements: t,
|
|
200
|
+
draggingElements: n,
|
|
201
|
+
hovered: o,
|
|
202
|
+
selectedElements: l,
|
|
203
|
+
isDragging: i
|
|
204
|
+
} = T(), s = I(null), v = S(
|
|
205
|
+
() => {
|
|
206
|
+
var r;
|
|
207
|
+
return ((r = o.element.value) == null ? void 0 : r.node) === s.value;
|
|
208
|
+
}
|
|
209
|
+
), c = S(
|
|
210
|
+
() => n.value.some((r) => r.node === s.value)
|
|
211
|
+
), d = S(() => {
|
|
212
|
+
if (!s.value || !i.value) return !1;
|
|
213
|
+
const r = t.value.find(
|
|
214
|
+
(a) => a.node === s.value
|
|
215
|
+
);
|
|
216
|
+
return r != null && r.groups.length ? !n.value.some((a) => a.groups.length ? !a.groups.some(
|
|
217
|
+
(f) => r.groups.includes(f)
|
|
218
|
+
) : !1) : !0;
|
|
219
|
+
});
|
|
220
|
+
return {
|
|
221
|
+
elementRef: s,
|
|
222
|
+
registerElement: () => {
|
|
223
|
+
if (!s.value) throw new Error("ElementRef is not set");
|
|
224
|
+
t.value.push({
|
|
225
|
+
node: s.value,
|
|
226
|
+
groups: (e == null ? void 0 : e.groups) ?? [],
|
|
227
|
+
layer: (e == null ? void 0 : e.layer) ?? null,
|
|
228
|
+
defaultLayer: (e == null ? void 0 : e.layer) ?? null,
|
|
229
|
+
events: (e == null ? void 0 : e.events) ?? {},
|
|
230
|
+
data: (e == null ? void 0 : e.data) ?? void 0
|
|
231
|
+
}), s.value.addEventListener("dragstart", D), s.value.addEventListener("drag", D), s.value.setAttribute(Q, "true"), s.value.setAttribute("draggable", "false");
|
|
232
|
+
},
|
|
233
|
+
unregisterElement: () => {
|
|
234
|
+
var f, y, p, _;
|
|
235
|
+
const r = t.value.findIndex(
|
|
236
|
+
(L) => L.node === s.value
|
|
237
|
+
);
|
|
238
|
+
r !== -1 && t.value.splice(r, 1);
|
|
239
|
+
const a = l.value.findIndex(
|
|
240
|
+
(L) => L.node === s.value
|
|
241
|
+
);
|
|
242
|
+
a !== -1 && l.value.splice(a, 1), (f = s.value) == null || f.removeEventListener("dragstart", D), (y = s.value) == null || y.removeEventListener("drag", D), (p = s.value) == null || p.removeAttribute(Q), (_ = s.value) == null || _.removeAttribute("draggable");
|
|
243
|
+
},
|
|
244
|
+
isDragging: c,
|
|
245
|
+
isOvered: v,
|
|
246
|
+
isAllowed: d
|
|
247
|
+
};
|
|
248
|
+
}, R = (e, t) => e ? t.contains(e) : !1, pe = (e) => {
|
|
249
|
+
var u, m;
|
|
250
|
+
const t = b(e.activeContainer.ref.value), n = Y(t), o = ((u = e.pointerPosition.current.value) == null ? void 0 : u.x) ?? 0, l = ((m = e.pointerPosition.current.value) == null ? void 0 : m.y) ?? 0, s = !(t && o >= t.x && o <= t.x + t.width && l >= t.y && l <= t.y + t.height), v = e.draggingElements.value.map((r) => r.node), c = e.elements.value.filter((r) => {
|
|
251
|
+
if (!r.node) return !1;
|
|
252
|
+
const a = b(r.node);
|
|
253
|
+
return a && t && j(a, t);
|
|
263
254
|
}).map((r) => {
|
|
264
|
-
const
|
|
265
|
-
(
|
|
255
|
+
const a = b(r.node), f = Y(a), y = o >= a.x && o <= a.x + a.width && l >= a.y && l <= a.y + a.height, p = J(a, t), _ = G(n, f), L = e.elements.value.filter(
|
|
256
|
+
(C) => C !== r && C.node && r.node && R(r.node, C.node)
|
|
266
257
|
).length;
|
|
267
258
|
return {
|
|
268
259
|
element: r,
|
|
269
260
|
node: r.node,
|
|
270
|
-
isPointerInElement:
|
|
271
|
-
overlapPercent:
|
|
272
|
-
depth:
|
|
273
|
-
centerDistance:
|
|
261
|
+
isPointerInElement: y,
|
|
262
|
+
overlapPercent: p,
|
|
263
|
+
depth: L,
|
|
264
|
+
centerDistance: _
|
|
274
265
|
};
|
|
275
|
-
}).sort((r,
|
|
266
|
+
}).sort((r, a) => {
|
|
276
267
|
if (!s) {
|
|
277
|
-
if (r.isPointerInElement &&
|
|
278
|
-
return
|
|
279
|
-
if (r.isPointerInElement !==
|
|
268
|
+
if (r.isPointerInElement && a.isPointerInElement)
|
|
269
|
+
return a.depth - r.depth;
|
|
270
|
+
if (r.isPointerInElement !== a.isPointerInElement)
|
|
280
271
|
return r.isPointerInElement ? -1 : 1;
|
|
281
272
|
}
|
|
282
|
-
return Math.abs(r.overlapPercent -
|
|
283
|
-
}),
|
|
284
|
-
if (!r.node ||
|
|
285
|
-
(f) => f &&
|
|
273
|
+
return Math.abs(r.overlapPercent - a.overlapPercent) <= 1 ? r.centerDistance - a.centerDistance : a.overlapPercent - r.overlapPercent;
|
|
274
|
+
}), d = e.zones.value.filter((r) => {
|
|
275
|
+
if (!r.node || v.some(
|
|
276
|
+
(f) => f && R(r.node, f)
|
|
286
277
|
))
|
|
287
278
|
return !1;
|
|
288
|
-
const
|
|
289
|
-
return
|
|
279
|
+
const a = b(r.node);
|
|
280
|
+
return a && t && j(a, t);
|
|
290
281
|
}).map((r) => {
|
|
291
|
-
const
|
|
292
|
-
(
|
|
282
|
+
const a = b(r.node), f = Y(a), y = o >= a.x && o <= a.x + a.width && l >= a.y && l <= a.y + a.height, p = J(a, t), _ = G(n, f), L = e.zones.value.filter(
|
|
283
|
+
(C) => C !== r && C.node && r.node && R(r.node, C.node)
|
|
293
284
|
).length;
|
|
294
285
|
return {
|
|
295
286
|
zone: r,
|
|
296
287
|
node: r.node,
|
|
297
|
-
isPointerInElement:
|
|
298
|
-
overlapPercent:
|
|
299
|
-
depth:
|
|
300
|
-
centerDistance:
|
|
288
|
+
isPointerInElement: y,
|
|
289
|
+
overlapPercent: p,
|
|
290
|
+
depth: L,
|
|
291
|
+
centerDistance: _
|
|
301
292
|
};
|
|
302
|
-
}).sort((r,
|
|
293
|
+
}).sort((r, a) => {
|
|
303
294
|
if (!s) {
|
|
304
|
-
if (r.isPointerInElement &&
|
|
305
|
-
return
|
|
306
|
-
if (r.isPointerInElement !==
|
|
295
|
+
if (r.isPointerInElement && a.isPointerInElement)
|
|
296
|
+
return a.depth - r.depth;
|
|
297
|
+
if (r.isPointerInElement !== a.isPointerInElement)
|
|
307
298
|
return r.isPointerInElement ? -1 : 1;
|
|
308
299
|
}
|
|
309
|
-
return Math.abs(r.overlapPercent -
|
|
300
|
+
return Math.abs(r.overlapPercent - a.overlapPercent) <= 1 ? r.centerDistance - a.centerDistance : a.overlapPercent - r.overlapPercent;
|
|
310
301
|
});
|
|
311
302
|
return [
|
|
312
|
-
...
|
|
313
|
-
...
|
|
303
|
+
...c.map((r) => r.node),
|
|
304
|
+
...d.map((r) => r.node)
|
|
314
305
|
];
|
|
315
|
-
},
|
|
306
|
+
}, Pe = (e, t) => {
|
|
307
|
+
const { pointerPosition: n, keyboard: o } = T(), l = (t == null ? void 0 : t.moveStep) || 10;
|
|
308
|
+
return {
|
|
309
|
+
onKeyboardStart: (c) => {
|
|
310
|
+
var r;
|
|
311
|
+
D(c);
|
|
312
|
+
const d = b(e.value);
|
|
313
|
+
(r = e.value) == null || r.blur();
|
|
314
|
+
const u = d.x + d.width / 2, m = d.y + d.height / 2;
|
|
315
|
+
n.start.value = {
|
|
316
|
+
x: u,
|
|
317
|
+
y: m
|
|
318
|
+
}, n.current.value = {
|
|
319
|
+
x: u,
|
|
320
|
+
y: m
|
|
321
|
+
}, n.offset.pixel.value = {
|
|
322
|
+
x: d.width / 2,
|
|
323
|
+
y: d.height / 2
|
|
324
|
+
}, n.offset.percent.value = {
|
|
325
|
+
x: 50,
|
|
326
|
+
y: 50
|
|
327
|
+
};
|
|
328
|
+
},
|
|
329
|
+
onKeyboardMove: () => {
|
|
330
|
+
if (!n.current.value) return;
|
|
331
|
+
const c = n.current.value.x, d = n.current.value.y;
|
|
332
|
+
let u = c, m = d;
|
|
333
|
+
o.w.value && (m -= l), o.s.value && (m += l), o.a.value && (u -= l), o.d.value && (u += l), n.current.value = {
|
|
334
|
+
x: u,
|
|
335
|
+
y: m
|
|
336
|
+
};
|
|
337
|
+
},
|
|
338
|
+
onKeyboardEnd: () => {
|
|
339
|
+
n.current.value = null, n.start.value = null, n.offset.pixel.value = null, n.offset.percent.value = null;
|
|
340
|
+
}
|
|
341
|
+
};
|
|
342
|
+
}, we = (e) => {
|
|
316
343
|
const t = T();
|
|
317
344
|
return {
|
|
318
|
-
onPointerStart: (
|
|
319
|
-
t.pointerPosition.start.value = { x:
|
|
320
|
-
x:
|
|
321
|
-
y:
|
|
345
|
+
onPointerStart: (i) => {
|
|
346
|
+
t.pointerPosition.start.value = { x: i.clientX, y: i.clientY }, t.pointerPosition.current.value = {
|
|
347
|
+
x: i.clientX,
|
|
348
|
+
y: i.clientY
|
|
322
349
|
};
|
|
323
|
-
const { pixel: s, percent:
|
|
324
|
-
x:
|
|
325
|
-
y:
|
|
350
|
+
const { pixel: s, percent: v } = ye(e.value, {
|
|
351
|
+
x: i.clientX,
|
|
352
|
+
y: i.clientY
|
|
326
353
|
});
|
|
327
|
-
t.pointerPosition.offset.pixel.value = s, t.pointerPosition.offset.percent.value =
|
|
354
|
+
t.pointerPosition.offset.pixel.value = s, t.pointerPosition.offset.percent.value = v;
|
|
328
355
|
},
|
|
329
|
-
onPointerMove: (
|
|
356
|
+
onPointerMove: (i) => {
|
|
330
357
|
t.pointerPosition.current.value = {
|
|
331
|
-
x:
|
|
332
|
-
y:
|
|
358
|
+
x: i.clientX,
|
|
359
|
+
y: i.clientY
|
|
333
360
|
};
|
|
334
361
|
},
|
|
335
362
|
onPointerEnd: () => {
|
|
336
363
|
t.pointerPosition.current.value = null, t.pointerPosition.start.value = null, t.pointerPosition.offset.pixel.value = null, t.pointerPosition.offset.percent.value = null;
|
|
337
364
|
}
|
|
338
365
|
};
|
|
339
|
-
},
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
366
|
+
}, xe = (e, t) => {
|
|
367
|
+
var F, H;
|
|
368
|
+
const n = T(), { onPointerStart: o, onPointerMove: l, onPointerEnd: i } = we(e), { onKeyboardStart: s, onKeyboardMove: v, onKeyboardEnd: c } = Pe(
|
|
369
|
+
e,
|
|
370
|
+
t == null ? void 0 : t.keyboard
|
|
371
|
+
);
|
|
372
|
+
let d = null;
|
|
373
|
+
const u = (h) => {
|
|
374
|
+
var K, M;
|
|
375
|
+
const x = n.selectedElements.value.some(
|
|
376
|
+
(g) => g.node === h
|
|
346
377
|
);
|
|
347
|
-
if (n.selectedElements.value.length &&
|
|
348
|
-
return n.selectedElements.value.map((
|
|
349
|
-
var
|
|
378
|
+
if (n.selectedElements.value.length && x)
|
|
379
|
+
return n.selectedElements.value.map((g) => {
|
|
380
|
+
var E, k;
|
|
350
381
|
return {
|
|
351
|
-
...
|
|
352
|
-
initialHTML: ((
|
|
353
|
-
initialRect: (
|
|
382
|
+
...g,
|
|
383
|
+
initialHTML: ((E = g.node) == null ? void 0 : E.outerHTML) ?? "",
|
|
384
|
+
initialRect: (k = g.node) == null ? void 0 : k.getBoundingClientRect()
|
|
354
385
|
};
|
|
355
386
|
});
|
|
356
387
|
n.selectedElements.value = [];
|
|
357
|
-
const
|
|
358
|
-
(
|
|
388
|
+
const w = n.elements.value.find(
|
|
389
|
+
(g) => g.node === h
|
|
359
390
|
);
|
|
360
|
-
return
|
|
391
|
+
return w ? [
|
|
361
392
|
{
|
|
362
|
-
...
|
|
363
|
-
initialHTML: ((
|
|
364
|
-
initialRect: (
|
|
393
|
+
...w,
|
|
394
|
+
initialHTML: ((K = w.node) == null ? void 0 : K.outerHTML) ?? "",
|
|
395
|
+
initialRect: (M = w.node) == null ? void 0 : M.getBoundingClientRect()
|
|
365
396
|
}
|
|
366
397
|
] : [];
|
|
367
|
-
},
|
|
368
|
-
if (!
|
|
398
|
+
}, m = (h) => {
|
|
399
|
+
if (!h)
|
|
369
400
|
return { element: null, zone: null };
|
|
370
|
-
const
|
|
371
|
-
(
|
|
372
|
-
),
|
|
373
|
-
(
|
|
374
|
-
).filter((
|
|
375
|
-
(
|
|
376
|
-
|
|
401
|
+
const x = Array.isArray(h) ? h : [h], w = n.draggingElements.value.map(
|
|
402
|
+
(g) => g.node
|
|
403
|
+
), K = x.map(
|
|
404
|
+
(g) => n.elements.value.find((E) => E.node === g)
|
|
405
|
+
).filter((g) => !g || w.some(
|
|
406
|
+
(E) => E && (E === g.node || R(
|
|
407
|
+
g.node,
|
|
408
|
+
E
|
|
409
|
+
))
|
|
410
|
+
) ? !1 : g.groups.length ? !n.draggingElements.value.some(
|
|
411
|
+
(k) => k.groups.length ? !k.groups.some(
|
|
412
|
+
(A) => g.groups.includes(A)
|
|
377
413
|
) : !1
|
|
378
|
-
) : !0
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
});
|
|
414
|
+
) : !0), M = x.map(
|
|
415
|
+
(g) => n.zones.value.find((E) => E.node === g)
|
|
416
|
+
).filter((g) => !g || w.some(
|
|
417
|
+
(E) => E && (E === g.node || R(g.node, E))
|
|
418
|
+
) ? !1 : g.groups.length && !!n.draggingElements.value.some((k) => k.groups.length ? !k.groups.some((A) => g.groups.includes(A)) : !1) ? null : !0);
|
|
384
419
|
return {
|
|
385
|
-
element:
|
|
386
|
-
zone:
|
|
420
|
+
element: K[0] ?? null,
|
|
421
|
+
zone: M[0] ?? null
|
|
387
422
|
};
|
|
388
|
-
},
|
|
389
|
-
var
|
|
390
|
-
const
|
|
391
|
-
n.hovered.element.value =
|
|
392
|
-
},
|
|
393
|
-
const
|
|
394
|
-
|
|
395
|
-
}, (t == null ? void 0 : t.throttle) ?? 0),
|
|
396
|
-
|
|
397
|
-
},
|
|
398
|
-
|
|
423
|
+
}, r = ((F = t == null ? void 0 : t.sensor) == null ? void 0 : F.setup) || pe, a = (h) => {
|
|
424
|
+
var K, M, g, E, k, A;
|
|
425
|
+
const x = n.hovered.element.value, w = n.hovered.zone.value;
|
|
426
|
+
n.hovered.element.value = h.element, n.hovered.zone.value = h.zone, n.hovered.element.value !== x && ((K = x == null ? void 0 : x.events) != null && K.onLeave && x.events.onLeave(n), (g = (M = n.hovered.element.value) == null ? void 0 : M.events) != null && g.onHover && n.hovered.element.value.events.onHover(n)), n.hovered.zone.value !== w && ((E = w == null ? void 0 : w.events) != null && E.onLeave && w.events.onLeave(n), (A = (k = n.hovered.zone.value) == null ? void 0 : k.events) != null && A.onHover && n.hovered.zone.value.events.onHover(n));
|
|
427
|
+
}, f = fe(() => {
|
|
428
|
+
const h = r(n), x = m(h);
|
|
429
|
+
a(x);
|
|
430
|
+
}, ((H = t == null ? void 0 : t.sensor) == null ? void 0 : H.throttle) ?? 0), y = () => {
|
|
431
|
+
f(), d = requestAnimationFrame(y);
|
|
432
|
+
}, p = () => y(), _ = () => {
|
|
433
|
+
d !== null && (cancelAnimationFrame(d), d = null);
|
|
399
434
|
};
|
|
400
435
|
return {
|
|
401
|
-
activate: (
|
|
402
|
-
n.draggingElements.value =
|
|
436
|
+
activate: (h) => {
|
|
437
|
+
n.draggingElements.value = u(e.value), h instanceof PointerEvent ? o(h) : s(h), p();
|
|
403
438
|
},
|
|
404
|
-
track: (
|
|
405
|
-
|
|
439
|
+
track: (h) => {
|
|
440
|
+
h instanceof KeyboardEvent ? v() : l(h);
|
|
406
441
|
},
|
|
407
|
-
deactivate: () => {
|
|
408
|
-
var
|
|
409
|
-
|
|
410
|
-
(
|
|
411
|
-
var
|
|
412
|
-
return (
|
|
442
|
+
deactivate: (h = !0) => {
|
|
443
|
+
var x, w;
|
|
444
|
+
i(), c(), h && (n.hovered.zone.value ? (w = (x = n.hovered.zone.value.events).onDrop) == null || w.call(x, n) : n.draggingElements.value.forEach(
|
|
445
|
+
(K) => {
|
|
446
|
+
var M, g;
|
|
447
|
+
return (g = (M = K.events).onEnd) == null ? void 0 : g.call(M, n);
|
|
413
448
|
}
|
|
414
|
-
), n.
|
|
449
|
+
), n.selectedElements.value = []), n.draggingElements.value = [], n.hovered.zone.value = null, n.hovered.element.value = null, _();
|
|
415
450
|
}
|
|
416
451
|
};
|
|
417
|
-
},
|
|
452
|
+
}, De = ee(() => {
|
|
453
|
+
let e = "", t = "", n = "", o = null, l = null, i = null, s = null;
|
|
454
|
+
const { activeContainer: v, keyboard: c } = T(), d = () => {
|
|
455
|
+
const f = document.body;
|
|
456
|
+
e = f.style.userSelect, f.style.userSelect = "none", window.addEventListener("contextmenu", D), window.addEventListener("selectstart", D), window.addEventListener("touchstart", D), window.addEventListener("touchmove", D);
|
|
457
|
+
}, u = () => {
|
|
458
|
+
const f = document.body;
|
|
459
|
+
f.style.userSelect = e, f.style.touchAction = t, f.style.overscrollBehavior = n, window.removeEventListener("contextmenu", D), window.removeEventListener("selectstart", D), window.removeEventListener("touchstart", D), window.removeEventListener("touchmove", D);
|
|
460
|
+
}, m = () => {
|
|
461
|
+
o && (document.removeEventListener("pointermove", o), o = null), l && (document.removeEventListener("pointerup", () => l == null ? void 0 : l()), l = null), i && (document.removeEventListener("wheel", i), i = null), s && (document.removeEventListener("keydown", s), document.removeEventListener("keypress", s), document.removeEventListener("keyup", s), s = null);
|
|
462
|
+
}, r = (f, y, p) => {
|
|
463
|
+
m(), f.target.blur(), p != null && p.container && (v.component.value = ce(p.container));
|
|
464
|
+
const { activate: _, track: L, deactivate: C } = xe(y, p);
|
|
465
|
+
l = (P = !0) => {
|
|
466
|
+
v.component.value = null, u(), C(P), m();
|
|
467
|
+
}, o = (P) => L(P), i = (P) => L(P), s = (P) => {
|
|
468
|
+
P.type === "keydown" && a(P, !0), P.type === "keypress" && a(P, !0), P.type === "keyup" && (P.code === "Escape" && (l == null || l(!1)), P.code === "Enter" && (l == null || l()), a(P, !1)), L(P);
|
|
469
|
+
}, d(), _(f), document.addEventListener("pointermove", o), document.addEventListener("pointerup", () => l == null ? void 0 : l()), document.addEventListener("wheel", i), document.addEventListener("keydown", s), document.addEventListener("keypress", s), document.addEventListener("keyup", s);
|
|
470
|
+
}, a = (f, y = !0) => {
|
|
471
|
+
f.code === "KeyW" && (c.w.value = y), f.code === "KeyA" && (c.a.value = y), f.code === "KeyS" && (c.s.value = y), f.code === "KeyD" && (c.d.value = y);
|
|
472
|
+
};
|
|
473
|
+
return {
|
|
474
|
+
handleDragStart: r
|
|
475
|
+
};
|
|
476
|
+
}), ke = (e) => {
|
|
418
477
|
const {
|
|
419
478
|
elementRef: t,
|
|
420
479
|
registerElement: n,
|
|
421
|
-
unregisterElement:
|
|
422
|
-
isDragging:
|
|
423
|
-
isOvered:
|
|
480
|
+
unregisterElement: o,
|
|
481
|
+
isDragging: l,
|
|
482
|
+
isOvered: i,
|
|
424
483
|
isAllowed: s
|
|
425
|
-
} =
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
}), f = (c) => {
|
|
429
|
-
e != null && e.container && (h.component.value = le(e.container)), d(), E(c), document.addEventListener("pointermove", p), document.addEventListener("pointerup", x), document.addEventListener("wheel", D);
|
|
430
|
-
}, p = (c) => r(c), D = (c) => r(c), x = () => {
|
|
431
|
-
h.component.value = null, v(), o(), document.removeEventListener("pointermove", p), document.removeEventListener("pointerup", x), document.removeEventListener("wheel", D);
|
|
432
|
-
};
|
|
433
|
-
return V(n), H(i), {
|
|
434
|
-
pointerPosition: u,
|
|
484
|
+
} = Ee(e), { pointerPosition: v } = T(), { handleDragStart: c } = De(), d = (u) => c(u, t, e);
|
|
485
|
+
return U(n), X(o), {
|
|
486
|
+
pointerPosition: v,
|
|
435
487
|
elementRef: t,
|
|
436
|
-
isDragging:
|
|
437
|
-
isOvered:
|
|
488
|
+
isDragging: l,
|
|
489
|
+
isOvered: i,
|
|
438
490
|
isAllowed: s,
|
|
439
|
-
handleDragStart:
|
|
491
|
+
handleDragStart: d
|
|
440
492
|
};
|
|
441
|
-
},
|
|
442
|
-
const { zones: t, hovered: n, draggingElements:
|
|
493
|
+
}, _e = (e) => {
|
|
494
|
+
const { zones: t, hovered: n, draggingElements: o, isDragging: l } = T(), i = I(null), s = S(() => {
|
|
443
495
|
var u;
|
|
444
|
-
return ((u = n.zone.value) == null ? void 0 : u.node) ===
|
|
445
|
-
}),
|
|
446
|
-
if (!
|
|
496
|
+
return ((u = n.zone.value) == null ? void 0 : u.node) === i.value;
|
|
497
|
+
}), v = S(() => {
|
|
498
|
+
if (!i.value || !l.value) return !1;
|
|
447
499
|
const u = t.value.find(
|
|
448
|
-
(
|
|
500
|
+
(m) => m.node === i.value
|
|
449
501
|
);
|
|
450
|
-
return u != null && u.groups.length ? !
|
|
502
|
+
return u != null && u.groups.length ? !o.value.some((m) => m.groups.length ? !m.groups.some(
|
|
451
503
|
(r) => u.groups.includes(r)
|
|
452
504
|
) : !1) : !0;
|
|
453
505
|
});
|
|
454
|
-
return { elementRef:
|
|
455
|
-
if (!
|
|
506
|
+
return { elementRef: i, registerZone: () => {
|
|
507
|
+
if (!i.value) throw new Error("elementRef is not set");
|
|
456
508
|
t.value.push({
|
|
457
|
-
node:
|
|
509
|
+
node: i.value,
|
|
458
510
|
groups: (e == null ? void 0 : e.groups) ?? [],
|
|
459
511
|
events: (e == null ? void 0 : e.events) ?? {},
|
|
460
512
|
data: (e == null ? void 0 : e.data) ?? void 0
|
|
461
|
-
}),
|
|
513
|
+
}), i.value.setAttribute("data-dnd-droppable", "true");
|
|
462
514
|
}, unregisterZone: () => {
|
|
463
|
-
if (!
|
|
515
|
+
if (!i.value) throw new Error("elementRef is not set");
|
|
464
516
|
const u = t.value.findIndex(
|
|
465
|
-
(
|
|
517
|
+
(m) => m.node === i.value
|
|
466
518
|
);
|
|
467
519
|
u !== -1 && t.value.splice(u, 1);
|
|
468
|
-
}, isOvered: s, isAllowed:
|
|
469
|
-
},
|
|
470
|
-
const { elementRef: t, registerZone: n, unregisterZone:
|
|
471
|
-
return
|
|
472
|
-
},
|
|
473
|
-
const { selectedElements: t, elements: n } = T(),
|
|
520
|
+
}, isOvered: s, isAllowed: v };
|
|
521
|
+
}, Ce = (e) => {
|
|
522
|
+
const { elementRef: t, registerZone: n, unregisterZone: o, isOvered: l, isAllowed: i } = _e(e);
|
|
523
|
+
return U(n), X(o), { elementRef: t, isOvered: l, isAllowed: i };
|
|
524
|
+
}, Me = (e) => {
|
|
525
|
+
const { selectedElements: t, elements: n } = T(), o = S(
|
|
474
526
|
() => n.value.find((u) => u.node === e.value)
|
|
475
|
-
),
|
|
527
|
+
), l = S(
|
|
476
528
|
() => t.value.some((u) => u.node === e.value)
|
|
477
|
-
),
|
|
478
|
-
(u) => u.node &&
|
|
529
|
+
), i = S(() => e.value ? t.value.some(
|
|
530
|
+
(u) => u.node && R(
|
|
479
531
|
u.node,
|
|
480
532
|
e.value
|
|
481
533
|
)
|
|
482
|
-
) : !1), s =
|
|
483
|
-
(u) => u.node &&
|
|
534
|
+
) : !1), s = S(() => e.value ? t.value.some(
|
|
535
|
+
(u) => u.node && R(
|
|
484
536
|
e.value,
|
|
485
537
|
u.node
|
|
486
538
|
)
|
|
487
|
-
) : !1),
|
|
488
|
-
|
|
539
|
+
) : !1), v = () => {
|
|
540
|
+
o.value && (t.value = t.value.filter(
|
|
489
541
|
(u) => u.node !== e.value
|
|
490
542
|
));
|
|
491
|
-
},
|
|
492
|
-
|
|
493
|
-
(u) => u.node && !
|
|
543
|
+
}, c = () => {
|
|
544
|
+
o.value && (i.value && (t.value = t.value.filter(
|
|
545
|
+
(u) => u.node && !R(
|
|
494
546
|
u.node,
|
|
495
547
|
e.value
|
|
496
548
|
)
|
|
497
549
|
)), s.value && (t.value = t.value.filter(
|
|
498
|
-
(u) => u.node && !
|
|
550
|
+
(u) => u.node && !R(
|
|
499
551
|
e.value,
|
|
500
552
|
u.node
|
|
501
553
|
)
|
|
502
|
-
)), t.value.push(
|
|
554
|
+
)), t.value.push(o.value));
|
|
503
555
|
};
|
|
504
556
|
return {
|
|
505
|
-
handleUnselect:
|
|
506
|
-
handleSelect:
|
|
557
|
+
handleUnselect: v,
|
|
558
|
+
handleSelect: c,
|
|
507
559
|
handleToggleSelect: () => {
|
|
508
|
-
|
|
560
|
+
o.value && (t.value.some((u) => u.node === e.value) ? v() : c());
|
|
509
561
|
},
|
|
510
|
-
isSelected:
|
|
511
|
-
isParentOfSelected:
|
|
562
|
+
isSelected: l,
|
|
563
|
+
isParentOfSelected: i
|
|
512
564
|
};
|
|
513
565
|
};
|
|
514
566
|
export {
|
|
515
|
-
|
|
567
|
+
Se as default,
|
|
568
|
+
b as getBoundingBox,
|
|
516
569
|
T as useDnDStore,
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
570
|
+
ke as useDraggable,
|
|
571
|
+
Ce as useDroppable,
|
|
572
|
+
Me as useSelection
|
|
520
573
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue-dnd-kit/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
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",
|