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