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