@vue-dnd-kit/core 0.0.37-beta → 0.0.38-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,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,m;!n.isRef(t[0])&&typeof t[0]=="object"?{delay:s,trailing:v=!0,leading:f=!0,rejectOnCancel:m=!1}=t[0]:[s,v=!0,f=!0,m=!1]=t;const l=()=>{r&&(clearTimeout(r),r=void 0,c(),c=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((h,y)=>{c=m?y:h,r=setTimeout(()=>{e=Date.now(),i=!0,h(a()),l()},Math.max(0,p-E))})),!f&&!r&&(r=setTimeout(()=>i=!0,p)),i=!1,o)}}function se(t){return Array.isArray(t)?t:[t]}function ie(t,e=200,r=!1,i=!0,c=!1){return oe(le(e,r,i,c),t)}function ae(t,e,r){const i=n.watch(t,(...c)=>(n.nextTick(()=>i()),e(...c)),r);return i}const K=ne?window:void 0;function 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),m=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(()=>[m.value,V(i),g.value],([E,a])=>{if(l(),!g.value||!E.length)return;const h=new IntersectionObserver(e,{root:V(a),rootMargin:c,threshold:o});E.forEach(y=>y&&h.observe(y)),l=()=>{h.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,m=>{let l=v.value,g=0;for(const P of m)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((m,l,g)=>{var P;return console.log(l,g,m),(P=l.isVisible)!=null&&P.value&&m.push(g),m},[])),o=n.ref([]),s=n.ref([]),v={zone:n.ref(null),element:n.ref(null)},f={current:n.ref(null),start:n.ref(null),offset:{percent:n.ref(null),pixel:n.ref(null)}};return{isDragging:e,activeContainer:r,elements:i,draggingElements:t,selectedElements:o,zones:s,visibleElements:c,hovered:v,pointerPosition:f}}),fe=()=>{const t=n.ref(null),{draggingElements:e,pointerPosition:r,isDragging:i,activeContainer:c}=I();return n.onMounted(()=>{c.ref=t}),n.onBeforeUnmount(()=>{c.ref.value=null}),{elementRef:t,draggingElements:e,pointerPosition:r,isDragging:i}},ge=["innerHTML"],me=n.defineComponent({__name:"DefaultOverlay",setup(t){const{elementRef:e,pointerPosition:r,isDragging:i,draggingElements:c}=fe(),o=n.computed(()=>{var s,v,f,m;return{transform:`translate3d(${(((s=r.current.value)==null?void 0:s.x)??0)-(((v=r.offset.pixel.value)==null?void 0:v.x)??0)}px, ${(((f=r.current.value)==null?void 0:f.y)??0)-(((m=r.offset.pixel.value)==null?void 0:m.y)??0)}px, 0)`,zIndex:1e3,position:"fixed",top:0,left:0,transition:"0.3s cubic-bezier(0.165, 0.84, 0.44, 1)"}});return(s,v)=>n.unref(i)?(n.openBlock(),n.createElementBlock("div",{key:0,ref_key:"elementRef",ref:e,style:n.normalizeStyle(o.value)},[(n.openBlock(!0),n.createElementBlock(n.Fragment,null,n.renderList(n.unref(c),(f,m)=>{var l,g;return n.openBlock(),n.createElementBlock("div",{key:m,innerHTML:f.initialHTML,style:n.normalizeStyle({width:`${(l=f.initialRect)==null?void 0:l.width}px`,height:`${(g=f.initialRect)==null?void 0:g.height}px`})},null,12,ge)}),128))],4)):n.createCommentVNode("",!0)}}),he=n.defineComponent({__name:"DragOverlay",setup(t){const{activeContainer:e}=I(),r=n.computed(()=>e.component.value??me);return(i,c)=>(n.openBlock(),n.createBlock(n.resolveDynamicComponent(r.value)))}}),pe="data-dnd-draggable",ye=t=>{const{elements:e,draggingElements:r,hovered:i,selectedElements:c,isDragging:o}=I(),s=n.ref(null),v=n.computed(()=>{var p;return((p=i.element.value)==null?void 0:p.node)===s.value}),f=ve(s),m=n.computed(()=>r.value.some(p=>p.node===s.value)),l=n.computed(()=>{if(!s.value||!o.value)return!1;const p=e.value.find(E=>E.node===s.value);return p!=null&&p.groups.length?!r.value.some(E=>E.groups.length?!E.groups.some(a=>p.groups.includes(a)):!1):!0});return{elementRef:s,registerElement:()=>{if(!s.value)throw new Error("ElementRef is not set");e.value.push({node:s.value,groups:(t==null?void 0:t.groups)??[],layer:(t==null?void 0:t.layer)??null,defaultLayer:(t==null?void 0:t.layer)??null,events:(t==null?void 0:t.events)??{},data:(t==null?void 0:t.data)??void 0,isVisible:f}),s.value.setAttribute(pe,"true")},unregisterElement:()=>{const p=e.value.findIndex(a=>a.node===s.value);p!==-1&&e.value.splice(p,1);const E=c.value.findIndex(a=>a.node===s.value);E!==-1&&c.value.splice(E,1)},isDragging:m,isOvered:v,isAllowed:l,isVisible:f}},Ee=()=>{let t="",e="",r="";const i=()=>{const s=document.body;t=s.style.userSelect,e=s.style.touchAction,r=s.style.overscrollBehavior,s.style.userSelect="none",s.style.touchAction="none",s.style.overscrollBehavior="none",window.addEventListener("contextmenu",o),window.addEventListener("selectstart",o),window.addEventListener("touchstart",o),window.addEventListener("touchmove",o)},c=()=>{const s=document.body;s.style.userSelect=t,s.style.touchAction=e,s.style.overscrollBehavior=r,window.removeEventListener("contextmenu",o),window.removeEventListener("selectstart",o),window.removeEventListener("touchstart",o),window.removeEventListener("touchmove",o)},o=s=>s.preventDefault();return{disableInteractions:i,enableInteractions:c}},N=(t,e)=>t.x<e.x+e.width&&t.x+t.width>e.x&&t.y<e.y+e.height&&t.y+t.height>e.y,O=t=>{if(!t)return{x:0,y:0,width:0,height:0,bottom:0,left:0,right:0,top:0};const e=t.getBoundingClientRect();return{bottom:e.bottom,left:e.left,right:e.right,top:e.top,x:e.x,y:e.y,width:e.width,height:e.height}},A=t=>({x:t.x+t.width/2,y:t.y+t.height/2}),we=(t,e)=>{const r=O(t);return{pixel:{x:e.x-r.x,y:e.y-r.y},percent:{x:(e.x-r.x)/r.width*100,y:(e.y-r.y)/r.height*100}}},J=(t,e)=>{const r=e.x-t.x,i=e.y-t.y;return Math.sqrt(r*r+i*i)},C=(t,e)=>t?e.contains(t):!1,Pe=t=>{const e=I();return{onPointerStart:o=>{e.pointerPosition.start.value={x:o.clientX,y:o.clientY},e.pointerPosition.current.value={x:o.clientX,y:o.clientY};const{pixel:s,percent:v}=we(t.value,{x:o.clientX,y:o.clientY});e.pointerPosition.offset.pixel.value=s,e.pointerPosition.offset.percent.value=v},onPointerMove:o=>{e.pointerPosition.current.value={x:o.clientX,y:o.clientY}},onPointerEnd:()=>{e.pointerPosition.current.value=null,e.pointerPosition.start.value=null,e.pointerPosition.offset.pixel.value=null,e.pointerPosition.offset.percent.value=null}}},De=t=>{const e=I(),{onPointerStart:r,onPointerMove:i,onPointerEnd:c}=Pe(t);let o=null;const s=a=>{var w,D;const h=e.selectedElements.value.some(x=>x.node===a);if(e.selectedElements.value.length&&h)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,h)=>{const y=Math.max(0,Math.min(a.x+a.width,h.x+h.width)-Math.max(a.x,h.x)),w=Math.max(0,Math.min(a.y+a.height,h.y+h.height)-Math.max(a.y,h.y)),D=y*w,x=a.width*a.height,L=h.width*h.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),h=A(a),y=((F=e.pointerPosition.current.value)==null?void 0:F.x)??0,w=((U=e.pointerPosition.current.value)==null?void 0:U.y)??0,x=!(a&&y>=a.x&&y<=a.x+a.width&&w>=a.y&&w<=a.y+a.height),L=e.draggingElements.value.map(u=>u.node),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(h,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(h,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),m=()=>{f(),o=requestAnimationFrame(m)},l=()=>{m()},g=()=>{o!==null&&(cancelAnimationFrame(o),o=null)};return{activate:a=>{e.draggingElements.value=s(t.value),r(a),l()},track:a=>{i(a)},deactivate:()=>{var a,h;c(),e.hovered.zone.value?(h=(a=e.hovered.zone.value.events).onDrop)==null||h.call(a,e):e.draggingElements.value.forEach(y=>{var w,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:m}=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",h),document.addEventListener("pointerup",w),document.addEventListener("wheel",y)},h=D=>p(D),y=D=>p(D),w=()=>{l.component.value=null,m(),E(),document.removeEventListener("pointermove",h),document.removeEventListener("pointerup",w),document.removeEventListener("wheel",y)};return n.onMounted(r),n.onBeforeUnmount(i),{pointerPosition:g,elementRef:e,isDragging:c,isOvered:o,isAllowed:s,handleDragStart:a,isVisible:v}},Se=t=>{const{zones:e,hovered:r,draggingElements:i,isDragging:c}=I(),o=n.ref(null),s=n.computed(()=>{var l;return((l=r.zone.value)==null?void 0:l.node)===o.value}),v=n.computed(()=>{if(!o.value||!c.value)return!1;const l=e.value.find(g=>g.node===o.value);return l!=null&&l.groups.length?!i.value.some(g=>g.groups.length?!g.groups.some(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;
|
|
@@ -20,16 +20,16 @@ function Le(t, e) {
|
|
|
20
20
|
return n;
|
|
21
21
|
}
|
|
22
22
|
function Ce(...t) {
|
|
23
|
-
let e = 0, n, s = !0, u = H, r, l, v, d,
|
|
24
|
-
!fe(t[0]) && typeof t[0] == "object" ? { delay: l, trailing: v = !0, leading: d = !0, rejectOnCancel:
|
|
23
|
+
let e = 0, n, s = !0, u = H, r, l, v, d, g;
|
|
24
|
+
!fe(t[0]) && typeof t[0] == "object" ? { delay: l, trailing: v = !0, leading: d = !0, rejectOnCancel: g = !1 } = t[0] : [l, v = !0, d = !0, g = !1] = t;
|
|
25
25
|
const o = () => {
|
|
26
26
|
n && (clearTimeout(n), n = void 0, u(), u = H);
|
|
27
27
|
};
|
|
28
28
|
return (w) => {
|
|
29
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((
|
|
31
|
-
u =
|
|
32
|
-
e = Date.now(), s = !0,
|
|
30
|
+
return o(), m <= 0 ? (e = Date.now(), i()) : (y > m && (d || !s) ? (e = Date.now(), i()) : v && (r = new Promise((h, p) => {
|
|
31
|
+
u = g ? p : h, n = setTimeout(() => {
|
|
32
|
+
e = Date.now(), s = !0, h(i()), o();
|
|
33
33
|
}, Math.max(0, m - y));
|
|
34
34
|
})), !d && !n && (n = setTimeout(() => s = !0, m)), s = !1, r);
|
|
35
35
|
};
|
|
@@ -70,17 +70,17 @@ function Re(t, e, n = {}) {
|
|
|
70
70
|
threshold: r = 0,
|
|
71
71
|
window: l = ue,
|
|
72
72
|
immediate: v = !0
|
|
73
|
-
} = n, d = ze(() => l && "IntersectionObserver" in l),
|
|
73
|
+
} = n, d = ze(() => l && "IntersectionObserver" in l), g = D(() => {
|
|
74
74
|
const y = V(t);
|
|
75
75
|
return _e(y).map(X).filter(Se);
|
|
76
76
|
});
|
|
77
77
|
let o = H;
|
|
78
78
|
const f = U(v), w = d.value ? ie(
|
|
79
|
-
() => [
|
|
79
|
+
() => [g.value, X(s), f.value],
|
|
80
80
|
([y, i]) => {
|
|
81
81
|
if (o(), !f.value || !y.length)
|
|
82
82
|
return;
|
|
83
|
-
const
|
|
83
|
+
const h = new IntersectionObserver(
|
|
84
84
|
e,
|
|
85
85
|
{
|
|
86
86
|
root: X(i),
|
|
@@ -88,8 +88,8 @@ function Re(t, e, n = {}) {
|
|
|
88
88
|
threshold: r
|
|
89
89
|
}
|
|
90
90
|
);
|
|
91
|
-
y.forEach((p) => p &&
|
|
92
|
-
|
|
91
|
+
y.forEach((p) => p && h.observe(p)), o = () => {
|
|
92
|
+
h.disconnect(), o = H;
|
|
93
93
|
};
|
|
94
94
|
},
|
|
95
95
|
{ immediate: v, flush: "post" }
|
|
@@ -117,9 +117,9 @@ function He(t, e = {}) {
|
|
|
117
117
|
once: l = !1
|
|
118
118
|
} = e, v = U(!1), { stop: d } = Re(
|
|
119
119
|
t,
|
|
120
|
-
(
|
|
120
|
+
(g) => {
|
|
121
121
|
let o = v.value, f = 0;
|
|
122
|
-
for (const w of
|
|
122
|
+
for (const w of g)
|
|
123
123
|
w.time >= f && (f = w.time, o = w.isIntersecting);
|
|
124
124
|
v.value = o, l && Te(v, () => {
|
|
125
125
|
d();
|
|
@@ -139,9 +139,9 @@ const C = Ie(() => {
|
|
|
139
139
|
component: x(null),
|
|
140
140
|
ref: x(null)
|
|
141
141
|
}, s = x([]), u = D(
|
|
142
|
-
() => s.value.reduce((
|
|
142
|
+
() => s.value.reduce((g, o, f) => {
|
|
143
143
|
var w;
|
|
144
|
-
return (w = o.isVisible) != null && w.value &&
|
|
144
|
+
return console.log(o, f, g), (w = o.isVisible) != null && w.value && g.push(f), g;
|
|
145
145
|
}, [])
|
|
146
146
|
), r = x([]), l = x([]), v = {
|
|
147
147
|
zone: x(null),
|
|
@@ -181,9 +181,9 @@ const C = Ie(() => {
|
|
|
181
181
|
__name: "DefaultOverlay",
|
|
182
182
|
setup(t) {
|
|
183
183
|
const { elementRef: e, pointerPosition: n, isDragging: s, draggingElements: u } = Ae(), r = D(() => {
|
|
184
|
-
var l, v, d,
|
|
184
|
+
var l, v, d, g;
|
|
185
185
|
return {
|
|
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) - (((
|
|
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) - (((g = n.offset.pixel.value) == null ? void 0 : g.y) ?? 0)}px, 0)`,
|
|
187
187
|
zIndex: 1e3,
|
|
188
188
|
position: "fixed",
|
|
189
189
|
top: 0,
|
|
@@ -197,10 +197,10 @@ const C = Ie(() => {
|
|
|
197
197
|
ref: e,
|
|
198
198
|
style: oe(r.value)
|
|
199
199
|
}, [
|
|
200
|
-
(b(!0), W(ye, null, Ee(re(u), (d,
|
|
200
|
+
(b(!0), W(ye, null, Ee(re(u), (d, g) => {
|
|
201
201
|
var o, f;
|
|
202
202
|
return b(), W("div", {
|
|
203
|
-
key:
|
|
203
|
+
key: g,
|
|
204
204
|
innerHTML: d.initialHTML,
|
|
205
205
|
style: oe({
|
|
206
206
|
width: `${(o = d.initialRect) == null ? void 0 : o.width}px`,
|
|
@@ -230,7 +230,7 @@ const C = Ie(() => {
|
|
|
230
230
|
var m;
|
|
231
231
|
return ((m = s.element.value) == null ? void 0 : m.node) === l.value;
|
|
232
232
|
}
|
|
233
|
-
), d = He(l),
|
|
233
|
+
), d = He(l), g = D(
|
|
234
234
|
() => n.value.some((m) => m.node === l.value)
|
|
235
235
|
), o = D(() => {
|
|
236
236
|
if (!l.value || !r.value) return !1;
|
|
@@ -265,7 +265,7 @@ const C = Ie(() => {
|
|
|
265
265
|
);
|
|
266
266
|
y !== -1 && u.value.splice(y, 1);
|
|
267
267
|
},
|
|
268
|
-
isDragging:
|
|
268
|
+
isDragging: g,
|
|
269
269
|
isOvered: v,
|
|
270
270
|
isAllowed: o,
|
|
271
271
|
isVisible: d
|
|
@@ -353,10 +353,10 @@ const C = Ie(() => {
|
|
|
353
353
|
let r = null;
|
|
354
354
|
const l = (i) => {
|
|
355
355
|
var E, P;
|
|
356
|
-
const
|
|
356
|
+
const h = e.selectedElements.value.some(
|
|
357
357
|
(I) => I.node === i
|
|
358
358
|
);
|
|
359
|
-
if (e.selectedElements.value.length &&
|
|
359
|
+
if (e.selectedElements.value.length && h)
|
|
360
360
|
return e.selectedElements.value.map((I) => {
|
|
361
361
|
var _, A;
|
|
362
362
|
return {
|
|
@@ -376,18 +376,18 @@ const C = Ie(() => {
|
|
|
376
376
|
initialRect: (P = p.node) == null ? void 0 : P.getBoundingClientRect()
|
|
377
377
|
}
|
|
378
378
|
] : [];
|
|
379
|
-
}, v = (i,
|
|
379
|
+
}, v = (i, h) => {
|
|
380
380
|
const p = Math.max(
|
|
381
381
|
0,
|
|
382
|
-
Math.min(i.x + i.width,
|
|
382
|
+
Math.min(i.x + i.width, h.x + h.width) - Math.max(i.x, h.x)
|
|
383
383
|
), E = Math.max(
|
|
384
384
|
0,
|
|
385
|
-
Math.min(i.y + i.height,
|
|
386
|
-
), P = p * E, I = i.width * i.height, _ =
|
|
385
|
+
Math.min(i.y + i.height, h.y + h.height) - Math.max(i.y, h.y)
|
|
386
|
+
), P = p * E, I = i.width * i.height, _ = h.width * h.height;
|
|
387
387
|
return (P / I * 100 + P / _ * 100) / 2;
|
|
388
388
|
}, d = Oe(() => {
|
|
389
389
|
var G, N, q, B, J, K, Q, ee, te, ne;
|
|
390
|
-
const i = k(e.activeContainer.ref.value),
|
|
390
|
+
const i = k(e.activeContainer.ref.value), h = Y(i), p = ((G = e.pointerPosition.current.value) == null ? void 0 : G.x) ?? 0, E = ((N = e.pointerPosition.current.value) == null ? void 0 : N.y) ?? 0, I = !(i && p >= i.x && p <= i.x + i.width && E >= i.y && E <= i.y + i.height), _ = e.draggingElements.value.map((a) => a.node), A = e.visibleElements.value.map((a) => e.elements.value[a]).filter((a) => {
|
|
391
391
|
if (!a.node || _.some(
|
|
392
392
|
(M) => M && L(a.node, M)
|
|
393
393
|
) || a.groups.length && !!e.draggingElements.value.some(
|
|
@@ -399,7 +399,7 @@ const C = Ie(() => {
|
|
|
399
399
|
const c = k(a.node);
|
|
400
400
|
return c && i && le(c, i);
|
|
401
401
|
}).map((a) => {
|
|
402
|
-
const c = k(a.node), M = Y(c), S = p >= c.x && p <= c.x + c.width && E >= c.y && E <= c.y + c.height, O = v(c, i), Z = se(
|
|
402
|
+
const c = k(a.node), M = Y(c), S = p >= c.x && p <= c.x + c.width && E >= c.y && E <= c.y + c.height, O = v(c, i), Z = se(h, M), $ = e.elements.value.filter(
|
|
403
403
|
(T) => T !== a && T.node && a.node && L(
|
|
404
404
|
a.node,
|
|
405
405
|
T.node
|
|
@@ -428,7 +428,7 @@ const C = Ie(() => {
|
|
|
428
428
|
const c = k(a.node);
|
|
429
429
|
return c && i && le(c, i);
|
|
430
430
|
}).map((a) => {
|
|
431
|
-
const c = k(a.node), M = Y(c), S = p >= c.x && p <= c.x + c.width && E >= c.y && E <= c.y + c.height, O = v(c, i), Z = se(
|
|
431
|
+
const c = k(a.node), M = Y(c), S = p >= c.x && p <= c.x + c.width && E >= c.y && E <= c.y + c.height, O = v(c, i), Z = se(h, M), $ = e.zones.value.filter(
|
|
432
432
|
(T) => T !== a && T.node && a.node && L(a.node, T.node)
|
|
433
433
|
).length;
|
|
434
434
|
return {
|
|
@@ -448,10 +448,10 @@ const C = Ie(() => {
|
|
|
448
448
|
return Math.abs(a.overlapPercent - c.overlapPercent) <= 1 ? a.centerDistance - c.centerDistance : c.overlapPercent - a.overlapPercent;
|
|
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
|
-
}, 1e3),
|
|
452
|
-
d(), r = requestAnimationFrame(
|
|
451
|
+
}, 1e3), g = () => {
|
|
452
|
+
d(), r = requestAnimationFrame(g);
|
|
453
453
|
}, o = () => {
|
|
454
|
-
|
|
454
|
+
g();
|
|
455
455
|
}, f = () => {
|
|
456
456
|
r !== null && (cancelAnimationFrame(r), r = null);
|
|
457
457
|
};
|
|
@@ -463,8 +463,8 @@ const C = Ie(() => {
|
|
|
463
463
|
s(i);
|
|
464
464
|
},
|
|
465
465
|
deactivate: () => {
|
|
466
|
-
var i,
|
|
467
|
-
u(), e.hovered.zone.value ? (
|
|
466
|
+
var i, h;
|
|
467
|
+
u(), e.hovered.zone.value ? (h = (i = e.hovered.zone.value.events).onDrop) == null || h.call(i, e) : e.draggingElements.value.forEach(
|
|
468
468
|
(p) => {
|
|
469
469
|
var E, P;
|
|
470
470
|
return (P = (E = p.events).onEnd) == null ? void 0 : P.call(E, e);
|
|
@@ -481,10 +481,10 @@ const C = Ie(() => {
|
|
|
481
481
|
isOvered: r,
|
|
482
482
|
isAllowed: l,
|
|
483
483
|
isVisible: v
|
|
484
|
-
} = Ze(t), { disableInteractions: d, enableInteractions:
|
|
485
|
-
t != null && t.container && (o.component.value = xe(t.container)), d(), w(P), document.addEventListener("pointermove",
|
|
486
|
-
},
|
|
487
|
-
o.component.value = null,
|
|
484
|
+
} = Ze(t), { disableInteractions: d, enableInteractions: g } = $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", h), document.addEventListener("pointerup", E), document.addEventListener("wheel", p);
|
|
486
|
+
}, h = (P) => m(P), p = (P) => m(P), E = () => {
|
|
487
|
+
o.component.value = null, g(), y(), document.removeEventListener("pointermove", h), document.removeEventListener("pointerup", E), document.removeEventListener("wheel", p);
|
|
488
488
|
};
|
|
489
489
|
return F(n), j(s), {
|
|
490
490
|
pointerPosition: f,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue-dnd-kit/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.38-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",
|