@vue-dnd-kit/core 0.0.37-beta → 0.0.39-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.
@@ -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,z=()=>{};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=z,o,s,v,f,h;!n.isRef(t[0])&&typeof t[0]=="object"?{delay:s,trailing:v=!0,leading:f=!0,rejectOnCancel:h=!1}=t[0]:[s,v=!0,f=!0,h=!1]=t;const l=()=>{r&&(clearTimeout(r),r=void 0,c(),c=z)};return P=>{const p=n.toValue(s),E=Date.now()-e,a=()=>o=P();return l(),p<=0?(e=Date.now(),a()):(E>p&&(f||!i)?(e=Date.now(),a()):v&&(o=new Promise((m,y)=>{c=h?y:m,r=setTimeout(()=>{e=Date.now(),i=!0,m(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 V(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),h=n.computed(()=>{const E=n.toValue(t);return se(E).map(V).filter(re)});let l=z;const g=n.shallowRef(v),P=f.value?n.watch(()=>[h.value,V(i),g.value],([E,a])=>{if(l(),!g.value||!E.length)return;const m=new IntersectionObserver(e,{root:V(a),rootMargin:c,threshold:o});E.forEach(y=>y&&m.observe(y)),l=()=>{m.disconnect(),l=z}},{immediate:v,flush:"post"}):z,p=()=>{l(),P(),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,h=>{let l=v.value,g=0;for(const P of h)P.time>=g&&(g=P.time,l=P.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.reduce((h,l,g)=>{var P;return(P=l.isVisible)!=null&&P.value&&h.push(g),h},[])),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,h;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)-(((h=r.offset.pixel.value)==null?void 0:h.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,h)=>{var l,g;return n.openBlock(),n.createElementBlock("div",{key:h,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),h=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:h,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,D;const m=e.selectedElements.value.some(x=>x.node===a);if(e.selectedElements.value.length&&m)return e.selectedElements.value.map(x=>{var L,b;return{...x,initialHTML:((L=x.node)==null?void 0:L.outerHTML)??"",initialRect:(b=x.node)==null?void 0:b.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:(D=y.node)==null?void 0:D.getBoundingClientRect()}]:[]},v=(a,m)=>{const y=Math.max(0,Math.min(a.x+a.width,m.x+m.width)-Math.max(a.x,m.x)),w=Math.max(0,Math.min(a.y+a.height,m.y+m.height)-Math.max(a.y,m.y)),D=y*w,x=a.width*a.height,L=m.width*m.height;return(D/x*100+D/L*100)/2},f=ie(()=>{var F,U,Z,$,W,X,Y,j,q,G;const a=O(e.activeContainer.ref.value),m=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),b=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),B=J(m,S),H=e.elements.value.filter(k=>k!==u&&k.node&&u.node&&C(u.node,k.node)).length;return{element:u,isPointerInElement:M,overlapPercent:_,depth:H,centerDistance:B}}).sort((u,d)=>{if(!x){if(u.isPointerInElement&&d.isPointerInElement)return d.depth-u.depth;if(u.isPointerInElement!==d.isPointerInElement)return u.isPointerInElement?-1:1}return Math.abs(u.overlapPercent-d.overlapPercent)<=1?u.centerDistance-d.centerDistance:d.overlapPercent-u.overlapPercent}),Q=e.zones.value.filter(u=>{if(!u.node||L.some(S=>S&&C(u.node,S))||u.groups.length&&!!e.draggingElements.value.some(M=>M.groups.length?!M.groups.some(_=>u.groups.includes(_)):!1))return!1;const d=O(u.node);return d&&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),B=J(m,S),H=e.zones.value.filter(k=>k!==u&&k.node&&u.node&&C(u.node,k.node)).length;return{zone:u,isPointerInElement:M,overlapPercent:_,depth:H,centerDistance:B}}).sort((u,d)=>{if(!x){if(u.isPointerInElement&&d.isPointerInElement)return d.depth-u.depth;if(u.isPointerInElement!==d.isPointerInElement)return u.isPointerInElement?-1:1}return Math.abs(u.overlapPercent-d.overlapPercent)<=1?u.centerDistance-d.centerDistance:d.overlapPercent-u.overlapPercent}),T=e.hovered.element.value,R=e.hovered.zone.value;e.hovered.element.value=((Z=b[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),h=()=>{f(),o=requestAnimationFrame(h)},l=()=>{h()},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,m;c(),e.hovered.zone.value?(m=(a=e.hovered.zone.value.events).onDrop)==null||m.call(a,e):e.draggingElements.value.forEach(y=>{var w,D;return(D=(w=y.events).onEnd)==null?void 0:D.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:h}=Ee(),{activeContainer:l,pointerPosition:g}=I(),{activate:P,track:p,deactivate:E}=De(e),a=D=>{t!=null&&t.container&&(l.component.value=n.markRaw(t.container)),f(),P(D),document.addEventListener("pointermove",m),document.addEventListener("pointerup",w),document.addEventListener("wheel",y)},m=D=>p(D),y=D=>p(D),w=()=>{l.component.value=null,h(),E(),document.removeEventListener("pointermove",m),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(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(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.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,z=()=>{};function oe(t,e){function r(...i){return new Promise((c,l)=>{Promise.resolve(t(()=>e.apply(this,i),{fn:e,thisArg:this,args:i})).then(c).catch(l)})}return r}function le(...t){let e=0,r,i=!0,c=z,l,s,v,f,h;!n.isRef(t[0])&&typeof t[0]=="object"?{delay:s,trailing:v=!0,leading:f=!0,rejectOnCancel:h=!1}=t[0]:[s,v=!0,f=!0,h=!1]=t;const o=()=>{r&&(clearTimeout(r),r=void 0,c(),c=z)};return D=>{const p=n.toValue(s),E=Date.now()-e,a=()=>l=D();return o(),p<=0?(e=Date.now(),a()):(E>p&&(f||!i)?(e=Date.now(),a()):v&&(l=new Promise((m,y)=>{c=h?y:m,r=setTimeout(()=>{e=Date.now(),i=!0,m(a()),o()},Math.max(0,p-E))})),!f&&!r&&(r=setTimeout(()=>i=!0,p)),i=!1,l)}}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 V(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:l=0,window:s=K,immediate:v=!0}=r,f=ce(()=>s&&"IntersectionObserver"in s),h=n.computed(()=>{const E=n.toValue(t);return se(E).map(V).filter(re)});let o=z;const g=n.shallowRef(v),D=f.value?n.watch(()=>[h.value,V(i),g.value],([E,a])=>{if(o(),!g.value||!E.length)return;const m=new IntersectionObserver(e,{root:V(a),rootMargin:c,threshold:l});E.forEach(y=>y&&m.observe(y)),o=()=>{m.disconnect(),o=z}},{immediate:v,flush:"post"}):z,p=()=>{o(),D(),g.value=!1};return ee(p),{isSupported:f,isActive:g,pause(){o(),g.value=!1},resume(){g.value=!0},stop:p}}function ve(t,e={}){const{window:r=K,scrollTarget:i,threshold:c=0,rootMargin:l,once:s=!1}=e,v=n.shallowRef(!1),{stop:f}=de(t,h=>{let o=v.value,g=0;for(const D of h)D.time>=g&&(g=D.time,o=D.isIntersecting);v.value=o,s&&ae(v,()=>{f()})},{root:i,window:r,threshold:c,rootMargin:n.toValue(l)});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.filter(h=>{var o;return(o=h.isVisible)==null?void 0:o.value}).map((h,o)=>o)),l=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:l,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(),l=n.computed(()=>{var s,v,f,h;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)-(((h=r.offset.pixel.value)==null?void 0:h.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(l.value)},[(n.openBlock(!0),n.createElementBlock(n.Fragment,null,n.renderList(n.unref(c),(f,h)=>{var o,g;return n.openBlock(),n.createElementBlock("div",{key:h,innerHTML:f.initialHTML,style:n.normalizeStyle({width:`${(o=f.initialRect)==null?void 0:o.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:l}=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),h=n.computed(()=>r.value.some(p=>p.node===s.value)),o=n.computed(()=>{if(!s.value||!l.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:h,isOvered:v,isAllowed:o,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",l),window.addEventListener("selectstart",l),window.addEventListener("touchstart",l),window.addEventListener("touchmove",l)},c=()=>{const s=document.body;s.style.userSelect=t,s.style.touchAction=e,s.style.overscrollBehavior=r,window.removeEventListener("contextmenu",l),window.removeEventListener("selectstart",l),window.removeEventListener("touchstart",l),window.removeEventListener("touchmove",l)},l=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:l=>{e.pointerPosition.start.value={x:l.clientX,y:l.clientY},e.pointerPosition.current.value={x:l.clientX,y:l.clientY};const{pixel:s,percent:v}=we(t.value,{x:l.clientX,y:l.clientY});e.pointerPosition.offset.pixel.value=s,e.pointerPosition.offset.percent.value=v},onPointerMove:l=>{e.pointerPosition.current.value={x:l.clientX,y:l.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 l=null;const s=a=>{var w,P;const m=e.selectedElements.value.some(x=>x.node===a);if(e.selectedElements.value.length&&m)return e.selectedElements.value.map(x=>{var L,b;return{...x,initialHTML:((L=x.node)==null?void 0:L.outerHTML)??"",initialRect:(b=x.node)==null?void 0:b.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,m)=>{const y=Math.max(0,Math.min(a.x+a.width,m.x+m.width)-Math.max(a.x,m.x)),w=Math.max(0,Math.min(a.y+a.height,m.y+m.height)-Math.max(a.y,m.y)),P=y*w,x=a.width*a.height,L=m.width*m.height;return(P/x*100+P/L*100)/2},f=ie(()=>{var F,U,Z,$,W,X,Y,j,q,G;const a=O(e.activeContainer.ref.value),m=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),b=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),B=J(m,S),H=e.elements.value.filter(k=>k!==u&&k.node&&u.node&&C(u.node,k.node)).length;return{element:u,isPointerInElement:M,overlapPercent:_,depth:H,centerDistance:B}}).sort((u,d)=>{if(!x){if(u.isPointerInElement&&d.isPointerInElement)return d.depth-u.depth;if(u.isPointerInElement!==d.isPointerInElement)return u.isPointerInElement?-1:1}return Math.abs(u.overlapPercent-d.overlapPercent)<=1?u.centerDistance-d.centerDistance:d.overlapPercent-u.overlapPercent}),Q=e.zones.value.filter(u=>{if(!u.node||L.some(S=>S&&C(u.node,S))||u.groups.length&&!!e.draggingElements.value.some(M=>M.groups.length?!M.groups.some(_=>u.groups.includes(_)):!1))return!1;const d=O(u.node);return d&&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),B=J(m,S),H=e.zones.value.filter(k=>k!==u&&k.node&&u.node&&C(u.node,k.node)).length;return{zone:u,isPointerInElement:M,overlapPercent:_,depth:H,centerDistance:B}}).sort((u,d)=>{if(!x){if(u.isPointerInElement&&d.isPointerInElement)return d.depth-u.depth;if(u.isPointerInElement!==d.isPointerInElement)return u.isPointerInElement?-1:1}return Math.abs(u.overlapPercent-d.overlapPercent)<=1?u.centerDistance-d.centerDistance:d.overlapPercent-u.overlapPercent}),T=e.hovered.element.value,R=e.hovered.zone.value;e.hovered.element.value=((Z=b[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),h=()=>{f(),l=requestAnimationFrame(h)},o=()=>{h()},g=()=>{l!==null&&(cancelAnimationFrame(l),l=null)};return{activate:a=>{e.draggingElements.value=s(t.value),r(a),o()},track:a=>{i(a)},deactivate:()=>{var a,m;c(),e.hovered.zone.value?(m=(a=e.hovered.zone.value.events).onDrop)==null||m.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:l,isAllowed:s,isVisible:v}=ye(t),{disableInteractions:f,enableInteractions:h}=Ee(),{activeContainer:o,pointerPosition:g}=I(),{activate:D,track:p,deactivate:E}=De(e),a=P=>{t!=null&&t.container&&(o.component.value=n.markRaw(t.container)),f(),D(P),document.addEventListener("pointermove",m),document.addEventListener("pointerup",w),document.addEventListener("wheel",y)},m=P=>p(P),y=P=>p(P),w=()=>{o.component.value=null,h(),E(),document.removeEventListener("pointermove",m),document.removeEventListener("pointerup",w),document.removeEventListener("wheel",y)};return n.onMounted(r),n.onBeforeUnmount(i),{pointerPosition:g,elementRef:e,isDragging:c,isOvered:l,isAllowed:s,handleDragStart:a,isVisible:v}},Se=t=>{const{zones:e,hovered:r,draggingElements:i,isDragging:c}=I(),l=n.ref(null),s=n.computed(()=>{var o;return((o=r.zone.value)==null?void 0:o.node)===l.value}),v=n.computed(()=>{if(!l.value||!c.value)return!1;const o=e.value.find(g=>g.node===l.value);return o!=null&&o.groups.length?!i.value.some(g=>g.groups.length?!g.groups.some(D=>o.groups.includes(D)):!1):!0});return{elementRef:l,registerZone:()=>{if(!l.value)throw new Error("elementRef is not set");e.value.push({node:l.value,groups:(t==null?void 0:t.groups)??[],events:(t==null?void 0:t.events)??{},data:(t==null?void 0:t.data)??void 0}),l.value.setAttribute("data-dnd-droppable","true")},unregisterZone:()=>{if(!l.value)throw new Error("elementRef is not set");const o=e.value.findIndex(g=>g.node===l.value);o!==-1&&e.value.splice(o,1)},isOvered:s,isAllowed:v}},Me=t=>{const{elementRef:e,registerZone:r,unregisterZone:i,isOvered:c,isAllowed:l}=Se(t);return n.onMounted(r),n.onBeforeUnmount(i),{elementRef:e,isOvered:c,isAllowed:l}},Ie=t=>{const{selectedElements:e,elements:r}=I(),i=n.computed(()=>r.value.find(o=>o.node===t.value)),c=n.computed(()=>e.value.some(o=>o.node===t.value)),l=n.computed(()=>t.value?e.value.some(o=>o.node&&C(o.node,t.value)):!1),s=n.computed(()=>t.value?e.value.some(o=>o.node&&C(t.value,o.node)):!1),v=()=>{i.value&&(e.value=e.value.filter(o=>o.node!==t.value))},f=()=>{i.value&&(l.value&&(e.value=e.value.filter(o=>o.node&&!C(o.node,t.value))),s.value&&(e.value=e.value.filter(o=>o.node&&!C(t.value,o.node))),e.value.push(i.value))};return{handleUnselect:v,handleSelect:f,handleToggleSelect:()=>{i.value&&(e.value.some(o=>o.node===t.value)?v():f())},isSelected:c,isParentOfSelected:l}};exports.DragOverlay=he;exports.getBoundingBox=O;exports.useDnDStore=I;exports.useDraggable=xe;exports.useDroppable=Me;exports.useSelection=Ie;
@@ -1,4 +1,4 @@
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 D, getCurrentInstance as me, onMounted as F, ref as x, 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";
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
2
  function De(t) {
3
3
  return ge() ? (he(t), !0) : !1;
4
4
  }
@@ -13,25 +13,25 @@ const Se = (t) => t != null, H = () => {
13
13
  };
14
14
  function Le(t, e) {
15
15
  function n(...s) {
16
- return new Promise((u, r) => {
17
- Promise.resolve(t(() => e.apply(this, s), { fn: e, thisArg: this, args: s })).then(u).catch(r);
16
+ return new Promise((u, o) => {
17
+ Promise.resolve(t(() => e.apply(this, s), { fn: e, thisArg: this, args: s })).then(u).catch(o);
18
18
  });
19
19
  }
20
20
  return n;
21
21
  }
22
22
  function Ce(...t) {
23
- let e = 0, n, s = !0, u = H, r, l, v, d, h;
23
+ let e = 0, n, s = !0, u = H, o, l, v, d, h;
24
24
  !fe(t[0]) && typeof t[0] == "object" ? { delay: l, trailing: v = !0, leading: d = !0, rejectOnCancel: h = !1 } = t[0] : [l, v = !0, d = !0, h = !1] = t;
25
- const o = () => {
25
+ const r = () => {
26
26
  n && (clearTimeout(n), n = void 0, u(), u = H);
27
27
  };
28
- return (w) => {
29
- const m = V(l), y = Date.now() - e, i = () => r = w();
30
- return o(), m <= 0 ? (e = Date.now(), i()) : (y > m && (d || !s) ? (e = Date.now(), i()) : v && (r = new Promise((g, p) => {
28
+ return (D) => {
29
+ const m = V(l), y = Date.now() - e, i = () => o = D();
30
+ return r(), m <= 0 ? (e = Date.now(), i()) : (y > m && (d || !s) ? (e = Date.now(), i()) : v && (o = new Promise((g, p) => {
31
31
  u = h ? p : g, n = setTimeout(() => {
32
- e = Date.now(), s = !0, g(i()), o();
32
+ e = Date.now(), s = !0, g(i()), r();
33
33
  }, Math.max(0, m - y));
34
- })), !d && !n && (n = setTimeout(() => s = !0, m)), s = !1, r);
34
+ })), !d && !n && (n = setTimeout(() => s = !0, m)), s = !1, o);
35
35
  };
36
36
  }
37
37
  function _e(t) {
@@ -61,46 +61,46 @@ function ke() {
61
61
  }
62
62
  function ze(t) {
63
63
  const e = ke();
64
- return D(() => (e.value, !!t()));
64
+ return x(() => (e.value, !!t()));
65
65
  }
66
66
  function Re(t, e, n = {}) {
67
67
  const {
68
68
  root: s,
69
69
  rootMargin: u = "0px",
70
- threshold: r = 0,
70
+ threshold: o = 0,
71
71
  window: l = ue,
72
72
  immediate: v = !0
73
- } = n, d = ze(() => l && "IntersectionObserver" in l), h = D(() => {
73
+ } = n, d = ze(() => l && "IntersectionObserver" in l), h = x(() => {
74
74
  const y = V(t);
75
75
  return _e(y).map(X).filter(Se);
76
76
  });
77
- let o = H;
78
- const f = U(v), w = d.value ? ie(
77
+ let r = H;
78
+ const f = U(v), D = d.value ? ie(
79
79
  () => [h.value, X(s), f.value],
80
80
  ([y, i]) => {
81
- if (o(), !f.value || !y.length)
81
+ if (r(), !f.value || !y.length)
82
82
  return;
83
83
  const g = new IntersectionObserver(
84
84
  e,
85
85
  {
86
86
  root: X(i),
87
87
  rootMargin: u,
88
- threshold: r
88
+ threshold: o
89
89
  }
90
90
  );
91
- y.forEach((p) => p && g.observe(p)), o = () => {
92
- g.disconnect(), o = H;
91
+ y.forEach((p) => p && g.observe(p)), r = () => {
92
+ g.disconnect(), r = H;
93
93
  };
94
94
  },
95
95
  { immediate: v, flush: "post" }
96
96
  ) : H, m = () => {
97
- o(), w(), f.value = !1;
97
+ r(), D(), f.value = !1;
98
98
  };
99
99
  return De(m), {
100
100
  isSupported: d,
101
101
  isActive: f,
102
102
  pause() {
103
- o(), f.value = !1;
103
+ r(), f.value = !1;
104
104
  },
105
105
  resume() {
106
106
  f.value = !0;
@@ -113,15 +113,15 @@ function He(t, e = {}) {
113
113
  window: n = ue,
114
114
  scrollTarget: s,
115
115
  threshold: u = 0,
116
- rootMargin: r,
116
+ rootMargin: o,
117
117
  once: l = !1
118
118
  } = e, v = U(!1), { stop: d } = Re(
119
119
  t,
120
120
  (h) => {
121
- let o = v.value, f = 0;
122
- for (const w of h)
123
- w.time >= f && (f = w.time, o = w.isIntersecting);
124
- v.value = o, l && Te(v, () => {
121
+ let r = v.value, f = 0;
122
+ for (const D of h)
123
+ D.time >= f && (f = D.time, r = D.isIntersecting);
124
+ v.value = r, l && Te(v, () => {
125
125
  d();
126
126
  });
127
127
  },
@@ -129,29 +129,29 @@ function He(t, e = {}) {
129
129
  root: s,
130
130
  window: n,
131
131
  threshold: u,
132
- rootMargin: V(r)
132
+ rootMargin: V(o)
133
133
  }
134
134
  );
135
135
  return v;
136
136
  }
137
137
  const C = Ie(() => {
138
- const t = x([]), e = D(() => t.value.length > 0), n = {
139
- component: x(null),
140
- ref: x(null)
141
- }, s = x([]), u = D(
142
- () => s.value.reduce((h, o, f) => {
143
- var w;
144
- return (w = o.isVisible) != null && w.value && h.push(f), h;
145
- }, [])
146
- ), r = x([]), l = x([]), v = {
147
- zone: x(null),
148
- element: x(null)
138
+ const t = P([]), e = x(() => t.value.length > 0), n = {
139
+ component: P(null),
140
+ ref: P(null)
141
+ }, s = P([]), u = x(
142
+ () => s.value.filter((h) => {
143
+ var r;
144
+ return (r = h.isVisible) == null ? void 0 : r.value;
145
+ }).map((h, r) => r)
146
+ ), o = P([]), l = P([]), v = {
147
+ zone: P(null),
148
+ element: P(null)
149
149
  }, d = {
150
- current: x(null),
151
- start: x(null),
150
+ current: P(null),
151
+ start: P(null),
152
152
  offset: {
153
- percent: x(null),
154
- pixel: x(null)
153
+ percent: P(null),
154
+ pixel: P(null)
155
155
  }
156
156
  };
157
157
  return {
@@ -159,14 +159,14 @@ const C = Ie(() => {
159
159
  activeContainer: n,
160
160
  elements: s,
161
161
  draggingElements: t,
162
- selectedElements: r,
162
+ selectedElements: o,
163
163
  zones: l,
164
164
  visibleElements: u,
165
165
  hovered: v,
166
166
  pointerPosition: d
167
167
  };
168
168
  }), Ae = () => {
169
- const t = x(null), { draggingElements: e, pointerPosition: n, isDragging: s, activeContainer: u } = C();
169
+ const t = P(null), { draggingElements: e, pointerPosition: n, isDragging: s, activeContainer: u } = C();
170
170
  return F(() => {
171
171
  u.ref = t;
172
172
  }), j(() => {
@@ -180,7 +180,7 @@ const C = Ie(() => {
180
180
  }, be = ["innerHTML"], Ve = /* @__PURE__ */ ae({
181
181
  __name: "DefaultOverlay",
182
182
  setup(t) {
183
- const { elementRef: e, pointerPosition: n, isDragging: s, draggingElements: u } = Ae(), r = D(() => {
183
+ const { elementRef: e, pointerPosition: n, isDragging: s, draggingElements: u } = Ae(), o = x(() => {
184
184
  var l, v, d, h;
185
185
  return {
186
186
  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) - (((h = n.offset.pixel.value) == null ? void 0 : h.y) ?? 0)}px, 0)`,
@@ -195,15 +195,15 @@ const C = Ie(() => {
195
195
  key: 0,
196
196
  ref_key: "elementRef",
197
197
  ref: e,
198
- style: oe(r.value)
198
+ style: oe(o.value)
199
199
  }, [
200
200
  (b(!0), W(ye, null, Ee(re(u), (d, h) => {
201
- var o, f;
201
+ var r, f;
202
202
  return b(), W("div", {
203
203
  key: h,
204
204
  innerHTML: d.initialHTML,
205
205
  style: oe({
206
- width: `${(o = d.initialRect) == null ? void 0 : o.width}px`,
206
+ width: `${(r = d.initialRect) == null ? void 0 : r.width}px`,
207
207
  height: `${(f = d.initialRect) == null ? void 0 : f.height}px`
208
208
  })
209
209
  }, null, 12, be);
@@ -213,7 +213,7 @@ const C = Ie(() => {
213
213
  }), Ge = /* @__PURE__ */ ae({
214
214
  __name: "DragOverlay",
215
215
  setup(t) {
216
- const { activeContainer: e } = C(), n = D(
216
+ const { activeContainer: e } = C(), n = x(
217
217
  () => e.component.value ?? Ve
218
218
  );
219
219
  return (s, u) => (b(), we(Pe(n.value)));
@@ -224,16 +224,16 @@ const C = Ie(() => {
224
224
  draggingElements: n,
225
225
  hovered: s,
226
226
  selectedElements: u,
227
- isDragging: r
228
- } = C(), l = x(null), v = D(
227
+ isDragging: o
228
+ } = C(), l = P(null), v = x(
229
229
  () => {
230
230
  var m;
231
231
  return ((m = s.element.value) == null ? void 0 : m.node) === l.value;
232
232
  }
233
- ), d = He(l), h = D(
233
+ ), d = He(l), h = x(
234
234
  () => n.value.some((m) => m.node === l.value)
235
- ), o = D(() => {
236
- if (!l.value || !r.value) return !1;
235
+ ), r = x(() => {
236
+ if (!l.value || !o.value) return !1;
237
237
  const m = e.value.find(
238
238
  (y) => y.node === l.value
239
239
  );
@@ -267,18 +267,18 @@ const C = Ie(() => {
267
267
  },
268
268
  isDragging: h,
269
269
  isOvered: v,
270
- isAllowed: o,
270
+ isAllowed: r,
271
271
  isVisible: d
272
272
  };
273
273
  }, $e = () => {
274
274
  let t = "", e = "", n = "";
275
275
  const s = () => {
276
276
  const l = document.body;
277
- 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);
277
+ 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", o), window.addEventListener("selectstart", o), window.addEventListener("touchstart", o), window.addEventListener("touchmove", o);
278
278
  }, u = () => {
279
279
  const l = document.body;
280
- 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);
281
- }, r = (l) => l.preventDefault();
280
+ l.style.userSelect = t, l.style.touchAction = e, l.style.overscrollBehavior = n, window.removeEventListener("contextmenu", o), window.removeEventListener("selectstart", o), window.removeEventListener("touchstart", o), window.removeEventListener("touchmove", o);
281
+ }, o = (l) => l.preventDefault();
282
282
  return {
283
283
  disableInteractions: s,
284
284
  enableInteractions: u
@@ -327,21 +327,21 @@ const C = Ie(() => {
327
327
  }, L = (t, e) => t ? e.contains(t) : !1, Xe = (t) => {
328
328
  const e = C();
329
329
  return {
330
- onPointerStart: (r) => {
331
- e.pointerPosition.start.value = { x: r.clientX, y: r.clientY }, e.pointerPosition.current.value = {
332
- x: r.clientX,
333
- y: r.clientY
330
+ onPointerStart: (o) => {
331
+ e.pointerPosition.start.value = { x: o.clientX, y: o.clientY }, e.pointerPosition.current.value = {
332
+ x: o.clientX,
333
+ y: o.clientY
334
334
  };
335
335
  const { pixel: l, percent: v } = We(t.value, {
336
- x: r.clientX,
337
- y: r.clientY
336
+ x: o.clientX,
337
+ y: o.clientY
338
338
  });
339
339
  e.pointerPosition.offset.pixel.value = l, e.pointerPosition.offset.percent.value = v;
340
340
  },
341
- onPointerMove: (r) => {
341
+ onPointerMove: (o) => {
342
342
  e.pointerPosition.current.value = {
343
- x: r.clientX,
344
- y: r.clientY
343
+ x: o.clientX,
344
+ y: o.clientY
345
345
  };
346
346
  },
347
347
  onPointerEnd: () => {
@@ -350,9 +350,9 @@ const C = Ie(() => {
350
350
  };
351
351
  }, Ye = (t) => {
352
352
  const e = C(), { onPointerStart: n, onPointerMove: s, onPointerEnd: u } = Xe(t);
353
- let r = null;
353
+ let o = null;
354
354
  const l = (i) => {
355
- var E, P;
355
+ var E, w;
356
356
  const g = e.selectedElements.value.some(
357
357
  (I) => I.node === i
358
358
  );
@@ -373,7 +373,7 @@ const C = Ie(() => {
373
373
  {
374
374
  ...p,
375
375
  initialHTML: ((E = p.node) == null ? void 0 : E.outerHTML) ?? "",
376
- initialRect: (P = p.node) == null ? void 0 : P.getBoundingClientRect()
376
+ initialRect: (w = p.node) == null ? void 0 : w.getBoundingClientRect()
377
377
  }
378
378
  ] : [];
379
379
  }, v = (i, g) => {
@@ -383,8 +383,8 @@ const C = Ie(() => {
383
383
  ), E = Math.max(
384
384
  0,
385
385
  Math.min(i.y + i.height, g.y + g.height) - Math.max(i.y, g.y)
386
- ), P = p * E, I = i.width * i.height, _ = g.width * g.height;
387
- return (P / I * 100 + P / _ * 100) / 2;
386
+ ), w = p * E, I = i.width * i.height, _ = g.width * g.height;
387
+ return (w / I * 100 + w / _ * 100) / 2;
388
388
  }, d = Oe(() => {
389
389
  var G, N, q, B, J, K, Q, ee, te, ne;
390
390
  const i = k(e.activeContainer.ref.value), g = 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) => {
@@ -449,15 +449,15 @@ const C = Ie(() => {
449
449
  }), z = e.hovered.element.value, R = e.hovered.zone.value;
450
450
  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));
451
451
  }, 1e3), h = () => {
452
- d(), r = requestAnimationFrame(h);
453
- }, o = () => {
452
+ d(), o = requestAnimationFrame(h);
453
+ }, r = () => {
454
454
  h();
455
455
  }, f = () => {
456
- r !== null && (cancelAnimationFrame(r), r = null);
456
+ o !== null && (cancelAnimationFrame(o), o = null);
457
457
  };
458
458
  return {
459
459
  activate: (i) => {
460
- e.draggingElements.value = l(t.value), n(i), o();
460
+ e.draggingElements.value = l(t.value), n(i), r();
461
461
  },
462
462
  track: (i) => {
463
463
  s(i);
@@ -466,8 +466,8 @@ const C = Ie(() => {
466
466
  var i, g;
467
467
  u(), e.hovered.zone.value ? (g = (i = e.hovered.zone.value.events).onDrop) == null || g.call(i, e) : e.draggingElements.value.forEach(
468
468
  (p) => {
469
- var E, P;
470
- return (P = (E = p.events).onEnd) == null ? void 0 : P.call(E, e);
469
+ var E, w;
470
+ return (w = (E = p.events).onEnd) == null ? void 0 : w.call(E, e);
471
471
  }
472
472
  ), e.draggingElements.value = [], e.selectedElements.value = [], e.hovered.zone.value = null, e.hovered.element.value = null, f();
473
473
  }
@@ -478,83 +478,83 @@ const C = Ie(() => {
478
478
  registerElement: n,
479
479
  unregisterElement: s,
480
480
  isDragging: u,
481
- isOvered: r,
481
+ isOvered: o,
482
482
  isAllowed: l,
483
483
  isVisible: v
484
- } = Ze(t), { disableInteractions: d, enableInteractions: h } = $e(), { activeContainer: o, pointerPosition: f } = C(), { activate: w, track: m, deactivate: y } = Ye(e), i = (P) => {
485
- t != null && t.container && (o.component.value = xe(t.container)), d(), w(P), document.addEventListener("pointermove", g), document.addEventListener("pointerup", E), document.addEventListener("wheel", p);
486
- }, g = (P) => m(P), p = (P) => m(P), E = () => {
487
- o.component.value = null, h(), y(), document.removeEventListener("pointermove", g), document.removeEventListener("pointerup", E), document.removeEventListener("wheel", p);
484
+ } = Ze(t), { disableInteractions: d, enableInteractions: h } = $e(), { activeContainer: r, pointerPosition: f } = C(), { activate: D, track: m, deactivate: y } = Ye(e), i = (w) => {
485
+ t != null && t.container && (r.component.value = xe(t.container)), d(), D(w), document.addEventListener("pointermove", g), document.addEventListener("pointerup", E), document.addEventListener("wheel", p);
486
+ }, g = (w) => m(w), p = (w) => m(w), E = () => {
487
+ r.component.value = null, h(), y(), document.removeEventListener("pointermove", g), document.removeEventListener("pointerup", E), document.removeEventListener("wheel", p);
488
488
  };
489
489
  return F(n), j(s), {
490
490
  pointerPosition: f,
491
491
  elementRef: e,
492
492
  isDragging: u,
493
- isOvered: r,
493
+ isOvered: o,
494
494
  isAllowed: l,
495
495
  handleDragStart: i,
496
496
  isVisible: v
497
497
  };
498
498
  }, Ue = (t) => {
499
- const { zones: e, hovered: n, draggingElements: s, isDragging: u } = C(), r = x(null), l = D(() => {
500
- var o;
501
- return ((o = n.zone.value) == null ? void 0 : o.node) === r.value;
502
- }), v = D(() => {
503
- if (!r.value || !u.value) return !1;
504
- const o = e.value.find(
505
- (f) => f.node === r.value
499
+ const { zones: e, hovered: n, draggingElements: s, isDragging: u } = C(), o = P(null), l = x(() => {
500
+ var r;
501
+ return ((r = n.zone.value) == null ? void 0 : r.node) === o.value;
502
+ }), v = x(() => {
503
+ if (!o.value || !u.value) return !1;
504
+ const r = e.value.find(
505
+ (f) => f.node === o.value
506
506
  );
507
- return o != null && o.groups.length ? !s.value.some((f) => f.groups.length ? !f.groups.some(
508
- (w) => o.groups.includes(w)
507
+ return r != null && r.groups.length ? !s.value.some((f) => f.groups.length ? !f.groups.some(
508
+ (D) => r.groups.includes(D)
509
509
  ) : !1) : !0;
510
510
  });
511
- return { elementRef: r, registerZone: () => {
512
- if (!r.value) throw new Error("elementRef is not set");
511
+ return { elementRef: o, registerZone: () => {
512
+ if (!o.value) throw new Error("elementRef is not set");
513
513
  e.value.push({
514
- node: r.value,
514
+ node: o.value,
515
515
  groups: (t == null ? void 0 : t.groups) ?? [],
516
516
  events: (t == null ? void 0 : t.events) ?? {},
517
517
  data: (t == null ? void 0 : t.data) ?? void 0
518
- }), r.value.setAttribute("data-dnd-droppable", "true");
518
+ }), o.value.setAttribute("data-dnd-droppable", "true");
519
519
  }, unregisterZone: () => {
520
- if (!r.value) throw new Error("elementRef is not set");
521
- const o = e.value.findIndex(
522
- (f) => f.node === r.value
520
+ if (!o.value) throw new Error("elementRef is not set");
521
+ const r = e.value.findIndex(
522
+ (f) => f.node === o.value
523
523
  );
524
- o !== -1 && e.value.splice(o, 1);
524
+ r !== -1 && e.value.splice(r, 1);
525
525
  }, isOvered: l, isAllowed: v };
526
526
  }, qe = (t) => {
527
- const { elementRef: e, registerZone: n, unregisterZone: s, isOvered: u, isAllowed: r } = Ue(t);
528
- return F(n), j(s), { elementRef: e, isOvered: u, isAllowed: r };
527
+ const { elementRef: e, registerZone: n, unregisterZone: s, isOvered: u, isAllowed: o } = Ue(t);
528
+ return F(n), j(s), { elementRef: e, isOvered: u, isAllowed: o };
529
529
  }, Be = (t) => {
530
- const { selectedElements: e, elements: n } = C(), s = D(
531
- () => n.value.find((o) => o.node === t.value)
532
- ), u = D(
533
- () => e.value.some((o) => o.node === t.value)
534
- ), r = D(() => t.value ? e.value.some(
535
- (o) => o.node && L(
536
- o.node,
530
+ const { selectedElements: e, elements: n } = C(), s = x(
531
+ () => n.value.find((r) => r.node === t.value)
532
+ ), u = x(
533
+ () => e.value.some((r) => r.node === t.value)
534
+ ), o = x(() => t.value ? e.value.some(
535
+ (r) => r.node && L(
536
+ r.node,
537
537
  t.value
538
538
  )
539
- ) : !1), l = D(() => t.value ? e.value.some(
540
- (o) => o.node && L(
539
+ ) : !1), l = x(() => t.value ? e.value.some(
540
+ (r) => r.node && L(
541
541
  t.value,
542
- o.node
542
+ r.node
543
543
  )
544
544
  ) : !1), v = () => {
545
545
  s.value && (e.value = e.value.filter(
546
- (o) => o.node !== t.value
546
+ (r) => r.node !== t.value
547
547
  ));
548
548
  }, d = () => {
549
- s.value && (r.value && (e.value = e.value.filter(
550
- (o) => o.node && !L(
551
- o.node,
549
+ s.value && (o.value && (e.value = e.value.filter(
550
+ (r) => r.node && !L(
551
+ r.node,
552
552
  t.value
553
553
  )
554
554
  )), l.value && (e.value = e.value.filter(
555
- (o) => o.node && !L(
555
+ (r) => r.node && !L(
556
556
  t.value,
557
- o.node
557
+ r.node
558
558
  )
559
559
  )), e.value.push(s.value));
560
560
  };
@@ -562,10 +562,10 @@ const C = Ie(() => {
562
562
  handleUnselect: v,
563
563
  handleSelect: d,
564
564
  handleToggleSelect: () => {
565
- s.value && (e.value.some((o) => o.node === t.value) ? v() : d());
565
+ s.value && (e.value.some((r) => r.node === t.value) ? v() : d());
566
566
  },
567
567
  isSelected: u,
568
- isParentOfSelected: r
568
+ isParentOfSelected: o
569
569
  };
570
570
  };
571
571
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue-dnd-kit/core",
3
- "version": "0.0.37-beta",
3
+ "version": "0.0.39-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",