@vue-dnd-kit/core 0.0.34-beta → 0.0.36-beta
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 +8 -0
- package/dist/composables/useDragContainer.d.ts +2 -0
- package/dist/composables/useDraggable.d.ts +1 -41
- package/dist/managers/useElementManager.d.ts +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/vue-dnd-kit-core.cjs.js +1 -1
- package/dist/vue-dnd-kit-core.es.js +405 -274
- package/package.json +1 -1
|
@@ -478,6 +478,7 @@ export declare const useDnDStore: () => {
|
|
|
478
478
|
__file?: string | undefined;
|
|
479
479
|
__name?: string | undefined;
|
|
480
480
|
} | null;
|
|
481
|
+
isVisible?: any;
|
|
481
482
|
data: any;
|
|
482
483
|
events: {
|
|
483
484
|
onHover?: ((store: import('../types').IDnDStore) => void) | undefined;
|
|
@@ -725,6 +726,7 @@ export declare const useDnDStore: () => {
|
|
|
725
726
|
__file?: string | undefined;
|
|
726
727
|
__name?: string | undefined;
|
|
727
728
|
} | null;
|
|
729
|
+
isVisible?: any;
|
|
728
730
|
data: any;
|
|
729
731
|
events: {
|
|
730
732
|
onHover?: ((store: import('../types').IDnDStore) => void) | undefined;
|
|
@@ -985,6 +987,7 @@ export declare const useDnDStore: () => {
|
|
|
985
987
|
__file?: string | undefined;
|
|
986
988
|
__name?: string | undefined;
|
|
987
989
|
} | null;
|
|
990
|
+
isVisible?: any;
|
|
988
991
|
data: any;
|
|
989
992
|
events: {
|
|
990
993
|
onHover?: ((store: import('../types').IDnDStore) => void) | undefined;
|
|
@@ -1244,6 +1247,7 @@ export declare const useDnDStore: () => {
|
|
|
1244
1247
|
__file?: string | undefined;
|
|
1245
1248
|
__name?: string | undefined;
|
|
1246
1249
|
} | null;
|
|
1250
|
+
isVisible?: any;
|
|
1247
1251
|
data: any;
|
|
1248
1252
|
events: {
|
|
1249
1253
|
onHover?: ((store: import('../types').IDnDStore) => void) | undefined;
|
|
@@ -1492,6 +1496,7 @@ export declare const useDnDStore: () => {
|
|
|
1492
1496
|
__file?: string | undefined;
|
|
1493
1497
|
__name?: string | undefined;
|
|
1494
1498
|
} | null;
|
|
1499
|
+
isVisible?: any;
|
|
1495
1500
|
data: any;
|
|
1496
1501
|
events: {
|
|
1497
1502
|
onHover?: ((store: import('../types').IDnDStore) => void) | undefined;
|
|
@@ -1739,6 +1744,7 @@ export declare const useDnDStore: () => {
|
|
|
1739
1744
|
__file?: string | undefined;
|
|
1740
1745
|
__name?: string | undefined;
|
|
1741
1746
|
} | null;
|
|
1747
|
+
isVisible?: any;
|
|
1742
1748
|
data: any;
|
|
1743
1749
|
events: {
|
|
1744
1750
|
onHover?: ((store: import('../types').IDnDStore) => void) | undefined;
|
|
@@ -2026,6 +2032,7 @@ export declare const useDnDStore: () => {
|
|
|
2026
2032
|
__file?: string | undefined;
|
|
2027
2033
|
__name?: string | undefined;
|
|
2028
2034
|
} | null;
|
|
2035
|
+
isVisible?: any;
|
|
2029
2036
|
data: any;
|
|
2030
2037
|
events: {
|
|
2031
2038
|
onHover?: ((store: import('../types').IDnDStore) => void) | undefined;
|
|
@@ -2273,6 +2280,7 @@ export declare const useDnDStore: () => {
|
|
|
2273
2280
|
__file?: string | undefined;
|
|
2274
2281
|
__name?: string | undefined;
|
|
2275
2282
|
} | null;
|
|
2283
|
+
isVisible?: any;
|
|
2276
2284
|
data: any;
|
|
2277
2285
|
events: {
|
|
2278
2286
|
onHover?: ((store: import('../types').IDnDStore) => void) | undefined;
|
|
@@ -320,6 +320,7 @@ export declare const useDragContainer: () => {
|
|
|
320
320
|
__file?: string | undefined;
|
|
321
321
|
__name?: string | undefined;
|
|
322
322
|
} | null;
|
|
323
|
+
isVisible?: any;
|
|
323
324
|
data: any;
|
|
324
325
|
events: {
|
|
325
326
|
onHover?: ((store: import('..').IDnDStore) => void) | undefined;
|
|
@@ -579,6 +580,7 @@ export declare const useDragContainer: () => {
|
|
|
579
580
|
__file?: string | undefined;
|
|
580
581
|
__name?: string | undefined;
|
|
581
582
|
} | null;
|
|
583
|
+
isVisible?: any;
|
|
582
584
|
data: any;
|
|
583
585
|
events: {
|
|
584
586
|
onHover?: ((store: import('..').IDnDStore) => void) | undefined;
|
|
@@ -1,45 +1,4 @@
|
|
|
1
1
|
import { IUseDragOptions } from "../types";
|
|
2
|
-
/**
|
|
3
|
-
* Main hook for making elements draggable.
|
|
4
|
-
* Provides all necessary functionality for drag and drop operations.
|
|
5
|
-
*
|
|
6
|
-
* @param options - Configuration options for draggable element
|
|
7
|
-
* @param options.groups - Groups that element belongs to (for drop zone filtering)
|
|
8
|
-
* @param options.events - Event handlers for drag lifecycle
|
|
9
|
-
* @param options.data - Custom data to be passed to event handlers
|
|
10
|
-
* @param options.layer - Custom component to render while dragging
|
|
11
|
-
* @param options.container - Parent container component reference
|
|
12
|
-
*
|
|
13
|
-
* @returns Object containing:
|
|
14
|
-
* - elementRef: Reference to be bound to draggable element
|
|
15
|
-
* - isDragging: Whether element is currently being dragged
|
|
16
|
-
* - isOvered: Whether element is being hovered by dragged element
|
|
17
|
-
* - isAllowed: Whether element can interact with current drop zone based on group matching
|
|
18
|
-
* - pointerPosition: Current pointer coordinates
|
|
19
|
-
* - handleDragStart: Function to initiate drag operation
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
* ```vue
|
|
23
|
-
* <template>
|
|
24
|
-
* <div
|
|
25
|
-
* ref="elementRef"
|
|
26
|
-
* :class="{ 'dragging': isDragging }"
|
|
27
|
-
* @pointerdown="handleDragStart"
|
|
28
|
-
* >
|
|
29
|
-
* Drag me!
|
|
30
|
-
* </div>
|
|
31
|
-
* </template>
|
|
32
|
-
*
|
|
33
|
-
* <script setup lang="ts">
|
|
34
|
-
* const { elementRef, isDragging, handleDragStart } = useDraggable({
|
|
35
|
-
* groups: ['items'],
|
|
36
|
-
* events: {
|
|
37
|
-
* onEnd: (store) => console.log('Drag ended!'),
|
|
38
|
-
* }
|
|
39
|
-
* });
|
|
40
|
-
* </script>
|
|
41
|
-
* ```
|
|
42
|
-
*/
|
|
43
2
|
export declare const useDraggable: (options?: IUseDragOptions) => {
|
|
44
3
|
pointerPosition: {
|
|
45
4
|
current: import('vue').Ref<{
|
|
@@ -78,4 +37,5 @@ export declare const useDraggable: (options?: IUseDragOptions) => {
|
|
|
78
37
|
isOvered: import('vue').ComputedRef<boolean>;
|
|
79
38
|
isAllowed: import('vue').ComputedRef<boolean>;
|
|
80
39
|
handleDragStart: (event: PointerEvent) => void;
|
|
40
|
+
isVisible: import('vue').ShallowRef<boolean, boolean>;
|
|
81
41
|
};
|
|
@@ -14,4 +14,5 @@ export declare const useElementManager: (options?: IUseDragOptions) => {
|
|
|
14
14
|
isDragging: import('vue').ComputedRef<boolean>;
|
|
15
15
|
isOvered: import('vue').ComputedRef<boolean>;
|
|
16
16
|
isAllowed: import('vue').ComputedRef<boolean>;
|
|
17
|
+
isVisible: import('vue').ShallowRef<boolean, boolean>;
|
|
17
18
|
};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -57,6 +57,8 @@ export interface IDragElement {
|
|
|
57
57
|
layer: Component | null;
|
|
58
58
|
/** Default layer component */
|
|
59
59
|
defaultLayer: Component | null;
|
|
60
|
+
/** Visibility state of the element */
|
|
61
|
+
isVisible?: any;
|
|
60
62
|
/** Custom data associated with element */
|
|
61
63
|
data: any;
|
|
62
64
|
/** Event handlers */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("vue");function J(t){let e=!1,i;const c=n.effectScope(!0);return(...d)=>(e||(i=c.run(()=>t(...d)),e=!0),i)}typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const L=J(()=>{const t=n.ref([]),e=n.computed(()=>t.value.length>0),i={component:n.ref(null),ref:n.ref(null)},c=n.ref([]),d=n.ref([]),r=n.ref([]),s={zone:n.ref(null),element:n.ref(null)},g={current:n.ref(null),start:n.ref(null),offset:{percent:n.ref(null),pixel:n.ref(null)}};return{isDragging:e,activeContainer:i,elements:c,draggingElements:t,selectedElements:d,zones:r,hovered:s,pointerPosition:g}}),K=()=>{const t=n.ref(null),{draggingElements:e,pointerPosition:i,isDragging:c,activeContainer:d}=L();return n.onMounted(()=>{d.ref=t}),n.onBeforeUnmount(()=>{d.ref.value=null}),{elementRef:t,draggingElements:e,pointerPosition:i,isDragging:c}},Q=["innerHTML"],b=n.defineComponent({__name:"DefaultOverlay",setup(t){const{elementRef:e,pointerPosition:i,isDragging:c,draggingElements:d}=K(),r=n.computed(()=>{var s,g,h,y;return{transform:`translate3d(${(((s=i.current.value)==null?void 0:s.x)??0)-(((g=i.offset.pixel.value)==null?void 0:g.x)??0)}px, ${(((h=i.current.value)==null?void 0:h.y)??0)-(((y=i.offset.pixel.value)==null?void 0:y.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(s,g)=>n.unref(c)?(n.openBlock(),n.createElementBlock("div",{key:0,ref_key:"elementRef",ref:e,style:n.normalizeStyle(r.value)},[(n.openBlock(!0),n.createElementBlock(n.Fragment,null,n.renderList(n.unref(d),(h,y)=>{var a,E;return n.openBlock(),n.createElementBlock("div",{key:y,innerHTML:h.initialHTML,style:n.normalizeStyle({width:`${(a=h.initialRect)==null?void 0:a.width}px`,height:`${(E=h.initialRect)==null?void 0:E.height}px`})},null,12,Q)}),128))],4)):n.createCommentVNode("",!0)}}),ee=n.defineComponent({__name:"DragOverlay",setup(t){const{activeContainer:e}=L(),i=n.computed(()=>e.component.value??b);return(c,d)=>(n.openBlock(),n.createBlock(n.resolveDynamicComponent(i.value)))}}),te="data-dnd-draggable",ne=t=>{const{elements:e,draggingElements:i,hovered:c,selectedElements:d,isDragging:r}=L(),s=n.ref(null),g=n.computed(()=>{var p;return((p=c.element.value)==null?void 0:p.node)===s.value}),h=n.computed(()=>i.value.some(p=>p.node===s.value)),y=n.computed(()=>{if(!s.value||!r.value)return!1;const p=e.value.find(D=>D.node===s.value);return p!=null&&p.groups.length?!i.value.some(D=>D.groups.length?!D.groups.some(o=>p.groups.includes(o)):!1):!0});return{elementRef:s,registerElement:()=>{if(!s.value)throw new Error("ElementRef is not set");e.value.push({node:s.value,groups:(t==null?void 0:t.groups)??[],layer:(t==null?void 0:t.layer)??null,defaultLayer:(t==null?void 0:t.layer)??null,events:(t==null?void 0:t.events)??{},data:(t==null?void 0:t.data)??void 0}),s.value.setAttribute(te,"true")},unregisterElement:()=>{const p=e.value.findIndex(o=>o.node===s.value);p!==-1&&e.value.splice(p,1);const D=d.value.findIndex(o=>o.node===s.value);D!==-1&&d.value.splice(D,1)},isDragging:h,isOvered:g,isAllowed:y}},re=()=>{let t="",e="",i="";const c=()=>{const s=document.body;t=s.style.userSelect,e=s.style.touchAction,i=s.style.overscrollBehavior,s.style.userSelect="none",s.style.touchAction="none",s.style.overscrollBehavior="none",window.addEventListener("contextmenu",r),window.addEventListener("selectstart",r),window.addEventListener("touchstart",r),window.addEventListener("touchmove",r)},d=()=>{const s=document.body;s.style.userSelect=t,s.style.touchAction=e,s.style.overscrollBehavior=i,window.removeEventListener("contextmenu",r),window.removeEventListener("selectstart",r),window.removeEventListener("touchstart",r),window.removeEventListener("touchmove",r)},r=s=>s.preventDefault();return{disableInteractions:c,enableInteractions:d}},W=(t,e)=>t.x<e.x+e.width&&t.x+t.width>e.x&&t.y<e.y+e.height&&t.y+t.height>e.y,k=t=>{if(!t)return{x:0,y:0,width:0,height:0,bottom:0,left:0,right:0,top:0};const e=t.getBoundingClientRect();return{bottom:e.bottom,left:e.left,right:e.right,top:e.top,x:e.x,y:e.y,width:e.width,height:e.height}},R=t=>({x:t.x+t.width/2,y:t.y+t.height/2}),oe=(t,e)=>{const i=k(t);return{pixel:{x:e.x-i.x,y:e.y-i.y},percent:{x:(e.x-i.x)/i.width*100,y:(e.y-i.y)/i.height*100}}},j=(t,e)=>{const i=e.x-t.x,c=e.y-t.y;return Math.sqrt(i*i+c*c)},M=(t,e)=>t?e.contains(t):!1,le=t=>{const e=L();return{onPointerStart:r=>{e.pointerPosition.start.value={x:r.clientX,y:r.clientY},e.pointerPosition.current.value={x:r.clientX,y:r.clientY};const{pixel:s,percent:g}=oe(t.value,{x:r.clientX,y:r.clientY});e.pointerPosition.offset.pixel.value=s,e.pointerPosition.offset.percent.value=g},onPointerMove:r=>{e.pointerPosition.current.value={x:r.clientX,y:r.clientY}},onPointerEnd:()=>{e.pointerPosition.current.value=null,e.pointerPosition.start.value=null,e.pointerPosition.offset.pixel.value=null,e.pointerPosition.offset.percent.value=null}}},ie=t=>{const e=L(),{onPointerStart:i,onPointerMove:c,onPointerEnd:d}=le(t);let r=null;const s=o=>{var v,x;const f=e.selectedElements.value.some(P=>P.node===o);if(e.selectedElements.value.length&&f)return e.selectedElements.value.map(P=>{var C,T;return{...P,initialHTML:((C=P.node)==null?void 0:C.outerHTML)??"",initialRect:(T=P.node)==null?void 0:T.getBoundingClientRect()}});e.selectedElements.value=[];const m=e.elements.value.find(P=>P.node===o);return m?[{...m,initialHTML:((v=m.node)==null?void 0:v.outerHTML)??"",initialRect:(x=m.node)==null?void 0:x.getBoundingClientRect()}]:[]},g=(o,f)=>{const m=Math.max(0,Math.min(o.x+o.width,f.x+f.width)-Math.max(o.x,f.x)),v=Math.max(0,Math.min(o.y+o.height,f.y+f.height)-Math.max(o.y,f.y)),x=m*v,P=o.width*o.height,C=f.width*f.height;return(x/P*100+x/C*100)/2},h=()=>{var U,Z,A,X,Y,$,F,q,G,N;const o=k(e.activeContainer.ref.value),f=R(o),m=((U=e.pointerPosition.current.value)==null?void 0:U.x)??0,v=((Z=e.pointerPosition.current.value)==null?void 0:Z.y)??0,P=!(o&&m>=o.x&&m<=o.x+o.width&&v>=o.y&&v<=o.y+o.height),C=e.draggingElements.value.map(l=>l.node),T=e.elements.value.filter(l=>{if(!l.node||C.some(w=>w&&M(l.node,w))||l.groups.length&&!!e.draggingElements.value.some(S=>S.groups.length?!S.groups.some(I=>l.groups.includes(I)):!1))return!1;const u=k(l.node);return u&&o&&W(u,o)}).map(l=>{const u=k(l.node),w=R(u),S=m>=u.x&&m<=u.x+u.width&&v>=u.y&&v<=u.y+u.height,I=g(u,o),H=j(f,w),B=e.elements.value.filter(_=>_!==l&&_.node&&l.node&&M(l.node,_.node)).length;return{element:l,isPointerInElement:S,overlapPercent:I,depth:B,centerDistance:H}}).sort((l,u)=>{if(!P){if(l.isPointerInElement&&u.isPointerInElement)return u.depth-l.depth;if(l.isPointerInElement!==u.isPointerInElement)return l.isPointerInElement?-1:1}return Math.abs(l.overlapPercent-u.overlapPercent)<=1?l.centerDistance-u.centerDistance:u.overlapPercent-l.overlapPercent}),V=e.zones.value.filter(l=>{if(!l.node||C.some(w=>w&&M(l.node,w))||l.groups.length&&!!e.draggingElements.value.some(S=>S.groups.length?!S.groups.some(I=>l.groups.includes(I)):!1))return!1;const u=k(l.node);return u&&o&&W(u,o)}).map(l=>{const u=k(l.node),w=R(u),S=m>=u.x&&m<=u.x+u.width&&v>=u.y&&v<=u.y+u.height,I=g(u,o),H=j(f,w),B=e.zones.value.filter(_=>_!==l&&_.node&&l.node&&M(l.node,_.node)).length;return{zone:l,isPointerInElement:S,overlapPercent:I,depth:B,centerDistance:H}}).sort((l,u)=>{if(!P){if(l.isPointerInElement&&u.isPointerInElement)return u.depth-l.depth;if(l.isPointerInElement!==u.isPointerInElement)return l.isPointerInElement?-1:1}return Math.abs(l.overlapPercent-u.overlapPercent)<=1?l.centerDistance-u.centerDistance:u.overlapPercent-l.overlapPercent}),O=e.hovered.element.value,z=e.hovered.zone.value;e.hovered.element.value=((A=T[0])==null?void 0:A.element)??null,e.hovered.zone.value=((X=V[0])==null?void 0:X.zone)??null,e.hovered.element.value!==O&&((Y=O==null?void 0:O.events)!=null&&Y.onLeave&&O.events.onLeave(e),(F=($=e.hovered.element.value)==null?void 0:$.events)!=null&&F.onHover&&e.hovered.element.value.events.onHover(e)),e.hovered.zone.value!==z&&((q=z==null?void 0:z.events)!=null&&q.onLeave&&z.events.onLeave(e),(N=(G=e.hovered.zone.value)==null?void 0:G.events)!=null&&N.onHover&&e.hovered.zone.value.events.onHover(e)),r=requestAnimationFrame(h)},y=()=>{h()},a=()=>{r!==null&&(cancelAnimationFrame(r),r=null)};return{activate:o=>{e.draggingElements.value=s(t.value),i(o),y()},track:o=>{c(o)},deactivate:()=>{var o,f;d(),e.hovered.zone.value?(f=(o=e.hovered.zone.value.events).onDrop)==null||f.call(o,e):e.draggingElements.value.forEach(m=>{var v,x;return(x=(v=m.events).onEnd)==null?void 0:x.call(v,e)}),e.draggingElements.value=[],e.selectedElements.value=[],e.hovered.zone.value=null,e.hovered.element.value=null,a()}}},se=t=>{const{elementRef:e,registerElement:i,unregisterElement:c,isDragging:d,isOvered:r,isAllowed:s}=ne(t),{disableInteractions:g,enableInteractions:h}=re(),y=L(),{activate:a,track:E,deactivate:p}=ie(e),D=v=>{t!=null&&t.container&&(y.activeContainer.component.value=n.markRaw(t.container)),g(),a(v),document.addEventListener("pointermove",o),document.addEventListener("pointerup",m),document.addEventListener("wheel",f)},o=v=>{E(v)},f=v=>{E(v)},m=()=>{y.activeContainer.component.value=null,h(),p(),document.removeEventListener("pointermove",o),document.removeEventListener("pointerup",m),document.removeEventListener("wheel",f)};return n.onMounted(i),n.onBeforeUnmount(c),{pointerPosition:y.pointerPosition,elementRef:e,isDragging:d,isOvered:r,isAllowed:s,handleDragStart:D}},ae=t=>{const{zones:e,hovered:i,draggingElements:c,isDragging:d}=L(),r=n.ref(null),s=n.computed(()=>{var a;return((a=i.zone.value)==null?void 0:a.node)===r.value}),g=n.computed(()=>{if(!r.value||!d.value)return!1;const a=e.value.find(E=>E.node===r.value);return a!=null&&a.groups.length?!c.value.some(E=>E.groups.length?!E.groups.some(p=>a.groups.includes(p)):!1):!0});return{elementRef:r,registerZone:()=>{if(!r.value)throw new Error("elementRef is not set");e.value.push({node:r.value,groups:(t==null?void 0:t.groups)??[],events:(t==null?void 0:t.events)??{},data:(t==null?void 0:t.data)??void 0}),r.value.setAttribute("data-dnd-droppable","true")},unregisterZone:()=>{if(!r.value)throw new Error("elementRef is not set");const a=e.value.findIndex(E=>E.node===r.value);a!==-1&&e.value.splice(a,1)},isOvered:s,isAllowed:g}},ue=t=>{const{elementRef:e,registerZone:i,unregisterZone:c,isOvered:d,isAllowed:r}=ae(t);return n.onMounted(i),n.onBeforeUnmount(c),{elementRef:e,isOvered:d,isAllowed:r}},ce=t=>{const{selectedElements:e,elements:i}=L(),c=n.computed(()=>i.value.find(a=>a.node===t.value)),d=n.computed(()=>e.value.some(a=>a.node===t.value)),r=n.computed(()=>t.value?e.value.some(a=>a.node&&M(a.node,t.value)):!1),s=n.computed(()=>t.value?e.value.some(a=>a.node&&M(t.value,a.node)):!1),g=()=>{c.value&&(e.value=e.value.filter(a=>a.node!==t.value))},h=()=>{c.value&&(r.value&&(e.value=e.value.filter(a=>a.node&&!M(a.node,t.value))),s.value&&(e.value=e.value.filter(a=>a.node&&!M(t.value,a.node))),e.value.push(c.value))};return{handleUnselect:g,handleSelect:h,handleToggleSelect:()=>{c.value&&(e.value.some(a=>a.node===t.value)?g():h())},isSelected:d,isParentOfSelected:r}};exports.DragOverlay=ee;exports.getBoundingBox=k;exports.useDnDStore=L;exports.useDraggable=se;exports.useDroppable=ue;exports.useSelection=ce;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("vue");function ee(t){return n.getCurrentScope()?(n.onScopeDispose(t),!0):!1}function te(t){let e=!1,r;const a=n.effectScope(!0);return(...c)=>(e||(r=a.run(()=>t(...c)),e=!0),r)}const ne=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const re=t=>t!=null,z=()=>{};function oe(t,e){function r(...a){return new Promise((c,o)=>{Promise.resolve(t(()=>e.apply(this,a),{fn:e,thisArg:this,args:a})).then(c).catch(o)})}return r}function le(...t){let e=0,r,a=!0,c=z,o,s,v,f,y;!n.isRef(t[0])&&typeof t[0]=="object"?{delay:s,trailing:v=!0,leading:f=!0,rejectOnCancel:y=!1}=t[0]:[s,v=!0,f=!0,y=!1]=t;const l=()=>{r&&(clearTimeout(r),r=void 0,c(),c=z)};return D=>{const h=n.toValue(s),w=Date.now()-e,i=()=>o=D();return l(),h<=0?(e=Date.now(),i()):(w>h&&(f||!a)?(e=Date.now(),i()):v&&(o=new Promise((m,p)=>{c=y?p:m,r=setTimeout(()=>{e=Date.now(),a=!0,m(i()),l()},Math.max(0,h-w))})),!f&&!r&&(r=setTimeout(()=>a=!0,h)),a=!1,o)}}function se(t){return Array.isArray(t)?t:[t]}function ie(t,e=200,r=!1,a=!0,c=!1){return oe(le(e,r,a,c),t)}function ae(t,e,r){const a=n.watch(t,(...c)=>(n.nextTick(()=>a()),e(...c)),r);return a}const K=ne?window:void 0;function H(t){var e;const r=n.toValue(t);return(e=r==null?void 0:r.$el)!=null?e:r}function ue(){const t=n.shallowRef(!1),e=n.getCurrentInstance();return e&&n.onMounted(()=>{t.value=!0},e),t}function ce(t){const e=ue();return n.computed(()=>(e.value,!!t()))}function de(t,e,r={}){const{root:a,rootMargin:c="0px",threshold:o=0,window:s=K,immediate:v=!0}=r,f=ce(()=>s&&"IntersectionObserver"in s),y=n.computed(()=>{const w=n.toValue(t);return se(w).map(H).filter(re)});let l=z;const g=n.shallowRef(v),D=f.value?n.watch(()=>[y.value,H(a),g.value],([w,i])=>{if(l(),!g.value||!w.length)return;const m=new IntersectionObserver(e,{root:H(i),rootMargin:c,threshold:o});w.forEach(p=>p&&m.observe(p)),l=()=>{m.disconnect(),l=z}},{immediate:v,flush:"post"}):z,h=()=>{l(),D(),g.value=!1};return ee(h),{isSupported:f,isActive:g,pause(){l(),g.value=!1},resume(){g.value=!0},stop:h}}function ve(t,e={}){const{window:r=K,scrollTarget:a,threshold:c=0,rootMargin:o,once:s=!1}=e,v=n.shallowRef(!1),{stop:f}=de(t,y=>{let l=v.value,g=0;for(const D of y)D.time>=g&&(g=D.time,l=D.isIntersecting);v.value=l,s&&ae(v,()=>{f()})},{root:a,window:r,threshold:c,rootMargin:n.toValue(o)});return v}const I=te(()=>{const t=n.ref([]),e=n.computed(()=>t.value.length>0),r={component:n.ref(null),ref:n.ref(null)},a=n.ref([]),c=n.ref([]),o=n.ref([]),s={zone:n.ref(null),element:n.ref(null)},v={current:n.ref(null),start:n.ref(null),offset:{percent:n.ref(null),pixel:n.ref(null)}};return{isDragging:e,activeContainer:r,elements:a,draggingElements:t,selectedElements:c,zones:o,hovered:s,pointerPosition:v}}),fe=()=>{const t=n.ref(null),{draggingElements:e,pointerPosition:r,isDragging:a,activeContainer:c}=I();return n.onMounted(()=>{c.ref=t}),n.onBeforeUnmount(()=>{c.ref.value=null}),{elementRef:t,draggingElements:e,pointerPosition:r,isDragging:a}},ge=["innerHTML"],me=n.defineComponent({__name:"DefaultOverlay",setup(t){const{elementRef:e,pointerPosition:r,isDragging:a,draggingElements:c}=fe(),o=n.computed(()=>{var s,v,f,y;return{transform:`translate3d(${(((s=r.current.value)==null?void 0:s.x)??0)-(((v=r.offset.pixel.value)==null?void 0:v.x)??0)}px, ${(((f=r.current.value)==null?void 0:f.y)??0)-(((y=r.offset.pixel.value)==null?void 0:y.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(s,v)=>n.unref(a)?(n.openBlock(),n.createElementBlock("div",{key:0,ref_key:"elementRef",ref:e,style:n.normalizeStyle(o.value)},[(n.openBlock(!0),n.createElementBlock(n.Fragment,null,n.renderList(n.unref(c),(f,y)=>{var l,g;return n.openBlock(),n.createElementBlock("div",{key:y,innerHTML:f.initialHTML,style:n.normalizeStyle({width:`${(l=f.initialRect)==null?void 0:l.width}px`,height:`${(g=f.initialRect)==null?void 0:g.height}px`})},null,12,ge)}),128))],4)):n.createCommentVNode("",!0)}}),he=n.defineComponent({__name:"DragOverlay",setup(t){const{activeContainer:e}=I(),r=n.computed(()=>e.component.value??me);return(a,c)=>(n.openBlock(),n.createBlock(n.resolveDynamicComponent(r.value)))}}),pe="data-dnd-draggable",ye=t=>{const{elements:e,draggingElements:r,hovered:a,selectedElements:c,isDragging:o}=I(),s=n.ref(null),v=n.computed(()=>{var h;return((h=a.element.value)==null?void 0:h.node)===s.value}),f=ve(s),y=n.computed(()=>r.value.some(h=>h.node===s.value)),l=n.computed(()=>{if(!s.value||!o.value)return!1;const h=e.value.find(w=>w.node===s.value);return h!=null&&h.groups.length?!r.value.some(w=>w.groups.length?!w.groups.some(i=>h.groups.includes(i)):!1):!0});return{elementRef:s,registerElement:()=>{if(!s.value)throw new Error("ElementRef is not set");e.value.push({node:s.value,groups:(t==null?void 0:t.groups)??[],layer:(t==null?void 0:t.layer)??null,defaultLayer:(t==null?void 0:t.layer)??null,events:(t==null?void 0:t.events)??{},data:(t==null?void 0:t.data)??void 0,isVisible:f}),s.value.setAttribute(pe,"true")},unregisterElement:()=>{const h=e.value.findIndex(i=>i.node===s.value);h!==-1&&e.value.splice(h,1);const w=c.value.findIndex(i=>i.node===s.value);w!==-1&&c.value.splice(w,1)},isDragging:y,isOvered:v,isAllowed:l,isVisible:f}},we=()=>{let t="",e="",r="";const a=()=>{const s=document.body;t=s.style.userSelect,e=s.style.touchAction,r=s.style.overscrollBehavior,s.style.userSelect="none",s.style.touchAction="none",s.style.overscrollBehavior="none",window.addEventListener("contextmenu",o),window.addEventListener("selectstart",o),window.addEventListener("touchstart",o),window.addEventListener("touchmove",o)},c=()=>{const s=document.body;s.style.userSelect=t,s.style.touchAction=e,s.style.overscrollBehavior=r,window.removeEventListener("contextmenu",o),window.removeEventListener("selectstart",o),window.removeEventListener("touchstart",o),window.removeEventListener("touchmove",o)},o=s=>s.preventDefault();return{disableInteractions:a,enableInteractions:c}},N=(t,e)=>t.x<e.x+e.width&&t.x+t.width>e.x&&t.y<e.y+e.height&&t.y+t.height>e.y,O=t=>{if(!t)return{x:0,y:0,width:0,height:0,bottom:0,left:0,right:0,top:0};const e=t.getBoundingClientRect();return{bottom:e.bottom,left:e.left,right:e.right,top:e.top,x:e.x,y:e.y,width:e.width,height:e.height}},A=t=>({x:t.x+t.width/2,y:t.y+t.height/2}),Ee=(t,e)=>{const r=O(t);return{pixel:{x:e.x-r.x,y:e.y-r.y},percent:{x:(e.x-r.x)/r.width*100,y:(e.y-r.y)/r.height*100}}},J=(t,e)=>{const r=e.x-t.x,a=e.y-t.y;return Math.sqrt(r*r+a*a)},C=(t,e)=>t?e.contains(t):!1,Pe=t=>{const e=I();return{onPointerStart:o=>{e.pointerPosition.start.value={x:o.clientX,y:o.clientY},e.pointerPosition.current.value={x:o.clientX,y:o.clientY};const{pixel:s,percent:v}=Ee(t.value,{x:o.clientX,y:o.clientY});e.pointerPosition.offset.pixel.value=s,e.pointerPosition.offset.percent.value=v},onPointerMove:o=>{e.pointerPosition.current.value={x:o.clientX,y:o.clientY}},onPointerEnd:()=>{e.pointerPosition.current.value=null,e.pointerPosition.start.value=null,e.pointerPosition.offset.pixel.value=null,e.pointerPosition.offset.percent.value=null}}},De=t=>{const e=I(),{onPointerStart:r,onPointerMove:a,onPointerEnd:c}=Pe(t);let o=null;const s=i=>{var E,P;const m=e.selectedElements.value.some(x=>x.node===i);if(e.selectedElements.value.length&&m)return e.selectedElements.value.map(x=>{var L,V;return{...x,initialHTML:((L=x.node)==null?void 0:L.outerHTML)??"",initialRect:(V=x.node)==null?void 0:V.getBoundingClientRect()}});e.selectedElements.value=[];const p=e.elements.value.find(x=>x.node===i);return p?[{...p,initialHTML:((E=p.node)==null?void 0:E.outerHTML)??"",initialRect:(P=p.node)==null?void 0:P.getBoundingClientRect()}]:[]},v=(i,m)=>{const p=Math.max(0,Math.min(i.x+i.width,m.x+m.width)-Math.max(i.x,m.x)),E=Math.max(0,Math.min(i.y+i.height,m.y+m.height)-Math.max(i.y,m.y)),P=p*E,x=i.width*i.height,L=m.width*m.height;return(P/x*100+P/L*100)/2},f=ie(()=>{var F,U,Z,$,W,X,Y,j,q,G;const i=O(e.activeContainer.ref.value),m=A(i),p=((F=e.pointerPosition.current.value)==null?void 0:F.x)??0,E=((U=e.pointerPosition.current.value)==null?void 0:U.y)??0,x=!(i&&p>=i.x&&p<=i.x+i.width&&E>=i.y&&E<=i.y+i.height),L=e.draggingElements.value.map(u=>u.node),V=e.elements.value.filter(u=>{if(!u.isVisible||!u.isVisible.value||!u.node||L.some(S=>S&&C(u.node,S))||u.groups.length&&!!e.draggingElements.value.some(M=>M.groups.length?!M.groups.some(_=>u.groups.includes(_)):!1))return!1;const d=O(u.node);return d&&i&&N(d,i)}).map(u=>{const d=O(u.node),S=A(d),M=p>=d.x&&p<=d.x+d.width&&E>=d.y&&E<=d.y+d.height,_=v(d,i),b=J(m,S),B=e.elements.value.filter(k=>k!==u&&k.node&&u.node&&C(u.node,k.node)).length;return{element:u,isPointerInElement:M,overlapPercent:_,depth:B,centerDistance:b}}).sort((u,d)=>{if(!x){if(u.isPointerInElement&&d.isPointerInElement)return d.depth-u.depth;if(u.isPointerInElement!==d.isPointerInElement)return u.isPointerInElement?-1:1}return Math.abs(u.overlapPercent-d.overlapPercent)<=1?u.centerDistance-d.centerDistance:d.overlapPercent-u.overlapPercent}),Q=e.zones.value.filter(u=>{if(!u.node||L.some(S=>S&&C(u.node,S))||u.groups.length&&!!e.draggingElements.value.some(M=>M.groups.length?!M.groups.some(_=>u.groups.includes(_)):!1))return!1;const d=O(u.node);return d&&i&&N(d,i)}).map(u=>{const d=O(u.node),S=A(d),M=p>=d.x&&p<=d.x+d.width&&E>=d.y&&E<=d.y+d.height,_=v(d,i),b=J(m,S),B=e.zones.value.filter(k=>k!==u&&k.node&&u.node&&C(u.node,k.node)).length;return{zone:u,isPointerInElement:M,overlapPercent:_,depth:B,centerDistance:b}}).sort((u,d)=>{if(!x){if(u.isPointerInElement&&d.isPointerInElement)return d.depth-u.depth;if(u.isPointerInElement!==d.isPointerInElement)return u.isPointerInElement?-1:1}return Math.abs(u.overlapPercent-d.overlapPercent)<=1?u.centerDistance-d.centerDistance:d.overlapPercent-u.overlapPercent}),T=e.hovered.element.value,R=e.hovered.zone.value;e.hovered.element.value=((Z=V[0])==null?void 0:Z.element)??null,e.hovered.zone.value=(($=Q[0])==null?void 0:$.zone)??null,e.hovered.element.value!==T&&((W=T==null?void 0:T.events)!=null&&W.onLeave&&T.events.onLeave(e),(Y=(X=e.hovered.element.value)==null?void 0:X.events)!=null&&Y.onHover&&e.hovered.element.value.events.onHover(e)),e.hovered.zone.value!==R&&((j=R==null?void 0:R.events)!=null&&j.onLeave&&R.events.onLeave(e),(G=(q=e.hovered.zone.value)==null?void 0:q.events)!=null&&G.onHover&&e.hovered.zone.value.events.onHover(e)),console.log("processing collisions")},1e3),y=()=>{f(),o=requestAnimationFrame(y)},l=()=>{y()},g=()=>{o!==null&&(cancelAnimationFrame(o),o=null)};return{activate:i=>{e.draggingElements.value=s(t.value),r(i),l()},track:i=>{a(i)},deactivate:()=>{var i,m;c(),e.hovered.zone.value?(m=(i=e.hovered.zone.value.events).onDrop)==null||m.call(i,e):e.draggingElements.value.forEach(p=>{var E,P;return(P=(E=p.events).onEnd)==null?void 0:P.call(E,e)}),e.draggingElements.value=[],e.selectedElements.value=[],e.hovered.zone.value=null,e.hovered.element.value=null,g()}}},xe=t=>{const{elementRef:e,registerElement:r,unregisterElement:a,isDragging:c,isOvered:o,isAllowed:s,isVisible:v}=ye(t),{disableInteractions:f,enableInteractions:y}=we(),{activeContainer:l,pointerPosition:g}=I(),{activate:D,track:h,deactivate:w}=De(e),i=P=>{t!=null&&t.container&&(l.component.value=n.markRaw(t.container)),f(),D(P),document.addEventListener("pointermove",m),document.addEventListener("pointerup",E),document.addEventListener("wheel",p)},m=P=>h(P),p=P=>h(P),E=()=>{l.component.value=null,y(),w(),document.removeEventListener("pointermove",m),document.removeEventListener("pointerup",E),document.removeEventListener("wheel",p)};return n.onMounted(r),n.onBeforeUnmount(a),{pointerPosition:g,elementRef:e,isDragging:c,isOvered:o,isAllowed:s,handleDragStart:i,isVisible:v}},Se=t=>{const{zones:e,hovered:r,draggingElements:a,isDragging:c}=I(),o=n.ref(null),s=n.computed(()=>{var l;return((l=r.zone.value)==null?void 0:l.node)===o.value}),v=n.computed(()=>{if(!o.value||!c.value)return!1;const l=e.value.find(g=>g.node===o.value);return l!=null&&l.groups.length?!a.value.some(g=>g.groups.length?!g.groups.some(D=>l.groups.includes(D)):!1):!0});return{elementRef:o,registerZone:()=>{if(!o.value)throw new Error("elementRef is not set");e.value.push({node:o.value,groups:(t==null?void 0:t.groups)??[],events:(t==null?void 0:t.events)??{},data:(t==null?void 0:t.data)??void 0}),o.value.setAttribute("data-dnd-droppable","true")},unregisterZone:()=>{if(!o.value)throw new Error("elementRef is not set");const l=e.value.findIndex(g=>g.node===o.value);l!==-1&&e.value.splice(l,1)},isOvered:s,isAllowed:v}},Me=t=>{const{elementRef:e,registerZone:r,unregisterZone:a,isOvered:c,isAllowed:o}=Se(t);return n.onMounted(r),n.onBeforeUnmount(a),{elementRef:e,isOvered:c,isAllowed:o}},Ie=t=>{const{selectedElements:e,elements:r}=I(),a=n.computed(()=>r.value.find(l=>l.node===t.value)),c=n.computed(()=>e.value.some(l=>l.node===t.value)),o=n.computed(()=>t.value?e.value.some(l=>l.node&&C(l.node,t.value)):!1),s=n.computed(()=>t.value?e.value.some(l=>l.node&&C(t.value,l.node)):!1),v=()=>{a.value&&(e.value=e.value.filter(l=>l.node!==t.value))},f=()=>{a.value&&(o.value&&(e.value=e.value.filter(l=>l.node&&!C(l.node,t.value))),s.value&&(e.value=e.value.filter(l=>l.node&&!C(t.value,l.node))),e.value.push(a.value))};return{handleUnselect:v,handleSelect:f,handleToggleSelect:()=>{a.value&&(e.value.some(l=>l.node===t.value)?v():f())},isSelected:c,isParentOfSelected:o}};exports.DragOverlay=he;exports.getBoundingBox=O;exports.useDnDStore=I;exports.useDraggable=xe;exports.useDroppable=Me;exports.useSelection=Ie;
|
|
@@ -1,54 +1,183 @@
|
|
|
1
|
-
import { effectScope as
|
|
2
|
-
function
|
|
3
|
-
|
|
4
|
-
const u = oe(!0);
|
|
5
|
-
return (...c) => (e || (l = u.run(() => t(...c)), e = !0), l);
|
|
1
|
+
import { effectScope as ve, watch as ie, nextTick as de, isRef as fe, getCurrentScope as ge, onScopeDispose as he, toValue as b, shallowRef as U, computed as x, getCurrentInstance as me, onMounted as F, ref as P, onBeforeUnmount as j, defineComponent as ae, createElementBlock as W, createCommentVNode as pe, unref as re, openBlock as V, normalizeStyle as oe, Fragment as ye, renderList as we, createBlock as Ee, resolveDynamicComponent as Pe, markRaw as xe } from "vue";
|
|
2
|
+
function De(t) {
|
|
3
|
+
return ge() ? (he(t), !0) : !1;
|
|
6
4
|
}
|
|
5
|
+
function Ie(t) {
|
|
6
|
+
let e = !1, n;
|
|
7
|
+
const i = ve(!0);
|
|
8
|
+
return (...u) => (e || (n = i.run(() => t(...u)), e = !0), n);
|
|
9
|
+
}
|
|
10
|
+
const Me = typeof window < "u" && typeof document < "u";
|
|
7
11
|
typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
const Se = (t) => t != null, H = () => {
|
|
13
|
+
};
|
|
14
|
+
function Le(t, e) {
|
|
15
|
+
function n(...i) {
|
|
16
|
+
return new Promise((u, r) => {
|
|
17
|
+
Promise.resolve(t(() => e.apply(this, i), { fn: e, thisArg: this, args: i })).then(u).catch(r);
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return n;
|
|
21
|
+
}
|
|
22
|
+
function Ce(...t) {
|
|
23
|
+
let e = 0, n, i = !0, u = H, r, l, v, d, p;
|
|
24
|
+
!fe(t[0]) && typeof t[0] == "object" ? { delay: l, trailing: v = !0, leading: d = !0, rejectOnCancel: p = !1 } = t[0] : [l, v = !0, d = !0, p = !1] = t;
|
|
25
|
+
const o = () => {
|
|
26
|
+
n && (clearTimeout(n), n = void 0, u(), u = H);
|
|
27
|
+
};
|
|
28
|
+
return (D) => {
|
|
29
|
+
const h = b(l), y = Date.now() - e, s = () => r = D();
|
|
30
|
+
return o(), h <= 0 ? (e = Date.now(), s()) : (y > h && (d || !i) ? (e = Date.now(), s()) : v && (r = new Promise((g, m) => {
|
|
31
|
+
u = p ? m : g, n = setTimeout(() => {
|
|
32
|
+
e = Date.now(), i = !0, g(s()), o();
|
|
33
|
+
}, Math.max(0, h - y));
|
|
34
|
+
})), !d && !n && (n = setTimeout(() => i = !0, h)), i = !1, r);
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function _e(t) {
|
|
38
|
+
return Array.isArray(t) ? t : [t];
|
|
39
|
+
}
|
|
40
|
+
function Oe(t, e = 200, n = !1, i = !0, u = !1) {
|
|
41
|
+
return Le(
|
|
42
|
+
Ce(e, n, i, u),
|
|
43
|
+
t
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
function Te(t, e, n) {
|
|
47
|
+
const i = ie(t, (...u) => (de(() => i()), e(...u)), n);
|
|
48
|
+
return i;
|
|
49
|
+
}
|
|
50
|
+
const ue = Me ? window : void 0;
|
|
51
|
+
function X(t) {
|
|
52
|
+
var e;
|
|
53
|
+
const n = b(t);
|
|
54
|
+
return (e = n == null ? void 0 : n.$el) != null ? e : n;
|
|
55
|
+
}
|
|
56
|
+
function ke() {
|
|
57
|
+
const t = U(!1), e = me();
|
|
58
|
+
return e && F(() => {
|
|
59
|
+
t.value = !0;
|
|
60
|
+
}, e), t;
|
|
61
|
+
}
|
|
62
|
+
function ze(t) {
|
|
63
|
+
const e = ke();
|
|
64
|
+
return x(() => (e.value, !!t()));
|
|
65
|
+
}
|
|
66
|
+
function Re(t, e, n = {}) {
|
|
67
|
+
const {
|
|
68
|
+
root: i,
|
|
69
|
+
rootMargin: u = "0px",
|
|
70
|
+
threshold: r = 0,
|
|
71
|
+
window: l = ue,
|
|
72
|
+
immediate: v = !0
|
|
73
|
+
} = n, d = ze(() => l && "IntersectionObserver" in l), p = x(() => {
|
|
74
|
+
const y = b(t);
|
|
75
|
+
return _e(y).map(X).filter(Se);
|
|
76
|
+
});
|
|
77
|
+
let o = H;
|
|
78
|
+
const f = U(v), D = d.value ? ie(
|
|
79
|
+
() => [p.value, X(i), f.value],
|
|
80
|
+
([y, s]) => {
|
|
81
|
+
if (o(), !f.value || !y.length)
|
|
82
|
+
return;
|
|
83
|
+
const g = new IntersectionObserver(
|
|
84
|
+
e,
|
|
85
|
+
{
|
|
86
|
+
root: X(s),
|
|
87
|
+
rootMargin: u,
|
|
88
|
+
threshold: r
|
|
89
|
+
}
|
|
90
|
+
);
|
|
91
|
+
y.forEach((m) => m && g.observe(m)), o = () => {
|
|
92
|
+
g.disconnect(), o = H;
|
|
93
|
+
};
|
|
94
|
+
},
|
|
95
|
+
{ immediate: v, flush: "post" }
|
|
96
|
+
) : H, h = () => {
|
|
97
|
+
o(), D(), f.value = !1;
|
|
98
|
+
};
|
|
99
|
+
return De(h), {
|
|
100
|
+
isSupported: d,
|
|
101
|
+
isActive: f,
|
|
102
|
+
pause() {
|
|
103
|
+
o(), f.value = !1;
|
|
104
|
+
},
|
|
105
|
+
resume() {
|
|
106
|
+
f.value = !0;
|
|
107
|
+
},
|
|
108
|
+
stop: h
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
function He(t, e = {}) {
|
|
112
|
+
const {
|
|
113
|
+
window: n = ue,
|
|
114
|
+
scrollTarget: i,
|
|
115
|
+
threshold: u = 0,
|
|
116
|
+
rootMargin: r,
|
|
117
|
+
once: l = !1
|
|
118
|
+
} = e, v = U(!1), { stop: d } = Re(
|
|
119
|
+
t,
|
|
120
|
+
(p) => {
|
|
121
|
+
let o = v.value, f = 0;
|
|
122
|
+
for (const D of p)
|
|
123
|
+
D.time >= f && (f = D.time, o = D.isIntersecting);
|
|
124
|
+
v.value = o, l && Te(v, () => {
|
|
125
|
+
d();
|
|
126
|
+
});
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
root: i,
|
|
130
|
+
window: n,
|
|
131
|
+
threshold: u,
|
|
132
|
+
rootMargin: b(r)
|
|
133
|
+
}
|
|
134
|
+
);
|
|
135
|
+
return v;
|
|
136
|
+
}
|
|
137
|
+
const C = Ie(() => {
|
|
138
|
+
const t = P([]), e = x(() => t.value.length > 0), n = {
|
|
139
|
+
component: P(null),
|
|
140
|
+
ref: P(null)
|
|
141
|
+
}, i = P([]), u = P([]), r = P([]), l = {
|
|
142
|
+
zone: P(null),
|
|
143
|
+
element: P(null)
|
|
144
|
+
}, v = {
|
|
145
|
+
current: P(null),
|
|
146
|
+
start: P(null),
|
|
18
147
|
offset: {
|
|
19
|
-
percent:
|
|
20
|
-
pixel:
|
|
148
|
+
percent: P(null),
|
|
149
|
+
pixel: P(null)
|
|
21
150
|
}
|
|
22
151
|
};
|
|
23
152
|
return {
|
|
24
153
|
isDragging: e,
|
|
25
|
-
activeContainer:
|
|
26
|
-
elements:
|
|
154
|
+
activeContainer: n,
|
|
155
|
+
elements: i,
|
|
27
156
|
draggingElements: t,
|
|
28
|
-
selectedElements:
|
|
29
|
-
zones:
|
|
30
|
-
hovered:
|
|
31
|
-
pointerPosition:
|
|
157
|
+
selectedElements: u,
|
|
158
|
+
zones: r,
|
|
159
|
+
hovered: l,
|
|
160
|
+
pointerPosition: v
|
|
32
161
|
};
|
|
33
|
-
}),
|
|
34
|
-
const t =
|
|
35
|
-
return
|
|
36
|
-
|
|
37
|
-
}),
|
|
38
|
-
|
|
162
|
+
}), Ae = () => {
|
|
163
|
+
const t = P(null), { draggingElements: e, pointerPosition: n, isDragging: i, activeContainer: u } = C();
|
|
164
|
+
return F(() => {
|
|
165
|
+
u.ref = t;
|
|
166
|
+
}), j(() => {
|
|
167
|
+
u.ref.value = null;
|
|
39
168
|
}), {
|
|
40
169
|
elementRef: t,
|
|
41
170
|
draggingElements: e,
|
|
42
|
-
pointerPosition:
|
|
43
|
-
isDragging:
|
|
171
|
+
pointerPosition: n,
|
|
172
|
+
isDragging: i
|
|
44
173
|
};
|
|
45
|
-
},
|
|
174
|
+
}, Ve = ["innerHTML"], be = /* @__PURE__ */ ae({
|
|
46
175
|
__name: "DefaultOverlay",
|
|
47
176
|
setup(t) {
|
|
48
|
-
const { elementRef: e, pointerPosition:
|
|
49
|
-
var
|
|
177
|
+
const { elementRef: e, pointerPosition: n, isDragging: i, draggingElements: u } = Ae(), r = x(() => {
|
|
178
|
+
var l, v, d, p;
|
|
50
179
|
return {
|
|
51
|
-
transform: `translate3d(${(((
|
|
180
|
+
transform: `translate3d(${(((l = n.current.value) == null ? void 0 : l.x) ?? 0) - (((v = n.offset.pixel.value) == null ? void 0 : v.x) ?? 0)}px, ${(((d = n.current.value) == null ? void 0 : d.y) ?? 0) - (((p = n.offset.pixel.value) == null ? void 0 : p.y) ?? 0)}px, 0)`,
|
|
52
181
|
zIndex: 1e3,
|
|
53
182
|
position: "fixed",
|
|
54
183
|
top: 0,
|
|
@@ -56,97 +185,99 @@ const C = ve(() => {
|
|
|
56
185
|
transition: "0.3s cubic-bezier(0.165, 0.84, 0.44, 1)"
|
|
57
186
|
};
|
|
58
187
|
});
|
|
59
|
-
return (
|
|
188
|
+
return (l, v) => re(i) ? (V(), W("div", {
|
|
60
189
|
key: 0,
|
|
61
190
|
ref_key: "elementRef",
|
|
62
191
|
ref: e,
|
|
63
|
-
style:
|
|
192
|
+
style: oe(r.value)
|
|
64
193
|
}, [
|
|
65
|
-
(
|
|
66
|
-
var
|
|
67
|
-
return
|
|
68
|
-
key:
|
|
69
|
-
innerHTML:
|
|
70
|
-
style:
|
|
71
|
-
width: `${(
|
|
72
|
-
height: `${(
|
|
194
|
+
(V(!0), W(ye, null, we(re(u), (d, p) => {
|
|
195
|
+
var o, f;
|
|
196
|
+
return V(), W("div", {
|
|
197
|
+
key: p,
|
|
198
|
+
innerHTML: d.initialHTML,
|
|
199
|
+
style: oe({
|
|
200
|
+
width: `${(o = d.initialRect) == null ? void 0 : o.width}px`,
|
|
201
|
+
height: `${(f = d.initialRect) == null ? void 0 : f.height}px`
|
|
73
202
|
})
|
|
74
|
-
}, null, 12,
|
|
203
|
+
}, null, 12, Ve);
|
|
75
204
|
}), 128))
|
|
76
|
-
], 4)) :
|
|
205
|
+
], 4)) : pe("", !0);
|
|
77
206
|
}
|
|
78
|
-
}),
|
|
207
|
+
}), Ge = /* @__PURE__ */ ae({
|
|
79
208
|
__name: "DragOverlay",
|
|
80
209
|
setup(t) {
|
|
81
|
-
const { activeContainer: e } = C(),
|
|
82
|
-
() => e.component.value ??
|
|
210
|
+
const { activeContainer: e } = C(), n = x(
|
|
211
|
+
() => e.component.value ?? be
|
|
83
212
|
);
|
|
84
|
-
return (
|
|
213
|
+
return (i, u) => (V(), Ee(Pe(n.value)));
|
|
85
214
|
}
|
|
86
|
-
}),
|
|
215
|
+
}), Fe = "data-dnd-draggable", Ze = (t) => {
|
|
87
216
|
const {
|
|
88
217
|
elements: e,
|
|
89
|
-
draggingElements:
|
|
90
|
-
hovered:
|
|
91
|
-
selectedElements:
|
|
92
|
-
isDragging:
|
|
93
|
-
} = C(),
|
|
218
|
+
draggingElements: n,
|
|
219
|
+
hovered: i,
|
|
220
|
+
selectedElements: u,
|
|
221
|
+
isDragging: r
|
|
222
|
+
} = C(), l = P(null), v = x(
|
|
94
223
|
() => {
|
|
95
|
-
var
|
|
96
|
-
return ((
|
|
224
|
+
var h;
|
|
225
|
+
return ((h = i.element.value) == null ? void 0 : h.node) === l.value;
|
|
97
226
|
}
|
|
98
|
-
),
|
|
99
|
-
() =>
|
|
100
|
-
),
|
|
101
|
-
if (!
|
|
102
|
-
const
|
|
103
|
-
(
|
|
227
|
+
), d = He(l), p = x(
|
|
228
|
+
() => n.value.some((h) => h.node === l.value)
|
|
229
|
+
), o = x(() => {
|
|
230
|
+
if (!l.value || !r.value) return !1;
|
|
231
|
+
const h = e.value.find(
|
|
232
|
+
(y) => y.node === l.value
|
|
104
233
|
);
|
|
105
|
-
return
|
|
106
|
-
(
|
|
234
|
+
return h != null && h.groups.length ? !n.value.some((y) => y.groups.length ? !y.groups.some(
|
|
235
|
+
(s) => h.groups.includes(s)
|
|
107
236
|
) : !1) : !0;
|
|
108
237
|
});
|
|
109
238
|
return {
|
|
110
|
-
elementRef:
|
|
239
|
+
elementRef: l,
|
|
111
240
|
registerElement: () => {
|
|
112
|
-
if (!
|
|
241
|
+
if (!l.value) throw new Error("ElementRef is not set");
|
|
113
242
|
e.value.push({
|
|
114
|
-
node:
|
|
243
|
+
node: l.value,
|
|
115
244
|
groups: (t == null ? void 0 : t.groups) ?? [],
|
|
116
245
|
layer: (t == null ? void 0 : t.layer) ?? null,
|
|
117
246
|
defaultLayer: (t == null ? void 0 : t.layer) ?? null,
|
|
118
247
|
events: (t == null ? void 0 : t.events) ?? {},
|
|
119
|
-
data: (t == null ? void 0 : t.data) ?? void 0
|
|
120
|
-
|
|
248
|
+
data: (t == null ? void 0 : t.data) ?? void 0,
|
|
249
|
+
isVisible: d
|
|
250
|
+
}), l.value.setAttribute(Fe, "true");
|
|
121
251
|
},
|
|
122
252
|
unregisterElement: () => {
|
|
123
|
-
const
|
|
124
|
-
(
|
|
253
|
+
const h = e.value.findIndex(
|
|
254
|
+
(s) => s.node === l.value
|
|
125
255
|
);
|
|
126
|
-
|
|
127
|
-
const
|
|
128
|
-
(
|
|
256
|
+
h !== -1 && e.value.splice(h, 1);
|
|
257
|
+
const y = u.value.findIndex(
|
|
258
|
+
(s) => s.node === l.value
|
|
129
259
|
);
|
|
130
|
-
|
|
260
|
+
y !== -1 && u.value.splice(y, 1);
|
|
131
261
|
},
|
|
132
|
-
isDragging:
|
|
133
|
-
isOvered:
|
|
134
|
-
isAllowed:
|
|
262
|
+
isDragging: p,
|
|
263
|
+
isOvered: v,
|
|
264
|
+
isAllowed: o,
|
|
265
|
+
isVisible: d
|
|
135
266
|
};
|
|
136
|
-
},
|
|
137
|
-
let t = "", e = "",
|
|
138
|
-
const
|
|
139
|
-
const
|
|
140
|
-
t =
|
|
141
|
-
},
|
|
142
|
-
const
|
|
143
|
-
|
|
144
|
-
},
|
|
267
|
+
}, $e = () => {
|
|
268
|
+
let t = "", e = "", n = "";
|
|
269
|
+
const i = () => {
|
|
270
|
+
const l = document.body;
|
|
271
|
+
t = l.style.userSelect, e = l.style.touchAction, n = l.style.overscrollBehavior, l.style.userSelect = "none", l.style.touchAction = "none", l.style.overscrollBehavior = "none", window.addEventListener("contextmenu", r), window.addEventListener("selectstart", r), window.addEventListener("touchstart", r), window.addEventListener("touchmove", r);
|
|
272
|
+
}, u = () => {
|
|
273
|
+
const l = document.body;
|
|
274
|
+
l.style.userSelect = t, l.style.touchAction = e, l.style.overscrollBehavior = n, window.removeEventListener("contextmenu", r), window.removeEventListener("selectstart", r), window.removeEventListener("touchstart", r), window.removeEventListener("touchmove", r);
|
|
275
|
+
}, r = (l) => l.preventDefault();
|
|
145
276
|
return {
|
|
146
|
-
disableInteractions:
|
|
147
|
-
enableInteractions:
|
|
277
|
+
disableInteractions: i,
|
|
278
|
+
enableInteractions: u
|
|
148
279
|
};
|
|
149
|
-
},
|
|
280
|
+
}, le = (t, e) => t.x < e.x + e.width && t.x + t.width > e.x && t.y < e.y + e.height && t.y + t.height > e.y, k = (t) => {
|
|
150
281
|
if (!t)
|
|
151
282
|
return {
|
|
152
283
|
x: 0,
|
|
@@ -172,270 +303,270 @@ const C = ve(() => {
|
|
|
172
303
|
}, Y = (t) => ({
|
|
173
304
|
x: t.x + t.width / 2,
|
|
174
305
|
y: t.y + t.height / 2
|
|
175
|
-
}),
|
|
176
|
-
const
|
|
306
|
+
}), We = (t, e) => {
|
|
307
|
+
const n = k(t);
|
|
177
308
|
return {
|
|
178
309
|
pixel: {
|
|
179
|
-
x: e.x -
|
|
180
|
-
y: e.y -
|
|
310
|
+
x: e.x - n.x,
|
|
311
|
+
y: e.y - n.y
|
|
181
312
|
},
|
|
182
313
|
percent: {
|
|
183
|
-
x: (e.x -
|
|
184
|
-
y: (e.y -
|
|
314
|
+
x: (e.x - n.x) / n.width * 100,
|
|
315
|
+
y: (e.y - n.y) / n.height * 100
|
|
185
316
|
}
|
|
186
317
|
};
|
|
187
|
-
},
|
|
188
|
-
const
|
|
189
|
-
return Math.sqrt(
|
|
190
|
-
},
|
|
318
|
+
}, se = (t, e) => {
|
|
319
|
+
const n = e.x - t.x, i = e.y - t.y;
|
|
320
|
+
return Math.sqrt(n * n + i * i);
|
|
321
|
+
}, L = (t, e) => t ? e.contains(t) : !1, Xe = (t) => {
|
|
191
322
|
const e = C();
|
|
192
323
|
return {
|
|
193
|
-
onPointerStart: (
|
|
194
|
-
e.pointerPosition.start.value = { x:
|
|
195
|
-
x:
|
|
196
|
-
y:
|
|
324
|
+
onPointerStart: (r) => {
|
|
325
|
+
e.pointerPosition.start.value = { x: r.clientX, y: r.clientY }, e.pointerPosition.current.value = {
|
|
326
|
+
x: r.clientX,
|
|
327
|
+
y: r.clientY
|
|
197
328
|
};
|
|
198
|
-
const { pixel:
|
|
199
|
-
x:
|
|
200
|
-
y:
|
|
329
|
+
const { pixel: l, percent: v } = We(t.value, {
|
|
330
|
+
x: r.clientX,
|
|
331
|
+
y: r.clientY
|
|
201
332
|
});
|
|
202
|
-
e.pointerPosition.offset.pixel.value =
|
|
333
|
+
e.pointerPosition.offset.pixel.value = l, e.pointerPosition.offset.percent.value = v;
|
|
203
334
|
},
|
|
204
|
-
onPointerMove: (
|
|
335
|
+
onPointerMove: (r) => {
|
|
205
336
|
e.pointerPosition.current.value = {
|
|
206
|
-
x:
|
|
207
|
-
y:
|
|
337
|
+
x: r.clientX,
|
|
338
|
+
y: r.clientY
|
|
208
339
|
};
|
|
209
340
|
},
|
|
210
341
|
onPointerEnd: () => {
|
|
211
342
|
e.pointerPosition.current.value = null, e.pointerPosition.start.value = null, e.pointerPosition.offset.pixel.value = null, e.pointerPosition.offset.percent.value = null;
|
|
212
343
|
}
|
|
213
344
|
};
|
|
214
|
-
},
|
|
215
|
-
const e = C(), { onPointerStart:
|
|
216
|
-
let
|
|
217
|
-
const
|
|
218
|
-
var
|
|
345
|
+
}, Ye = (t) => {
|
|
346
|
+
const e = C(), { onPointerStart: n, onPointerMove: i, onPointerEnd: u } = Xe(t);
|
|
347
|
+
let r = null;
|
|
348
|
+
const l = (s) => {
|
|
349
|
+
var w, E;
|
|
219
350
|
const g = e.selectedElements.value.some(
|
|
220
|
-
(
|
|
351
|
+
(I) => I.node === s
|
|
221
352
|
);
|
|
222
353
|
if (e.selectedElements.value.length && g)
|
|
223
|
-
return e.selectedElements.value.map((
|
|
224
|
-
var
|
|
354
|
+
return e.selectedElements.value.map((I) => {
|
|
355
|
+
var _, A;
|
|
225
356
|
return {
|
|
226
|
-
...
|
|
227
|
-
initialHTML: ((
|
|
228
|
-
initialRect: (
|
|
357
|
+
...I,
|
|
358
|
+
initialHTML: ((_ = I.node) == null ? void 0 : _.outerHTML) ?? "",
|
|
359
|
+
initialRect: (A = I.node) == null ? void 0 : A.getBoundingClientRect()
|
|
229
360
|
};
|
|
230
361
|
});
|
|
231
362
|
e.selectedElements.value = [];
|
|
232
|
-
const
|
|
233
|
-
(
|
|
363
|
+
const m = e.elements.value.find(
|
|
364
|
+
(I) => I.node === s
|
|
234
365
|
);
|
|
235
|
-
return
|
|
366
|
+
return m ? [
|
|
236
367
|
{
|
|
237
|
-
...
|
|
238
|
-
initialHTML: ((
|
|
239
|
-
initialRect: (
|
|
368
|
+
...m,
|
|
369
|
+
initialHTML: ((w = m.node) == null ? void 0 : w.outerHTML) ?? "",
|
|
370
|
+
initialRect: (E = m.node) == null ? void 0 : E.getBoundingClientRect()
|
|
240
371
|
}
|
|
241
372
|
] : [];
|
|
242
|
-
},
|
|
243
|
-
const
|
|
373
|
+
}, v = (s, g) => {
|
|
374
|
+
const m = Math.max(
|
|
244
375
|
0,
|
|
245
|
-
Math.min(
|
|
246
|
-
),
|
|
376
|
+
Math.min(s.x + s.width, g.x + g.width) - Math.max(s.x, g.x)
|
|
377
|
+
), w = Math.max(
|
|
247
378
|
0,
|
|
248
|
-
Math.min(
|
|
249
|
-
),
|
|
250
|
-
return (
|
|
251
|
-
},
|
|
252
|
-
var
|
|
253
|
-
const
|
|
254
|
-
if (!
|
|
255
|
-
(
|
|
256
|
-
) ||
|
|
257
|
-
(
|
|
258
|
-
(
|
|
379
|
+
Math.min(s.y + s.height, g.y + g.height) - Math.max(s.y, g.y)
|
|
380
|
+
), E = m * w, I = s.width * s.height, _ = g.width * g.height;
|
|
381
|
+
return (E / I * 100 + E / _ * 100) / 2;
|
|
382
|
+
}, d = Oe(() => {
|
|
383
|
+
var G, N, q, B, J, K, Q, ee, te, ne;
|
|
384
|
+
const s = k(e.activeContainer.ref.value), g = Y(s), m = ((G = e.pointerPosition.current.value) == null ? void 0 : G.x) ?? 0, w = ((N = e.pointerPosition.current.value) == null ? void 0 : N.y) ?? 0, I = !(s && m >= s.x && m <= s.x + s.width && w >= s.y && w <= s.y + s.height), _ = e.draggingElements.value.map((a) => a.node), A = e.elements.value.filter((a) => {
|
|
385
|
+
if (!a.isVisible || !a.isVisible.value || !a.node || _.some(
|
|
386
|
+
(M) => M && L(a.node, M)
|
|
387
|
+
) || a.groups.length && !!e.draggingElements.value.some(
|
|
388
|
+
(S) => S.groups.length ? !S.groups.some(
|
|
389
|
+
(O) => a.groups.includes(O)
|
|
259
390
|
) : !1
|
|
260
391
|
))
|
|
261
392
|
return !1;
|
|
262
|
-
const
|
|
263
|
-
return
|
|
264
|
-
}).map((
|
|
265
|
-
const
|
|
266
|
-
(
|
|
267
|
-
|
|
268
|
-
|
|
393
|
+
const c = k(a.node);
|
|
394
|
+
return c && s && le(c, s);
|
|
395
|
+
}).map((a) => {
|
|
396
|
+
const c = k(a.node), M = Y(c), S = m >= c.x && m <= c.x + c.width && w >= c.y && w <= c.y + c.height, O = v(c, s), Z = se(g, M), $ = e.elements.value.filter(
|
|
397
|
+
(T) => T !== a && T.node && a.node && L(
|
|
398
|
+
a.node,
|
|
399
|
+
T.node
|
|
269
400
|
)
|
|
270
401
|
).length;
|
|
271
402
|
return {
|
|
272
|
-
element:
|
|
273
|
-
isPointerInElement:
|
|
274
|
-
overlapPercent:
|
|
275
|
-
depth:
|
|
403
|
+
element: a,
|
|
404
|
+
isPointerInElement: S,
|
|
405
|
+
overlapPercent: O,
|
|
406
|
+
depth: $,
|
|
276
407
|
centerDistance: Z
|
|
277
408
|
};
|
|
278
|
-
}).sort((
|
|
279
|
-
if (!
|
|
280
|
-
if (
|
|
281
|
-
return
|
|
282
|
-
if (
|
|
283
|
-
return
|
|
409
|
+
}).sort((a, c) => {
|
|
410
|
+
if (!I) {
|
|
411
|
+
if (a.isPointerInElement && c.isPointerInElement)
|
|
412
|
+
return c.depth - a.depth;
|
|
413
|
+
if (a.isPointerInElement !== c.isPointerInElement)
|
|
414
|
+
return a.isPointerInElement ? -1 : 1;
|
|
284
415
|
}
|
|
285
|
-
return Math.abs(
|
|
286
|
-
}),
|
|
287
|
-
if (!
|
|
288
|
-
(
|
|
289
|
-
) ||
|
|
416
|
+
return Math.abs(a.overlapPercent - c.overlapPercent) <= 1 ? a.centerDistance - c.centerDistance : c.overlapPercent - a.overlapPercent;
|
|
417
|
+
}), ce = e.zones.value.filter((a) => {
|
|
418
|
+
if (!a.node || _.some(
|
|
419
|
+
(M) => M && L(a.node, M)
|
|
420
|
+
) || a.groups.length && !!e.draggingElements.value.some((S) => S.groups.length ? !S.groups.some((O) => a.groups.includes(O)) : !1))
|
|
290
421
|
return !1;
|
|
291
|
-
const
|
|
292
|
-
return
|
|
293
|
-
}).map((
|
|
294
|
-
const
|
|
295
|
-
(
|
|
422
|
+
const c = k(a.node);
|
|
423
|
+
return c && s && le(c, s);
|
|
424
|
+
}).map((a) => {
|
|
425
|
+
const c = k(a.node), M = Y(c), S = m >= c.x && m <= c.x + c.width && w >= c.y && w <= c.y + c.height, O = v(c, s), Z = se(g, M), $ = e.zones.value.filter(
|
|
426
|
+
(T) => T !== a && T.node && a.node && L(a.node, T.node)
|
|
296
427
|
).length;
|
|
297
428
|
return {
|
|
298
|
-
zone:
|
|
299
|
-
isPointerInElement:
|
|
300
|
-
overlapPercent:
|
|
301
|
-
depth:
|
|
429
|
+
zone: a,
|
|
430
|
+
isPointerInElement: S,
|
|
431
|
+
overlapPercent: O,
|
|
432
|
+
depth: $,
|
|
302
433
|
centerDistance: Z
|
|
303
434
|
};
|
|
304
|
-
}).sort((
|
|
305
|
-
if (!
|
|
306
|
-
if (
|
|
307
|
-
return
|
|
308
|
-
if (
|
|
309
|
-
return
|
|
435
|
+
}).sort((a, c) => {
|
|
436
|
+
if (!I) {
|
|
437
|
+
if (a.isPointerInElement && c.isPointerInElement)
|
|
438
|
+
return c.depth - a.depth;
|
|
439
|
+
if (a.isPointerInElement !== c.isPointerInElement)
|
|
440
|
+
return a.isPointerInElement ? -1 : 1;
|
|
310
441
|
}
|
|
311
|
-
return Math.abs(
|
|
312
|
-
}), z = e.hovered.element.value,
|
|
313
|
-
e.hovered.element.value = ((q =
|
|
314
|
-
},
|
|
315
|
-
|
|
316
|
-
},
|
|
317
|
-
|
|
442
|
+
return Math.abs(a.overlapPercent - c.overlapPercent) <= 1 ? a.centerDistance - c.centerDistance : c.overlapPercent - a.overlapPercent;
|
|
443
|
+
}), z = e.hovered.element.value, R = e.hovered.zone.value;
|
|
444
|
+
e.hovered.element.value = ((q = A[0]) == null ? void 0 : q.element) ?? null, e.hovered.zone.value = ((B = ce[0]) == null ? void 0 : B.zone) ?? null, e.hovered.element.value !== z && ((J = z == null ? void 0 : z.events) != null && J.onLeave && z.events.onLeave(e), (Q = (K = e.hovered.element.value) == null ? void 0 : K.events) != null && Q.onHover && e.hovered.element.value.events.onHover(e)), e.hovered.zone.value !== R && ((ee = R == null ? void 0 : R.events) != null && ee.onLeave && R.events.onLeave(e), (ne = (te = e.hovered.zone.value) == null ? void 0 : te.events) != null && ne.onHover && e.hovered.zone.value.events.onHover(e)), console.log("processing collisions");
|
|
445
|
+
}, 1e3), p = () => {
|
|
446
|
+
d(), r = requestAnimationFrame(p);
|
|
447
|
+
}, o = () => {
|
|
448
|
+
p();
|
|
449
|
+
}, f = () => {
|
|
450
|
+
r !== null && (cancelAnimationFrame(r), r = null);
|
|
318
451
|
};
|
|
319
452
|
return {
|
|
320
|
-
activate: (
|
|
321
|
-
e.draggingElements.value =
|
|
453
|
+
activate: (s) => {
|
|
454
|
+
e.draggingElements.value = l(t.value), n(s), o();
|
|
322
455
|
},
|
|
323
|
-
track: (
|
|
324
|
-
|
|
456
|
+
track: (s) => {
|
|
457
|
+
i(s);
|
|
325
458
|
},
|
|
326
459
|
deactivate: () => {
|
|
327
|
-
var
|
|
328
|
-
|
|
329
|
-
(
|
|
330
|
-
var
|
|
331
|
-
return (
|
|
460
|
+
var s, g;
|
|
461
|
+
u(), e.hovered.zone.value ? (g = (s = e.hovered.zone.value.events).onDrop) == null || g.call(s, e) : e.draggingElements.value.forEach(
|
|
462
|
+
(m) => {
|
|
463
|
+
var w, E;
|
|
464
|
+
return (E = (w = m.events).onEnd) == null ? void 0 : E.call(w, e);
|
|
332
465
|
}
|
|
333
|
-
), e.draggingElements.value = [], e.selectedElements.value = [], e.hovered.zone.value = null, e.hovered.element.value = null,
|
|
466
|
+
), e.draggingElements.value = [], e.selectedElements.value = [], e.hovered.zone.value = null, e.hovered.element.value = null, f();
|
|
334
467
|
}
|
|
335
468
|
};
|
|
336
|
-
},
|
|
469
|
+
}, Ne = (t) => {
|
|
337
470
|
const {
|
|
338
471
|
elementRef: e,
|
|
339
|
-
registerElement:
|
|
340
|
-
unregisterElement:
|
|
341
|
-
isDragging:
|
|
342
|
-
isOvered:
|
|
343
|
-
isAllowed:
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
E(v);
|
|
350
|
-
}, h = () => {
|
|
351
|
-
y.activeContainer.component.value = null, f(), m(), document.removeEventListener("pointermove", r), document.removeEventListener("pointerup", h), document.removeEventListener("wheel", g);
|
|
472
|
+
registerElement: n,
|
|
473
|
+
unregisterElement: i,
|
|
474
|
+
isDragging: u,
|
|
475
|
+
isOvered: r,
|
|
476
|
+
isAllowed: l,
|
|
477
|
+
isVisible: v
|
|
478
|
+
} = Ze(t), { disableInteractions: d, enableInteractions: p } = $e(), { activeContainer: o, pointerPosition: f } = C(), { activate: D, track: h, deactivate: y } = Ye(e), s = (E) => {
|
|
479
|
+
t != null && t.container && (o.component.value = xe(t.container)), d(), D(E), document.addEventListener("pointermove", g), document.addEventListener("pointerup", w), document.addEventListener("wheel", m);
|
|
480
|
+
}, g = (E) => h(E), m = (E) => h(E), w = () => {
|
|
481
|
+
o.component.value = null, p(), y(), document.removeEventListener("pointermove", g), document.removeEventListener("pointerup", w), document.removeEventListener("wheel", m);
|
|
352
482
|
};
|
|
353
|
-
return
|
|
354
|
-
pointerPosition:
|
|
483
|
+
return F(n), j(i), {
|
|
484
|
+
pointerPosition: f,
|
|
355
485
|
elementRef: e,
|
|
356
|
-
isDragging:
|
|
357
|
-
isOvered:
|
|
358
|
-
isAllowed:
|
|
359
|
-
handleDragStart:
|
|
486
|
+
isDragging: u,
|
|
487
|
+
isOvered: r,
|
|
488
|
+
isAllowed: l,
|
|
489
|
+
handleDragStart: s,
|
|
490
|
+
isVisible: v
|
|
360
491
|
};
|
|
361
|
-
},
|
|
362
|
-
const { zones: e, hovered:
|
|
363
|
-
var
|
|
364
|
-
return ((
|
|
365
|
-
}),
|
|
366
|
-
if (!
|
|
367
|
-
const
|
|
368
|
-
(
|
|
492
|
+
}, Ue = (t) => {
|
|
493
|
+
const { zones: e, hovered: n, draggingElements: i, isDragging: u } = C(), r = P(null), l = x(() => {
|
|
494
|
+
var o;
|
|
495
|
+
return ((o = n.zone.value) == null ? void 0 : o.node) === r.value;
|
|
496
|
+
}), v = x(() => {
|
|
497
|
+
if (!r.value || !u.value) return !1;
|
|
498
|
+
const o = e.value.find(
|
|
499
|
+
(f) => f.node === r.value
|
|
369
500
|
);
|
|
370
|
-
return
|
|
371
|
-
(
|
|
501
|
+
return o != null && o.groups.length ? !i.value.some((f) => f.groups.length ? !f.groups.some(
|
|
502
|
+
(D) => o.groups.includes(D)
|
|
372
503
|
) : !1) : !0;
|
|
373
504
|
});
|
|
374
|
-
return { elementRef:
|
|
375
|
-
if (!
|
|
505
|
+
return { elementRef: r, registerZone: () => {
|
|
506
|
+
if (!r.value) throw new Error("elementRef is not set");
|
|
376
507
|
e.value.push({
|
|
377
|
-
node:
|
|
508
|
+
node: r.value,
|
|
378
509
|
groups: (t == null ? void 0 : t.groups) ?? [],
|
|
379
510
|
events: (t == null ? void 0 : t.events) ?? {},
|
|
380
511
|
data: (t == null ? void 0 : t.data) ?? void 0
|
|
381
|
-
}),
|
|
512
|
+
}), r.value.setAttribute("data-dnd-droppable", "true");
|
|
382
513
|
}, unregisterZone: () => {
|
|
383
|
-
if (!
|
|
384
|
-
const
|
|
385
|
-
(
|
|
514
|
+
if (!r.value) throw new Error("elementRef is not set");
|
|
515
|
+
const o = e.value.findIndex(
|
|
516
|
+
(f) => f.node === r.value
|
|
386
517
|
);
|
|
387
|
-
|
|
388
|
-
}, isOvered:
|
|
389
|
-
},
|
|
390
|
-
const { elementRef: e, registerZone:
|
|
391
|
-
return
|
|
392
|
-
},
|
|
393
|
-
const { selectedElements: e, elements:
|
|
394
|
-
() =>
|
|
395
|
-
),
|
|
396
|
-
() => e.value.some((
|
|
397
|
-
),
|
|
398
|
-
(
|
|
399
|
-
|
|
518
|
+
o !== -1 && e.value.splice(o, 1);
|
|
519
|
+
}, isOvered: l, isAllowed: v };
|
|
520
|
+
}, qe = (t) => {
|
|
521
|
+
const { elementRef: e, registerZone: n, unregisterZone: i, isOvered: u, isAllowed: r } = Ue(t);
|
|
522
|
+
return F(n), j(i), { elementRef: e, isOvered: u, isAllowed: r };
|
|
523
|
+
}, Be = (t) => {
|
|
524
|
+
const { selectedElements: e, elements: n } = C(), i = x(
|
|
525
|
+
() => n.value.find((o) => o.node === t.value)
|
|
526
|
+
), u = x(
|
|
527
|
+
() => e.value.some((o) => o.node === t.value)
|
|
528
|
+
), r = x(() => t.value ? e.value.some(
|
|
529
|
+
(o) => o.node && L(
|
|
530
|
+
o.node,
|
|
400
531
|
t.value
|
|
401
532
|
)
|
|
402
|
-
) : !1),
|
|
403
|
-
(
|
|
533
|
+
) : !1), l = x(() => t.value ? e.value.some(
|
|
534
|
+
(o) => o.node && L(
|
|
404
535
|
t.value,
|
|
405
|
-
|
|
536
|
+
o.node
|
|
406
537
|
)
|
|
407
|
-
) : !1),
|
|
408
|
-
|
|
409
|
-
(
|
|
538
|
+
) : !1), v = () => {
|
|
539
|
+
i.value && (e.value = e.value.filter(
|
|
540
|
+
(o) => o.node !== t.value
|
|
410
541
|
));
|
|
411
|
-
},
|
|
412
|
-
|
|
413
|
-
(
|
|
414
|
-
|
|
542
|
+
}, d = () => {
|
|
543
|
+
i.value && (r.value && (e.value = e.value.filter(
|
|
544
|
+
(o) => o.node && !L(
|
|
545
|
+
o.node,
|
|
415
546
|
t.value
|
|
416
547
|
)
|
|
417
|
-
)),
|
|
418
|
-
(
|
|
548
|
+
)), l.value && (e.value = e.value.filter(
|
|
549
|
+
(o) => o.node && !L(
|
|
419
550
|
t.value,
|
|
420
|
-
|
|
551
|
+
o.node
|
|
421
552
|
)
|
|
422
|
-
)), e.value.push(
|
|
553
|
+
)), e.value.push(i.value));
|
|
423
554
|
};
|
|
424
555
|
return {
|
|
425
|
-
handleUnselect:
|
|
426
|
-
handleSelect:
|
|
556
|
+
handleUnselect: v,
|
|
557
|
+
handleSelect: d,
|
|
427
558
|
handleToggleSelect: () => {
|
|
428
|
-
|
|
559
|
+
i.value && (e.value.some((o) => o.node === t.value) ? v() : d());
|
|
429
560
|
},
|
|
430
|
-
isSelected:
|
|
431
|
-
isParentOfSelected:
|
|
561
|
+
isSelected: u,
|
|
562
|
+
isParentOfSelected: r
|
|
432
563
|
};
|
|
433
564
|
};
|
|
434
565
|
export {
|
|
435
|
-
|
|
436
|
-
|
|
566
|
+
Ge as DragOverlay,
|
|
567
|
+
k as getBoundingBox,
|
|
437
568
|
C as useDnDStore,
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
569
|
+
Ne as useDraggable,
|
|
570
|
+
qe as useDroppable,
|
|
571
|
+
Be as useSelection
|
|
441
572
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue-dnd-kit/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.36-beta",
|
|
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",
|