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