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