@vue-dnd-kit/core 0.0.36-beta → 0.0.37-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.
|
@@ -1771,6 +1771,7 @@ export declare const useDnDStore: () => {
|
|
|
1771
1771
|
onDrop?: ((store: import('../types').IDnDStore) => void) | undefined;
|
|
1772
1772
|
};
|
|
1773
1773
|
}[]>;
|
|
1774
|
+
visibleElements: import('vue').ComputedRef<number[]>;
|
|
1774
1775
|
hovered: {
|
|
1775
1776
|
zone: import('vue').Ref<{
|
|
1776
1777
|
node: Element | HTMLElement | null;
|
|
@@ -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 a=n.effectScope(!0);return(...c)=>(e||(r=a.run(()=>t(...c)),e=!0),r)}const ne=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const re=t=>t!=null,z=()=>{};function oe(t,e){function r(...a){return new Promise((c,o)=>{Promise.resolve(t(()=>e.apply(this,a),{fn:e,thisArg:this,args:a})).then(c).catch(o)})}return r}function le(...t){let e=0,r,a=!0,c=z,o,s,v,f,y;!n.isRef(t[0])&&typeof t[0]=="object"?{delay:s,trailing:v=!0,leading:f=!0,rejectOnCancel:y=!1}=t[0]:[s,v=!0,f=!0,y=!1]=t;const l=()=>{r&&(clearTimeout(r),r=void 0,c(),c=z)};return D=>{const h=n.toValue(s),w=Date.now()-e,i=()=>o=D();return l(),h<=0?(e=Date.now(),i()):(w>h&&(f||!a)?(e=Date.now(),i()):v&&(o=new Promise((m,p)=>{c=y?p:m,r=setTimeout(()=>{e=Date.now(),a=!0,m(i()),l()},Math.max(0,h-w))})),!f&&!r&&(r=setTimeout(()=>a=!0,h)),a=!1,o)}}function se(t){return Array.isArray(t)?t:[t]}function ie(t,e=200,r=!1,a=!0,c=!1){return oe(le(e,r,a,c),t)}function ae(t,e,r){const a=n.watch(t,(...c)=>(n.nextTick(()=>a()),e(...c)),r);return a}const K=ne?window:void 0;function H(t){var e;const r=n.toValue(t);return(e=r==null?void 0:r.$el)!=null?e:r}function ue(){const t=n.shallowRef(!1),e=n.getCurrentInstance();return e&&n.onMounted(()=>{t.value=!0},e),t}function ce(t){const e=ue();return n.computed(()=>(e.value,!!t()))}function de(t,e,r={}){const{root:a,rootMargin:c="0px",threshold:o=0,window:s=K,immediate:v=!0}=r,f=ce(()=>s&&"IntersectionObserver"in s),y=n.computed(()=>{const w=n.toValue(t);return se(w).map(H).filter(re)});let l=z;const g=n.shallowRef(v),D=f.value?n.watch(()=>[y.value,H(a),g.value],([w,i])=>{if(l(),!g.value||!w.length)return;const m=new IntersectionObserver(e,{root:H(i),rootMargin:c,threshold:o});w.forEach(p=>p&&m.observe(p)),l=()=>{m.disconnect(),l=z}},{immediate:v,flush:"post"}):z,h=()=>{l(),D(),g.value=!1};return ee(h),{isSupported:f,isActive:g,pause(){l(),g.value=!1},resume(){g.value=!0},stop:h}}function ve(t,e={}){const{window:r=K,scrollTarget:a,threshold:c=0,rootMargin:o,once:s=!1}=e,v=n.shallowRef(!1),{stop:f}=de(t,y=>{let l=v.value,g=0;for(const D of y)D.time>=g&&(g=D.time,l=D.isIntersecting);v.value=l,s&&ae(v,()=>{f()})},{root:a,window:r,threshold:c,rootMargin:n.toValue(o)});return v}const I=te(()=>{const t=n.ref([]),e=n.computed(()=>t.value.length>0),r={component:n.ref(null),ref:n.ref(null)},a=n.ref([]),c=n.ref([]),o=n.ref([]),s={zone:n.ref(null),element:n.ref(null)},v={current:n.ref(null),start:n.ref(null),offset:{percent:n.ref(null),pixel:n.ref(null)}};return{isDragging:e,activeContainer:r,elements:a,draggingElements:t,selectedElements:c,zones:o,hovered:s,pointerPosition:v}}),fe=()=>{const t=n.ref(null),{draggingElements:e,pointerPosition:r,isDragging:a,activeContainer:c}=I();return n.onMounted(()=>{c.ref=t}),n.onBeforeUnmount(()=>{c.ref.value=null}),{elementRef:t,draggingElements:e,pointerPosition:r,isDragging:a}},ge=["innerHTML"],me=n.defineComponent({__name:"DefaultOverlay",setup(t){const{elementRef:e,pointerPosition:r,isDragging:a,draggingElements:c}=fe(),o=n.computed(()=>{var s,v,f,y;return{transform:`translate3d(${(((s=r.current.value)==null?void 0:s.x)??0)-(((v=r.offset.pixel.value)==null?void 0:v.x)??0)}px, ${(((f=r.current.value)==null?void 0:f.y)??0)-(((y=r.offset.pixel.value)==null?void 0:y.y)??0)}px, 0)`,zIndex:1e3,position:"fixed",top:0,left:0,transition:"0.3s cubic-bezier(0.165, 0.84, 0.44, 1)"}});return(s,v)=>n.unref(a)?(n.openBlock(),n.createElementBlock("div",{key:0,ref_key:"elementRef",ref:e,style:n.normalizeStyle(o.value)},[(n.openBlock(!0),n.createElementBlock(n.Fragment,null,n.renderList(n.unref(c),(f,y)=>{var l,g;return n.openBlock(),n.createElementBlock("div",{key:y,innerHTML:f.initialHTML,style:n.normalizeStyle({width:`${(l=f.initialRect)==null?void 0:l.width}px`,height:`${(g=f.initialRect)==null?void 0:g.height}px`})},null,12,ge)}),128))],4)):n.createCommentVNode("",!0)}}),he=n.defineComponent({__name:"DragOverlay",setup(t){const{activeContainer:e}=I(),r=n.computed(()=>e.component.value??me);return(a,c)=>(n.openBlock(),n.createBlock(n.resolveDynamicComponent(r.value)))}}),pe="data-dnd-draggable",ye=t=>{const{elements:e,draggingElements:r,hovered:a,selectedElements:c,isDragging:o}=I(),s=n.ref(null),v=n.computed(()=>{var h;return((h=a.element.value)==null?void 0:h.node)===s.value}),f=ve(s),y=n.computed(()=>r.value.some(h=>h.node===s.value)),l=n.computed(()=>{if(!s.value||!o.value)return!1;const h=e.value.find(w=>w.node===s.value);return h!=null&&h.groups.length?!r.value.some(w=>w.groups.length?!w.groups.some(i=>h.groups.includes(i)):!1):!0});return{elementRef:s,registerElement:()=>{if(!s.value)throw new Error("ElementRef is not set");e.value.push({node:s.value,groups:(t==null?void 0:t.groups)??[],layer:(t==null?void 0:t.layer)??null,defaultLayer:(t==null?void 0:t.layer)??null,events:(t==null?void 0:t.events)??{},data:(t==null?void 0:t.data)??void 0,isVisible:f}),s.value.setAttribute(pe,"true")},unregisterElement:()=>{const h=e.value.findIndex(i=>i.node===s.value);h!==-1&&e.value.splice(h,1);const w=c.value.findIndex(i=>i.node===s.value);w!==-1&&c.value.splice(w,1)},isDragging:y,isOvered:v,isAllowed:l,isVisible:f}},we=()=>{let t="",e="",r="";const a=()=>{const s=document.body;t=s.style.userSelect,e=s.style.touchAction,r=s.style.overscrollBehavior,s.style.userSelect="none",s.style.touchAction="none",s.style.overscrollBehavior="none",window.addEventListener("contextmenu",o),window.addEventListener("selectstart",o),window.addEventListener("touchstart",o),window.addEventListener("touchmove",o)},c=()=>{const s=document.body;s.style.userSelect=t,s.style.touchAction=e,s.style.overscrollBehavior=r,window.removeEventListener("contextmenu",o),window.removeEventListener("selectstart",o),window.removeEventListener("touchstart",o),window.removeEventListener("touchmove",o)},o=s=>s.preventDefault();return{disableInteractions:a,enableInteractions:c}},N=(t,e)=>t.x<e.x+e.width&&t.x+t.width>e.x&&t.y<e.y+e.height&&t.y+t.height>e.y,O=t=>{if(!t)return{x:0,y:0,width:0,height:0,bottom:0,left:0,right:0,top:0};const e=t.getBoundingClientRect();return{bottom:e.bottom,left:e.left,right:e.right,top:e.top,x:e.x,y:e.y,width:e.width,height:e.height}},A=t=>({x:t.x+t.width/2,y:t.y+t.height/2}),Ee=(t,e)=>{const r=O(t);return{pixel:{x:e.x-r.x,y:e.y-r.y},percent:{x:(e.x-r.x)/r.width*100,y:(e.y-r.y)/r.height*100}}},J=(t,e)=>{const r=e.x-t.x,a=e.y-t.y;return Math.sqrt(r*r+a*a)},C=(t,e)=>t?e.contains(t):!1,Pe=t=>{const e=I();return{onPointerStart:o=>{e.pointerPosition.start.value={x:o.clientX,y:o.clientY},e.pointerPosition.current.value={x:o.clientX,y:o.clientY};const{pixel:s,percent:v}=Ee(t.value,{x:o.clientX,y:o.clientY});e.pointerPosition.offset.pixel.value=s,e.pointerPosition.offset.percent.value=v},onPointerMove:o=>{e.pointerPosition.current.value={x:o.clientX,y:o.clientY}},onPointerEnd:()=>{e.pointerPosition.current.value=null,e.pointerPosition.start.value=null,e.pointerPosition.offset.pixel.value=null,e.pointerPosition.offset.percent.value=null}}},De=t=>{const e=I(),{onPointerStart:r,onPointerMove:a,onPointerEnd:c}=Pe(t);let o=null;const s=i=>{var E,P;const m=e.selectedElements.value.some(x=>x.node===i);if(e.selectedElements.value.length&&m)return e.selectedElements.value.map(x=>{var L,V;return{...x,initialHTML:((L=x.node)==null?void 0:L.outerHTML)??"",initialRect:(V=x.node)==null?void 0:V.getBoundingClientRect()}});e.selectedElements.value=[];const p=e.elements.value.find(x=>x.node===i);return p?[{...p,initialHTML:((E=p.node)==null?void 0:E.outerHTML)??"",initialRect:(P=p.node)==null?void 0:P.getBoundingClientRect()}]:[]},v=(i,m)=>{const p=Math.max(0,Math.min(i.x+i.width,m.x+m.width)-Math.max(i.x,m.x)),E=Math.max(0,Math.min(i.y+i.height,m.y+m.height)-Math.max(i.y,m.y)),P=p*E,x=i.width*i.height,L=m.width*m.height;return(P/x*100+P/L*100)/2},f=ie(()=>{var F,U,Z,$,W,X,Y,j,q,G;const i=O(e.activeContainer.ref.value),m=A(i),p=((F=e.pointerPosition.current.value)==null?void 0:F.x)??0,E=((U=e.pointerPosition.current.value)==null?void 0:U.y)??0,x=!(i&&p>=i.x&&p<=i.x+i.width&&E>=i.y&&E<=i.y+i.height),L=e.draggingElements.value.map(u=>u.node),V=e.elements.value.filter(u=>{if(!u.isVisible||!u.isVisible.value||!u.node||L.some(S=>S&&C(u.node,S))||u.groups.length&&!!e.draggingElements.value.some(M=>M.groups.length?!M.groups.some(_=>u.groups.includes(_)):!1))return!1;const d=O(u.node);return d&&i&&N(d,i)}).map(u=>{const d=O(u.node),S=A(d),M=p>=d.x&&p<=d.x+d.width&&E>=d.y&&E<=d.y+d.height,_=v(d,i),b=J(m,S),B=e.elements.value.filter(k=>k!==u&&k.node&&u.node&&C(u.node,k.node)).length;return{element:u,isPointerInElement:M,overlapPercent:_,depth:B,centerDistance:b}}).sort((u,d)=>{if(!x){if(u.isPointerInElement&&d.isPointerInElement)return d.depth-u.depth;if(u.isPointerInElement!==d.isPointerInElement)return u.isPointerInElement?-1:1}return Math.abs(u.overlapPercent-d.overlapPercent)<=1?u.centerDistance-d.centerDistance:d.overlapPercent-u.overlapPercent}),Q=e.zones.value.filter(u=>{if(!u.node||L.some(S=>S&&C(u.node,S))||u.groups.length&&!!e.draggingElements.value.some(M=>M.groups.length?!M.groups.some(_=>u.groups.includes(_)):!1))return!1;const d=O(u.node);return d&&i&&N(d,i)}).map(u=>{const d=O(u.node),S=A(d),M=p>=d.x&&p<=d.x+d.width&&E>=d.y&&E<=d.y+d.height,_=v(d,i),b=J(m,S),B=e.zones.value.filter(k=>k!==u&&k.node&&u.node&&C(u.node,k.node)).length;return{zone:u,isPointerInElement:M,overlapPercent:_,depth:B,centerDistance:b}}).sort((u,d)=>{if(!x){if(u.isPointerInElement&&d.isPointerInElement)return d.depth-u.depth;if(u.isPointerInElement!==d.isPointerInElement)return u.isPointerInElement?-1:1}return Math.abs(u.overlapPercent-d.overlapPercent)<=1?u.centerDistance-d.centerDistance:d.overlapPercent-u.overlapPercent}),T=e.hovered.element.value,R=e.hovered.zone.value;e.hovered.element.value=((Z=V[0])==null?void 0:Z.element)??null,e.hovered.zone.value=(($=Q[0])==null?void 0:$.zone)??null,e.hovered.element.value!==T&&((W=T==null?void 0:T.events)!=null&&W.onLeave&&T.events.onLeave(e),(Y=(X=e.hovered.element.value)==null?void 0:X.events)!=null&&Y.onHover&&e.hovered.element.value.events.onHover(e)),e.hovered.zone.value!==R&&((j=R==null?void 0:R.events)!=null&&j.onLeave&&R.events.onLeave(e),(G=(q=e.hovered.zone.value)==null?void 0:q.events)!=null&&G.onHover&&e.hovered.zone.value.events.onHover(e)),console.log("processing collisions")},1e3),y=()=>{f(),o=requestAnimationFrame(y)},l=()=>{y()},g=()=>{o!==null&&(cancelAnimationFrame(o),o=null)};return{activate:i=>{e.draggingElements.value=s(t.value),r(i),l()},track:i=>{a(i)},deactivate:()=>{var i,m;c(),e.hovered.zone.value?(m=(i=e.hovered.zone.value.events).onDrop)==null||m.call(i,e):e.draggingElements.value.forEach(p=>{var E,P;return(P=(E=p.events).onEnd)==null?void 0:P.call(E,e)}),e.draggingElements.value=[],e.selectedElements.value=[],e.hovered.zone.value=null,e.hovered.element.value=null,g()}}},xe=t=>{const{elementRef:e,registerElement:r,unregisterElement:a,isDragging:c,isOvered:o,isAllowed:s,isVisible:v}=ye(t),{disableInteractions:f,enableInteractions:y}=we(),{activeContainer:l,pointerPosition:g}=I(),{activate:D,track:h,deactivate:w}=De(e),i=P=>{t!=null&&t.container&&(l.component.value=n.markRaw(t.container)),f(),D(P),document.addEventListener("pointermove",m),document.addEventListener("pointerup",E),document.addEventListener("wheel",p)},m=P=>h(P),p=P=>h(P),E=()=>{l.component.value=null,y(),w(),document.removeEventListener("pointermove",m),document.removeEventListener("pointerup",E),document.removeEventListener("wheel",p)};return n.onMounted(r),n.onBeforeUnmount(a),{pointerPosition:g,elementRef:e,isDragging:c,isOvered:o,isAllowed:s,handleDragStart:i,isVisible:v}},Se=t=>{const{zones:e,hovered:r,draggingElements:a,isDragging:c}=I(),o=n.ref(null),s=n.computed(()=>{var l;return((l=r.zone.value)==null?void 0:l.node)===o.value}),v=n.computed(()=>{if(!o.value||!c.value)return!1;const l=e.value.find(g=>g.node===o.value);return l!=null&&l.groups.length?!a.value.some(g=>g.groups.length?!g.groups.some(D=>l.groups.includes(D)):!1):!0});return{elementRef:o,registerZone:()=>{if(!o.value)throw new Error("elementRef is not set");e.value.push({node:o.value,groups:(t==null?void 0:t.groups)??[],events:(t==null?void 0:t.events)??{},data:(t==null?void 0:t.data)??void 0}),o.value.setAttribute("data-dnd-droppable","true")},unregisterZone:()=>{if(!o.value)throw new Error("elementRef is not set");const l=e.value.findIndex(g=>g.node===o.value);l!==-1&&e.value.splice(l,1)},isOvered:s,isAllowed:v}},Me=t=>{const{elementRef:e,registerZone:r,unregisterZone:a,isOvered:c,isAllowed:o}=Se(t);return n.onMounted(r),n.onBeforeUnmount(a),{elementRef:e,isOvered:c,isAllowed:o}},Ie=t=>{const{selectedElements:e,elements:r}=I(),a=n.computed(()=>r.value.find(l=>l.node===t.value)),c=n.computed(()=>e.value.some(l=>l.node===t.value)),o=n.computed(()=>t.value?e.value.some(l=>l.node&&C(l.node,t.value)):!1),s=n.computed(()=>t.value?e.value.some(l=>l.node&&C(t.value,l.node)):!1),v=()=>{a.value&&(e.value=e.value.filter(l=>l.node!==t.value))},f=()=>{a.value&&(o.value&&(e.value=e.value.filter(l=>l.node&&!C(l.node,t.value))),s.value&&(e.value=e.value.filter(l=>l.node&&!C(t.value,l.node))),e.value.push(a.value))};return{handleUnselect:v,handleSelect:f,handleToggleSelect:()=>{a.value&&(e.value.some(l=>l.node===t.value)?v():f())},isSelected:c,isParentOfSelected:o}};exports.DragOverlay=he;exports.getBoundingBox=O;exports.useDnDStore=I;exports.useDraggable=xe;exports.useDroppable=Me;exports.useSelection=Ie;
|
|
1
|
+
"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,56 +1,56 @@
|
|
|
1
|
-
import { effectScope as ve, watch as ie, nextTick as de, isRef as fe, getCurrentScope as ge, onScopeDispose as he, toValue as
|
|
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";
|
|
2
2
|
function De(t) {
|
|
3
3
|
return ge() ? (he(t), !0) : !1;
|
|
4
4
|
}
|
|
5
5
|
function Ie(t) {
|
|
6
6
|
let e = !1, n;
|
|
7
|
-
const
|
|
8
|
-
return (...u) => (e || (n =
|
|
7
|
+
const s = ve(!0);
|
|
8
|
+
return (...u) => (e || (n = s.run(() => t(...u)), e = !0), n);
|
|
9
9
|
}
|
|
10
10
|
const Me = typeof window < "u" && typeof document < "u";
|
|
11
11
|
typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
|
|
12
12
|
const Se = (t) => t != null, H = () => {
|
|
13
13
|
};
|
|
14
14
|
function Le(t, e) {
|
|
15
|
-
function n(...
|
|
15
|
+
function n(...s) {
|
|
16
16
|
return new Promise((u, r) => {
|
|
17
|
-
Promise.resolve(t(() => e.apply(this,
|
|
17
|
+
Promise.resolve(t(() => e.apply(this, s), { fn: e, thisArg: this, args: s })).then(u).catch(r);
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
20
|
return n;
|
|
21
21
|
}
|
|
22
22
|
function Ce(...t) {
|
|
23
|
-
let e = 0, n,
|
|
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, h;
|
|
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
25
|
const o = () => {
|
|
26
26
|
n && (clearTimeout(n), n = void 0, u(), u = H);
|
|
27
27
|
};
|
|
28
|
-
return (
|
|
29
|
-
const
|
|
30
|
-
return o(),
|
|
31
|
-
u =
|
|
32
|
-
e = Date.now(),
|
|
33
|
-
}, Math.max(0,
|
|
34
|
-
})), !d && !n && (n = setTimeout(() =>
|
|
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) => {
|
|
31
|
+
u = h ? p : g, n = setTimeout(() => {
|
|
32
|
+
e = Date.now(), s = !0, g(i()), o();
|
|
33
|
+
}, Math.max(0, m - y));
|
|
34
|
+
})), !d && !n && (n = setTimeout(() => s = !0, m)), s = !1, r);
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
37
|
function _e(t) {
|
|
38
38
|
return Array.isArray(t) ? t : [t];
|
|
39
39
|
}
|
|
40
|
-
function Oe(t, e = 200, n = !1,
|
|
40
|
+
function Oe(t, e = 200, n = !1, s = !0, u = !1) {
|
|
41
41
|
return Le(
|
|
42
|
-
Ce(e, n,
|
|
42
|
+
Ce(e, n, s, u),
|
|
43
43
|
t
|
|
44
44
|
);
|
|
45
45
|
}
|
|
46
46
|
function Te(t, e, n) {
|
|
47
|
-
const
|
|
48
|
-
return
|
|
47
|
+
const s = ie(t, (...u) => (de(() => s()), e(...u)), n);
|
|
48
|
+
return s;
|
|
49
49
|
}
|
|
50
50
|
const ue = Me ? window : void 0;
|
|
51
51
|
function X(t) {
|
|
52
52
|
var e;
|
|
53
|
-
const n =
|
|
53
|
+
const n = V(t);
|
|
54
54
|
return (e = n == null ? void 0 : n.$el) != null ? e : n;
|
|
55
55
|
}
|
|
56
56
|
function ke() {
|
|
@@ -61,42 +61,42 @@ function ke() {
|
|
|
61
61
|
}
|
|
62
62
|
function ze(t) {
|
|
63
63
|
const e = ke();
|
|
64
|
-
return
|
|
64
|
+
return D(() => (e.value, !!t()));
|
|
65
65
|
}
|
|
66
66
|
function Re(t, e, n = {}) {
|
|
67
67
|
const {
|
|
68
|
-
root:
|
|
68
|
+
root: s,
|
|
69
69
|
rootMargin: u = "0px",
|
|
70
70
|
threshold: r = 0,
|
|
71
71
|
window: l = ue,
|
|
72
72
|
immediate: v = !0
|
|
73
|
-
} = n, d = ze(() => l && "IntersectionObserver" in l),
|
|
74
|
-
const y =
|
|
73
|
+
} = n, d = ze(() => l && "IntersectionObserver" in l), h = D(() => {
|
|
74
|
+
const y = V(t);
|
|
75
75
|
return _e(y).map(X).filter(Se);
|
|
76
76
|
});
|
|
77
77
|
let o = H;
|
|
78
|
-
const f = U(v),
|
|
79
|
-
() => [
|
|
80
|
-
([y,
|
|
78
|
+
const f = U(v), w = d.value ? ie(
|
|
79
|
+
() => [h.value, X(s), f.value],
|
|
80
|
+
([y, i]) => {
|
|
81
81
|
if (o(), !f.value || !y.length)
|
|
82
82
|
return;
|
|
83
83
|
const g = new IntersectionObserver(
|
|
84
84
|
e,
|
|
85
85
|
{
|
|
86
|
-
root: X(
|
|
86
|
+
root: X(i),
|
|
87
87
|
rootMargin: u,
|
|
88
88
|
threshold: r
|
|
89
89
|
}
|
|
90
90
|
);
|
|
91
|
-
y.forEach((
|
|
91
|
+
y.forEach((p) => p && g.observe(p)), o = () => {
|
|
92
92
|
g.disconnect(), o = H;
|
|
93
93
|
};
|
|
94
94
|
},
|
|
95
95
|
{ immediate: v, flush: "post" }
|
|
96
|
-
) : H,
|
|
97
|
-
o(),
|
|
96
|
+
) : H, m = () => {
|
|
97
|
+
o(), w(), f.value = !1;
|
|
98
98
|
};
|
|
99
|
-
return De(
|
|
99
|
+
return De(m), {
|
|
100
100
|
isSupported: d,
|
|
101
101
|
isActive: f,
|
|
102
102
|
pause() {
|
|
@@ -105,62 +105,68 @@ function Re(t, e, n = {}) {
|
|
|
105
105
|
resume() {
|
|
106
106
|
f.value = !0;
|
|
107
107
|
},
|
|
108
|
-
stop:
|
|
108
|
+
stop: m
|
|
109
109
|
};
|
|
110
110
|
}
|
|
111
111
|
function He(t, e = {}) {
|
|
112
112
|
const {
|
|
113
113
|
window: n = ue,
|
|
114
|
-
scrollTarget:
|
|
114
|
+
scrollTarget: s,
|
|
115
115
|
threshold: u = 0,
|
|
116
116
|
rootMargin: r,
|
|
117
117
|
once: l = !1
|
|
118
118
|
} = e, v = U(!1), { stop: d } = Re(
|
|
119
119
|
t,
|
|
120
|
-
(
|
|
120
|
+
(h) => {
|
|
121
121
|
let o = v.value, f = 0;
|
|
122
|
-
for (const
|
|
123
|
-
|
|
122
|
+
for (const w of h)
|
|
123
|
+
w.time >= f && (f = w.time, o = w.isIntersecting);
|
|
124
124
|
v.value = o, l && Te(v, () => {
|
|
125
125
|
d();
|
|
126
126
|
});
|
|
127
127
|
},
|
|
128
128
|
{
|
|
129
|
-
root:
|
|
129
|
+
root: s,
|
|
130
130
|
window: n,
|
|
131
131
|
threshold: u,
|
|
132
|
-
rootMargin:
|
|
132
|
+
rootMargin: V(r)
|
|
133
133
|
}
|
|
134
134
|
);
|
|
135
135
|
return v;
|
|
136
136
|
}
|
|
137
137
|
const C = Ie(() => {
|
|
138
|
-
const t =
|
|
139
|
-
component:
|
|
140
|
-
ref:
|
|
141
|
-
},
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
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)
|
|
149
|
+
}, d = {
|
|
150
|
+
current: x(null),
|
|
151
|
+
start: x(null),
|
|
147
152
|
offset: {
|
|
148
|
-
percent:
|
|
149
|
-
pixel:
|
|
153
|
+
percent: x(null),
|
|
154
|
+
pixel: x(null)
|
|
150
155
|
}
|
|
151
156
|
};
|
|
152
157
|
return {
|
|
153
158
|
isDragging: e,
|
|
154
159
|
activeContainer: n,
|
|
155
|
-
elements:
|
|
160
|
+
elements: s,
|
|
156
161
|
draggingElements: t,
|
|
157
|
-
selectedElements:
|
|
158
|
-
zones:
|
|
159
|
-
|
|
160
|
-
|
|
162
|
+
selectedElements: r,
|
|
163
|
+
zones: l,
|
|
164
|
+
visibleElements: u,
|
|
165
|
+
hovered: v,
|
|
166
|
+
pointerPosition: d
|
|
161
167
|
};
|
|
162
168
|
}), Ae = () => {
|
|
163
|
-
const t =
|
|
169
|
+
const t = x(null), { draggingElements: e, pointerPosition: n, isDragging: s, activeContainer: u } = C();
|
|
164
170
|
return F(() => {
|
|
165
171
|
u.ref = t;
|
|
166
172
|
}), j(() => {
|
|
@@ -169,15 +175,15 @@ const C = Ie(() => {
|
|
|
169
175
|
elementRef: t,
|
|
170
176
|
draggingElements: e,
|
|
171
177
|
pointerPosition: n,
|
|
172
|
-
isDragging:
|
|
178
|
+
isDragging: s
|
|
173
179
|
};
|
|
174
|
-
},
|
|
180
|
+
}, be = ["innerHTML"], Ve = /* @__PURE__ */ ae({
|
|
175
181
|
__name: "DefaultOverlay",
|
|
176
182
|
setup(t) {
|
|
177
|
-
const { elementRef: e, pointerPosition: n, isDragging:
|
|
178
|
-
var l, v, d,
|
|
183
|
+
const { elementRef: e, pointerPosition: n, isDragging: s, draggingElements: u } = Ae(), r = D(() => {
|
|
184
|
+
var l, v, d, h;
|
|
179
185
|
return {
|
|
180
|
-
transform: `translate3d(${(((l = n.current.value) == null ? void 0 : l.x) ?? 0) - (((v = n.offset.pixel.value) == null ? void 0 : v.x) ?? 0)}px, ${(((d = n.current.value) == null ? void 0 : d.y) ?? 0) - (((
|
|
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)`,
|
|
181
187
|
zIndex: 1e3,
|
|
182
188
|
position: "fixed",
|
|
183
189
|
top: 0,
|
|
@@ -185,54 +191,54 @@ const C = Ie(() => {
|
|
|
185
191
|
transition: "0.3s cubic-bezier(0.165, 0.84, 0.44, 1)"
|
|
186
192
|
};
|
|
187
193
|
});
|
|
188
|
-
return (l, v) => re(
|
|
194
|
+
return (l, v) => re(s) ? (b(), W("div", {
|
|
189
195
|
key: 0,
|
|
190
196
|
ref_key: "elementRef",
|
|
191
197
|
ref: e,
|
|
192
198
|
style: oe(r.value)
|
|
193
199
|
}, [
|
|
194
|
-
(
|
|
200
|
+
(b(!0), W(ye, null, Ee(re(u), (d, h) => {
|
|
195
201
|
var o, f;
|
|
196
|
-
return
|
|
197
|
-
key:
|
|
202
|
+
return b(), W("div", {
|
|
203
|
+
key: h,
|
|
198
204
|
innerHTML: d.initialHTML,
|
|
199
205
|
style: oe({
|
|
200
206
|
width: `${(o = d.initialRect) == null ? void 0 : o.width}px`,
|
|
201
207
|
height: `${(f = d.initialRect) == null ? void 0 : f.height}px`
|
|
202
208
|
})
|
|
203
|
-
}, null, 12,
|
|
209
|
+
}, null, 12, be);
|
|
204
210
|
}), 128))
|
|
205
211
|
], 4)) : pe("", !0);
|
|
206
212
|
}
|
|
207
213
|
}), Ge = /* @__PURE__ */ ae({
|
|
208
214
|
__name: "DragOverlay",
|
|
209
215
|
setup(t) {
|
|
210
|
-
const { activeContainer: e } = C(), n =
|
|
211
|
-
() => e.component.value ??
|
|
216
|
+
const { activeContainer: e } = C(), n = D(
|
|
217
|
+
() => e.component.value ?? Ve
|
|
212
218
|
);
|
|
213
|
-
return (
|
|
219
|
+
return (s, u) => (b(), we(Pe(n.value)));
|
|
214
220
|
}
|
|
215
221
|
}), Fe = "data-dnd-draggable", Ze = (t) => {
|
|
216
222
|
const {
|
|
217
223
|
elements: e,
|
|
218
224
|
draggingElements: n,
|
|
219
|
-
hovered:
|
|
225
|
+
hovered: s,
|
|
220
226
|
selectedElements: u,
|
|
221
227
|
isDragging: r
|
|
222
|
-
} = C(), l =
|
|
228
|
+
} = C(), l = x(null), v = D(
|
|
223
229
|
() => {
|
|
224
|
-
var
|
|
225
|
-
return ((
|
|
230
|
+
var m;
|
|
231
|
+
return ((m = s.element.value) == null ? void 0 : m.node) === l.value;
|
|
226
232
|
}
|
|
227
|
-
), d = He(l),
|
|
228
|
-
() => n.value.some((
|
|
229
|
-
), o =
|
|
233
|
+
), d = He(l), h = D(
|
|
234
|
+
() => n.value.some((m) => m.node === l.value)
|
|
235
|
+
), o = D(() => {
|
|
230
236
|
if (!l.value || !r.value) return !1;
|
|
231
|
-
const
|
|
237
|
+
const m = e.value.find(
|
|
232
238
|
(y) => y.node === l.value
|
|
233
239
|
);
|
|
234
|
-
return
|
|
235
|
-
(
|
|
240
|
+
return m != null && m.groups.length ? !n.value.some((y) => y.groups.length ? !y.groups.some(
|
|
241
|
+
(i) => m.groups.includes(i)
|
|
236
242
|
) : !1) : !0;
|
|
237
243
|
});
|
|
238
244
|
return {
|
|
@@ -250,23 +256,23 @@ const C = Ie(() => {
|
|
|
250
256
|
}), l.value.setAttribute(Fe, "true");
|
|
251
257
|
},
|
|
252
258
|
unregisterElement: () => {
|
|
253
|
-
const
|
|
254
|
-
(
|
|
259
|
+
const m = e.value.findIndex(
|
|
260
|
+
(i) => i.node === l.value
|
|
255
261
|
);
|
|
256
|
-
|
|
262
|
+
m !== -1 && e.value.splice(m, 1);
|
|
257
263
|
const y = u.value.findIndex(
|
|
258
|
-
(
|
|
264
|
+
(i) => i.node === l.value
|
|
259
265
|
);
|
|
260
266
|
y !== -1 && u.value.splice(y, 1);
|
|
261
267
|
},
|
|
262
|
-
isDragging:
|
|
268
|
+
isDragging: h,
|
|
263
269
|
isOvered: v,
|
|
264
270
|
isAllowed: o,
|
|
265
271
|
isVisible: d
|
|
266
272
|
};
|
|
267
273
|
}, $e = () => {
|
|
268
274
|
let t = "", e = "", n = "";
|
|
269
|
-
const
|
|
275
|
+
const s = () => {
|
|
270
276
|
const l = document.body;
|
|
271
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);
|
|
272
278
|
}, u = () => {
|
|
@@ -274,7 +280,7 @@ const C = Ie(() => {
|
|
|
274
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);
|
|
275
281
|
}, r = (l) => l.preventDefault();
|
|
276
282
|
return {
|
|
277
|
-
disableInteractions:
|
|
283
|
+
disableInteractions: s,
|
|
278
284
|
enableInteractions: u
|
|
279
285
|
};
|
|
280
286
|
}, le = (t, e) => t.x < e.x + e.width && t.x + t.width > e.x && t.y < e.y + e.height && t.y + t.height > e.y, k = (t) => {
|
|
@@ -316,8 +322,8 @@ const C = Ie(() => {
|
|
|
316
322
|
}
|
|
317
323
|
};
|
|
318
324
|
}, se = (t, e) => {
|
|
319
|
-
const n = e.x - t.x,
|
|
320
|
-
return Math.sqrt(n * n +
|
|
325
|
+
const n = e.x - t.x, s = e.y - t.y;
|
|
326
|
+
return Math.sqrt(n * n + s * s);
|
|
321
327
|
}, L = (t, e) => t ? e.contains(t) : !1, Xe = (t) => {
|
|
322
328
|
const e = C();
|
|
323
329
|
return {
|
|
@@ -343,12 +349,12 @@ const C = Ie(() => {
|
|
|
343
349
|
}
|
|
344
350
|
};
|
|
345
351
|
}, Ye = (t) => {
|
|
346
|
-
const e = C(), { onPointerStart: n, onPointerMove:
|
|
352
|
+
const e = C(), { onPointerStart: n, onPointerMove: s, onPointerEnd: u } = Xe(t);
|
|
347
353
|
let r = null;
|
|
348
|
-
const l = (
|
|
349
|
-
var
|
|
354
|
+
const l = (i) => {
|
|
355
|
+
var E, P;
|
|
350
356
|
const g = e.selectedElements.value.some(
|
|
351
|
-
(I) => I.node ===
|
|
357
|
+
(I) => I.node === i
|
|
352
358
|
);
|
|
353
359
|
if (e.selectedElements.value.length && g)
|
|
354
360
|
return e.selectedElements.value.map((I) => {
|
|
@@ -360,29 +366,29 @@ const C = Ie(() => {
|
|
|
360
366
|
};
|
|
361
367
|
});
|
|
362
368
|
e.selectedElements.value = [];
|
|
363
|
-
const
|
|
364
|
-
(I) => I.node ===
|
|
369
|
+
const p = e.elements.value.find(
|
|
370
|
+
(I) => I.node === i
|
|
365
371
|
);
|
|
366
|
-
return
|
|
372
|
+
return p ? [
|
|
367
373
|
{
|
|
368
|
-
...
|
|
369
|
-
initialHTML: ((
|
|
370
|
-
initialRect: (
|
|
374
|
+
...p,
|
|
375
|
+
initialHTML: ((E = p.node) == null ? void 0 : E.outerHTML) ?? "",
|
|
376
|
+
initialRect: (P = p.node) == null ? void 0 : P.getBoundingClientRect()
|
|
371
377
|
}
|
|
372
378
|
] : [];
|
|
373
|
-
}, v = (
|
|
374
|
-
const
|
|
379
|
+
}, v = (i, g) => {
|
|
380
|
+
const p = Math.max(
|
|
375
381
|
0,
|
|
376
|
-
Math.min(
|
|
377
|
-
),
|
|
382
|
+
Math.min(i.x + i.width, g.x + g.width) - Math.max(i.x, g.x)
|
|
383
|
+
), E = Math.max(
|
|
378
384
|
0,
|
|
379
|
-
Math.min(
|
|
380
|
-
),
|
|
381
|
-
return (
|
|
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;
|
|
382
388
|
}, d = Oe(() => {
|
|
383
389
|
var G, N, q, B, J, K, Q, ee, te, ne;
|
|
384
|
-
const
|
|
385
|
-
if (!a.
|
|
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) => {
|
|
391
|
+
if (!a.node || _.some(
|
|
386
392
|
(M) => M && L(a.node, M)
|
|
387
393
|
) || a.groups.length && !!e.draggingElements.value.some(
|
|
388
394
|
(S) => S.groups.length ? !S.groups.some(
|
|
@@ -391,9 +397,9 @@ const C = Ie(() => {
|
|
|
391
397
|
))
|
|
392
398
|
return !1;
|
|
393
399
|
const c = k(a.node);
|
|
394
|
-
return c &&
|
|
400
|
+
return c && i && le(c, i);
|
|
395
401
|
}).map((a) => {
|
|
396
|
-
const c = k(a.node), M = Y(c), S =
|
|
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(g, M), $ = e.elements.value.filter(
|
|
397
403
|
(T) => T !== a && T.node && a.node && L(
|
|
398
404
|
a.node,
|
|
399
405
|
T.node
|
|
@@ -420,9 +426,9 @@ const C = Ie(() => {
|
|
|
420
426
|
) || a.groups.length && !!e.draggingElements.value.some((S) => S.groups.length ? !S.groups.some((O) => a.groups.includes(O)) : !1))
|
|
421
427
|
return !1;
|
|
422
428
|
const c = k(a.node);
|
|
423
|
-
return c &&
|
|
429
|
+
return c && i && le(c, i);
|
|
424
430
|
}).map((a) => {
|
|
425
|
-
const c = k(a.node), M = Y(c), S =
|
|
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(g, M), $ = e.zones.value.filter(
|
|
426
432
|
(T) => T !== a && T.node && a.node && L(a.node, T.node)
|
|
427
433
|
).length;
|
|
428
434
|
return {
|
|
@@ -441,27 +447,27 @@ const C = Ie(() => {
|
|
|
441
447
|
}
|
|
442
448
|
return Math.abs(a.overlapPercent - c.overlapPercent) <= 1 ? a.centerDistance - c.centerDistance : c.overlapPercent - a.overlapPercent;
|
|
443
449
|
}), z = e.hovered.element.value, R = e.hovered.zone.value;
|
|
444
|
-
e.hovered.element.value = ((q = A[0]) == null ? void 0 : q.element) ?? null, e.hovered.zone.value = ((B = ce[0]) == null ? void 0 : B.zone) ?? null, e.hovered.element.value !== z && ((J = z == null ? void 0 : z.events) != null && J.onLeave && z.events.onLeave(e), (Q = (K = e.hovered.element.value) == null ? void 0 : K.events) != null && Q.onHover && e.hovered.element.value.events.onHover(e)), e.hovered.zone.value !== R && ((ee = R == null ? void 0 : R.events) != null && ee.onLeave && R.events.onLeave(e), (ne = (te = e.hovered.zone.value) == null ? void 0 : te.events) != null && ne.onHover && e.hovered.zone.value.events.onHover(e))
|
|
445
|
-
}, 1e3),
|
|
446
|
-
d(), r = requestAnimationFrame(
|
|
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), h = () => {
|
|
452
|
+
d(), r = requestAnimationFrame(h);
|
|
447
453
|
}, o = () => {
|
|
448
|
-
|
|
454
|
+
h();
|
|
449
455
|
}, f = () => {
|
|
450
456
|
r !== null && (cancelAnimationFrame(r), r = null);
|
|
451
457
|
};
|
|
452
458
|
return {
|
|
453
|
-
activate: (
|
|
454
|
-
e.draggingElements.value = l(t.value), n(
|
|
459
|
+
activate: (i) => {
|
|
460
|
+
e.draggingElements.value = l(t.value), n(i), o();
|
|
455
461
|
},
|
|
456
|
-
track: (
|
|
457
|
-
i
|
|
462
|
+
track: (i) => {
|
|
463
|
+
s(i);
|
|
458
464
|
},
|
|
459
465
|
deactivate: () => {
|
|
460
|
-
var
|
|
461
|
-
u(), e.hovered.zone.value ? (g = (
|
|
462
|
-
(
|
|
463
|
-
var
|
|
464
|
-
return (
|
|
466
|
+
var i, g;
|
|
467
|
+
u(), e.hovered.zone.value ? (g = (i = e.hovered.zone.value.events).onDrop) == null || g.call(i, e) : e.draggingElements.value.forEach(
|
|
468
|
+
(p) => {
|
|
469
|
+
var E, P;
|
|
470
|
+
return (P = (E = p.events).onEnd) == null ? void 0 : P.call(E, e);
|
|
465
471
|
}
|
|
466
472
|
), e.draggingElements.value = [], e.selectedElements.value = [], e.hovered.zone.value = null, e.hovered.element.value = null, f();
|
|
467
473
|
}
|
|
@@ -470,36 +476,36 @@ const C = Ie(() => {
|
|
|
470
476
|
const {
|
|
471
477
|
elementRef: e,
|
|
472
478
|
registerElement: n,
|
|
473
|
-
unregisterElement:
|
|
479
|
+
unregisterElement: s,
|
|
474
480
|
isDragging: u,
|
|
475
481
|
isOvered: r,
|
|
476
482
|
isAllowed: l,
|
|
477
483
|
isVisible: v
|
|
478
|
-
} = Ze(t), { disableInteractions: d, enableInteractions:
|
|
479
|
-
t != null && t.container && (o.component.value = xe(t.container)), d(),
|
|
480
|
-
}, g = (
|
|
481
|
-
o.component.value = null,
|
|
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);
|
|
482
488
|
};
|
|
483
|
-
return F(n), j(
|
|
489
|
+
return F(n), j(s), {
|
|
484
490
|
pointerPosition: f,
|
|
485
491
|
elementRef: e,
|
|
486
492
|
isDragging: u,
|
|
487
493
|
isOvered: r,
|
|
488
494
|
isAllowed: l,
|
|
489
|
-
handleDragStart:
|
|
495
|
+
handleDragStart: i,
|
|
490
496
|
isVisible: v
|
|
491
497
|
};
|
|
492
498
|
}, Ue = (t) => {
|
|
493
|
-
const { zones: e, hovered: n, draggingElements:
|
|
499
|
+
const { zones: e, hovered: n, draggingElements: s, isDragging: u } = C(), r = x(null), l = D(() => {
|
|
494
500
|
var o;
|
|
495
501
|
return ((o = n.zone.value) == null ? void 0 : o.node) === r.value;
|
|
496
|
-
}), v =
|
|
502
|
+
}), v = D(() => {
|
|
497
503
|
if (!r.value || !u.value) return !1;
|
|
498
504
|
const o = e.value.find(
|
|
499
505
|
(f) => f.node === r.value
|
|
500
506
|
);
|
|
501
|
-
return o != null && o.groups.length ? !
|
|
502
|
-
(
|
|
507
|
+
return o != null && o.groups.length ? !s.value.some((f) => f.groups.length ? !f.groups.some(
|
|
508
|
+
(w) => o.groups.includes(w)
|
|
503
509
|
) : !1) : !0;
|
|
504
510
|
});
|
|
505
511
|
return { elementRef: r, registerZone: () => {
|
|
@@ -518,29 +524,29 @@ const C = Ie(() => {
|
|
|
518
524
|
o !== -1 && e.value.splice(o, 1);
|
|
519
525
|
}, isOvered: l, isAllowed: v };
|
|
520
526
|
}, qe = (t) => {
|
|
521
|
-
const { elementRef: e, registerZone: n, unregisterZone:
|
|
522
|
-
return F(n), j(
|
|
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 };
|
|
523
529
|
}, Be = (t) => {
|
|
524
|
-
const { selectedElements: e, elements: n } = C(),
|
|
530
|
+
const { selectedElements: e, elements: n } = C(), s = D(
|
|
525
531
|
() => n.value.find((o) => o.node === t.value)
|
|
526
|
-
), u =
|
|
532
|
+
), u = D(
|
|
527
533
|
() => e.value.some((o) => o.node === t.value)
|
|
528
|
-
), r =
|
|
534
|
+
), r = D(() => t.value ? e.value.some(
|
|
529
535
|
(o) => o.node && L(
|
|
530
536
|
o.node,
|
|
531
537
|
t.value
|
|
532
538
|
)
|
|
533
|
-
) : !1), l =
|
|
539
|
+
) : !1), l = D(() => t.value ? e.value.some(
|
|
534
540
|
(o) => o.node && L(
|
|
535
541
|
t.value,
|
|
536
542
|
o.node
|
|
537
543
|
)
|
|
538
544
|
) : !1), v = () => {
|
|
539
|
-
|
|
545
|
+
s.value && (e.value = e.value.filter(
|
|
540
546
|
(o) => o.node !== t.value
|
|
541
547
|
));
|
|
542
548
|
}, d = () => {
|
|
543
|
-
|
|
549
|
+
s.value && (r.value && (e.value = e.value.filter(
|
|
544
550
|
(o) => o.node && !L(
|
|
545
551
|
o.node,
|
|
546
552
|
t.value
|
|
@@ -550,13 +556,13 @@ const C = Ie(() => {
|
|
|
550
556
|
t.value,
|
|
551
557
|
o.node
|
|
552
558
|
)
|
|
553
|
-
)), e.value.push(
|
|
559
|
+
)), e.value.push(s.value));
|
|
554
560
|
};
|
|
555
561
|
return {
|
|
556
562
|
handleUnselect: v,
|
|
557
563
|
handleSelect: d,
|
|
558
564
|
handleToggleSelect: () => {
|
|
559
|
-
|
|
565
|
+
s.value && (e.value.some((o) => o.node === t.value) ? v() : d());
|
|
560
566
|
},
|
|
561
567
|
isSelected: u,
|
|
562
568
|
isParentOfSelected: r
|
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.37-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",
|