@vue-dnd-kit/core 0.0.45-beta → 0.0.47-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.
@@ -238,7 +238,7 @@ export declare const useDnDStore: () => {
238
238
  ref: import('vue').Ref<HTMLElement | null, HTMLElement | null>;
239
239
  };
240
240
  elements: import('vue').Ref<{
241
- node: Element | HTMLElement | null;
241
+ node: HTMLElement | Element | null;
242
242
  groups: string[];
243
243
  layer: import('vue').FunctionalComponent<any, {}, any, {}> | {
244
244
  new (...args: any[]): any;
@@ -486,7 +486,7 @@ export declare const useDnDStore: () => {
486
486
  onEnd?: ((store: import('../types').IDnDStore) => void) | undefined;
487
487
  };
488
488
  }[], IDragElement[] | {
489
- node: Element | HTMLElement | null;
489
+ node: HTMLElement | Element | null;
490
490
  groups: string[];
491
491
  layer: import('vue').FunctionalComponent<any, {}, any, {}> | {
492
492
  new (...args: any[]): any;
@@ -747,7 +747,7 @@ export declare const useDnDStore: () => {
747
747
  readonly top: number;
748
748
  toJSON: () => any;
749
749
  } | undefined;
750
- node: Element | HTMLElement | null;
750
+ node: HTMLElement | Element | null;
751
751
  groups: string[];
752
752
  layer: import('vue').FunctionalComponent<any, {}, any, {}> | {
753
753
  new (...args: any[]): any;
@@ -1007,7 +1007,7 @@ export declare const useDnDStore: () => {
1007
1007
  readonly top: number;
1008
1008
  toJSON: () => any;
1009
1009
  } | undefined;
1010
- node: Element | HTMLElement | null;
1010
+ node: HTMLElement | Element | null;
1011
1011
  groups: string[];
1012
1012
  layer: import('vue').FunctionalComponent<any, {}, any, {}> | {
1013
1013
  new (...args: any[]): any;
@@ -1256,7 +1256,7 @@ export declare const useDnDStore: () => {
1256
1256
  };
1257
1257
  }[]>;
1258
1258
  selectedElements: import('vue').Ref<{
1259
- node: Element | HTMLElement | null;
1259
+ node: HTMLElement | Element | null;
1260
1260
  groups: string[];
1261
1261
  layer: import('vue').FunctionalComponent<any, {}, any, {}> | {
1262
1262
  new (...args: any[]): any;
@@ -1504,7 +1504,7 @@ export declare const useDnDStore: () => {
1504
1504
  onEnd?: ((store: import('../types').IDnDStore) => void) | undefined;
1505
1505
  };
1506
1506
  }[], IDragElement[] | {
1507
- node: Element | HTMLElement | null;
1507
+ node: HTMLElement | Element | null;
1508
1508
  groups: string[];
1509
1509
  layer: import('vue').FunctionalComponent<any, {}, any, {}> | {
1510
1510
  new (...args: any[]): any;
@@ -1753,7 +1753,7 @@ export declare const useDnDStore: () => {
1753
1753
  };
1754
1754
  }[]>;
1755
1755
  zones: import('vue').Ref<{
1756
- node: Element | HTMLElement | null;
1756
+ node: HTMLElement | Element | null;
1757
1757
  groups: string[];
1758
1758
  data: any;
1759
1759
  events: {
@@ -1762,7 +1762,7 @@ export declare const useDnDStore: () => {
1762
1762
  onDrop?: ((store: import('../types').IDnDStore) => void) | undefined;
1763
1763
  };
1764
1764
  }[], IDropZone[] | {
1765
- node: Element | HTMLElement | null;
1765
+ node: HTMLElement | Element | null;
1766
1766
  groups: string[];
1767
1767
  data: any;
1768
1768
  events: {
@@ -1774,7 +1774,7 @@ export declare const useDnDStore: () => {
1774
1774
  visibleElements: import('vue').ComputedRef<number[]>;
1775
1775
  hovered: {
1776
1776
  zone: import('vue').Ref<{
1777
- node: Element | HTMLElement | null;
1777
+ node: HTMLElement | Element | null;
1778
1778
  groups: string[];
1779
1779
  data: any;
1780
1780
  events: {
@@ -1783,7 +1783,7 @@ export declare const useDnDStore: () => {
1783
1783
  onDrop?: ((store: import('../types').IDnDStore) => void) | undefined;
1784
1784
  };
1785
1785
  } | null, IDropZone | {
1786
- node: Element | HTMLElement | null;
1786
+ node: HTMLElement | Element | null;
1787
1787
  groups: string[];
1788
1788
  data: any;
1789
1789
  events: {
@@ -1793,7 +1793,7 @@ export declare const useDnDStore: () => {
1793
1793
  };
1794
1794
  } | null>;
1795
1795
  element: import('vue').Ref<{
1796
- node: Element | HTMLElement | null;
1796
+ node: HTMLElement | Element | null;
1797
1797
  groups: string[];
1798
1798
  layer: import('vue').FunctionalComponent<any, {}, any, {}> | {
1799
1799
  new (...args: any[]): any;
@@ -2041,7 +2041,7 @@ export declare const useDnDStore: () => {
2041
2041
  onEnd?: ((store: import('../types').IDnDStore) => void) | undefined;
2042
2042
  };
2043
2043
  } | null, IDragElement | {
2044
- node: Element | HTMLElement | null;
2044
+ node: HTMLElement | Element | null;
2045
2045
  groups: string[];
2046
2046
  layer: import('vue').FunctionalComponent<any, {}, any, {}> | {
2047
2047
  new (...args: any[]): any;
@@ -80,7 +80,7 @@ export declare const useDragContainer: () => {
80
80
  readonly top: number;
81
81
  toJSON: () => any;
82
82
  } | undefined;
83
- node: Element | HTMLElement | null;
83
+ node: HTMLElement | Element | null;
84
84
  groups: string[];
85
85
  layer: import('vue').FunctionalComponent<any, {}, any, {}> | {
86
86
  new (...args: any[]): any;
@@ -340,7 +340,7 @@ export declare const useDragContainer: () => {
340
340
  readonly top: number;
341
341
  toJSON: () => any;
342
342
  } | undefined;
343
- node: Element | HTMLElement | null;
343
+ node: HTMLElement | Element | null;
344
344
  groups: string[];
345
345
  layer: import('vue').FunctionalComponent<any, {}, any, {}> | {
346
346
  new (...args: any[]): any;
package/dist/index.d.ts CHANGED
@@ -1,8 +1,10 @@
1
1
  import { default as DragOverlay } from './components/DragOverlay';
2
+ import { VueDndKitPlugin } from './plugin';
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';
7
+ export default VueDndKitPlugin;
6
8
  export { DragOverlay, useDraggable, useDroppable, useDnDStore, useSelection };
7
9
  export { getBoundingBox } from './utils/geometry';
8
10
  export type { IDnDStore, IActiveContainer, IBoundingBox, IDragElement, IDraggingElement, IDropZone, IPoint, IPointerPosition, IUseDragOptions, IUseDropOptions, } from './types';
package/dist/plugin.d.ts CHANGED
@@ -2,3 +2,11 @@ import { App } from 'vue';
2
2
  export declare const VueDndKitPlugin: {
3
3
  install(app: App): void;
4
4
  };
5
+ declare module '@vue/runtime-core' {
6
+ interface App {
7
+ __VUE_DND_KIT_OVERLAY__?: {
8
+ container: HTMLElement;
9
+ vnode: any;
10
+ };
11
+ }
12
+ }
@@ -1 +1 @@
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 i=n.effectScope(!0);return(...c)=>(e||(r=i.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,b=()=>{};function oe(t,e){function r(...i){return new Promise((c,o)=>{Promise.resolve(t(()=>e.apply(this,i),{fn:e,thisArg:this,args:i})).then(c).catch(o)})}return r}function le(...t){let e=0,r,i=!0,c=b,o,s,v,f,m;!n.isRef(t[0])&&typeof t[0]=="object"?{delay:s,trailing:v=!0,leading:f=!0,rejectOnCancel:m=!1}=t[0]:[s,v=!0,f=!0,m=!1]=t;const l=()=>{r&&(clearTimeout(r),r=void 0,c(),c=b)};return D=>{const p=n.toValue(s),E=Date.now()-e,a=()=>o=D();return l(),p<=0?(e=Date.now(),a()):(E>p&&(f||!i)?(e=Date.now(),a()):v&&(o=new Promise((h,y)=>{c=m?y:h,r=setTimeout(()=>{e=Date.now(),i=!0,h(a()),l()},Math.max(0,p-E))})),!f&&!r&&(r=setTimeout(()=>i=!0,p)),i=!1,o)}}function se(t){return Array.isArray(t)?t:[t]}function ie(t,e=200,r=!1,i=!0,c=!1){return oe(le(e,r,i,c),t)}function ae(t,e,r){const i=n.watch(t,(...c)=>(n.nextTick(()=>i()),e(...c)),r);return i}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:i,rootMargin:c="0px",threshold:o=0,window:s=K,immediate:v=!0}=r,f=ce(()=>s&&"IntersectionObserver"in s),m=n.computed(()=>{const E=n.toValue(t);return se(E).map(H).filter(re)});let l=b;const g=n.shallowRef(v),D=f.value?n.watch(()=>[m.value,H(i),g.value],([E,a])=>{if(l(),!g.value||!E.length)return;const h=new IntersectionObserver(e,{root:H(a),rootMargin:c,threshold:o});E.forEach(y=>y&&h.observe(y)),l=()=>{h.disconnect(),l=b}},{immediate:v,flush:"post"}):b,p=()=>{l(),D(),g.value=!1};return ee(p),{isSupported:f,isActive:g,pause(){l(),g.value=!1},resume(){g.value=!0},stop:p}}function ve(t,e={}){const{window:r=K,scrollTarget:i,threshold:c=0,rootMargin:o,once:s=!1}=e,v=n.shallowRef(!1),{stop:f}=de(t,m=>{let l=v.value,g=0;for(const D of m)D.time>=g&&(g=D.time,l=D.isIntersecting);v.value=l,s&&ae(v,()=>{f()})},{root:i,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)},i=n.ref([]),c=n.computed(()=>i.value.map((m,l)=>{var g;if((g=m.isVisible)!=null&&g.value||m.isVisible&&l)return l}).filter(m=>m!==void 0)),o=n.ref([]),s=n.ref([]),v={zone:n.ref(null),element:n.ref(null)},f={current:n.ref(null),start:n.ref(null),offset:{percent:n.ref(null),pixel:n.ref(null)}};return{isDragging:e,activeContainer:r,elements:i,draggingElements:t,selectedElements:o,zones:s,visibleElements:c,hovered:v,pointerPosition:f}}),fe=()=>{const t=n.ref(null),{draggingElements:e,pointerPosition:r,isDragging:i,activeContainer:c}=I();return n.onMounted(()=>{c.ref=t}),n.onBeforeUnmount(()=>{c.ref.value=null}),{elementRef:t,draggingElements:e,pointerPosition:r,isDragging:i}},ge=["innerHTML"],me=n.defineComponent({__name:"DefaultOverlay",setup(t){const{elementRef:e,pointerPosition:r,isDragging:i,draggingElements:c}=fe(),o=n.computed(()=>{var s,v,f,m;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)-(((m=r.offset.pixel.value)==null?void 0:m.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(i)?(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,m)=>{var l,g;return n.openBlock(),n.createElementBlock("div",{key:m,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(i,c)=>(n.openBlock(),n.createBlock(n.resolveDynamicComponent(r.value)))}}),pe="data-dnd-draggable",ye=t=>{const{elements:e,draggingElements:r,hovered:i,selectedElements:c,isDragging:o}=I(),s=n.ref(null),v=n.computed(()=>{var p;return((p=i.element.value)==null?void 0:p.node)===s.value}),f=ve(s),m=n.computed(()=>r.value.some(p=>p.node===s.value)),l=n.computed(()=>{if(!s.value||!o.value)return!1;const p=e.value.find(E=>E.node===s.value);return p!=null&&p.groups.length?!r.value.some(E=>E.groups.length?!E.groups.some(a=>p.groups.includes(a)):!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 p=e.value.findIndex(a=>a.node===s.value);p!==-1&&e.value.splice(p,1);const E=c.value.findIndex(a=>a.node===s.value);E!==-1&&c.value.splice(E,1)},isDragging:m,isOvered:v,isAllowed:l,isVisible:f}},Ee=()=>{let t="",e="",r="";const i=()=>{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:i,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}),we=(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,i=e.y-t.y;return Math.sqrt(r*r+i*i)},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}=we(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:i,onPointerEnd:c}=Pe(t);let o=null;const s=a=>{var w,P;const h=e.selectedElements.value.some(x=>x.node===a);if(e.selectedElements.value.length&&h)return e.selectedElements.value.map(x=>{var L,z;return{...x,initialHTML:((L=x.node)==null?void 0:L.outerHTML)??"",initialRect:(z=x.node)==null?void 0:z.getBoundingClientRect()}});e.selectedElements.value=[];const y=e.elements.value.find(x=>x.node===a);return y?[{...y,initialHTML:((w=y.node)==null?void 0:w.outerHTML)??"",initialRect:(P=y.node)==null?void 0:P.getBoundingClientRect()}]:[]},v=(a,h)=>{const y=Math.max(0,Math.min(a.x+a.width,h.x+h.width)-Math.max(a.x,h.x)),w=Math.max(0,Math.min(a.y+a.height,h.y+h.height)-Math.max(a.y,h.y)),P=y*w,x=a.width*a.height,L=h.width*h.height;return(P/x*100+P/L*100)/2},f=ie(()=>{var F,U,Z,$,W,X,Y,j,q,G;const a=O(e.activeContainer.ref.value),h=A(a),y=((F=e.pointerPosition.current.value)==null?void 0:F.x)??0,w=((U=e.pointerPosition.current.value)==null?void 0:U.y)??0,x=!(a&&y>=a.x&&y<=a.x+a.width&&w>=a.y&&w<=a.y+a.height),L=e.draggingElements.value.map(u=>u.node),z=e.visibleElements.value.map(u=>e.elements.value[u]).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&&a&&N(d,a)}).map(u=>{const d=O(u.node),S=A(d),M=y>=d.x&&y<=d.x+d.width&&w>=d.y&&w<=d.y+d.height,_=v(d,a),V=J(h,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:V}}).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&&a&&N(d,a)}).map(u=>{const d=O(u.node),S=A(d),M=y>=d.x&&y<=d.x+d.width&&w>=d.y&&w<=d.y+d.height,_=v(d,a),V=J(h,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:V}}).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=z[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))},1e3),m=()=>{f(),o=requestAnimationFrame(m)},l=()=>{m()},g=()=>{o!==null&&(cancelAnimationFrame(o),o=null)};return{activate:a=>{e.draggingElements.value=s(t.value),r(a),l()},track:a=>{i(a)},deactivate:()=>{var a,h;c(),e.hovered.zone.value?(h=(a=e.hovered.zone.value.events).onDrop)==null||h.call(a,e):e.draggingElements.value.forEach(y=>{var w,P;return(P=(w=y.events).onEnd)==null?void 0:P.call(w,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:i,isDragging:c,isOvered:o,isAllowed:s,isVisible:v}=ye(t),{disableInteractions:f,enableInteractions:m}=Ee(),{activeContainer:l,pointerPosition:g}=I(),{activate:D,track:p,deactivate:E}=De(e),a=P=>{t!=null&&t.container&&(l.component.value=n.markRaw(t.container)),f(),D(P),document.addEventListener("pointermove",h),document.addEventListener("pointerup",w),document.addEventListener("wheel",y)},h=P=>p(P),y=P=>p(P),w=()=>{l.component.value=null,m(),E(),document.removeEventListener("pointermove",h),document.removeEventListener("pointerup",w),document.removeEventListener("wheel",y)};return n.onMounted(r),n.onBeforeUnmount(i),{pointerPosition:g,elementRef:e,isDragging:c,isOvered:o,isAllowed:s,handleDragStart:a,isVisible:v}},Se=t=>{const{zones:e,hovered:r,draggingElements:i,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?!i.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:i,isOvered:c,isAllowed:o}=Se(t);return n.onMounted(r),n.onBeforeUnmount(i),{elementRef:e,isOvered:c,isAllowed:o}},Ie=t=>{const{selectedElements:e,elements:r}=I(),i=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=()=>{i.value&&(e.value=e.value.filter(l=>l.node!==t.value))},f=()=>{i.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(i.value))};return{handleUnselect:v,handleSelect:f,handleToggleSelect:()=>{i.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
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("vue");function te(t){return n.getCurrentScope()?(n.onScopeDispose(t),!0):!1}function ne(t){let e=!1,r;const s=n.effectScope(!0);return(...c)=>(e||(r=s.run(()=>t(...c)),e=!0),r)}const re=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const oe=t=>t!=null,R=()=>{};function le(t,e){function r(...s){return new Promise((c,o)=>{Promise.resolve(t(()=>e.apply(this,s),{fn:e,thisArg:this,args:s})).then(c).catch(o)})}return r}function ie(...t){let e=0,r,s=!0,c=R,o,i,v,f,m;!n.isRef(t[0])&&typeof t[0]=="object"?{delay:i,trailing:v=!0,leading:f=!0,rejectOnCancel:m=!1}=t[0]:[i,v=!0,f=!0,m=!1]=t;const l=()=>{r&&(clearTimeout(r),r=void 0,c(),c=R)};return D=>{const p=n.toValue(i),E=Date.now()-e,u=()=>o=D();return l(),p<=0?(e=Date.now(),u()):(E>p&&(f||!s)?(e=Date.now(),u()):v&&(o=new Promise((h,y)=>{c=m?y:h,r=setTimeout(()=>{e=Date.now(),s=!0,h(u()),l()},Math.max(0,p-E))})),!f&&!r&&(r=setTimeout(()=>s=!0,p)),s=!1,o)}}function se(t){return Array.isArray(t)?t:[t]}function ue(t,e=200,r=!1,s=!0,c=!1){return le(ie(e,r,s,c),t)}function ae(t,e,r){const s=n.watch(t,(...c)=>(n.nextTick(()=>s()),e(...c)),r);return s}const Q=re?window:void 0;function B(t){var e;const r=n.toValue(t);return(e=r==null?void 0:r.$el)!=null?e:r}function ce(){const t=n.shallowRef(!1),e=n.getCurrentInstance();return e&&n.onMounted(()=>{t.value=!0},e),t}function de(t){const e=ce();return n.computed(()=>(e.value,!!t()))}function ve(t,e,r={}){const{root:s,rootMargin:c="0px",threshold:o=0,window:i=Q,immediate:v=!0}=r,f=de(()=>i&&"IntersectionObserver"in i),m=n.computed(()=>{const E=n.toValue(t);return se(E).map(B).filter(oe)});let l=R;const g=n.shallowRef(v),D=f.value?n.watch(()=>[m.value,B(s),g.value],([E,u])=>{if(l(),!g.value||!E.length)return;const h=new IntersectionObserver(e,{root:B(u),rootMargin:c,threshold:o});E.forEach(y=>y&&h.observe(y)),l=()=>{h.disconnect(),l=R}},{immediate:v,flush:"post"}):R,p=()=>{l(),D(),g.value=!1};return te(p),{isSupported:f,isActive:g,pause(){l(),g.value=!1},resume(){g.value=!0},stop:p}}function fe(t,e={}){const{window:r=Q,scrollTarget:s,threshold:c=0,rootMargin:o,once:i=!1}=e,v=n.shallowRef(!1),{stop:f}=ve(t,m=>{let l=v.value,g=0;for(const D of m)D.time>=g&&(g=D.time,l=D.isIntersecting);v.value=l,i&&ae(v,()=>{f()})},{root:s,window:r,threshold:c,rootMargin:n.toValue(o)});return v}const I=ne(()=>{const t=n.ref([]),e=n.computed(()=>t.value.length>0),r={component:n.ref(null),ref:n.ref(null)},s=n.ref([]),c=n.computed(()=>s.value.map((m,l)=>{var g;if((g=m.isVisible)!=null&&g.value||m.isVisible&&l)return l}).filter(m=>m!==void 0)),o=n.ref([]),i=n.ref([]),v={zone:n.ref(null),element:n.ref(null)},f={current:n.ref(null),start:n.ref(null),offset:{percent:n.ref(null),pixel:n.ref(null)}};return{isDragging:e,activeContainer:r,elements:s,draggingElements:t,selectedElements:o,zones:i,visibleElements:c,hovered:v,pointerPosition:f}}),ge=()=>{const t=n.ref(null),{draggingElements:e,pointerPosition:r,isDragging:s,activeContainer:c}=I();return n.onMounted(()=>{c.ref=t}),n.onBeforeUnmount(()=>{c.ref.value=null}),{elementRef:t,draggingElements:e,pointerPosition:r,isDragging:s}},me=["innerHTML"],he=n.defineComponent({__name:"DefaultOverlay",setup(t){const{elementRef:e,pointerPosition:r,isDragging:s,draggingElements:c}=ge(),o=n.computed(()=>{var i,v,f,m;return{transform:`translate3d(${(((i=r.current.value)==null?void 0:i.x)??0)-(((v=r.offset.pixel.value)==null?void 0:v.x)??0)}px, ${(((f=r.current.value)==null?void 0:f.y)??0)-(((m=r.offset.pixel.value)==null?void 0:m.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(i,v)=>n.unref(s)?(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,m)=>{var l,g;return n.openBlock(),n.createElementBlock("div",{key:m,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,me)}),128))],4)):n.createCommentVNode("",!0)}}),U=n.defineComponent({__name:"DragOverlay",setup(t){const{activeContainer:e}=I(),r=n.computed(()=>e.component.value??he);return(s,c)=>(n.openBlock(),n.createBlock(n.resolveDynamicComponent(r.value)))}}),pe={install(t){t.component("DragOverlay",U);const e=t.mount;t.mount=function(s){const c=e.call(this,s),o=typeof s=="string"?document.querySelector(s):s;if(o&&o instanceof Element&&!o.querySelector("#vue-dnd-kit-overlay")){const i=document.createElement("div");i.id="vue-dnd-kit-overlay",o.appendChild(i);const v=n.createVNode(U);n.render(v,i),t.__VUE_DND_KIT_OVERLAY__={container:i,vnode:v}}return c};const r=t.unmount;t.unmount=function(){return t.__VUE_DND_KIT_OVERLAY__&&(n.render(null,t.__VUE_DND_KIT_OVERLAY__.container),delete t.__VUE_DND_KIT_OVERLAY__),r.call(this)}}},ye="data-dnd-draggable",Ee=t=>{const{elements:e,draggingElements:r,hovered:s,selectedElements:c,isDragging:o}=I(),i=n.ref(null),v=n.computed(()=>{var p;return((p=s.element.value)==null?void 0:p.node)===i.value}),f=fe(i),m=n.computed(()=>r.value.some(p=>p.node===i.value)),l=n.computed(()=>{if(!i.value||!o.value)return!1;const p=e.value.find(E=>E.node===i.value);return p!=null&&p.groups.length?!r.value.some(E=>E.groups.length?!E.groups.some(u=>p.groups.includes(u)):!1):!0});return{elementRef:i,registerElement:()=>{if(!i.value)throw new Error("ElementRef is not set");e.value.push({node:i.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}),i.value.setAttribute(ye,"true")},unregisterElement:()=>{const p=e.value.findIndex(u=>u.node===i.value);p!==-1&&e.value.splice(p,1);const E=c.value.findIndex(u=>u.node===i.value);E!==-1&&c.value.splice(E,1)},isDragging:m,isOvered:v,isAllowed:l,isVisible:f}},we=()=>{let t="",e="",r="";const s=()=>{const i=document.body;t=i.style.userSelect,e=i.style.touchAction,r=i.style.overscrollBehavior,i.style.userSelect="none",i.style.touchAction="none",i.style.overscrollBehavior="none",window.addEventListener("contextmenu",o),window.addEventListener("selectstart",o),window.addEventListener("touchstart",o),window.addEventListener("touchmove",o)},c=()=>{const i=document.body;i.style.userSelect=t,i.style.touchAction=e,i.style.overscrollBehavior=r,window.removeEventListener("contextmenu",o),window.removeEventListener("selectstart",o),window.removeEventListener("touchstart",o),window.removeEventListener("touchmove",o)},o=i=>i.preventDefault();return{disableInteractions:s,enableInteractions:c}},G=(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,T=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}},H=t=>({x:t.x+t.width/2,y:t.y+t.height/2}),Pe=(t,e)=>{const r=T(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,s=e.y-t.y;return Math.sqrt(r*r+s*s)},M=(t,e)=>t?e.contains(t):!1,De=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:i,percent:v}=Pe(t.value,{x:o.clientX,y:o.clientY});e.pointerPosition.offset.pixel.value=i,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}}},_e=t=>{const e=I(),{onPointerStart:r,onPointerMove:s,onPointerEnd:c}=De(t);let o=null;const i=u=>{var w,P;const h=e.selectedElements.value.some(_=>_.node===u);if(e.selectedElements.value.length&&h)return e.selectedElements.value.map(_=>{var L,A;return{..._,initialHTML:((L=_.node)==null?void 0:L.outerHTML)??"",initialRect:(A=_.node)==null?void 0:A.getBoundingClientRect()}});e.selectedElements.value=[];const y=e.elements.value.find(_=>_.node===u);return y?[{...y,initialHTML:((w=y.node)==null?void 0:w.outerHTML)??"",initialRect:(P=y.node)==null?void 0:P.getBoundingClientRect()}]:[]},v=(u,h)=>{const y=Math.max(0,Math.min(u.x+u.width,h.x+h.width)-Math.max(u.x,h.x)),w=Math.max(0,Math.min(u.y+u.height,h.y+h.height)-Math.max(u.y,h.y)),P=y*w,_=u.width*u.height,L=h.width*h.height;return(P/_*100+P/L*100)/2},f=ue(()=>{var Y,N,F,Z,$,q,K,W,X,j;const u=T(e.activeContainer.ref.value),h=H(u),y=((Y=e.pointerPosition.current.value)==null?void 0:Y.x)??0,w=((N=e.pointerPosition.current.value)==null?void 0:N.y)??0,_=!(u&&y>=u.x&&y<=u.x+u.width&&w>=u.y&&w<=u.y+u.height),L=e.draggingElements.value.map(a=>a.node),A=e.visibleElements.value.map(a=>e.elements.value[a]).filter(a=>{if(!a.node||L.some(x=>x&&M(a.node,x))||a.groups.length&&!!e.draggingElements.value.some(S=>S.groups.length?!S.groups.some(C=>a.groups.includes(C)):!1))return!1;const d=T(a.node);return d&&u&&G(d,u)}).map(a=>{const d=T(a.node),x=H(d),S=y>=d.x&&y<=d.x+d.width&&w>=d.y&&w<=d.y+d.height,C=v(d,u),b=J(h,x),z=e.elements.value.filter(O=>O!==a&&O.node&&a.node&&M(a.node,O.node)).length;return{element:a,isPointerInElement:S,overlapPercent:C,depth:z,centerDistance:b}}).sort((a,d)=>{if(!_){if(a.isPointerInElement&&d.isPointerInElement)return d.depth-a.depth;if(a.isPointerInElement!==d.isPointerInElement)return a.isPointerInElement?-1:1}return Math.abs(a.overlapPercent-d.overlapPercent)<=1?a.centerDistance-d.centerDistance:d.overlapPercent-a.overlapPercent}),ee=e.zones.value.filter(a=>{if(!a.node||L.some(x=>x&&M(a.node,x))||a.groups.length&&!!e.draggingElements.value.some(S=>S.groups.length?!S.groups.some(C=>a.groups.includes(C)):!1))return!1;const d=T(a.node);return d&&u&&G(d,u)}).map(a=>{const d=T(a.node),x=H(d),S=y>=d.x&&y<=d.x+d.width&&w>=d.y&&w<=d.y+d.height,C=v(d,u),b=J(h,x),z=e.zones.value.filter(O=>O!==a&&O.node&&a.node&&M(a.node,O.node)).length;return{zone:a,isPointerInElement:S,overlapPercent:C,depth:z,centerDistance:b}}).sort((a,d)=>{if(!_){if(a.isPointerInElement&&d.isPointerInElement)return d.depth-a.depth;if(a.isPointerInElement!==d.isPointerInElement)return a.isPointerInElement?-1:1}return Math.abs(a.overlapPercent-d.overlapPercent)<=1?a.centerDistance-d.centerDistance:d.overlapPercent-a.overlapPercent}),k=e.hovered.element.value,V=e.hovered.zone.value;e.hovered.element.value=((F=A[0])==null?void 0:F.element)??null,e.hovered.zone.value=((Z=ee[0])==null?void 0:Z.zone)??null,e.hovered.element.value!==k&&(($=k==null?void 0:k.events)!=null&&$.onLeave&&k.events.onLeave(e),(K=(q=e.hovered.element.value)==null?void 0:q.events)!=null&&K.onHover&&e.hovered.element.value.events.onHover(e)),e.hovered.zone.value!==V&&((W=V==null?void 0:V.events)!=null&&W.onLeave&&V.events.onLeave(e),(j=(X=e.hovered.zone.value)==null?void 0:X.events)!=null&&j.onHover&&e.hovered.zone.value.events.onHover(e))},1e3),m=()=>{f(),o=requestAnimationFrame(m)},l=()=>{m()},g=()=>{o!==null&&(cancelAnimationFrame(o),o=null)};return{activate:u=>{e.draggingElements.value=i(t.value),r(u),l()},track:u=>{s(u)},deactivate:()=>{var u,h;c(),e.hovered.zone.value?(h=(u=e.hovered.zone.value.events).onDrop)==null||h.call(u,e):e.draggingElements.value.forEach(y=>{var w,P;return(P=(w=y.events).onEnd)==null?void 0:P.call(w,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:s,isDragging:c,isOvered:o,isAllowed:i,isVisible:v}=Ee(t),{disableInteractions:f,enableInteractions:m}=we(),{activeContainer:l,pointerPosition:g}=I(),{activate:D,track:p,deactivate:E}=_e(e),u=P=>{t!=null&&t.container&&(l.component.value=n.markRaw(t.container)),f(),D(P),document.addEventListener("pointermove",h),document.addEventListener("pointerup",w),document.addEventListener("wheel",y)},h=P=>p(P),y=P=>p(P),w=()=>{l.component.value=null,m(),E(),document.removeEventListener("pointermove",h),document.removeEventListener("pointerup",w),document.removeEventListener("wheel",y)};return n.onMounted(r),n.onBeforeUnmount(s),{pointerPosition:g,elementRef:e,isDragging:c,isOvered:o,isAllowed:i,handleDragStart:u,isVisible:v}},Se=t=>{const{zones:e,hovered:r,draggingElements:s,isDragging:c}=I(),o=n.ref(null),i=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?!s.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:i,isAllowed:v}},Ie=t=>{const{elementRef:e,registerZone:r,unregisterZone:s,isOvered:c,isAllowed:o}=Se(t);return n.onMounted(r),n.onBeforeUnmount(s),{elementRef:e,isOvered:c,isAllowed:o}},Me=t=>{const{selectedElements:e,elements:r}=I(),s=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&&M(l.node,t.value)):!1),i=n.computed(()=>t.value?e.value.some(l=>l.node&&M(t.value,l.node)):!1),v=()=>{s.value&&(e.value=e.value.filter(l=>l.node!==t.value))},f=()=>{s.value&&(o.value&&(e.value=e.value.filter(l=>l.node&&!M(l.node,t.value))),i.value&&(e.value=e.value.filter(l=>l.node&&!M(t.value,l.node))),e.value.push(s.value))};return{handleUnselect:v,handleSelect:f,handleToggleSelect:()=>{s.value&&(e.value.some(l=>l.node===t.value)?v():f())},isSelected:c,isParentOfSelected:o}};exports.DragOverlay=U;exports.default=pe;exports.getBoundingBox=T;exports.useDnDStore=I;exports.useDraggable=xe;exports.useDroppable=Ie;exports.useSelection=Me;
@@ -1,103 +1,103 @@
1
- import { effectScope as ve, watch as ie, nextTick as de, isRef as fe, getCurrentScope as ge, onScopeDispose as he, toValue as V, 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 b, normalizeStyle as oe, Fragment as ye, renderList as Ee, createBlock as we, resolveDynamicComponent as Pe, markRaw as xe } from "vue";
2
- function De(t) {
3
- return ge() ? (he(t), !0) : !1;
1
+ import { effectScope as fe, watch as ue, nextTick as ge, isRef as me, getCurrentScope as he, onScopeDispose as pe, toValue as b, shallowRef as K, computed as D, getCurrentInstance as ye, onMounted as U, ref as P, onBeforeUnmount as W, defineComponent as ce, createElementBlock as F, createCommentVNode as Ee, unref as re, openBlock as H, normalizeStyle as oe, Fragment as we, renderList as Pe, createBlock as De, resolveDynamicComponent as _e, createVNode as xe, render as le, markRaw as Ie } from "vue";
2
+ function Le(t) {
3
+ return he() ? (pe(t), !0) : !1;
4
4
  }
5
- function Ie(t) {
5
+ function Se(t) {
6
6
  let e = !1, n;
7
- const s = ve(!0);
8
- return (...u) => (e || (n = s.run(() => t(...u)), e = !0), n);
7
+ const i = fe(!0);
8
+ return (...u) => (e || (n = i.run(() => t(...u)), e = !0), n);
9
9
  }
10
10
  const Me = typeof window < "u" && typeof document < "u";
11
11
  typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
12
- const Se = (t) => t != null, H = () => {
12
+ const Ce = (t) => t != null, A = () => {
13
13
  };
14
- function Le(t, e) {
15
- function n(...s) {
14
+ function Oe(t, e) {
15
+ function n(...i) {
16
16
  return new Promise((u, r) => {
17
- Promise.resolve(t(() => e.apply(this, s), { fn: e, thisArg: this, args: s })).then(u).catch(r);
17
+ Promise.resolve(t(() => e.apply(this, i), { fn: e, thisArg: this, args: i })).then(u).catch(r);
18
18
  });
19
19
  }
20
20
  return n;
21
21
  }
22
- function Ce(...t) {
23
- let e = 0, n, s = !0, u = H, r, l, v, d, g;
24
- !fe(t[0]) && typeof t[0] == "object" ? { delay: l, trailing: v = !0, leading: d = !0, rejectOnCancel: g = !1 } = t[0] : [l, v = !0, d = !0, g = !1] = t;
22
+ function Te(...t) {
23
+ let e = 0, n, i = !0, u = A, r, l, d, v, g;
24
+ !me(t[0]) && typeof t[0] == "object" ? { delay: l, trailing: d = !0, leading: v = !0, rejectOnCancel: g = !1 } = t[0] : [l, d = !0, v = !0, g = !1] = t;
25
25
  const o = () => {
26
- n && (clearTimeout(n), n = void 0, u(), u = H);
26
+ n && (clearTimeout(n), n = void 0, u(), u = A);
27
27
  };
28
- return (D) => {
29
- const m = V(l), y = Date.now() - e, i = () => r = D();
30
- return o(), m <= 0 ? (e = Date.now(), i()) : (y > m && (d || !s) ? (e = Date.now(), i()) : v && (r = new Promise((h, p) => {
31
- u = g ? p : h, n = setTimeout(() => {
32
- e = Date.now(), s = !0, h(i()), o();
33
- }, Math.max(0, m - y));
34
- })), !d && !n && (n = setTimeout(() => s = !0, m)), s = !1, r);
28
+ return (_) => {
29
+ const h = b(l), y = Date.now() - e, s = () => r = _();
30
+ return o(), h <= 0 ? (e = Date.now(), s()) : (y > h && (v || !i) ? (e = Date.now(), s()) : d && (r = new Promise((m, p) => {
31
+ u = g ? p : m, n = setTimeout(() => {
32
+ e = Date.now(), i = !0, m(s()), o();
33
+ }, Math.max(0, h - y));
34
+ })), !v && !n && (n = setTimeout(() => i = !0, h)), i = !1, r);
35
35
  };
36
36
  }
37
- function _e(t) {
37
+ function Ve(t) {
38
38
  return Array.isArray(t) ? t : [t];
39
39
  }
40
- function Oe(t, e = 200, n = !1, s = !0, u = !1) {
41
- return Le(
42
- Ce(e, n, s, u),
40
+ function ke(t, e = 200, n = !1, i = !0, u = !1) {
41
+ return Oe(
42
+ Te(e, n, i, u),
43
43
  t
44
44
  );
45
45
  }
46
- function Te(t, e, n) {
47
- const s = ie(t, (...u) => (de(() => s()), e(...u)), n);
48
- return s;
46
+ function Re(t, e, n) {
47
+ const i = ue(t, (...u) => (ge(() => i()), e(...u)), n);
48
+ return i;
49
49
  }
50
- const ue = Me ? window : void 0;
51
- function X(t) {
50
+ const de = Me ? window : void 0;
51
+ function Z(t) {
52
52
  var e;
53
- const n = V(t);
53
+ const n = b(t);
54
54
  return (e = n == null ? void 0 : n.$el) != null ? e : n;
55
55
  }
56
- function ke() {
57
- const t = U(!1), e = me();
58
- return e && F(() => {
56
+ function Ae() {
57
+ const t = K(!1), e = ye();
58
+ return e && U(() => {
59
59
  t.value = !0;
60
60
  }, e), t;
61
61
  }
62
62
  function ze(t) {
63
- const e = ke();
64
- return x(() => (e.value, !!t()));
63
+ const e = Ae();
64
+ return D(() => (e.value, !!t()));
65
65
  }
66
- function Re(t, e, n = {}) {
66
+ function He(t, e, n = {}) {
67
67
  const {
68
- root: s,
68
+ root: i,
69
69
  rootMargin: u = "0px",
70
70
  threshold: r = 0,
71
- window: l = ue,
72
- immediate: v = !0
73
- } = n, d = ze(() => l && "IntersectionObserver" in l), g = x(() => {
74
- const y = V(t);
75
- return _e(y).map(X).filter(Se);
71
+ window: l = de,
72
+ immediate: d = !0
73
+ } = n, v = ze(() => l && "IntersectionObserver" in l), g = D(() => {
74
+ const y = b(t);
75
+ return Ve(y).map(Z).filter(Ce);
76
76
  });
77
- let o = H;
78
- const f = U(v), D = d.value ? ie(
79
- () => [g.value, X(s), f.value],
80
- ([y, i]) => {
77
+ let o = A;
78
+ const f = K(d), _ = v.value ? ue(
79
+ () => [g.value, Z(i), f.value],
80
+ ([y, s]) => {
81
81
  if (o(), !f.value || !y.length)
82
82
  return;
83
- const h = new IntersectionObserver(
83
+ const m = new IntersectionObserver(
84
84
  e,
85
85
  {
86
- root: X(i),
86
+ root: Z(s),
87
87
  rootMargin: u,
88
88
  threshold: r
89
89
  }
90
90
  );
91
- y.forEach((p) => p && h.observe(p)), o = () => {
92
- h.disconnect(), o = H;
91
+ y.forEach((p) => p && m.observe(p)), o = () => {
92
+ m.disconnect(), o = A;
93
93
  };
94
94
  },
95
- { immediate: v, flush: "post" }
96
- ) : H, m = () => {
97
- o(), D(), f.value = !1;
95
+ { immediate: d, flush: "post" }
96
+ ) : A, h = () => {
97
+ o(), _(), f.value = !1;
98
98
  };
99
- return De(m), {
100
- isSupported: d,
99
+ return Le(h), {
100
+ isSupported: v,
101
101
  isActive: f,
102
102
  pause() {
103
103
  o(), f.value = !1;
@@ -105,49 +105,49 @@ function Re(t, e, n = {}) {
105
105
  resume() {
106
106
  f.value = !0;
107
107
  },
108
- stop: m
108
+ stop: h
109
109
  };
110
110
  }
111
- function He(t, e = {}) {
111
+ function be(t, e = {}) {
112
112
  const {
113
- window: n = ue,
114
- scrollTarget: s,
113
+ window: n = de,
114
+ scrollTarget: i,
115
115
  threshold: u = 0,
116
116
  rootMargin: r,
117
117
  once: l = !1
118
- } = e, v = U(!1), { stop: d } = Re(
118
+ } = e, d = K(!1), { stop: v } = He(
119
119
  t,
120
120
  (g) => {
121
- let o = v.value, f = 0;
122
- for (const D of g)
123
- D.time >= f && (f = D.time, o = D.isIntersecting);
124
- v.value = o, l && Te(v, () => {
125
- d();
121
+ let o = d.value, f = 0;
122
+ for (const _ of g)
123
+ _.time >= f && (f = _.time, o = _.isIntersecting);
124
+ d.value = o, l && Re(d, () => {
125
+ v();
126
126
  });
127
127
  },
128
128
  {
129
- root: s,
129
+ root: i,
130
130
  window: n,
131
131
  threshold: u,
132
- rootMargin: V(r)
132
+ rootMargin: b(r)
133
133
  }
134
134
  );
135
- return v;
135
+ return d;
136
136
  }
137
- const C = Ie(() => {
138
- const t = P([]), e = x(() => t.value.length > 0), n = {
137
+ const M = Se(() => {
138
+ const t = P([]), e = D(() => t.value.length > 0), n = {
139
139
  component: P(null),
140
140
  ref: P(null)
141
- }, s = P([]), u = x(
142
- () => s.value.map((g, o) => {
141
+ }, i = P([]), u = D(
142
+ () => i.value.map((g, o) => {
143
143
  var f;
144
144
  if ((f = g.isVisible) != null && f.value || g.isVisible && o)
145
145
  return o;
146
146
  }).filter((g) => g !== void 0)
147
- ), r = P([]), l = P([]), v = {
147
+ ), r = P([]), l = P([]), d = {
148
148
  zone: P(null),
149
149
  element: P(null)
150
- }, d = {
150
+ }, v = {
151
151
  current: P(null),
152
152
  start: P(null),
153
153
  offset: {
@@ -158,33 +158,33 @@ const C = Ie(() => {
158
158
  return {
159
159
  isDragging: e,
160
160
  activeContainer: n,
161
- elements: s,
161
+ elements: i,
162
162
  draggingElements: t,
163
163
  selectedElements: r,
164
164
  zones: l,
165
165
  visibleElements: u,
166
- hovered: v,
167
- pointerPosition: d
166
+ hovered: d,
167
+ pointerPosition: v
168
168
  };
169
- }), Ae = () => {
170
- const t = P(null), { draggingElements: e, pointerPosition: n, isDragging: s, activeContainer: u } = C();
171
- return F(() => {
169
+ }), Ue = () => {
170
+ const t = P(null), { draggingElements: e, pointerPosition: n, isDragging: i, activeContainer: u } = M();
171
+ return U(() => {
172
172
  u.ref = t;
173
- }), j(() => {
173
+ }), W(() => {
174
174
  u.ref.value = null;
175
175
  }), {
176
176
  elementRef: t,
177
177
  draggingElements: e,
178
178
  pointerPosition: n,
179
- isDragging: s
179
+ isDragging: i
180
180
  };
181
- }, be = ["innerHTML"], Ve = /* @__PURE__ */ ae({
181
+ }, Ye = ["innerHTML"], Ne = /* @__PURE__ */ ce({
182
182
  __name: "DefaultOverlay",
183
183
  setup(t) {
184
- const { elementRef: e, pointerPosition: n, isDragging: s, draggingElements: u } = Ae(), r = x(() => {
185
- var l, v, d, g;
184
+ const { elementRef: e, pointerPosition: n, isDragging: i, draggingElements: u } = Ue(), r = D(() => {
185
+ var l, d, v, g;
186
186
  return {
187
- 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) - (((g = n.offset.pixel.value) == null ? void 0 : g.y) ?? 0)}px, 0)`,
187
+ transform: `translate3d(${(((l = n.current.value) == null ? void 0 : l.x) ?? 0) - (((d = n.offset.pixel.value) == null ? void 0 : d.x) ?? 0)}px, ${(((v = n.current.value) == null ? void 0 : v.y) ?? 0) - (((g = n.offset.pixel.value) == null ? void 0 : g.y) ?? 0)}px, 0)`,
188
188
  zIndex: 1e3,
189
189
  position: "fixed",
190
190
  top: 0,
@@ -192,54 +192,76 @@ const C = Ie(() => {
192
192
  transition: "0.3s cubic-bezier(0.165, 0.84, 0.44, 1)"
193
193
  };
194
194
  });
195
- return (l, v) => re(s) ? (b(), W("div", {
195
+ return (l, d) => re(i) ? (H(), F("div", {
196
196
  key: 0,
197
197
  ref_key: "elementRef",
198
198
  ref: e,
199
199
  style: oe(r.value)
200
200
  }, [
201
- (b(!0), W(ye, null, Ee(re(u), (d, g) => {
201
+ (H(!0), F(we, null, Pe(re(u), (v, g) => {
202
202
  var o, f;
203
- return b(), W("div", {
203
+ return H(), F("div", {
204
204
  key: g,
205
- innerHTML: d.initialHTML,
205
+ innerHTML: v.initialHTML,
206
206
  style: oe({
207
- width: `${(o = d.initialRect) == null ? void 0 : o.width}px`,
208
- height: `${(f = d.initialRect) == null ? void 0 : f.height}px`
207
+ width: `${(o = v.initialRect) == null ? void 0 : o.width}px`,
208
+ height: `${(f = v.initialRect) == null ? void 0 : f.height}px`
209
209
  })
210
- }, null, 12, be);
210
+ }, null, 12, Ye);
211
211
  }), 128))
212
- ], 4)) : pe("", !0);
212
+ ], 4)) : Ee("", !0);
213
213
  }
214
- }), Ge = /* @__PURE__ */ ae({
214
+ }), ie = /* @__PURE__ */ ce({
215
215
  __name: "DragOverlay",
216
216
  setup(t) {
217
- const { activeContainer: e } = C(), n = x(
218
- () => e.component.value ?? Ve
217
+ const { activeContainer: e } = M(), n = D(
218
+ () => e.component.value ?? Ne
219
219
  );
220
- return (s, u) => (b(), we(Pe(n.value)));
220
+ return (i, u) => (H(), De(_e(n.value)));
221
221
  }
222
- }), Fe = "data-dnd-draggable", Ze = (t) => {
222
+ }), Ge = {
223
+ install(t) {
224
+ t.component("DragOverlay", ie);
225
+ const e = t.mount;
226
+ t.mount = function(i) {
227
+ const u = e.call(this, i), r = typeof i == "string" ? document.querySelector(i) : i;
228
+ if (r && r instanceof Element && !r.querySelector("#vue-dnd-kit-overlay")) {
229
+ const l = document.createElement("div");
230
+ l.id = "vue-dnd-kit-overlay", r.appendChild(l);
231
+ const d = xe(ie);
232
+ le(d, l), t.__VUE_DND_KIT_OVERLAY__ = {
233
+ container: l,
234
+ vnode: d
235
+ };
236
+ }
237
+ return u;
238
+ };
239
+ const n = t.unmount;
240
+ t.unmount = function() {
241
+ return t.__VUE_DND_KIT_OVERLAY__ && (le(null, t.__VUE_DND_KIT_OVERLAY__.container), delete t.__VUE_DND_KIT_OVERLAY__), n.call(this);
242
+ };
243
+ }
244
+ }, Fe = "data-dnd-draggable", Ze = (t) => {
223
245
  const {
224
246
  elements: e,
225
247
  draggingElements: n,
226
- hovered: s,
248
+ hovered: i,
227
249
  selectedElements: u,
228
250
  isDragging: r
229
- } = C(), l = P(null), v = x(
251
+ } = M(), l = P(null), d = D(
230
252
  () => {
231
- var m;
232
- return ((m = s.element.value) == null ? void 0 : m.node) === l.value;
253
+ var h;
254
+ return ((h = i.element.value) == null ? void 0 : h.node) === l.value;
233
255
  }
234
- ), d = He(l), g = x(
235
- () => n.value.some((m) => m.node === l.value)
236
- ), o = x(() => {
256
+ ), v = be(l), g = D(
257
+ () => n.value.some((h) => h.node === l.value)
258
+ ), o = D(() => {
237
259
  if (!l.value || !r.value) return !1;
238
- const m = e.value.find(
260
+ const h = e.value.find(
239
261
  (y) => y.node === l.value
240
262
  );
241
- return m != null && m.groups.length ? !n.value.some((y) => y.groups.length ? !y.groups.some(
242
- (i) => m.groups.includes(i)
263
+ return h != null && h.groups.length ? !n.value.some((y) => y.groups.length ? !y.groups.some(
264
+ (s) => h.groups.includes(s)
243
265
  ) : !1) : !0;
244
266
  });
245
267
  return {
@@ -253,27 +275,27 @@ const C = Ie(() => {
253
275
  defaultLayer: (t == null ? void 0 : t.layer) ?? null,
254
276
  events: (t == null ? void 0 : t.events) ?? {},
255
277
  data: (t == null ? void 0 : t.data) ?? void 0,
256
- isVisible: d
278
+ isVisible: v
257
279
  }), l.value.setAttribute(Fe, "true");
258
280
  },
259
281
  unregisterElement: () => {
260
- const m = e.value.findIndex(
261
- (i) => i.node === l.value
282
+ const h = e.value.findIndex(
283
+ (s) => s.node === l.value
262
284
  );
263
- m !== -1 && e.value.splice(m, 1);
285
+ h !== -1 && e.value.splice(h, 1);
264
286
  const y = u.value.findIndex(
265
- (i) => i.node === l.value
287
+ (s) => s.node === l.value
266
288
  );
267
289
  y !== -1 && u.value.splice(y, 1);
268
290
  },
269
291
  isDragging: g,
270
- isOvered: v,
292
+ isOvered: d,
271
293
  isAllowed: o,
272
- isVisible: d
294
+ isVisible: v
273
295
  };
274
296
  }, $e = () => {
275
297
  let t = "", e = "", n = "";
276
- const s = () => {
298
+ const i = () => {
277
299
  const l = document.body;
278
300
  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);
279
301
  }, u = () => {
@@ -281,10 +303,10 @@ const C = Ie(() => {
281
303
  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);
282
304
  }, r = (l) => l.preventDefault();
283
305
  return {
284
- disableInteractions: s,
306
+ disableInteractions: i,
285
307
  enableInteractions: u
286
308
  };
287
- }, 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) => {
309
+ }, se = (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, V = (t) => {
288
310
  if (!t)
289
311
  return {
290
312
  x: 0,
@@ -307,11 +329,11 @@ const C = Ie(() => {
307
329
  width: e.width,
308
330
  height: e.height
309
331
  };
310
- }, Y = (t) => ({
332
+ }, $ = (t) => ({
311
333
  x: t.x + t.width / 2,
312
334
  y: t.y + t.height / 2
313
- }), We = (t, e) => {
314
- const n = k(t);
335
+ }), Ke = (t, e) => {
336
+ const n = V(t);
315
337
  return {
316
338
  pixel: {
317
339
  x: e.x - n.x,
@@ -322,22 +344,22 @@ const C = Ie(() => {
322
344
  y: (e.y - n.y) / n.height * 100
323
345
  }
324
346
  };
325
- }, se = (t, e) => {
326
- const n = e.x - t.x, s = e.y - t.y;
327
- return Math.sqrt(n * n + s * s);
328
- }, L = (t, e) => t ? e.contains(t) : !1, Xe = (t) => {
329
- const e = C();
347
+ }, ae = (t, e) => {
348
+ const n = e.x - t.x, i = e.y - t.y;
349
+ return Math.sqrt(n * n + i * i);
350
+ }, S = (t, e) => t ? e.contains(t) : !1, We = (t) => {
351
+ const e = M();
330
352
  return {
331
353
  onPointerStart: (r) => {
332
354
  e.pointerPosition.start.value = { x: r.clientX, y: r.clientY }, e.pointerPosition.current.value = {
333
355
  x: r.clientX,
334
356
  y: r.clientY
335
357
  };
336
- const { pixel: l, percent: v } = We(t.value, {
358
+ const { pixel: l, percent: d } = Ke(t.value, {
337
359
  x: r.clientX,
338
360
  y: r.clientY
339
361
  });
340
- e.pointerPosition.offset.pixel.value = l, e.pointerPosition.offset.percent.value = v;
362
+ e.pointerPosition.offset.pixel.value = l, e.pointerPosition.offset.percent.value = d;
341
363
  },
342
364
  onPointerMove: (r) => {
343
365
  e.pointerPosition.current.value = {
@@ -349,26 +371,26 @@ const C = Ie(() => {
349
371
  e.pointerPosition.current.value = null, e.pointerPosition.start.value = null, e.pointerPosition.offset.pixel.value = null, e.pointerPosition.offset.percent.value = null;
350
372
  }
351
373
  };
352
- }, Ye = (t) => {
353
- const e = C(), { onPointerStart: n, onPointerMove: s, onPointerEnd: u } = Xe(t);
374
+ }, Xe = (t) => {
375
+ const e = M(), { onPointerStart: n, onPointerMove: i, onPointerEnd: u } = We(t);
354
376
  let r = null;
355
- const l = (i) => {
377
+ const l = (s) => {
356
378
  var E, w;
357
- const h = e.selectedElements.value.some(
358
- (I) => I.node === i
379
+ const m = e.selectedElements.value.some(
380
+ (x) => x.node === s
359
381
  );
360
- if (e.selectedElements.value.length && h)
361
- return e.selectedElements.value.map((I) => {
362
- var _, A;
382
+ if (e.selectedElements.value.length && m)
383
+ return e.selectedElements.value.map((x) => {
384
+ var C, z;
363
385
  return {
364
- ...I,
365
- initialHTML: ((_ = I.node) == null ? void 0 : _.outerHTML) ?? "",
366
- initialRect: (A = I.node) == null ? void 0 : A.getBoundingClientRect()
386
+ ...x,
387
+ initialHTML: ((C = x.node) == null ? void 0 : C.outerHTML) ?? "",
388
+ initialRect: (z = x.node) == null ? void 0 : z.getBoundingClientRect()
367
389
  };
368
390
  });
369
391
  e.selectedElements.value = [];
370
392
  const p = e.elements.value.find(
371
- (I) => I.node === i
393
+ (x) => x.node === s
372
394
  );
373
395
  return p ? [
374
396
  {
@@ -377,91 +399,91 @@ const C = Ie(() => {
377
399
  initialRect: (w = p.node) == null ? void 0 : w.getBoundingClientRect()
378
400
  }
379
401
  ] : [];
380
- }, v = (i, h) => {
402
+ }, d = (s, m) => {
381
403
  const p = Math.max(
382
404
  0,
383
- Math.min(i.x + i.width, h.x + h.width) - Math.max(i.x, h.x)
405
+ Math.min(s.x + s.width, m.x + m.width) - Math.max(s.x, m.x)
384
406
  ), E = Math.max(
385
407
  0,
386
- Math.min(i.y + i.height, h.y + h.height) - Math.max(i.y, h.y)
387
- ), w = p * E, I = i.width * i.height, _ = h.width * h.height;
388
- return (w / I * 100 + w / _ * 100) / 2;
389
- }, d = Oe(() => {
390
- var G, N, q, B, J, K, Q, ee, te, ne;
391
- const i = k(e.activeContainer.ref.value), h = Y(i), p = ((G = e.pointerPosition.current.value) == null ? void 0 : G.x) ?? 0, E = ((N = e.pointerPosition.current.value) == null ? void 0 : N.y) ?? 0, I = !(i && p >= i.x && p <= i.x + i.width && E >= i.y && E <= i.y + i.height), _ = e.draggingElements.value.map((a) => a.node), A = e.visibleElements.value.map((a) => e.elements.value[a]).filter((a) => {
392
- if (!a.node || _.some(
393
- (M) => M && L(a.node, M)
408
+ Math.min(s.y + s.height, m.y + m.height) - Math.max(s.y, m.y)
409
+ ), w = p * E, x = s.width * s.height, C = m.width * m.height;
410
+ return (w / x * 100 + w / C * 100) / 2;
411
+ }, v = ke(() => {
412
+ var X, q, j, G, B, J, Q, ee, te, ne;
413
+ const s = V(e.activeContainer.ref.value), m = $(s), p = ((X = e.pointerPosition.current.value) == null ? void 0 : X.x) ?? 0, E = ((q = e.pointerPosition.current.value) == null ? void 0 : q.y) ?? 0, x = !(s && p >= s.x && p <= s.x + s.width && E >= s.y && E <= s.y + s.height), C = e.draggingElements.value.map((a) => a.node), z = e.visibleElements.value.map((a) => e.elements.value[a]).filter((a) => {
414
+ if (!a.node || C.some(
415
+ (I) => I && S(a.node, I)
394
416
  ) || a.groups.length && !!e.draggingElements.value.some(
395
- (S) => S.groups.length ? !S.groups.some(
417
+ (L) => L.groups.length ? !L.groups.some(
396
418
  (O) => a.groups.includes(O)
397
419
  ) : !1
398
420
  ))
399
421
  return !1;
400
- const c = k(a.node);
401
- return c && i && le(c, i);
422
+ const c = V(a.node);
423
+ return c && s && se(c, s);
402
424
  }).map((a) => {
403
- const c = k(a.node), M = Y(c), S = p >= c.x && p <= c.x + c.width && E >= c.y && E <= c.y + c.height, O = v(c, i), Z = se(h, M), $ = e.elements.value.filter(
404
- (T) => T !== a && T.node && a.node && L(
425
+ const c = V(a.node), I = $(c), L = p >= c.x && p <= c.x + c.width && E >= c.y && E <= c.y + c.height, O = d(c, s), Y = ae(m, I), N = e.elements.value.filter(
426
+ (T) => T !== a && T.node && a.node && S(
405
427
  a.node,
406
428
  T.node
407
429
  )
408
430
  ).length;
409
431
  return {
410
432
  element: a,
411
- isPointerInElement: S,
433
+ isPointerInElement: L,
412
434
  overlapPercent: O,
413
- depth: $,
414
- centerDistance: Z
435
+ depth: N,
436
+ centerDistance: Y
415
437
  };
416
438
  }).sort((a, c) => {
417
- if (!I) {
439
+ if (!x) {
418
440
  if (a.isPointerInElement && c.isPointerInElement) return c.depth - a.depth;
419
441
  if (a.isPointerInElement !== c.isPointerInElement) return a.isPointerInElement ? -1 : 1;
420
442
  }
421
443
  return Math.abs(a.overlapPercent - c.overlapPercent) <= 1 ? a.centerDistance - c.centerDistance : c.overlapPercent - a.overlapPercent;
422
- }), ce = e.zones.value.filter((a) => {
423
- if (!a.node || _.some(
424
- (M) => M && L(a.node, M)
425
- ) || a.groups.length && !!e.draggingElements.value.some((S) => S.groups.length ? !S.groups.some((O) => a.groups.includes(O)) : !1))
444
+ }), ve = e.zones.value.filter((a) => {
445
+ if (!a.node || C.some(
446
+ (I) => I && S(a.node, I)
447
+ ) || a.groups.length && !!e.draggingElements.value.some((L) => L.groups.length ? !L.groups.some((O) => a.groups.includes(O)) : !1))
426
448
  return !1;
427
- const c = k(a.node);
428
- return c && i && le(c, i);
449
+ const c = V(a.node);
450
+ return c && s && se(c, s);
429
451
  }).map((a) => {
430
- const c = k(a.node), M = Y(c), S = p >= c.x && p <= c.x + c.width && E >= c.y && E <= c.y + c.height, O = v(c, i), Z = se(h, M), $ = e.zones.value.filter(
431
- (T) => T !== a && T.node && a.node && L(a.node, T.node)
452
+ const c = V(a.node), I = $(c), L = p >= c.x && p <= c.x + c.width && E >= c.y && E <= c.y + c.height, O = d(c, s), Y = ae(m, I), N = e.zones.value.filter(
453
+ (T) => T !== a && T.node && a.node && S(a.node, T.node)
432
454
  ).length;
433
455
  return {
434
456
  zone: a,
435
- isPointerInElement: S,
457
+ isPointerInElement: L,
436
458
  overlapPercent: O,
437
- depth: $,
438
- centerDistance: Z
459
+ depth: N,
460
+ centerDistance: Y
439
461
  };
440
462
  }).sort((a, c) => {
441
- if (!I) {
463
+ if (!x) {
442
464
  if (a.isPointerInElement && c.isPointerInElement) return c.depth - a.depth;
443
465
  if (a.isPointerInElement !== c.isPointerInElement) return a.isPointerInElement ? -1 : 1;
444
466
  }
445
467
  return Math.abs(a.overlapPercent - c.overlapPercent) <= 1 ? a.centerDistance - c.centerDistance : c.overlapPercent - a.overlapPercent;
446
- }), z = e.hovered.element.value, R = e.hovered.zone.value;
447
- 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));
468
+ }), k = e.hovered.element.value, R = e.hovered.zone.value;
469
+ e.hovered.element.value = ((j = z[0]) == null ? void 0 : j.element) ?? null, e.hovered.zone.value = ((G = ve[0]) == null ? void 0 : G.zone) ?? null, e.hovered.element.value !== k && ((B = k == null ? void 0 : k.events) != null && B.onLeave && k.events.onLeave(e), (Q = (J = e.hovered.element.value) == null ? void 0 : J.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));
448
470
  }, 1e3), g = () => {
449
- d(), r = requestAnimationFrame(g);
471
+ v(), r = requestAnimationFrame(g);
450
472
  }, o = () => {
451
473
  g();
452
474
  }, f = () => {
453
475
  r !== null && (cancelAnimationFrame(r), r = null);
454
476
  };
455
477
  return {
456
- activate: (i) => {
457
- e.draggingElements.value = l(t.value), n(i), o();
478
+ activate: (s) => {
479
+ e.draggingElements.value = l(t.value), n(s), o();
458
480
  },
459
- track: (i) => {
460
- s(i);
481
+ track: (s) => {
482
+ i(s);
461
483
  },
462
484
  deactivate: () => {
463
- var i, h;
464
- u(), e.hovered.zone.value ? (h = (i = e.hovered.zone.value.events).onDrop) == null || h.call(i, e) : e.draggingElements.value.forEach(
485
+ var s, m;
486
+ u(), e.hovered.zone.value ? (m = (s = e.hovered.zone.value.events).onDrop) == null || m.call(s, e) : e.draggingElements.value.forEach(
465
487
  (p) => {
466
488
  var E, w;
467
489
  return (w = (E = p.events).onEnd) == null ? void 0 : w.call(E, e);
@@ -469,40 +491,40 @@ const C = Ie(() => {
469
491
  ), e.draggingElements.value = [], e.selectedElements.value = [], e.hovered.zone.value = null, e.hovered.element.value = null, f();
470
492
  }
471
493
  };
472
- }, Ne = (t) => {
494
+ }, Be = (t) => {
473
495
  const {
474
496
  elementRef: e,
475
497
  registerElement: n,
476
- unregisterElement: s,
498
+ unregisterElement: i,
477
499
  isDragging: u,
478
500
  isOvered: r,
479
501
  isAllowed: l,
480
- isVisible: v
481
- } = Ze(t), { disableInteractions: d, enableInteractions: g } = $e(), { activeContainer: o, pointerPosition: f } = C(), { activate: D, track: m, deactivate: y } = Ye(e), i = (w) => {
482
- t != null && t.container && (o.component.value = xe(t.container)), d(), D(w), document.addEventListener("pointermove", h), document.addEventListener("pointerup", E), document.addEventListener("wheel", p);
483
- }, h = (w) => m(w), p = (w) => m(w), E = () => {
484
- o.component.value = null, g(), y(), document.removeEventListener("pointermove", h), document.removeEventListener("pointerup", E), document.removeEventListener("wheel", p);
502
+ isVisible: d
503
+ } = Ze(t), { disableInteractions: v, enableInteractions: g } = $e(), { activeContainer: o, pointerPosition: f } = M(), { activate: _, track: h, deactivate: y } = Xe(e), s = (w) => {
504
+ t != null && t.container && (o.component.value = Ie(t.container)), v(), _(w), document.addEventListener("pointermove", m), document.addEventListener("pointerup", E), document.addEventListener("wheel", p);
505
+ }, m = (w) => h(w), p = (w) => h(w), E = () => {
506
+ o.component.value = null, g(), y(), document.removeEventListener("pointermove", m), document.removeEventListener("pointerup", E), document.removeEventListener("wheel", p);
485
507
  };
486
- return F(n), j(s), {
508
+ return U(n), W(i), {
487
509
  pointerPosition: f,
488
510
  elementRef: e,
489
511
  isDragging: u,
490
512
  isOvered: r,
491
513
  isAllowed: l,
492
- handleDragStart: i,
493
- isVisible: v
514
+ handleDragStart: s,
515
+ isVisible: d
494
516
  };
495
- }, Ue = (t) => {
496
- const { zones: e, hovered: n, draggingElements: s, isDragging: u } = C(), r = P(null), l = x(() => {
517
+ }, qe = (t) => {
518
+ const { zones: e, hovered: n, draggingElements: i, isDragging: u } = M(), r = P(null), l = D(() => {
497
519
  var o;
498
520
  return ((o = n.zone.value) == null ? void 0 : o.node) === r.value;
499
- }), v = x(() => {
521
+ }), d = D(() => {
500
522
  if (!r.value || !u.value) return !1;
501
523
  const o = e.value.find(
502
524
  (f) => f.node === r.value
503
525
  );
504
- return o != null && o.groups.length ? !s.value.some((f) => f.groups.length ? !f.groups.some(
505
- (D) => o.groups.includes(D)
526
+ return o != null && o.groups.length ? !i.value.some((f) => f.groups.length ? !f.groups.some(
527
+ (_) => o.groups.includes(_)
506
528
  ) : !1) : !0;
507
529
  });
508
530
  return { elementRef: r, registerZone: () => {
@@ -519,57 +541,58 @@ const C = Ie(() => {
519
541
  (f) => f.node === r.value
520
542
  );
521
543
  o !== -1 && e.value.splice(o, 1);
522
- }, isOvered: l, isAllowed: v };
523
- }, qe = (t) => {
524
- const { elementRef: e, registerZone: n, unregisterZone: s, isOvered: u, isAllowed: r } = Ue(t);
525
- return F(n), j(s), { elementRef: e, isOvered: u, isAllowed: r };
526
- }, Be = (t) => {
527
- const { selectedElements: e, elements: n } = C(), s = x(
544
+ }, isOvered: l, isAllowed: d };
545
+ }, Je = (t) => {
546
+ const { elementRef: e, registerZone: n, unregisterZone: i, isOvered: u, isAllowed: r } = qe(t);
547
+ return U(n), W(i), { elementRef: e, isOvered: u, isAllowed: r };
548
+ }, Qe = (t) => {
549
+ const { selectedElements: e, elements: n } = M(), i = D(
528
550
  () => n.value.find((o) => o.node === t.value)
529
- ), u = x(
551
+ ), u = D(
530
552
  () => e.value.some((o) => o.node === t.value)
531
- ), r = x(() => t.value ? e.value.some(
532
- (o) => o.node && L(
553
+ ), r = D(() => t.value ? e.value.some(
554
+ (o) => o.node && S(
533
555
  o.node,
534
556
  t.value
535
557
  )
536
- ) : !1), l = x(() => t.value ? e.value.some(
537
- (o) => o.node && L(
558
+ ) : !1), l = D(() => t.value ? e.value.some(
559
+ (o) => o.node && S(
538
560
  t.value,
539
561
  o.node
540
562
  )
541
- ) : !1), v = () => {
542
- s.value && (e.value = e.value.filter(
563
+ ) : !1), d = () => {
564
+ i.value && (e.value = e.value.filter(
543
565
  (o) => o.node !== t.value
544
566
  ));
545
- }, d = () => {
546
- s.value && (r.value && (e.value = e.value.filter(
547
- (o) => o.node && !L(
567
+ }, v = () => {
568
+ i.value && (r.value && (e.value = e.value.filter(
569
+ (o) => o.node && !S(
548
570
  o.node,
549
571
  t.value
550
572
  )
551
573
  )), l.value && (e.value = e.value.filter(
552
- (o) => o.node && !L(
574
+ (o) => o.node && !S(
553
575
  t.value,
554
576
  o.node
555
577
  )
556
- )), e.value.push(s.value));
578
+ )), e.value.push(i.value));
557
579
  };
558
580
  return {
559
- handleUnselect: v,
560
- handleSelect: d,
581
+ handleUnselect: d,
582
+ handleSelect: v,
561
583
  handleToggleSelect: () => {
562
- s.value && (e.value.some((o) => o.node === t.value) ? v() : d());
584
+ i.value && (e.value.some((o) => o.node === t.value) ? d() : v());
563
585
  },
564
586
  isSelected: u,
565
587
  isParentOfSelected: r
566
588
  };
567
589
  };
568
590
  export {
569
- Ge as DragOverlay,
570
- k as getBoundingBox,
571
- C as useDnDStore,
572
- Ne as useDraggable,
573
- qe as useDroppable,
574
- Be as useSelection
591
+ ie as DragOverlay,
592
+ Ge as default,
593
+ V as getBoundingBox,
594
+ M as useDnDStore,
595
+ Be as useDraggable,
596
+ Je as useDroppable,
597
+ Qe as useSelection
575
598
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue-dnd-kit/core",
3
- "version": "0.0.45-beta",
3
+ "version": "0.0.47-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",