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