@vue-dnd-kit/core 0.0.27-beta → 0.0.28-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.
@@ -78,4 +78,5 @@ export declare const useDraggable: (options?: IUseDragOptions) => {
78
78
  isOvered: import('vue').ComputedRef<boolean>;
79
79
  isAllowed: import('vue').ComputedRef<boolean>;
80
80
  handleDragStart: (event: PointerEvent) => void;
81
+ isVisible: import('vue').ShallowRef<boolean, boolean>;
81
82
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("vue");function Q(t){return n.getCurrentScope()?(n.onScopeDispose(t),!0):!1}function ee(t){let e=!1,r;const c=n.effectScope(!0);return(...d)=>(e||(r=c.run(()=>t(...d)),e=!0),r)}const te=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const ne=t=>t!=null,H=()=>{};function re(t){return Array.isArray(t)?t:[t]}function oe(t,e,r){const c=n.watch(t,(...d)=>(n.nextTick(()=>c()),e(...d)),r);return c}const J=te?window:void 0;function A(t){var e;const r=n.toValue(t);return(e=r==null?void 0:r.$el)!=null?e:r}function le(){const t=n.shallowRef(!1),e=n.getCurrentInstance();return e&&n.onMounted(()=>{t.value=!0},e),t}function se(t){const e=le();return n.computed(()=>(e.value,!!t()))}function ie(t,e,r={}){const{root:c,rootMargin:d="0px",threshold:o=0,window:i=J,immediate:v=!0}=r,m=se(()=>i&&"IntersectionObserver"in i),y=n.computed(()=>{const l=n.toValue(t);return re(l).map(A).filter(ne)});let s=H;const g=n.shallowRef(v),P=m.value?n.watch(()=>[y.value,A(c),g.value],([l,f])=>{if(s(),!g.value||!l.length)return;const p=new IntersectionObserver(e,{root:A(f),rootMargin:d,threshold:o});l.forEach(h=>h&&p.observe(h)),s=()=>{p.disconnect(),s=H}},{immediate:v,flush:"post"}):H,E=()=>{s(),P(),g.value=!1};return Q(E),{isSupported:m,isActive:g,pause(){s(),g.value=!1},resume(){g.value=!0},stop:E}}function ae(t,e={}){const{window:r=J,scrollTarget:c,threshold:d=0,rootMargin:o,once:i=!1}=e,v=n.shallowRef(!1),{stop:m}=ie(t,y=>{let s=v.value,g=0;for(const P of y)P.time>=g&&(g=P.time,s=P.isIntersecting);v.value=s,i&&oe(v,()=>{m()})},{root:c,window:r,threshold:d,rootMargin:n.toValue(o)});return v}const M=ee(()=>{const t=n.ref([]),e=n.computed(()=>t.value.length>0),r={component:n.ref(null),ref:n.ref(null)},c=n.ref([]),d=n.ref([]),o=n.ref([]),i={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:c,draggingElements:t,selectedElements:d,zones:o,hovered:i,pointerPosition:v}}),ue=()=>{const t=n.ref(null),{draggingElements:e,pointerPosition:r,isDragging:c,activeContainer:d}=M();return n.onMounted(()=>{d.ref=t}),n.onBeforeUnmount(()=>{d.ref.value=null}),{elementRef:t,draggingElements:e,pointerPosition:r,isDragging:c}},ce=["innerHTML"],de=n.defineComponent({__name:"DefaultOverlay",setup(t){const{elementRef:e,pointerPosition:r,isDragging:c,draggingElements:d}=ue(),o=n.computed(()=>{var i,v,m,y;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, ${(((m=r.current.value)==null?void 0:m.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(i,v)=>n.unref(c)?(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(d),(m,y)=>{var s,g;return n.openBlock(),n.createElementBlock("div",{key:y,innerHTML:m.initialHTML,style:n.normalizeStyle({width:`${(s=m.initialRect)==null?void 0:s.width}px`,height:`${(g=m.initialRect)==null?void 0:g.height}px`})},null,12,ce)}),128))],4)):n.createCommentVNode("",!0)}}),ve=n.defineComponent({__name:"DragOverlay",setup(t){const{activeContainer:e}=M(),r=n.computed(()=>e.component.value??de);return(c,d)=>(n.openBlock(),n.createBlock(n.resolveDynamicComponent(r.value)))}}),fe="data-dnd-draggable",ge=t=>{const{elements:e,draggingElements:r,hovered:c,selectedElements:d,isDragging:o}=M(),i=n.ref(null),v=n.computed(()=>{var E;return((E=c.element.value)==null?void 0:E.node)===i.value}),m=ae(i),y=n.computed(()=>r.value.some(E=>E.node===i.value)),s=n.computed(()=>{if(!i.value||!o.value)return!1;const E=e.value.find(l=>l.node===i.value);return E!=null&&E.groups.length?!r.value.some(l=>l.groups.length?!l.groups.some(f=>E.groups.includes(f)):!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:m.value}),i.value.setAttribute(fe,"true")},unregisterElement:()=>{const E=e.value.findIndex(f=>f.node===i.value);E!==-1&&e.value.splice(E,1);const l=d.value.findIndex(f=>f.node===i.value);l!==-1&&d.value.splice(l,1)},isDragging:y,isOvered:v,isAllowed:s,isVisible:m}},me=()=>{let t="",e="",r="";const c=()=>{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)},d=()=>{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:c,enableInteractions:d}},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,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}},b=t=>({x:t.x+t.width/2,y:t.y+t.height/2}),he=(t,e)=>{const r=k(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,c=e.y-t.y;return Math.sqrt(r*r+c*c)},I=(t,e)=>t?e.contains(t):!1,pe=t=>{const e=M();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}=he(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}}},ye=t=>{const e=M(),{onPointerStart:r,onPointerMove:c,onPointerEnd:d}=pe(t);let o=null;const i=l=>{var h,x;const f=e.selectedElements.value.some(w=>w.node===l);if(e.selectedElements.value.length&&f)return e.selectedElements.value.map(w=>{var C,z;return{...w,initialHTML:((C=w.node)==null?void 0:C.outerHTML)??"",initialRect:(z=w.node)==null?void 0:z.getBoundingClientRect()}});e.selectedElements.value=[];const p=e.elements.value.find(w=>w.node===l);return p?[{...p,initialHTML:((h=p.node)==null?void 0:h.outerHTML)??"",initialRect:(x=p.node)==null?void 0:x.getBoundingClientRect()}]:[]},v=(l,f)=>{const p=Math.max(0,Math.min(l.x+l.width,f.x+f.width)-Math.max(l.x,f.x)),h=Math.max(0,Math.min(l.y+l.height,f.y+f.height)-Math.max(l.y,f.y)),x=p*h,w=l.width*l.height,C=f.width*f.height;return(x/w*100+x/C*100)/2},m=()=>{var V,U,Z,$,X,Y,F,W,q,G;const l=k(e.activeContainer.ref.value),f=b(l),p=((V=e.pointerPosition.current.value)==null?void 0:V.x)??0,h=((U=e.pointerPosition.current.value)==null?void 0:U.y)??0,w=!(l&&p>=l.x&&p<=l.x+l.width&&h>=l.y&&h<=l.y+l.height),C=e.draggingElements.value.map(a=>a.node),z=e.elements.value.filter(a=>{if(!a.node||C.some(D=>D&&I(a.node,D))||a.groups.length&&!!e.draggingElements.value.some(S=>S.groups.length?!S.groups.some(L=>a.groups.includes(L)):!1))return!1;const u=k(a.node);return u&&l&&N(u,l)}).map(a=>{const u=k(a.node),D=b(u),S=p>=u.x&&p<=u.x+u.width&&h>=u.y&&h<=u.y+u.height,L=v(u,l),R=j(f,D),B=e.elements.value.filter(_=>_!==a&&_.node&&a.node&&I(a.node,_.node)).length;return{element:a,isPointerInElement:S,overlapPercent:L,depth:B,centerDistance:R}}).sort((a,u)=>{if(!w){if(a.isPointerInElement&&u.isPointerInElement)return u.depth-a.depth;if(a.isPointerInElement!==u.isPointerInElement)return a.isPointerInElement?-1:1}return Math.abs(a.overlapPercent-u.overlapPercent)<=1?a.centerDistance-u.centerDistance:u.overlapPercent-a.overlapPercent}),K=e.zones.value.filter(a=>{if(!a.node||C.some(D=>D&&I(a.node,D))||a.groups.length&&!!e.draggingElements.value.some(S=>S.groups.length?!S.groups.some(L=>a.groups.includes(L)):!1))return!1;const u=k(a.node);return u&&l&&N(u,l)}).map(a=>{const u=k(a.node),D=b(u),S=p>=u.x&&p<=u.x+u.width&&h>=u.y&&h<=u.y+u.height,L=v(u,l),R=j(f,D),B=e.zones.value.filter(_=>_!==a&&_.node&&a.node&&I(a.node,_.node)).length;return{zone:a,isPointerInElement:S,overlapPercent:L,depth:B,centerDistance:R}}).sort((a,u)=>{if(!w){if(a.isPointerInElement&&u.isPointerInElement)return u.depth-a.depth;if(a.isPointerInElement!==u.isPointerInElement)return a.isPointerInElement?-1:1}return Math.abs(a.overlapPercent-u.overlapPercent)<=1?a.centerDistance-u.centerDistance:u.overlapPercent-a.overlapPercent}),O=e.hovered.element.value,T=e.hovered.zone.value;e.hovered.element.value=((Z=z[0])==null?void 0:Z.element)??null,e.hovered.zone.value=(($=K[0])==null?void 0:$.zone)??null,e.hovered.element.value!==O&&((X=O==null?void 0:O.events)!=null&&X.onLeave&&O.events.onLeave(e),(F=(Y=e.hovered.element.value)==null?void 0:Y.events)!=null&&F.onHover&&e.hovered.element.value.events.onHover(e)),e.hovered.zone.value!==T&&((W=T==null?void 0:T.events)!=null&&W.onLeave&&T.events.onLeave(e),(G=(q=e.hovered.zone.value)==null?void 0:q.events)!=null&&G.onHover&&e.hovered.zone.value.events.onHover(e)),o=requestAnimationFrame(m)},y=()=>{m()},s=()=>{o!==null&&(cancelAnimationFrame(o),o=null)};return{activate:l=>{e.draggingElements.value=i(t.value),r(l),y()},track:l=>{c(l)},deactivate:()=>{var l,f;d(),e.hovered.zone.value?(f=(l=e.hovered.zone.value.events).onDrop)==null||f.call(l,e):e.draggingElements.value.forEach(p=>{var h,x;return(x=(h=p.events).onEnd)==null?void 0:x.call(h,e)}),e.draggingElements.value=[],e.selectedElements.value=[],e.hovered.zone.value=null,e.hovered.element.value=null,s()}}},Ee=t=>{const{elementRef:e,registerElement:r,unregisterElement:c,isDragging:d,isOvered:o,isAllowed:i}=ge(t),{disableInteractions:v,enableInteractions:m}=me(),y=M(),{activate:s,track:g,deactivate:P}=ye(e),E=h=>{t!=null&&t.container&&(y.activeContainer.component.value=n.markRaw(t.container)),v(),s(h),document.addEventListener("pointermove",l),document.addEventListener("pointerup",p),document.addEventListener("wheel",f)},l=h=>{g(h)},f=h=>{g(h)},p=()=>{y.activeContainer.component.value=null,m(),P(),document.removeEventListener("pointermove",l),document.removeEventListener("pointerup",p),document.removeEventListener("wheel",f)};return n.onMounted(r),n.onBeforeUnmount(c),{pointerPosition:y.pointerPosition,elementRef:e,isDragging:d,isOvered:o,isAllowed:i,handleDragStart:E}},we=t=>{const{zones:e,hovered:r,draggingElements:c,isDragging:d}=M(),o=n.ref(null),i=n.computed(()=>{var s;return((s=r.zone.value)==null?void 0:s.node)===o.value}),v=n.computed(()=>{if(!o.value||!d.value)return!1;const s=e.value.find(g=>g.node===o.value);return s!=null&&s.groups.length?!c.value.some(g=>g.groups.length?!g.groups.some(P=>s.groups.includes(P)):!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 s=e.value.findIndex(g=>g.node===o.value);s!==-1&&e.value.splice(s,1)},isOvered:i,isAllowed:v}},Pe=t=>{const{elementRef:e,registerZone:r,unregisterZone:c,isOvered:d,isAllowed:o}=we(t);return n.onMounted(r),n.onBeforeUnmount(c),{elementRef:e,isOvered:d,isAllowed:o}},De=t=>{const{selectedElements:e,elements:r}=M(),c=n.computed(()=>r.value.find(s=>s.node===t.value)),d=n.computed(()=>e.value.some(s=>s.node===t.value)),o=n.computed(()=>t.value?e.value.some(s=>s.node&&I(s.node,t.value)):!1),i=n.computed(()=>t.value?e.value.some(s=>s.node&&I(t.value,s.node)):!1),v=()=>{c.value&&(e.value=e.value.filter(s=>s.node!==t.value))},m=()=>{c.value&&(o.value&&(e.value=e.value.filter(s=>s.node&&!I(s.node,t.value))),i.value&&(e.value=e.value.filter(s=>s.node&&!I(t.value,s.node))),e.value.push(c.value))};return{handleUnselect:v,handleSelect:m,handleToggleSelect:()=>{c.value&&(e.value.some(s=>s.node===t.value)?v():m())},isSelected:d,isParentOfSelected:o}};exports.DragOverlay=ve;exports.getBoundingBox=k;exports.useDnDStore=M;exports.useDraggable=Ee;exports.useDroppable=Pe;exports.useSelection=De;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("vue");function Q(t){return n.getCurrentScope()?(n.onScopeDispose(t),!0):!1}function ee(t){let e=!1,r;const c=n.effectScope(!0);return(...d)=>(e||(r=c.run(()=>t(...d)),e=!0),r)}const te=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const ne=t=>t!=null,H=()=>{};function re(t){return Array.isArray(t)?t:[t]}function oe(t,e,r){const c=n.watch(t,(...d)=>(n.nextTick(()=>c()),e(...d)),r);return c}const J=te?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 le(){const t=n.shallowRef(!1),e=n.getCurrentInstance();return e&&n.onMounted(()=>{t.value=!0},e),t}function se(t){const e=le();return n.computed(()=>(e.value,!!t()))}function ie(t,e,r={}){const{root:c,rootMargin:d="0px",threshold:o=0,window:i=J,immediate:v=!0}=r,g=se(()=>i&&"IntersectionObserver"in i),E=n.computed(()=>{const s=n.toValue(t);return re(s).map(b).filter(ne)});let l=H;const m=n.shallowRef(v),P=g.value?n.watch(()=>[E.value,b(c),m.value],([s,f])=>{if(l(),!m.value||!s.length)return;const h=new IntersectionObserver(e,{root:b(f),rootMargin:d,threshold:o});s.forEach(p=>p&&h.observe(p)),l=()=>{h.disconnect(),l=H}},{immediate:v,flush:"post"}):H,y=()=>{l(),P(),m.value=!1};return Q(y),{isSupported:g,isActive:m,pause(){l(),m.value=!1},resume(){m.value=!0},stop:y}}function ae(t,e={}){const{window:r=J,scrollTarget:c,threshold:d=0,rootMargin:o,once:i=!1}=e,v=n.shallowRef(!1),{stop:g}=ie(t,E=>{let l=v.value,m=0;for(const P of E)P.time>=m&&(m=P.time,l=P.isIntersecting);v.value=l,i&&oe(v,()=>{g()})},{root:c,window:r,threshold:d,rootMargin:n.toValue(o)});return v}const M=ee(()=>{const t=n.ref([]),e=n.computed(()=>t.value.length>0),r={component:n.ref(null),ref:n.ref(null)},c=n.ref([]),d=n.ref([]),o=n.ref([]),i={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:c,draggingElements:t,selectedElements:d,zones:o,hovered:i,pointerPosition:v}}),ue=()=>{const t=n.ref(null),{draggingElements:e,pointerPosition:r,isDragging:c,activeContainer:d}=M();return n.onMounted(()=>{d.ref=t}),n.onBeforeUnmount(()=>{d.ref.value=null}),{elementRef:t,draggingElements:e,pointerPosition:r,isDragging:c}},ce=["innerHTML"],de=n.defineComponent({__name:"DefaultOverlay",setup(t){const{elementRef:e,pointerPosition:r,isDragging:c,draggingElements:d}=ue(),o=n.computed(()=>{var i,v,g,E;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, ${(((g=r.current.value)==null?void 0:g.y)??0)-(((E=r.offset.pixel.value)==null?void 0:E.y)??0)}px, 0)`,zIndex:1e3,position:"fixed",top:0,left:0,transition:"0.3s cubic-bezier(0.165, 0.84, 0.44, 1)"}});return(i,v)=>n.unref(c)?(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(d),(g,E)=>{var l,m;return n.openBlock(),n.createElementBlock("div",{key:E,innerHTML:g.initialHTML,style:n.normalizeStyle({width:`${(l=g.initialRect)==null?void 0:l.width}px`,height:`${(m=g.initialRect)==null?void 0:m.height}px`})},null,12,ce)}),128))],4)):n.createCommentVNode("",!0)}}),ve=n.defineComponent({__name:"DragOverlay",setup(t){const{activeContainer:e}=M(),r=n.computed(()=>e.component.value??de);return(c,d)=>(n.openBlock(),n.createBlock(n.resolveDynamicComponent(r.value)))}}),fe="data-dnd-draggable",ge=t=>{const{elements:e,draggingElements:r,hovered:c,selectedElements:d,isDragging:o}=M(),i=n.ref(null),v=n.computed(()=>{var y;return((y=c.element.value)==null?void 0:y.node)===i.value}),g=ae(i),E=n.computed(()=>r.value.some(y=>y.node===i.value)),l=n.computed(()=>{if(!i.value||!o.value)return!1;const y=e.value.find(s=>s.node===i.value);return y!=null&&y.groups.length?!r.value.some(s=>s.groups.length?!s.groups.some(f=>y.groups.includes(f)):!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:g.value}),i.value.setAttribute(fe,"true")},unregisterElement:()=>{const y=e.value.findIndex(f=>f.node===i.value);y!==-1&&e.value.splice(y,1);const s=d.value.findIndex(f=>f.node===i.value);s!==-1&&d.value.splice(s,1)},isDragging:E,isOvered:v,isAllowed:l,isVisible:g}},me=()=>{let t="",e="",r="";const c=()=>{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)},d=()=>{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:c,enableInteractions:d}},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,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}},A=t=>({x:t.x+t.width/2,y:t.y+t.height/2}),he=(t,e)=>{const r=k(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,c=e.y-t.y;return Math.sqrt(r*r+c*c)},I=(t,e)=>t?e.contains(t):!1,pe=t=>{const e=M();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}=he(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}}},ye=t=>{const e=M(),{onPointerStart:r,onPointerMove:c,onPointerEnd:d}=pe(t);let o=null;const i=s=>{var p,w;const f=e.selectedElements.value.some(D=>D.node===s);if(e.selectedElements.value.length&&f)return e.selectedElements.value.map(D=>{var C,z;return{...D,initialHTML:((C=D.node)==null?void 0:C.outerHTML)??"",initialRect:(z=D.node)==null?void 0:z.getBoundingClientRect()}});e.selectedElements.value=[];const h=e.elements.value.find(D=>D.node===s);return h?[{...h,initialHTML:((p=h.node)==null?void 0:p.outerHTML)??"",initialRect:(w=h.node)==null?void 0:w.getBoundingClientRect()}]:[]},v=(s,f)=>{const h=Math.max(0,Math.min(s.x+s.width,f.x+f.width)-Math.max(s.x,f.x)),p=Math.max(0,Math.min(s.y+s.height,f.y+f.height)-Math.max(s.y,f.y)),w=h*p,D=s.width*s.height,C=f.width*f.height;return(w/D*100+w/C*100)/2},g=()=>{var V,U,Z,$,X,Y,F,W,q,G;const s=k(e.activeContainer.ref.value),f=A(s),h=((V=e.pointerPosition.current.value)==null?void 0:V.x)??0,p=((U=e.pointerPosition.current.value)==null?void 0:U.y)??0,D=!(s&&h>=s.x&&h<=s.x+s.width&&p>=s.y&&p<=s.y+s.height),C=e.draggingElements.value.map(a=>a.node),z=e.elements.value.filter(a=>{if(!a.node||C.some(x=>x&&I(a.node,x))||a.groups.length&&!!e.draggingElements.value.some(S=>S.groups.length?!S.groups.some(L=>a.groups.includes(L)):!1))return!1;const u=k(a.node);return u&&s&&N(u,s)}).map(a=>{const u=k(a.node),x=A(u),S=h>=u.x&&h<=u.x+u.width&&p>=u.y&&p<=u.y+u.height,L=v(u,s),R=j(f,x),B=e.elements.value.filter(_=>_!==a&&_.node&&a.node&&I(a.node,_.node)).length;return{element:a,isPointerInElement:S,overlapPercent:L,depth:B,centerDistance:R}}).sort((a,u)=>{if(!D){if(a.isPointerInElement&&u.isPointerInElement)return u.depth-a.depth;if(a.isPointerInElement!==u.isPointerInElement)return a.isPointerInElement?-1:1}return Math.abs(a.overlapPercent-u.overlapPercent)<=1?a.centerDistance-u.centerDistance:u.overlapPercent-a.overlapPercent}),K=e.zones.value.filter(a=>{if(!a.node||C.some(x=>x&&I(a.node,x))||a.groups.length&&!!e.draggingElements.value.some(S=>S.groups.length?!S.groups.some(L=>a.groups.includes(L)):!1))return!1;const u=k(a.node);return u&&s&&N(u,s)}).map(a=>{const u=k(a.node),x=A(u),S=h>=u.x&&h<=u.x+u.width&&p>=u.y&&p<=u.y+u.height,L=v(u,s),R=j(f,x),B=e.zones.value.filter(_=>_!==a&&_.node&&a.node&&I(a.node,_.node)).length;return{zone:a,isPointerInElement:S,overlapPercent:L,depth:B,centerDistance:R}}).sort((a,u)=>{if(!D){if(a.isPointerInElement&&u.isPointerInElement)return u.depth-a.depth;if(a.isPointerInElement!==u.isPointerInElement)return a.isPointerInElement?-1:1}return Math.abs(a.overlapPercent-u.overlapPercent)<=1?a.centerDistance-u.centerDistance:u.overlapPercent-a.overlapPercent}),O=e.hovered.element.value,T=e.hovered.zone.value;e.hovered.element.value=((Z=z[0])==null?void 0:Z.element)??null,e.hovered.zone.value=(($=K[0])==null?void 0:$.zone)??null,e.hovered.element.value!==O&&((X=O==null?void 0:O.events)!=null&&X.onLeave&&O.events.onLeave(e),(F=(Y=e.hovered.element.value)==null?void 0:Y.events)!=null&&F.onHover&&e.hovered.element.value.events.onHover(e)),e.hovered.zone.value!==T&&((W=T==null?void 0:T.events)!=null&&W.onLeave&&T.events.onLeave(e),(G=(q=e.hovered.zone.value)==null?void 0:q.events)!=null&&G.onHover&&e.hovered.zone.value.events.onHover(e)),o=requestAnimationFrame(g)},E=()=>{g()},l=()=>{o!==null&&(cancelAnimationFrame(o),o=null)};return{activate:s=>{e.draggingElements.value=i(t.value),r(s),E()},track:s=>{c(s)},deactivate:()=>{var s,f;d(),e.hovered.zone.value?(f=(s=e.hovered.zone.value.events).onDrop)==null||f.call(s,e):e.draggingElements.value.forEach(h=>{var p,w;return(w=(p=h.events).onEnd)==null?void 0:w.call(p,e)}),e.draggingElements.value=[],e.selectedElements.value=[],e.hovered.zone.value=null,e.hovered.element.value=null,l()}}},Ee=t=>{const{elementRef:e,registerElement:r,unregisterElement:c,isDragging:d,isOvered:o,isAllowed:i,isVisible:v}=ge(t),{disableInteractions:g,enableInteractions:E}=me(),l=M(),{activate:m,track:P,deactivate:y}=ye(e),s=w=>{t!=null&&t.container&&(l.activeContainer.component.value=n.markRaw(t.container)),g(),m(w),document.addEventListener("pointermove",f),document.addEventListener("pointerup",p),document.addEventListener("wheel",h)},f=w=>{P(w)},h=w=>{P(w)},p=()=>{l.activeContainer.component.value=null,E(),y(),document.removeEventListener("pointermove",f),document.removeEventListener("pointerup",p),document.removeEventListener("wheel",h)};return n.onMounted(r),n.onBeforeUnmount(c),{pointerPosition:l.pointerPosition,elementRef:e,isDragging:d,isOvered:o,isAllowed:i,handleDragStart:s,isVisible:v}},we=t=>{const{zones:e,hovered:r,draggingElements:c,isDragging:d}=M(),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||!d.value)return!1;const l=e.value.find(m=>m.node===o.value);return l!=null&&l.groups.length?!c.value.some(m=>m.groups.length?!m.groups.some(P=>l.groups.includes(P)):!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(m=>m.node===o.value);l!==-1&&e.value.splice(l,1)},isOvered:i,isAllowed:v}},Pe=t=>{const{elementRef:e,registerZone:r,unregisterZone:c,isOvered:d,isAllowed:o}=we(t);return n.onMounted(r),n.onBeforeUnmount(c),{elementRef:e,isOvered:d,isAllowed:o}},De=t=>{const{selectedElements:e,elements:r}=M(),c=n.computed(()=>r.value.find(l=>l.node===t.value)),d=n.computed(()=>e.value.some(l=>l.node===t.value)),o=n.computed(()=>t.value?e.value.some(l=>l.node&&I(l.node,t.value)):!1),i=n.computed(()=>t.value?e.value.some(l=>l.node&&I(t.value,l.node)):!1),v=()=>{c.value&&(e.value=e.value.filter(l=>l.node!==t.value))},g=()=>{c.value&&(o.value&&(e.value=e.value.filter(l=>l.node&&!I(l.node,t.value))),i.value&&(e.value=e.value.filter(l=>l.node&&!I(t.value,l.node))),e.value.push(c.value))};return{handleUnselect:v,handleSelect:g,handleToggleSelect:()=>{c.value&&(e.value.some(l=>l.node===t.value)?v():g())},isSelected:d,isParentOfSelected:o}};exports.DragOverlay=ve;exports.getBoundingBox=k;exports.useDnDStore=M;exports.useDraggable=Ee;exports.useDroppable=Pe;exports.useSelection=De;
@@ -1,4 +1,4 @@
1
- import { effectScope as ce, watch as se, nextTick as ve, getCurrentScope as de, onScopeDispose as ge, shallowRef as F, toValue as U, computed as w, getCurrentInstance as fe, onMounted as A, ref as E, onBeforeUnmount as W, defineComponent as ie, createElementBlock as $, createCommentVNode as he, unref as ne, openBlock as R, normalizeStyle as re, Fragment as me, renderList as pe, createBlock as ye, resolveDynamicComponent as Ee, markRaw as we } from "vue";
1
+ import { effectScope as ce, watch as se, nextTick as ve, getCurrentScope as de, onScopeDispose as ge, shallowRef as F, toValue as U, computed as P, getCurrentInstance as fe, onMounted as A, ref as w, onBeforeUnmount as W, defineComponent as ie, createElementBlock as $, createCommentVNode as he, unref as ne, openBlock as R, normalizeStyle as re, Fragment as me, renderList as pe, createBlock as ye, resolveDynamicComponent as Ee, markRaw as we } from "vue";
2
2
  function Pe(t) {
3
3
  return de() ? (ge(t), !0) : !1;
4
4
  }
@@ -9,7 +9,7 @@ function xe(t) {
9
9
  }
10
10
  const De = typeof window < "u" && typeof document < "u";
11
11
  typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
12
- const Ie = (t) => t != null, X = () => {
12
+ const Ie = (t) => t != null, b = () => {
13
13
  };
14
14
  function Se(t) {
15
15
  return Array.isArray(t) ? t : [t];
@@ -19,7 +19,7 @@ function Me(t, e, n) {
19
19
  return u;
20
20
  }
21
21
  const ae = De ? window : void 0;
22
- function Y(t) {
22
+ function X(t) {
23
23
  var e;
24
24
  const n = U(t);
25
25
  return (e = n == null ? void 0 : n.$el) != null ? e : n;
@@ -32,7 +32,7 @@ function Ce() {
32
32
  }
33
33
  function Le(t) {
34
34
  const e = Ce();
35
- return w(() => (e.value, !!t()));
35
+ return P(() => (e.value, !!t()));
36
36
  }
37
37
  function _e(t, e, n = {}) {
38
38
  const {
@@ -41,42 +41,42 @@ function _e(t, e, n = {}) {
41
41
  threshold: r = 0,
42
42
  window: s = ae,
43
43
  immediate: v = !0
44
- } = n, f = Le(() => s && "IntersectionObserver" in s), p = w(() => {
45
- const o = U(t);
46
- return Se(o).map(Y).filter(Ie);
44
+ } = n, g = Le(() => s && "IntersectionObserver" in s), y = P(() => {
45
+ const l = U(t);
46
+ return Se(l).map(X).filter(Ie);
47
47
  });
48
- let l = X;
49
- const g = F(v), x = f.value ? se(
50
- () => [p.value, Y(u), g.value],
51
- ([o, d]) => {
52
- if (l(), !g.value || !o.length)
48
+ let o = b;
49
+ const f = F(v), x = g.value ? se(
50
+ () => [y.value, X(u), f.value],
51
+ ([l, d]) => {
52
+ if (o(), !f.value || !l.length)
53
53
  return;
54
- const m = new IntersectionObserver(
54
+ const h = new IntersectionObserver(
55
55
  e,
56
56
  {
57
- root: Y(d),
57
+ root: X(d),
58
58
  rootMargin: c,
59
59
  threshold: r
60
60
  }
61
61
  );
62
- o.forEach((h) => h && m.observe(h)), l = () => {
63
- m.disconnect(), l = X;
62
+ l.forEach((m) => m && h.observe(m)), o = () => {
63
+ h.disconnect(), o = b;
64
64
  };
65
65
  },
66
66
  { immediate: v, flush: "post" }
67
- ) : X, y = () => {
68
- l(), x(), g.value = !1;
67
+ ) : b, p = () => {
68
+ o(), x(), f.value = !1;
69
69
  };
70
- return Pe(y), {
71
- isSupported: f,
72
- isActive: g,
70
+ return Pe(p), {
71
+ isSupported: g,
72
+ isActive: f,
73
73
  pause() {
74
- l(), g.value = !1;
74
+ o(), f.value = !1;
75
75
  },
76
76
  resume() {
77
- g.value = !0;
77
+ f.value = !0;
78
78
  },
79
- stop: y
79
+ stop: p
80
80
  };
81
81
  }
82
82
  function Oe(t, e = {}) {
@@ -86,14 +86,14 @@ function Oe(t, e = {}) {
86
86
  threshold: c = 0,
87
87
  rootMargin: r,
88
88
  once: s = !1
89
- } = e, v = F(!1), { stop: f } = _e(
89
+ } = e, v = F(!1), { stop: g } = _e(
90
90
  t,
91
- (p) => {
92
- let l = v.value, g = 0;
93
- for (const x of p)
94
- x.time >= g && (g = x.time, l = x.isIntersecting);
95
- v.value = l, s && Me(v, () => {
96
- f();
91
+ (y) => {
92
+ let o = v.value, f = 0;
93
+ for (const x of y)
94
+ x.time >= f && (f = x.time, o = x.isIntersecting);
95
+ v.value = o, s && Me(v, () => {
96
+ g();
97
97
  });
98
98
  },
99
99
  {
@@ -106,18 +106,18 @@ function Oe(t, e = {}) {
106
106
  return v;
107
107
  }
108
108
  const C = xe(() => {
109
- const t = E([]), e = w(() => t.value.length > 0), n = {
110
- component: E(null),
111
- ref: E(null)
112
- }, u = E([]), c = E([]), r = E([]), s = {
113
- zone: E(null),
114
- element: E(null)
109
+ const t = w([]), e = P(() => t.value.length > 0), n = {
110
+ component: w(null),
111
+ ref: w(null)
112
+ }, u = w([]), c = w([]), r = w([]), s = {
113
+ zone: w(null),
114
+ element: w(null)
115
115
  }, v = {
116
- current: E(null),
117
- start: E(null),
116
+ current: w(null),
117
+ start: w(null),
118
118
  offset: {
119
- percent: E(null),
120
- pixel: E(null)
119
+ percent: w(null),
120
+ pixel: w(null)
121
121
  }
122
122
  };
123
123
  return {
@@ -131,7 +131,7 @@ const C = xe(() => {
131
131
  pointerPosition: v
132
132
  };
133
133
  }), ke = () => {
134
- const t = E(null), { draggingElements: e, pointerPosition: n, isDragging: u, activeContainer: c } = C();
134
+ const t = w(null), { draggingElements: e, pointerPosition: n, isDragging: u, activeContainer: c } = C();
135
135
  return A(() => {
136
136
  c.ref = t;
137
137
  }), W(() => {
@@ -145,10 +145,10 @@ const C = xe(() => {
145
145
  }, Te = ["innerHTML"], ze = /* @__PURE__ */ ie({
146
146
  __name: "DefaultOverlay",
147
147
  setup(t) {
148
- const { elementRef: e, pointerPosition: n, isDragging: u, draggingElements: c } = ke(), r = w(() => {
149
- var s, v, f, p;
148
+ const { elementRef: e, pointerPosition: n, isDragging: u, draggingElements: c } = ke(), r = P(() => {
149
+ var s, v, g, y;
150
150
  return {
151
- transform: `translate3d(${(((s = n.current.value) == null ? void 0 : s.x) ?? 0) - (((v = n.offset.pixel.value) == null ? void 0 : v.x) ?? 0)}px, ${(((f = n.current.value) == null ? void 0 : f.y) ?? 0) - (((p = n.offset.pixel.value) == null ? void 0 : p.y) ?? 0)}px, 0)`,
151
+ transform: `translate3d(${(((s = n.current.value) == null ? void 0 : s.x) ?? 0) - (((v = n.offset.pixel.value) == null ? void 0 : v.x) ?? 0)}px, ${(((g = n.current.value) == null ? void 0 : g.y) ?? 0) - (((y = n.offset.pixel.value) == null ? void 0 : y.y) ?? 0)}px, 0)`,
152
152
  zIndex: 1e3,
153
153
  position: "fixed",
154
154
  top: 0,
@@ -162,23 +162,23 @@ const C = xe(() => {
162
162
  ref: e,
163
163
  style: re(r.value)
164
164
  }, [
165
- (R(!0), $(me, null, pe(ne(c), (f, p) => {
166
- var l, g;
165
+ (R(!0), $(me, null, pe(ne(c), (g, y) => {
166
+ var o, f;
167
167
  return R(), $("div", {
168
- key: p,
169
- innerHTML: f.initialHTML,
168
+ key: y,
169
+ innerHTML: g.initialHTML,
170
170
  style: re({
171
- width: `${(l = f.initialRect) == null ? void 0 : l.width}px`,
172
- height: `${(g = f.initialRect) == null ? void 0 : g.height}px`
171
+ width: `${(o = g.initialRect) == null ? void 0 : o.width}px`,
172
+ height: `${(f = g.initialRect) == null ? void 0 : f.height}px`
173
173
  })
174
174
  }, null, 12, Te);
175
175
  }), 128))
176
176
  ], 4)) : he("", !0);
177
177
  }
178
- }), be = /* @__PURE__ */ ie({
178
+ }), Ye = /* @__PURE__ */ ie({
179
179
  __name: "DragOverlay",
180
180
  setup(t) {
181
- const { activeContainer: e } = C(), n = w(
181
+ const { activeContainer: e } = C(), n = P(
182
182
  () => e.component.value ?? ze
183
183
  );
184
184
  return (u, c) => (R(), ye(Ee(n.value)));
@@ -190,20 +190,20 @@ const C = xe(() => {
190
190
  hovered: u,
191
191
  selectedElements: c,
192
192
  isDragging: r
193
- } = C(), s = E(null), v = w(
193
+ } = C(), s = w(null), v = P(
194
194
  () => {
195
- var y;
196
- return ((y = u.element.value) == null ? void 0 : y.node) === s.value;
195
+ var p;
196
+ return ((p = u.element.value) == null ? void 0 : p.node) === s.value;
197
197
  }
198
- ), f = Oe(s), p = w(
199
- () => n.value.some((y) => y.node === s.value)
200
- ), l = w(() => {
198
+ ), g = Oe(s), y = P(
199
+ () => n.value.some((p) => p.node === s.value)
200
+ ), o = P(() => {
201
201
  if (!s.value || !r.value) return !1;
202
- const y = e.value.find(
203
- (o) => o.node === s.value
202
+ const p = e.value.find(
203
+ (l) => l.node === s.value
204
204
  );
205
- return y != null && y.groups.length ? !n.value.some((o) => o.groups.length ? !o.groups.some(
206
- (d) => y.groups.includes(d)
205
+ return p != null && p.groups.length ? !n.value.some((l) => l.groups.length ? !l.groups.some(
206
+ (d) => p.groups.includes(d)
207
207
  ) : !1) : !0;
208
208
  });
209
209
  return {
@@ -217,23 +217,23 @@ const C = xe(() => {
217
217
  defaultLayer: (t == null ? void 0 : t.layer) ?? null,
218
218
  events: (t == null ? void 0 : t.events) ?? {},
219
219
  data: (t == null ? void 0 : t.data) ?? void 0,
220
- isVisible: f.value
220
+ isVisible: g.value
221
221
  }), s.value.setAttribute(He, "true");
222
222
  },
223
223
  unregisterElement: () => {
224
- const y = e.value.findIndex(
224
+ const p = e.value.findIndex(
225
225
  (d) => d.node === s.value
226
226
  );
227
- y !== -1 && e.value.splice(y, 1);
228
- const o = c.value.findIndex(
227
+ p !== -1 && e.value.splice(p, 1);
228
+ const l = c.value.findIndex(
229
229
  (d) => d.node === s.value
230
230
  );
231
- o !== -1 && c.value.splice(o, 1);
231
+ l !== -1 && c.value.splice(l, 1);
232
232
  },
233
- isDragging: p,
233
+ isDragging: y,
234
234
  isOvered: v,
235
- isAllowed: l,
236
- isVisible: f
235
+ isAllowed: o,
236
+ isVisible: g
237
237
  };
238
238
  }, Ae = () => {
239
239
  let t = "", e = "", n = "";
@@ -271,7 +271,7 @@ const C = xe(() => {
271
271
  width: e.width,
272
272
  height: e.height
273
273
  };
274
- }, b = (t) => ({
274
+ }, Y = (t) => ({
275
275
  x: t.x + t.width / 2,
276
276
  y: t.y + t.height / 2
277
277
  }), Ve = (t, e) => {
@@ -316,45 +316,45 @@ const C = xe(() => {
316
316
  }, $e = (t) => {
317
317
  const e = C(), { onPointerStart: n, onPointerMove: u, onPointerEnd: c } = Ze(t);
318
318
  let r = null;
319
- const s = (o) => {
320
- var h, I;
319
+ const s = (l) => {
320
+ var m, E;
321
321
  const d = e.selectedElements.value.some(
322
- (P) => P.node === o
322
+ (D) => D.node === l
323
323
  );
324
324
  if (e.selectedElements.value.length && d)
325
- return e.selectedElements.value.map((P) => {
325
+ return e.selectedElements.value.map((D) => {
326
326
  var L, H;
327
327
  return {
328
- ...P,
329
- initialHTML: ((L = P.node) == null ? void 0 : L.outerHTML) ?? "",
330
- initialRect: (H = P.node) == null ? void 0 : H.getBoundingClientRect()
328
+ ...D,
329
+ initialHTML: ((L = D.node) == null ? void 0 : L.outerHTML) ?? "",
330
+ initialRect: (H = D.node) == null ? void 0 : H.getBoundingClientRect()
331
331
  };
332
332
  });
333
333
  e.selectedElements.value = [];
334
- const m = e.elements.value.find(
335
- (P) => P.node === o
334
+ const h = e.elements.value.find(
335
+ (D) => D.node === l
336
336
  );
337
- return m ? [
337
+ return h ? [
338
338
  {
339
- ...m,
340
- initialHTML: ((h = m.node) == null ? void 0 : h.outerHTML) ?? "",
341
- initialRect: (I = m.node) == null ? void 0 : I.getBoundingClientRect()
339
+ ...h,
340
+ initialHTML: ((m = h.node) == null ? void 0 : m.outerHTML) ?? "",
341
+ initialRect: (E = h.node) == null ? void 0 : E.getBoundingClientRect()
342
342
  }
343
343
  ] : [];
344
- }, v = (o, d) => {
345
- const m = Math.max(
344
+ }, v = (l, d) => {
345
+ const h = Math.max(
346
346
  0,
347
- Math.min(o.x + o.width, d.x + d.width) - Math.max(o.x, d.x)
348
- ), h = Math.max(
347
+ Math.min(l.x + l.width, d.x + d.width) - Math.max(l.x, d.x)
348
+ ), m = Math.max(
349
349
  0,
350
- Math.min(o.y + o.height, d.y + d.height) - Math.max(o.y, d.y)
351
- ), I = m * h, P = o.width * o.height, L = d.width * d.height;
352
- return (I / P * 100 + I / L * 100) / 2;
353
- }, f = () => {
350
+ Math.min(l.y + l.height, d.y + d.height) - Math.max(l.y, d.y)
351
+ ), E = h * m, D = l.width * l.height, L = d.width * d.height;
352
+ return (E / D * 100 + E / L * 100) / 2;
353
+ }, g = () => {
354
354
  var G, N, q, B, j, J, K, Q, ee, te;
355
- const o = k(e.activeContainer.ref.value), d = b(o), m = ((G = e.pointerPosition.current.value) == null ? void 0 : G.x) ?? 0, h = ((N = e.pointerPosition.current.value) == null ? void 0 : N.y) ?? 0, P = !(o && m >= o.x && m <= o.x + o.width && h >= o.y && h <= o.y + o.height), L = e.draggingElements.value.map((i) => i.node), H = e.elements.value.filter((i) => {
355
+ const l = k(e.activeContainer.ref.value), d = Y(l), h = ((G = e.pointerPosition.current.value) == null ? void 0 : G.x) ?? 0, m = ((N = e.pointerPosition.current.value) == null ? void 0 : N.y) ?? 0, D = !(l && h >= l.x && h <= l.x + l.width && m >= l.y && m <= l.y + l.height), L = e.draggingElements.value.map((i) => i.node), H = e.elements.value.filter((i) => {
356
356
  if (!i.node || L.some(
357
- (D) => D && M(i.node, D)
357
+ (I) => I && M(i.node, I)
358
358
  ) || i.groups.length && !!e.draggingElements.value.some(
359
359
  (S) => S.groups.length ? !S.groups.some(
360
360
  (_) => i.groups.includes(_)
@@ -362,9 +362,9 @@ const C = xe(() => {
362
362
  ))
363
363
  return !1;
364
364
  const a = k(i.node);
365
- return a && o && oe(a, o);
365
+ return a && l && oe(a, l);
366
366
  }).map((i) => {
367
- const a = k(i.node), D = b(a), S = m >= a.x && m <= a.x + a.width && h >= a.y && h <= a.y + a.height, _ = v(a, o), V = le(d, D), Z = e.elements.value.filter(
367
+ const a = k(i.node), I = Y(a), S = h >= a.x && h <= a.x + a.width && m >= a.y && m <= a.y + a.height, _ = v(a, l), V = le(d, I), Z = e.elements.value.filter(
368
368
  (O) => O !== i && O.node && i.node && M(
369
369
  i.node,
370
370
  O.node
@@ -378,7 +378,7 @@ const C = xe(() => {
378
378
  centerDistance: V
379
379
  };
380
380
  }).sort((i, a) => {
381
- if (!P) {
381
+ if (!D) {
382
382
  if (i.isPointerInElement && a.isPointerInElement)
383
383
  return a.depth - i.depth;
384
384
  if (i.isPointerInElement !== a.isPointerInElement)
@@ -387,13 +387,13 @@ const C = xe(() => {
387
387
  return Math.abs(i.overlapPercent - a.overlapPercent) <= 1 ? i.centerDistance - a.centerDistance : a.overlapPercent - i.overlapPercent;
388
388
  }), ue = e.zones.value.filter((i) => {
389
389
  if (!i.node || L.some(
390
- (D) => D && M(i.node, D)
390
+ (I) => I && M(i.node, I)
391
391
  ) || i.groups.length && !!e.draggingElements.value.some((S) => S.groups.length ? !S.groups.some((_) => i.groups.includes(_)) : !1))
392
392
  return !1;
393
393
  const a = k(i.node);
394
- return a && o && oe(a, o);
394
+ return a && l && oe(a, l);
395
395
  }).map((i) => {
396
- const a = k(i.node), D = b(a), S = m >= a.x && m <= a.x + a.width && h >= a.y && h <= a.y + a.height, _ = v(a, o), V = le(d, D), Z = e.zones.value.filter(
396
+ const a = k(i.node), I = Y(a), S = h >= a.x && h <= a.x + a.width && m >= a.y && m <= a.y + a.height, _ = v(a, l), V = le(d, I), Z = e.zones.value.filter(
397
397
  (O) => O !== i && O.node && i.node && M(i.node, O.node)
398
398
  ).length;
399
399
  return {
@@ -404,7 +404,7 @@ const C = xe(() => {
404
404
  centerDistance: V
405
405
  };
406
406
  }).sort((i, a) => {
407
- if (!P) {
407
+ if (!D) {
408
408
  if (i.isPointerInElement && a.isPointerInElement)
409
409
  return a.depth - i.depth;
410
410
  if (i.isPointerInElement !== a.isPointerInElement)
@@ -412,27 +412,27 @@ const C = xe(() => {
412
412
  }
413
413
  return Math.abs(i.overlapPercent - a.overlapPercent) <= 1 ? i.centerDistance - a.centerDistance : a.overlapPercent - i.overlapPercent;
414
414
  }), T = e.hovered.element.value, z = e.hovered.zone.value;
415
- e.hovered.element.value = ((q = H[0]) == null ? void 0 : q.element) ?? null, e.hovered.zone.value = ((B = ue[0]) == null ? void 0 : B.zone) ?? null, e.hovered.element.value !== T && ((j = T == null ? void 0 : T.events) != null && j.onLeave && T.events.onLeave(e), (K = (J = e.hovered.element.value) == null ? void 0 : J.events) != null && K.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), (te = (ee = e.hovered.zone.value) == null ? void 0 : ee.events) != null && te.onHover && e.hovered.zone.value.events.onHover(e)), r = requestAnimationFrame(f);
416
- }, p = () => {
417
- f();
418
- }, l = () => {
415
+ e.hovered.element.value = ((q = H[0]) == null ? void 0 : q.element) ?? null, e.hovered.zone.value = ((B = ue[0]) == null ? void 0 : B.zone) ?? null, e.hovered.element.value !== T && ((j = T == null ? void 0 : T.events) != null && j.onLeave && T.events.onLeave(e), (K = (J = e.hovered.element.value) == null ? void 0 : J.events) != null && K.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), (te = (ee = e.hovered.zone.value) == null ? void 0 : ee.events) != null && te.onHover && e.hovered.zone.value.events.onHover(e)), r = requestAnimationFrame(g);
416
+ }, y = () => {
417
+ g();
418
+ }, o = () => {
419
419
  r !== null && (cancelAnimationFrame(r), r = null);
420
420
  };
421
421
  return {
422
- activate: (o) => {
423
- e.draggingElements.value = s(t.value), n(o), p();
422
+ activate: (l) => {
423
+ e.draggingElements.value = s(t.value), n(l), y();
424
424
  },
425
- track: (o) => {
426
- u(o);
425
+ track: (l) => {
426
+ u(l);
427
427
  },
428
428
  deactivate: () => {
429
- var o, d;
430
- c(), e.hovered.zone.value ? (d = (o = e.hovered.zone.value.events).onDrop) == null || d.call(o, e) : e.draggingElements.value.forEach(
431
- (m) => {
432
- var h, I;
433
- return (I = (h = m.events).onEnd) == null ? void 0 : I.call(h, e);
429
+ var l, d;
430
+ c(), e.hovered.zone.value ? (d = (l = e.hovered.zone.value.events).onDrop) == null || d.call(l, e) : e.draggingElements.value.forEach(
431
+ (h) => {
432
+ var m, E;
433
+ return (E = (m = h.events).onEnd) == null ? void 0 : E.call(m, e);
434
434
  }
435
- ), e.draggingElements.value = [], e.selectedElements.value = [], e.hovered.zone.value = null, e.hovered.element.value = null, l();
435
+ ), e.draggingElements.value = [], e.selectedElements.value = [], e.hovered.zone.value = null, e.hovered.element.value = null, o();
436
436
  }
437
437
  };
438
438
  }, Fe = (t) => {
@@ -442,35 +442,37 @@ const C = xe(() => {
442
442
  unregisterElement: u,
443
443
  isDragging: c,
444
444
  isOvered: r,
445
- isAllowed: s
446
- } = Re(t), { disableInteractions: v, enableInteractions: f } = Ae(), p = C(), { activate: l, track: g, deactivate: x } = $e(e), y = (h) => {
447
- t != null && t.container && (p.activeContainer.component.value = we(t.container)), v(), l(h), document.addEventListener("pointermove", o), document.addEventListener("pointerup", m), document.addEventListener("wheel", d);
448
- }, o = (h) => {
449
- g(h);
450
- }, d = (h) => {
451
- g(h);
445
+ isAllowed: s,
446
+ isVisible: v
447
+ } = Re(t), { disableInteractions: g, enableInteractions: y } = Ae(), o = C(), { activate: f, track: x, deactivate: p } = $e(e), l = (E) => {
448
+ t != null && t.container && (o.activeContainer.component.value = we(t.container)), g(), f(E), document.addEventListener("pointermove", d), document.addEventListener("pointerup", m), document.addEventListener("wheel", h);
449
+ }, d = (E) => {
450
+ x(E);
451
+ }, h = (E) => {
452
+ x(E);
452
453
  }, m = () => {
453
- p.activeContainer.component.value = null, f(), x(), document.removeEventListener("pointermove", o), document.removeEventListener("pointerup", m), document.removeEventListener("wheel", d);
454
+ o.activeContainer.component.value = null, y(), p(), document.removeEventListener("pointermove", d), document.removeEventListener("pointerup", m), document.removeEventListener("wheel", h);
454
455
  };
455
456
  return A(n), W(u), {
456
- pointerPosition: p.pointerPosition,
457
+ pointerPosition: o.pointerPosition,
457
458
  elementRef: e,
458
459
  isDragging: c,
459
460
  isOvered: r,
460
461
  isAllowed: s,
461
- handleDragStart: y
462
+ handleDragStart: l,
463
+ isVisible: v
462
464
  };
463
- }, Xe = (t) => {
464
- const { zones: e, hovered: n, draggingElements: u, isDragging: c } = C(), r = E(null), s = w(() => {
465
- var l;
466
- return ((l = n.zone.value) == null ? void 0 : l.node) === r.value;
467
- }), v = w(() => {
465
+ }, be = (t) => {
466
+ const { zones: e, hovered: n, draggingElements: u, isDragging: c } = C(), r = w(null), s = P(() => {
467
+ var o;
468
+ return ((o = n.zone.value) == null ? void 0 : o.node) === r.value;
469
+ }), v = P(() => {
468
470
  if (!r.value || !c.value) return !1;
469
- const l = e.value.find(
470
- (g) => g.node === r.value
471
+ const o = e.value.find(
472
+ (f) => f.node === r.value
471
473
  );
472
- return l != null && l.groups.length ? !u.value.some((g) => g.groups.length ? !g.groups.some(
473
- (x) => l.groups.includes(x)
474
+ return o != null && o.groups.length ? !u.value.some((f) => f.groups.length ? !f.groups.some(
475
+ (x) => o.groups.includes(x)
474
476
  ) : !1) : !0;
475
477
  });
476
478
  return { elementRef: r, registerZone: () => {
@@ -483,58 +485,58 @@ const C = xe(() => {
483
485
  }), r.value.setAttribute("data-dnd-droppable", "true");
484
486
  }, unregisterZone: () => {
485
487
  if (!r.value) throw new Error("elementRef is not set");
486
- const l = e.value.findIndex(
487
- (g) => g.node === r.value
488
+ const o = e.value.findIndex(
489
+ (f) => f.node === r.value
488
490
  );
489
- l !== -1 && e.value.splice(l, 1);
491
+ o !== -1 && e.value.splice(o, 1);
490
492
  }, isOvered: s, isAllowed: v };
491
493
  }, Ue = (t) => {
492
- const { elementRef: e, registerZone: n, unregisterZone: u, isOvered: c, isAllowed: r } = Xe(t);
494
+ const { elementRef: e, registerZone: n, unregisterZone: u, isOvered: c, isAllowed: r } = be(t);
493
495
  return A(n), W(u), { elementRef: e, isOvered: c, isAllowed: r };
494
496
  }, We = (t) => {
495
- const { selectedElements: e, elements: n } = C(), u = w(
496
- () => n.value.find((l) => l.node === t.value)
497
- ), c = w(
498
- () => e.value.some((l) => l.node === t.value)
499
- ), r = w(() => t.value ? e.value.some(
500
- (l) => l.node && M(
501
- l.node,
497
+ const { selectedElements: e, elements: n } = C(), u = P(
498
+ () => n.value.find((o) => o.node === t.value)
499
+ ), c = P(
500
+ () => e.value.some((o) => o.node === t.value)
501
+ ), r = P(() => t.value ? e.value.some(
502
+ (o) => o.node && M(
503
+ o.node,
502
504
  t.value
503
505
  )
504
- ) : !1), s = w(() => t.value ? e.value.some(
505
- (l) => l.node && M(
506
+ ) : !1), s = P(() => t.value ? e.value.some(
507
+ (o) => o.node && M(
506
508
  t.value,
507
- l.node
509
+ o.node
508
510
  )
509
511
  ) : !1), v = () => {
510
512
  u.value && (e.value = e.value.filter(
511
- (l) => l.node !== t.value
513
+ (o) => o.node !== t.value
512
514
  ));
513
- }, f = () => {
515
+ }, g = () => {
514
516
  u.value && (r.value && (e.value = e.value.filter(
515
- (l) => l.node && !M(
516
- l.node,
517
+ (o) => o.node && !M(
518
+ o.node,
517
519
  t.value
518
520
  )
519
521
  )), s.value && (e.value = e.value.filter(
520
- (l) => l.node && !M(
522
+ (o) => o.node && !M(
521
523
  t.value,
522
- l.node
524
+ o.node
523
525
  )
524
526
  )), e.value.push(u.value));
525
527
  };
526
528
  return {
527
529
  handleUnselect: v,
528
- handleSelect: f,
530
+ handleSelect: g,
529
531
  handleToggleSelect: () => {
530
- u.value && (e.value.some((l) => l.node === t.value) ? v() : f());
532
+ u.value && (e.value.some((o) => o.node === t.value) ? v() : g());
531
533
  },
532
534
  isSelected: c,
533
535
  isParentOfSelected: r
534
536
  };
535
537
  };
536
538
  export {
537
- be as DragOverlay,
539
+ Ye as DragOverlay,
538
540
  k as getBoundingBox,
539
541
  C as useDnDStore,
540
542
  Fe as useDraggable,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue-dnd-kit/core",
3
- "version": "0.0.27-beta",
3
+ "version": "0.0.28-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",