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