@vue-dnd-kit/core 0.0.49-beta → 0.1.2-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -3
- package/dist/vue-dnd-kit-core.cjs.js +1 -1
- package/dist/vue-dnd-kit-core.es.js +84 -86
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { default as DragOverlay } from './components/DragOverlay';
|
|
2
1
|
import { VueDndKitPlugin } from './plugin';
|
|
3
2
|
import { useDnDStore } from './composables/useDnDStore';
|
|
4
3
|
import { useDraggable } from './composables/useDraggable';
|
|
5
4
|
import { useDroppable } from './composables/useDroppable';
|
|
6
5
|
import { useSelection } from './composables/useSelection';
|
|
7
6
|
export default VueDndKitPlugin;
|
|
8
|
-
export {
|
|
9
|
-
export { getBoundingBox } from './utils/geometry';
|
|
7
|
+
export { useDraggable, useDroppable, useDnDStore, useSelection };
|
|
10
8
|
export type { IDnDStore, IActiveContainer, IBoundingBox, IDragElement, IDraggingElement, IDropZone, IPoint, IPointerPosition, IUseDragOptions, IUseDropOptions, } from './types';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("vue");function te(t){return n.getCurrentScope()?(n.onScopeDispose(t),!0):!1}function ne(t){let e=!1,r;const s=n.effectScope(!0);return(...c)=>(e||(r=s.run(()=>t(...c)),e=!0),r)}const re=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const oe=t=>t!=null,R=()=>{};function le(t,e){function r(...s){return new Promise((c,o)=>{Promise.resolve(t(()=>e.apply(this,s),{fn:e,thisArg:this,args:s})).then(c).catch(o)})}return r}function ie(...t){let e=0,r,s=!0,c=R,o,i,v,f,m;!n.isRef(t[0])&&typeof t[0]=="object"?{delay:i,trailing:v=!0,leading:f=!0,rejectOnCancel:m=!1}=t[0]:[i,v=!0,f=!0,m=!1]=t;const l=()=>{r&&(clearTimeout(r),r=void 0,c(),c=R)};return D=>{const p=n.toValue(i),E=Date.now()-e,u=()=>o=D();return l(),p<=0?(e=Date.now(),u()):(E>p&&(f||!s)?(e=Date.now(),u()):v&&(o=new Promise((h,y)=>{c=m?y:h,r=setTimeout(()=>{e=Date.now(),s=!0,h(u()),l()},Math.max(0,p-E))})),!f&&!r&&(r=setTimeout(()=>s=!0,p)),s=!1,o)}}function se(t){return Array.isArray(t)?t:[t]}function ue(t,e=200,r=!1,s=!0,c=!1){return le(ie(e,r,s,c),t)}function ae(t,e,r){const s=n.watch(t,(...c)=>(n.nextTick(()=>s()),e(...c)),r);return s}const Q=re?window:void 0;function B(t){var e;const r=n.toValue(t);return(e=r==null?void 0:r.$el)!=null?e:r}function ce(){const t=n.shallowRef(!1),e=n.getCurrentInstance();return e&&n.onMounted(()=>{t.value=!0},e),t}function de(t){const e=ce();return n.computed(()=>(e.value,!!t()))}function ve(t,e,r={}){const{root:s,rootMargin:c="0px",threshold:o=0,window:i=Q,immediate:v=!0}=r,f=de(()=>i&&"IntersectionObserver"in i),m=n.computed(()=>{const E=n.toValue(t);return se(E).map(B).filter(oe)});let l=R;const g=n.shallowRef(v),D=f.value?n.watch(()=>[m.value,B(s),g.value],([E,u])=>{if(l(),!g.value||!E.length)return;const h=new IntersectionObserver(e,{root:B(u),rootMargin:c,threshold:o});E.forEach(y=>y&&h.observe(y)),l=()=>{h.disconnect(),l=R}},{immediate:v,flush:"post"}):R,p=()=>{l(),D(),g.value=!1};return te(p),{isSupported:f,isActive:g,pause(){l(),g.value=!1},resume(){g.value=!0},stop:p}}function fe(t,e={}){const{window:r=Q,scrollTarget:s,threshold:c=0,rootMargin:o,once:i=!1}=e,v=n.shallowRef(!1),{stop:f}=ve(t,m=>{let l=v.value,g=0;for(const D of m)D.time>=g&&(g=D.time,l=D.isIntersecting);v.value=l,i&&ae(v,()=>{f()})},{root:s,window:r,threshold:c,rootMargin:n.toValue(o)});return v}const I=ne(()=>{const t=n.ref([]),e=n.computed(()=>t.value.length>0),r={component:n.ref(null),ref:n.ref(null)},s=n.ref([]),c=n.computed(()=>s.value.map((m,l)=>{var g;if((g=m.isVisible)!=null&&g.value||m.isVisible&&l)return l}).filter(m=>m!==void 0)),o=n.ref([]),i=n.ref([]),v={zone:n.ref(null),element:n.ref(null)},f={current:n.ref(null),start:n.ref(null),offset:{percent:n.ref(null),pixel:n.ref(null)}};return{isDragging:e,activeContainer:r,elements:s,draggingElements:t,selectedElements:o,zones:i,visibleElements:c,hovered:v,pointerPosition:f}}),ge=()=>{const t=n.ref(null),{draggingElements:e,pointerPosition:r,isDragging:s,activeContainer:c}=I();return n.onMounted(()=>{c.ref=t}),n.onBeforeUnmount(()=>{c.ref.value=null}),{elementRef:t,draggingElements:e,pointerPosition:r,isDragging:s}},me=["innerHTML"],he=n.defineComponent({__name:"DefaultOverlay",setup(t){const{elementRef:e,pointerPosition:r,isDragging:s,draggingElements:c}=ge(),o=n.computed(()=>{var i,v,f,m;return{transform:`translate3d(${(((i=r.current.value)==null?void 0:i.x)??0)-(((v=r.offset.pixel.value)==null?void 0:v.x)??0)}px, ${(((f=r.current.value)==null?void 0:f.y)??0)-(((m=r.offset.pixel.value)==null?void 0:m.y)??0)}px, 0)`,zIndex:1e3,position:"fixed",top:0,left:0,transition:"0.3s cubic-bezier(0.165, 0.84, 0.44, 1)"}});return(i,v)=>n.unref(s)?(n.openBlock(),n.createElementBlock("div",{key:0,ref_key:"elementRef",ref:e,style:n.normalizeStyle(o.value)},[(n.openBlock(!0),n.createElementBlock(n.Fragment,null,n.renderList(n.unref(c),(f,m)=>{var l,g;return n.openBlock(),n.createElementBlock("div",{key:m,innerHTML:f.initialHTML,style:n.normalizeStyle({width:`${(l=f.initialRect)==null?void 0:l.width}px`,height:`${(g=f.initialRect)==null?void 0:g.height}px`})},null,12,me)}),128))],4)):n.createCommentVNode("",!0)}}),U=n.defineComponent({__name:"DragOverlay",setup(t){const{activeContainer:e}=I(),r=n.computed(()=>e.component.value??he);return(s,c)=>(n.openBlock(),n.createBlock(n.resolveDynamicComponent(r.value)))}}),pe={install(t){t.component("DragOverlay",U);const e=t.mount;t.mount=function(s){const c=e.call(this,s),o=typeof s=="string"?document.querySelector(s):s;if(o&&o instanceof Element&&!o.querySelector("#vue-dnd-kit-overlay")){const i=document.createElement("div");i.id="vue-dnd-kit-overlay",o.appendChild(i);const v=n.createVNode(U);n.render(v,i),t.__VUE_DND_KIT_OVERLAY__={container:i,vnode:v}}return c};const r=t.unmount;t.unmount=function(){return t.__VUE_DND_KIT_OVERLAY__&&(n.render(null,t.__VUE_DND_KIT_OVERLAY__.container),delete t.__VUE_DND_KIT_OVERLAY__),r.call(this)}}},ye="data-dnd-draggable",Ee=t=>{const{elements:e,draggingElements:r,hovered:s,selectedElements:c,isDragging:o}=I(),i=n.ref(null),v=n.computed(()=>{var p;return((p=s.element.value)==null?void 0:p.node)===i.value}),f=fe(i),m=n.computed(()=>r.value.some(p=>p.node===i.value)),l=n.computed(()=>{if(!i.value||!o.value)return!1;const p=e.value.find(E=>E.node===i.value);return p!=null&&p.groups.length?!r.value.some(E=>E.groups.length?!E.groups.some(u=>p.groups.includes(u)):!1):!0});return{elementRef:i,registerElement:()=>{if(!i.value)throw new Error("ElementRef is not set");e.value.push({node:i.value,groups:(t==null?void 0:t.groups)??[],layer:(t==null?void 0:t.layer)??null,defaultLayer:(t==null?void 0:t.layer)??null,events:(t==null?void 0:t.events)??{},data:(t==null?void 0:t.data)??void 0,isVisible:f}),i.value.setAttribute(ye,"true")},unregisterElement:()=>{const p=e.value.findIndex(u=>u.node===i.value);p!==-1&&e.value.splice(p,1);const E=c.value.findIndex(u=>u.node===i.value);E!==-1&&c.value.splice(E,1)},isDragging:m,isOvered:v,isAllowed:l,isVisible:f}},we=()=>{let t="",e="",r="";const s=()=>{const i=document.body;t=i.style.userSelect,e=i.style.touchAction,r=i.style.overscrollBehavior,i.style.userSelect="none",i.style.touchAction="none",i.style.overscrollBehavior="none",window.addEventListener("contextmenu",o),window.addEventListener("selectstart",o),window.addEventListener("touchstart",o),window.addEventListener("touchmove",o)},c=()=>{const i=document.body;i.style.userSelect=t,i.style.touchAction=e,i.style.overscrollBehavior=r,window.removeEventListener("contextmenu",o),window.removeEventListener("selectstart",o),window.removeEventListener("touchstart",o),window.removeEventListener("touchmove",o)},o=i=>i.preventDefault();return{disableInteractions:s,enableInteractions:c}},G=(t,e)=>t.x<e.x+e.width&&t.x+t.width>e.x&&t.y<e.y+e.height&&t.y+t.height>e.y,T=t=>{if(!t)return{x:0,y:0,width:0,height:0,bottom:0,left:0,right:0,top:0};const e=t.getBoundingClientRect();return{bottom:e.bottom,left:e.left,right:e.right,top:e.top,x:e.x,y:e.y,width:e.width,height:e.height}},H=t=>({x:t.x+t.width/2,y:t.y+t.height/2}),Pe=(t,e)=>{const r=T(t);return{pixel:{x:e.x-r.x,y:e.y-r.y},percent:{x:(e.x-r.x)/r.width*100,y:(e.y-r.y)/r.height*100}}},J=(t,e)=>{const r=e.x-t.x,s=e.y-t.y;return Math.sqrt(r*r+s*s)},M=(t,e)=>t?e.contains(t):!1,De=t=>{const e=I();return{onPointerStart:o=>{e.pointerPosition.start.value={x:o.clientX,y:o.clientY},e.pointerPosition.current.value={x:o.clientX,y:o.clientY};const{pixel:i,percent:v}=Pe(t.value,{x:o.clientX,y:o.clientY});e.pointerPosition.offset.pixel.value=i,e.pointerPosition.offset.percent.value=v},onPointerMove:o=>{e.pointerPosition.current.value={x:o.clientX,y:o.clientY}},onPointerEnd:()=>{e.pointerPosition.current.value=null,e.pointerPosition.start.value=null,e.pointerPosition.offset.pixel.value=null,e.pointerPosition.offset.percent.value=null}}},_e=t=>{const e=I(),{onPointerStart:r,onPointerMove:s,onPointerEnd:c}=De(t);let o=null;const i=u=>{var w,P;const h=e.selectedElements.value.some(_=>_.node===u);if(e.selectedElements.value.length&&h)return e.selectedElements.value.map(_=>{var L,A;return{..._,initialHTML:((L=_.node)==null?void 0:L.outerHTML)??"",initialRect:(A=_.node)==null?void 0:A.getBoundingClientRect()}});e.selectedElements.value=[];const y=e.elements.value.find(_=>_.node===u);return y?[{...y,initialHTML:((w=y.node)==null?void 0:w.outerHTML)??"",initialRect:(P=y.node)==null?void 0:P.getBoundingClientRect()}]:[]},v=(u,h)=>{const y=Math.max(0,Math.min(u.x+u.width,h.x+h.width)-Math.max(u.x,h.x)),w=Math.max(0,Math.min(u.y+u.height,h.y+h.height)-Math.max(u.y,h.y)),P=y*w,_=u.width*u.height,L=h.width*h.height;return(P/_*100+P/L*100)/2},f=ue(()=>{var Y,N,F,Z,$,q,K,W,X,j;const u=T(e.activeContainer.ref.value),h=H(u),y=((Y=e.pointerPosition.current.value)==null?void 0:Y.x)??0,w=((N=e.pointerPosition.current.value)==null?void 0:N.y)??0,_=!(u&&y>=u.x&&y<=u.x+u.width&&w>=u.y&&w<=u.y+u.height),L=e.draggingElements.value.map(a=>a.node),A=e.visibleElements.value.map(a=>e.elements.value[a]).filter(a=>{if(!a.node||L.some(x=>x&&M(a.node,x))||a.groups.length&&!!e.draggingElements.value.some(S=>S.groups.length?!S.groups.some(C=>a.groups.includes(C)):!1))return!1;const d=T(a.node);return d&&u&&G(d,u)}).map(a=>{const d=T(a.node),x=H(d),S=y>=d.x&&y<=d.x+d.width&&w>=d.y&&w<=d.y+d.height,C=v(d,u),b=J(h,x),z=e.elements.value.filter(O=>O!==a&&O.node&&a.node&&M(a.node,O.node)).length;return{element:a,isPointerInElement:S,overlapPercent:C,depth:z,centerDistance:b}}).sort((a,d)=>{if(!_){if(a.isPointerInElement&&d.isPointerInElement)return d.depth-a.depth;if(a.isPointerInElement!==d.isPointerInElement)return a.isPointerInElement?-1:1}return Math.abs(a.overlapPercent-d.overlapPercent)<=1?a.centerDistance-d.centerDistance:d.overlapPercent-a.overlapPercent}),ee=e.zones.value.filter(a=>{if(!a.node||L.some(x=>x&&M(a.node,x))||a.groups.length&&!!e.draggingElements.value.some(S=>S.groups.length?!S.groups.some(C=>a.groups.includes(C)):!1))return!1;const d=T(a.node);return d&&u&&G(d,u)}).map(a=>{const d=T(a.node),x=H(d),S=y>=d.x&&y<=d.x+d.width&&w>=d.y&&w<=d.y+d.height,C=v(d,u),b=J(h,x),z=e.zones.value.filter(O=>O!==a&&O.node&&a.node&&M(a.node,O.node)).length;return{zone:a,isPointerInElement:S,overlapPercent:C,depth:z,centerDistance:b}}).sort((a,d)=>{if(!_){if(a.isPointerInElement&&d.isPointerInElement)return d.depth-a.depth;if(a.isPointerInElement!==d.isPointerInElement)return a.isPointerInElement?-1:1}return Math.abs(a.overlapPercent-d.overlapPercent)<=1?a.centerDistance-d.centerDistance:d.overlapPercent-a.overlapPercent}),k=e.hovered.element.value,V=e.hovered.zone.value;e.hovered.element.value=((F=A[0])==null?void 0:F.element)??null,e.hovered.zone.value=((Z=ee[0])==null?void 0:Z.zone)??null,e.hovered.element.value!==k&&(($=k==null?void 0:k.events)!=null&&$.onLeave&&k.events.onLeave(e),(K=(q=e.hovered.element.value)==null?void 0:q.events)!=null&&K.onHover&&e.hovered.element.value.events.onHover(e)),e.hovered.zone.value!==V&&((W=V==null?void 0:V.events)!=null&&W.onLeave&&V.events.onLeave(e),(j=(X=e.hovered.zone.value)==null?void 0:X.events)!=null&&j.onHover&&e.hovered.zone.value.events.onHover(e))},1e3),m=()=>{f(),o=requestAnimationFrame(m)},l=()=>{m()},g=()=>{o!==null&&(cancelAnimationFrame(o),o=null)};return{activate:u=>{e.draggingElements.value=i(t.value),r(u),l()},track:u=>{s(u)},deactivate:()=>{var u,h;c(),e.hovered.zone.value?(h=(u=e.hovered.zone.value.events).onDrop)==null||h.call(u,e):e.draggingElements.value.forEach(y=>{var w,P;return(P=(w=y.events).onEnd)==null?void 0:P.call(w,e)}),e.draggingElements.value=[],e.selectedElements.value=[],e.hovered.zone.value=null,e.hovered.element.value=null,g()}}},xe=t=>{const{elementRef:e,registerElement:r,unregisterElement:s,isDragging:c,isOvered:o,isAllowed:i,isVisible:v}=Ee(t),{disableInteractions:f,enableInteractions:m}=we(),{activeContainer:l,pointerPosition:g}=I(),{activate:D,track:p,deactivate:E}=_e(e),u=P=>{t!=null&&t.container&&(l.component.value=n.markRaw(t.container)),f(),D(P),document.addEventListener("pointermove",h),document.addEventListener("pointerup",w),document.addEventListener("wheel",y)},h=P=>p(P),y=P=>p(P),w=()=>{l.component.value=null,m(),E(),document.removeEventListener("pointermove",h),document.removeEventListener("pointerup",w),document.removeEventListener("wheel",y)};return n.onMounted(r),n.onBeforeUnmount(s),{pointerPosition:g,elementRef:e,isDragging:c,isOvered:o,isAllowed:i,handleDragStart:u,isVisible:v}},Se=t=>{const{zones:e,hovered:r,draggingElements:s,isDragging:c}=I(),o=n.ref(null),i=n.computed(()=>{var l;return((l=r.zone.value)==null?void 0:l.node)===o.value}),v=n.computed(()=>{if(!o.value||!c.value)return!1;const l=e.value.find(g=>g.node===o.value);return l!=null&&l.groups.length?!s.value.some(g=>g.groups.length?!g.groups.some(D=>l.groups.includes(D)):!1):!0});return{elementRef:o,registerZone:()=>{if(!o.value)throw new Error("elementRef is not set");e.value.push({node:o.value,groups:(t==null?void 0:t.groups)??[],events:(t==null?void 0:t.events)??{},data:(t==null?void 0:t.data)??void 0}),o.value.setAttribute("data-dnd-droppable","true")},unregisterZone:()=>{if(!o.value)throw new Error("elementRef is not set");const l=e.value.findIndex(g=>g.node===o.value);l!==-1&&e.value.splice(l,1)},isOvered:i,isAllowed:v}},Ie=t=>{const{elementRef:e,registerZone:r,unregisterZone:s,isOvered:c,isAllowed:o}=Se(t);return n.onMounted(r),n.onBeforeUnmount(s),{elementRef:e,isOvered:c,isAllowed:o}},Me=t=>{const{selectedElements:e,elements:r}=I(),s=n.computed(()=>r.value.find(l=>l.node===t.value)),c=n.computed(()=>e.value.some(l=>l.node===t.value)),o=n.computed(()=>t.value?e.value.some(l=>l.node&&M(l.node,t.value)):!1),i=n.computed(()=>t.value?e.value.some(l=>l.node&&M(t.value,l.node)):!1),v=()=>{s.value&&(e.value=e.value.filter(l=>l.node!==t.value))},f=()=>{s.value&&(o.value&&(e.value=e.value.filter(l=>l.node&&!M(l.node,t.value))),i.value&&(e.value=e.value.filter(l=>l.node&&!M(t.value,l.node))),e.value.push(s.value))};return{handleUnselect:v,handleSelect:f,handleToggleSelect:()=>{s.value&&(e.value.some(l=>l.node===t.value)?v():f())},isSelected:c,isParentOfSelected:o}};exports.DragOverlay=U;exports.default=pe;exports.getBoundingBox=T;exports.useDnDStore=I;exports.useDraggable=xe;exports.useDroppable=Ie;exports.useSelection=Me;
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("vue");function te(t){return n.getCurrentScope()?(n.onScopeDispose(t),!0):!1}function ne(t){let e=!1,r;const s=n.effectScope(!0);return(...c)=>(e||(r=s.run(()=>t(...c)),e=!0),r)}const re=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const oe=t=>t!=null,R=()=>{};function le(t,e){function r(...s){return new Promise((c,o)=>{Promise.resolve(t(()=>e.apply(this,s),{fn:e,thisArg:this,args:s})).then(c).catch(o)})}return r}function ie(...t){let e=0,r,s=!0,c=R,o,l,v,f,g;!n.isRef(t[0])&&typeof t[0]=="object"?{delay:l,trailing:v=!0,leading:f=!0,rejectOnCancel:g=!1}=t[0]:[l,v=!0,f=!0,g=!1]=t;const i=()=>{r&&(clearTimeout(r),r=void 0,c(),c=R)};return D=>{const p=n.toValue(l),E=Date.now()-e,u=()=>o=D();return i(),p<=0?(e=Date.now(),u()):(E>p&&(f||!s)?(e=Date.now(),u()):v&&(o=new Promise((h,y)=>{c=g?y:h,r=setTimeout(()=>{e=Date.now(),s=!0,h(u()),i()},Math.max(0,p-E))})),!f&&!r&&(r=setTimeout(()=>s=!0,p)),s=!1,o)}}function se(t){return Array.isArray(t)?t:[t]}function ue(t,e=200,r=!1,s=!0,c=!1){return le(ie(e,r,s,c),t)}function ae(t,e,r){const s=n.watch(t,(...c)=>(n.nextTick(()=>s()),e(...c)),r);return s}const Q=re?window:void 0;function H(t){var e;const r=n.toValue(t);return(e=r==null?void 0:r.$el)!=null?e:r}function ce(){const t=n.shallowRef(!1),e=n.getCurrentInstance();return e&&n.onMounted(()=>{t.value=!0},e),t}function de(t){const e=ce();return n.computed(()=>(e.value,!!t()))}function ve(t,e,r={}){const{root:s,rootMargin:c="0px",threshold:o=0,window:l=Q,immediate:v=!0}=r,f=de(()=>l&&"IntersectionObserver"in l),g=n.computed(()=>{const E=n.toValue(t);return se(E).map(H).filter(oe)});let i=R;const m=n.shallowRef(v),D=f.value?n.watch(()=>[g.value,H(s),m.value],([E,u])=>{if(i(),!m.value||!E.length)return;const h=new IntersectionObserver(e,{root:H(u),rootMargin:c,threshold:o});E.forEach(y=>y&&h.observe(y)),i=()=>{h.disconnect(),i=R}},{immediate:v,flush:"post"}):R,p=()=>{i(),D(),m.value=!1};return te(p),{isSupported:f,isActive:m,pause(){i(),m.value=!1},resume(){m.value=!0},stop:p}}function fe(t,e={}){const{window:r=Q,scrollTarget:s,threshold:c=0,rootMargin:o,once:l=!1}=e,v=n.shallowRef(!1),{stop:f}=ve(t,g=>{let i=v.value,m=0;for(const D of g)D.time>=m&&(m=D.time,i=D.isIntersecting);v.value=i,l&&ae(v,()=>{f()})},{root:s,window:r,threshold:c,rootMargin:n.toValue(o)});return v}const I=ne(()=>{const t=n.ref([]),e=n.computed(()=>t.value.length>0),r={component:n.ref(null),ref:n.ref(null)},s=n.ref([]),c=n.computed(()=>s.value.map((g,i)=>{var m;if((m=g.isVisible)!=null&&m.value||g.isVisible&&i)return i}).filter(g=>g!==void 0)),o=n.ref([]),l=n.ref([]),v={zone:n.ref(null),element:n.ref(null)},f={current:n.ref(null),start:n.ref(null),offset:{percent:n.ref(null),pixel:n.ref(null)}};return{isDragging:e,activeContainer:r,elements:s,draggingElements:t,selectedElements:o,zones:l,visibleElements:c,hovered:v,pointerPosition:f}}),me=()=>{const t=n.ref(null),{draggingElements:e,pointerPosition:r,isDragging:s,activeContainer:c}=I();return n.onMounted(()=>{c.ref=t}),n.onBeforeUnmount(()=>{c.ref.value=null}),{elementRef:t,draggingElements:e,pointerPosition:r,isDragging:s}},ge=["innerHTML"],he=n.defineComponent({__name:"DefaultOverlay",setup(t){const{elementRef:e,pointerPosition:r,isDragging:s,draggingElements:c}=me(),o=n.computed(()=>{var l,v,f,g;return{transform:`translate3d(${(((l=r.current.value)==null?void 0:l.x)??0)-(((v=r.offset.pixel.value)==null?void 0:v.x)??0)}px, ${(((f=r.current.value)==null?void 0:f.y)??0)-(((g=r.offset.pixel.value)==null?void 0:g.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(l,v)=>n.unref(s)?(n.openBlock(),n.createElementBlock("div",{key:0,ref_key:"elementRef",ref:e,style:n.normalizeStyle(o.value)},[(n.openBlock(!0),n.createElementBlock(n.Fragment,null,n.renderList(n.unref(c),(f,g)=>{var i,m;return n.openBlock(),n.createElementBlock("div",{key:g,innerHTML:f.initialHTML,style:n.normalizeStyle({width:`${(i=f.initialRect)==null?void 0:i.width}px`,height:`${(m=f.initialRect)==null?void 0:m.height}px`})},null,12,ge)}),128))],4)):n.createCommentVNode("",!0)}}),j=n.defineComponent({__name:"DragOverlay",setup(t){const{activeContainer:e}=I(),r=n.computed(()=>e.component.value??he);return(s,c)=>(n.openBlock(),n.createBlock(n.resolveDynamicComponent(r.value)))}}),pe={install(t){t.component("DragOverlay",j);const e=t.mount;t.mount=function(s){const c=e.call(this,s),o=typeof s=="string"?document.querySelector(s):s;if(o&&o instanceof Element&&!o.querySelector("#vue-dnd-kit-overlay")){const l=document.createElement("div");l.id="vue-dnd-kit-overlay",l.style.pointerEvents="none",o.appendChild(l);const v=n.createVNode(j);n.render(v,l),t.__VUE_DND_KIT_OVERLAY__={container:l,vnode:v}}return c};const r=t.unmount;t.unmount=function(){return t.__VUE_DND_KIT_OVERLAY__&&(n.render(null,t.__VUE_DND_KIT_OVERLAY__.container),delete t.__VUE_DND_KIT_OVERLAY__),r.call(this)}}},ye="data-dnd-draggable",Ee=t=>{const{elements:e,draggingElements:r,hovered:s,selectedElements:c,isDragging:o}=I(),l=n.ref(null),v=n.computed(()=>{var p;return((p=s.element.value)==null?void 0:p.node)===l.value}),f=fe(l),g=n.computed(()=>r.value.some(p=>p.node===l.value)),i=n.computed(()=>{if(!l.value||!o.value)return!1;const p=e.value.find(E=>E.node===l.value);return p!=null&&p.groups.length?!r.value.some(E=>E.groups.length?!E.groups.some(u=>p.groups.includes(u)):!1):!0});return{elementRef:l,registerElement:()=>{if(!l.value)throw new Error("ElementRef is not set");e.value.push({node:l.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}),l.value.setAttribute(ye,"true")},unregisterElement:()=>{const p=e.value.findIndex(u=>u.node===l.value);p!==-1&&e.value.splice(p,1);const E=c.value.findIndex(u=>u.node===l.value);E!==-1&&c.value.splice(E,1)},isDragging:g,isOvered:v,isAllowed:i,isVisible:f}},we=()=>{let t="",e="",r="";const s=()=>{const l=document.body;t=l.style.userSelect,e=l.style.touchAction,r=l.style.overscrollBehavior,l.style.userSelect="none",l.style.touchAction="none",l.style.overscrollBehavior="none",window.addEventListener("contextmenu",o),window.addEventListener("selectstart",o),window.addEventListener("touchstart",o),window.addEventListener("touchmove",o)},c=()=>{const l=document.body;l.style.userSelect=t,l.style.touchAction=e,l.style.overscrollBehavior=r,window.removeEventListener("contextmenu",o),window.removeEventListener("selectstart",o),window.removeEventListener("touchstart",o),window.removeEventListener("touchmove",o)},o=l=>l.preventDefault();return{disableInteractions:s,enableInteractions:c}},G=(t,e)=>t.x<e.x+e.width&&t.x+t.width>e.x&&t.y<e.y+e.height&&t.y+t.height>e.y,T=t=>{if(!t)return{x:0,y:0,width:0,height:0,bottom:0,left:0,right:0,top:0};const e=t.getBoundingClientRect();return{bottom:e.bottom,left:e.left,right:e.right,top:e.top,x:e.x,y:e.y,width:e.width,height:e.height}},U=t=>({x:t.x+t.width/2,y:t.y+t.height/2}),Pe=(t,e)=>{const r=T(t);return{pixel:{x:e.x-r.x,y:e.y-r.y},percent:{x:(e.x-r.x)/r.width*100,y:(e.y-r.y)/r.height*100}}},J=(t,e)=>{const r=e.x-t.x,s=e.y-t.y;return Math.sqrt(r*r+s*s)},M=(t,e)=>t?e.contains(t):!1,De=t=>{const e=I();return{onPointerStart:o=>{e.pointerPosition.start.value={x:o.clientX,y:o.clientY},e.pointerPosition.current.value={x:o.clientX,y:o.clientY};const{pixel:l,percent:v}=Pe(t.value,{x:o.clientX,y:o.clientY});e.pointerPosition.offset.pixel.value=l,e.pointerPosition.offset.percent.value=v},onPointerMove:o=>{e.pointerPosition.current.value={x:o.clientX,y:o.clientY}},onPointerEnd:()=>{e.pointerPosition.current.value=null,e.pointerPosition.start.value=null,e.pointerPosition.offset.pixel.value=null,e.pointerPosition.offset.percent.value=null}}},_e=t=>{const e=I(),{onPointerStart:r,onPointerMove:s,onPointerEnd:c}=De(t);let o=null;const l=u=>{var w,P;const h=e.selectedElements.value.some(_=>_.node===u);if(e.selectedElements.value.length&&h)return e.selectedElements.value.map(_=>{var L,A;return{..._,initialHTML:((L=_.node)==null?void 0:L.outerHTML)??"",initialRect:(A=_.node)==null?void 0:A.getBoundingClientRect()}});e.selectedElements.value=[];const y=e.elements.value.find(_=>_.node===u);return y?[{...y,initialHTML:((w=y.node)==null?void 0:w.outerHTML)??"",initialRect:(P=y.node)==null?void 0:P.getBoundingClientRect()}]:[]},v=(u,h)=>{const y=Math.max(0,Math.min(u.x+u.width,h.x+h.width)-Math.max(u.x,h.x)),w=Math.max(0,Math.min(u.y+u.height,h.y+h.height)-Math.max(u.y,h.y)),P=y*w,_=u.width*u.height,L=h.width*h.height;return(P/_*100+P/L*100)/2},f=ue(()=>{var B,Y,N,F,Z,$,q,K,W,X;const u=T(e.activeContainer.ref.value),h=U(u),y=((B=e.pointerPosition.current.value)==null?void 0:B.x)??0,w=((Y=e.pointerPosition.current.value)==null?void 0:Y.y)??0,_=!(u&&y>=u.x&&y<=u.x+u.width&&w>=u.y&&w<=u.y+u.height),L=e.draggingElements.value.map(a=>a.node),A=e.visibleElements.value.map(a=>e.elements.value[a]).filter(a=>{if(!a.node||L.some(x=>x&&M(a.node,x))||a.groups.length&&!!e.draggingElements.value.some(S=>S.groups.length?!S.groups.some(C=>a.groups.includes(C)):!1))return!1;const d=T(a.node);return d&&u&&G(d,u)}).map(a=>{const d=T(a.node),x=U(d),S=y>=d.x&&y<=d.x+d.width&&w>=d.y&&w<=d.y+d.height,C=v(d,u),b=J(h,x),z=e.elements.value.filter(O=>O!==a&&O.node&&a.node&&M(a.node,O.node)).length;return{element:a,isPointerInElement:S,overlapPercent:C,depth:z,centerDistance:b}}).sort((a,d)=>{if(!_){if(a.isPointerInElement&&d.isPointerInElement)return d.depth-a.depth;if(a.isPointerInElement!==d.isPointerInElement)return a.isPointerInElement?-1:1}return Math.abs(a.overlapPercent-d.overlapPercent)<=1?a.centerDistance-d.centerDistance:d.overlapPercent-a.overlapPercent}),ee=e.zones.value.filter(a=>{if(!a.node||L.some(x=>x&&M(a.node,x))||a.groups.length&&!!e.draggingElements.value.some(S=>S.groups.length?!S.groups.some(C=>a.groups.includes(C)):!1))return!1;const d=T(a.node);return d&&u&&G(d,u)}).map(a=>{const d=T(a.node),x=U(d),S=y>=d.x&&y<=d.x+d.width&&w>=d.y&&w<=d.y+d.height,C=v(d,u),b=J(h,x),z=e.zones.value.filter(O=>O!==a&&O.node&&a.node&&M(a.node,O.node)).length;return{zone:a,isPointerInElement:S,overlapPercent:C,depth:z,centerDistance:b}}).sort((a,d)=>{if(!_){if(a.isPointerInElement&&d.isPointerInElement)return d.depth-a.depth;if(a.isPointerInElement!==d.isPointerInElement)return a.isPointerInElement?-1:1}return Math.abs(a.overlapPercent-d.overlapPercent)<=1?a.centerDistance-d.centerDistance:d.overlapPercent-a.overlapPercent}),k=e.hovered.element.value,V=e.hovered.zone.value;e.hovered.element.value=((N=A[0])==null?void 0:N.element)??null,e.hovered.zone.value=((F=ee[0])==null?void 0:F.zone)??null,e.hovered.element.value!==k&&((Z=k==null?void 0:k.events)!=null&&Z.onLeave&&k.events.onLeave(e),(q=($=e.hovered.element.value)==null?void 0:$.events)!=null&&q.onHover&&e.hovered.element.value.events.onHover(e)),e.hovered.zone.value!==V&&((K=V==null?void 0:V.events)!=null&&K.onLeave&&V.events.onLeave(e),(X=(W=e.hovered.zone.value)==null?void 0:W.events)!=null&&X.onHover&&e.hovered.zone.value.events.onHover(e))},1e3),g=()=>{f(),o=requestAnimationFrame(g)},i=()=>{g()},m=()=>{o!==null&&(cancelAnimationFrame(o),o=null)};return{activate:u=>{e.draggingElements.value=l(t.value),r(u),i()},track:u=>{s(u)},deactivate:()=>{var u,h;c(),e.hovered.zone.value?(h=(u=e.hovered.zone.value.events).onDrop)==null||h.call(u,e):e.draggingElements.value.forEach(y=>{var w,P;return(P=(w=y.events).onEnd)==null?void 0:P.call(w,e)}),e.draggingElements.value=[],e.selectedElements.value=[],e.hovered.zone.value=null,e.hovered.element.value=null,m()}}},xe=t=>{const{elementRef:e,registerElement:r,unregisterElement:s,isDragging:c,isOvered:o,isAllowed:l,isVisible:v}=Ee(t),{disableInteractions:f,enableInteractions:g}=we(),{activeContainer:i,pointerPosition:m}=I(),{activate:D,track:p,deactivate:E}=_e(e),u=P=>{t!=null&&t.container&&(i.component.value=n.markRaw(t.container)),f(),D(P),document.addEventListener("pointermove",h),document.addEventListener("pointerup",w),document.addEventListener("wheel",y)},h=P=>p(P),y=P=>p(P),w=()=>{i.component.value=null,g(),E(),document.removeEventListener("pointermove",h),document.removeEventListener("pointerup",w),document.removeEventListener("wheel",y)};return n.onMounted(r),n.onBeforeUnmount(s),{pointerPosition:m,elementRef:e,isDragging:c,isOvered:o,isAllowed:l,handleDragStart:u,isVisible:v}},Se=t=>{const{zones:e,hovered:r,draggingElements:s,isDragging:c}=I(),o=n.ref(null),l=n.computed(()=>{var i;return((i=r.zone.value)==null?void 0:i.node)===o.value}),v=n.computed(()=>{if(!o.value||!c.value)return!1;const i=e.value.find(m=>m.node===o.value);return i!=null&&i.groups.length?!s.value.some(m=>m.groups.length?!m.groups.some(D=>i.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 i=e.value.findIndex(m=>m.node===o.value);i!==-1&&e.value.splice(i,1)},isOvered:l,isAllowed:v}},Ie=t=>{const{elementRef:e,registerZone:r,unregisterZone:s,isOvered:c,isAllowed:o}=Se(t);return n.onMounted(r),n.onBeforeUnmount(s),{elementRef:e,isOvered:c,isAllowed:o}},Me=t=>{const{selectedElements:e,elements:r}=I(),s=n.computed(()=>r.value.find(i=>i.node===t.value)),c=n.computed(()=>e.value.some(i=>i.node===t.value)),o=n.computed(()=>t.value?e.value.some(i=>i.node&&M(i.node,t.value)):!1),l=n.computed(()=>t.value?e.value.some(i=>i.node&&M(t.value,i.node)):!1),v=()=>{s.value&&(e.value=e.value.filter(i=>i.node!==t.value))},f=()=>{s.value&&(o.value&&(e.value=e.value.filter(i=>i.node&&!M(i.node,t.value))),l.value&&(e.value=e.value.filter(i=>i.node&&!M(t.value,i.node))),e.value.push(s.value))};return{handleUnselect:v,handleSelect:f,handleToggleSelect:()=>{s.value&&(e.value.some(i=>i.node===t.value)?v():f())},isSelected:c,isParentOfSelected:o}};exports.default=pe;exports.useDnDStore=I;exports.useDraggable=xe;exports.useDroppable=Ie;exports.useSelection=Me;
|
|
@@ -20,16 +20,16 @@ function Oe(t, e) {
|
|
|
20
20
|
return n;
|
|
21
21
|
}
|
|
22
22
|
function Te(...t) {
|
|
23
|
-
let e = 0, n, i = !0, u = A, r,
|
|
24
|
-
!me(t[0]) && typeof t[0] == "object" ? { delay:
|
|
25
|
-
const
|
|
23
|
+
let e = 0, n, i = !0, u = A, r, o, d, v, g;
|
|
24
|
+
!me(t[0]) && typeof t[0] == "object" ? { delay: o, trailing: d = !0, leading: v = !0, rejectOnCancel: g = !1 } = t[0] : [o, d = !0, v = !0, g = !1] = t;
|
|
25
|
+
const l = () => {
|
|
26
26
|
n && (clearTimeout(n), n = void 0, u(), u = A);
|
|
27
27
|
};
|
|
28
28
|
return (_) => {
|
|
29
|
-
const h = b(
|
|
30
|
-
return
|
|
29
|
+
const h = b(o), y = Date.now() - e, s = () => r = _();
|
|
30
|
+
return l(), h <= 0 ? (e = Date.now(), s()) : (y > h && (v || !i) ? (e = Date.now(), s()) : d && (r = new Promise((m, p) => {
|
|
31
31
|
u = g ? p : m, n = setTimeout(() => {
|
|
32
|
-
e = Date.now(), i = !0, m(s()),
|
|
32
|
+
e = Date.now(), i = !0, m(s()), l();
|
|
33
33
|
}, Math.max(0, h - y));
|
|
34
34
|
})), !v && !n && (n = setTimeout(() => i = !0, h)), i = !1, r);
|
|
35
35
|
};
|
|
@@ -68,17 +68,17 @@ function He(t, e, n = {}) {
|
|
|
68
68
|
root: i,
|
|
69
69
|
rootMargin: u = "0px",
|
|
70
70
|
threshold: r = 0,
|
|
71
|
-
window:
|
|
71
|
+
window: o = de,
|
|
72
72
|
immediate: d = !0
|
|
73
|
-
} = n, v = ze(() =>
|
|
73
|
+
} = n, v = ze(() => o && "IntersectionObserver" in o), g = D(() => {
|
|
74
74
|
const y = b(t);
|
|
75
75
|
return Ve(y).map(Z).filter(Ce);
|
|
76
76
|
});
|
|
77
|
-
let
|
|
77
|
+
let l = A;
|
|
78
78
|
const f = K(d), _ = v.value ? ue(
|
|
79
79
|
() => [g.value, Z(i), f.value],
|
|
80
80
|
([y, s]) => {
|
|
81
|
-
if (
|
|
81
|
+
if (l(), !f.value || !y.length)
|
|
82
82
|
return;
|
|
83
83
|
const m = new IntersectionObserver(
|
|
84
84
|
e,
|
|
@@ -88,19 +88,19 @@ function He(t, e, n = {}) {
|
|
|
88
88
|
threshold: r
|
|
89
89
|
}
|
|
90
90
|
);
|
|
91
|
-
y.forEach((p) => p && m.observe(p)),
|
|
92
|
-
m.disconnect(),
|
|
91
|
+
y.forEach((p) => p && m.observe(p)), l = () => {
|
|
92
|
+
m.disconnect(), l = A;
|
|
93
93
|
};
|
|
94
94
|
},
|
|
95
95
|
{ immediate: d, flush: "post" }
|
|
96
96
|
) : A, h = () => {
|
|
97
|
-
|
|
97
|
+
l(), _(), f.value = !1;
|
|
98
98
|
};
|
|
99
99
|
return Le(h), {
|
|
100
100
|
isSupported: v,
|
|
101
101
|
isActive: f,
|
|
102
102
|
pause() {
|
|
103
|
-
|
|
103
|
+
l(), f.value = !1;
|
|
104
104
|
},
|
|
105
105
|
resume() {
|
|
106
106
|
f.value = !0;
|
|
@@ -114,14 +114,14 @@ function be(t, e = {}) {
|
|
|
114
114
|
scrollTarget: i,
|
|
115
115
|
threshold: u = 0,
|
|
116
116
|
rootMargin: r,
|
|
117
|
-
once:
|
|
117
|
+
once: o = !1
|
|
118
118
|
} = e, d = K(!1), { stop: v } = He(
|
|
119
119
|
t,
|
|
120
120
|
(g) => {
|
|
121
|
-
let
|
|
121
|
+
let l = d.value, f = 0;
|
|
122
122
|
for (const _ of g)
|
|
123
|
-
_.time >= f && (f = _.time,
|
|
124
|
-
d.value =
|
|
123
|
+
_.time >= f && (f = _.time, l = _.isIntersecting);
|
|
124
|
+
d.value = l, o && Re(d, () => {
|
|
125
125
|
v();
|
|
126
126
|
});
|
|
127
127
|
},
|
|
@@ -139,12 +139,12 @@ const M = Se(() => {
|
|
|
139
139
|
component: P(null),
|
|
140
140
|
ref: P(null)
|
|
141
141
|
}, i = P([]), u = D(
|
|
142
|
-
() => i.value.map((g,
|
|
142
|
+
() => i.value.map((g, l) => {
|
|
143
143
|
var f;
|
|
144
|
-
if ((f = g.isVisible) != null && f.value || g.isVisible &&
|
|
145
|
-
return
|
|
144
|
+
if ((f = g.isVisible) != null && f.value || g.isVisible && l)
|
|
145
|
+
return l;
|
|
146
146
|
}).filter((g) => g !== void 0)
|
|
147
|
-
), r = P([]),
|
|
147
|
+
), r = P([]), o = P([]), d = {
|
|
148
148
|
zone: P(null),
|
|
149
149
|
element: P(null)
|
|
150
150
|
}, v = {
|
|
@@ -161,7 +161,7 @@ const M = Se(() => {
|
|
|
161
161
|
elements: i,
|
|
162
162
|
draggingElements: t,
|
|
163
163
|
selectedElements: r,
|
|
164
|
-
zones:
|
|
164
|
+
zones: o,
|
|
165
165
|
visibleElements: u,
|
|
166
166
|
hovered: d,
|
|
167
167
|
pointerPosition: v
|
|
@@ -182,9 +182,9 @@ const M = Se(() => {
|
|
|
182
182
|
__name: "DefaultOverlay",
|
|
183
183
|
setup(t) {
|
|
184
184
|
const { elementRef: e, pointerPosition: n, isDragging: i, draggingElements: u } = Ue(), r = D(() => {
|
|
185
|
-
var
|
|
185
|
+
var o, d, v, g;
|
|
186
186
|
return {
|
|
187
|
-
transform: `translate3d(${(((
|
|
187
|
+
transform: `translate3d(${(((o = n.current.value) == null ? void 0 : o.x) ?? 0) - (((d = n.offset.pixel.value) == null ? void 0 : d.x) ?? 0)}px, ${(((v = n.current.value) == null ? void 0 : v.y) ?? 0) - (((g = n.offset.pixel.value) == null ? void 0 : g.y) ?? 0)}px, 0)`,
|
|
188
188
|
zIndex: 1e3,
|
|
189
189
|
position: "fixed",
|
|
190
190
|
top: 0,
|
|
@@ -192,19 +192,19 @@ const M = Se(() => {
|
|
|
192
192
|
transition: "0.3s cubic-bezier(0.165, 0.84, 0.44, 1)"
|
|
193
193
|
};
|
|
194
194
|
});
|
|
195
|
-
return (
|
|
195
|
+
return (o, d) => re(i) ? (H(), F("div", {
|
|
196
196
|
key: 0,
|
|
197
197
|
ref_key: "elementRef",
|
|
198
198
|
ref: e,
|
|
199
199
|
style: oe(r.value)
|
|
200
200
|
}, [
|
|
201
201
|
(H(!0), F(we, null, Pe(re(u), (v, g) => {
|
|
202
|
-
var
|
|
202
|
+
var l, f;
|
|
203
203
|
return H(), F("div", {
|
|
204
204
|
key: g,
|
|
205
205
|
innerHTML: v.initialHTML,
|
|
206
206
|
style: oe({
|
|
207
|
-
width: `${(
|
|
207
|
+
width: `${(l = v.initialRect) == null ? void 0 : l.width}px`,
|
|
208
208
|
height: `${(f = v.initialRect) == null ? void 0 : f.height}px`
|
|
209
209
|
})
|
|
210
210
|
}, null, 12, Ye);
|
|
@@ -226,11 +226,11 @@ const M = Se(() => {
|
|
|
226
226
|
t.mount = function(i) {
|
|
227
227
|
const u = e.call(this, i), r = typeof i == "string" ? document.querySelector(i) : i;
|
|
228
228
|
if (r && r instanceof Element && !r.querySelector("#vue-dnd-kit-overlay")) {
|
|
229
|
-
const
|
|
230
|
-
|
|
229
|
+
const o = document.createElement("div");
|
|
230
|
+
o.id = "vue-dnd-kit-overlay", o.style.pointerEvents = "none", r.appendChild(o);
|
|
231
231
|
const d = xe(ie);
|
|
232
|
-
le(d,
|
|
233
|
-
container:
|
|
232
|
+
le(d, o), t.__VUE_DND_KIT_OVERLAY__ = {
|
|
233
|
+
container: o,
|
|
234
234
|
vnode: d
|
|
235
235
|
};
|
|
236
236
|
}
|
|
@@ -248,60 +248,60 @@ const M = Se(() => {
|
|
|
248
248
|
hovered: i,
|
|
249
249
|
selectedElements: u,
|
|
250
250
|
isDragging: r
|
|
251
|
-
} = M(),
|
|
251
|
+
} = M(), o = P(null), d = D(
|
|
252
252
|
() => {
|
|
253
253
|
var h;
|
|
254
|
-
return ((h = i.element.value) == null ? void 0 : h.node) ===
|
|
254
|
+
return ((h = i.element.value) == null ? void 0 : h.node) === o.value;
|
|
255
255
|
}
|
|
256
|
-
), v = be(
|
|
257
|
-
() => n.value.some((h) => h.node ===
|
|
258
|
-
),
|
|
259
|
-
if (!
|
|
256
|
+
), v = be(o), g = D(
|
|
257
|
+
() => n.value.some((h) => h.node === o.value)
|
|
258
|
+
), l = D(() => {
|
|
259
|
+
if (!o.value || !r.value) return !1;
|
|
260
260
|
const h = e.value.find(
|
|
261
|
-
(y) => y.node ===
|
|
261
|
+
(y) => y.node === o.value
|
|
262
262
|
);
|
|
263
263
|
return h != null && h.groups.length ? !n.value.some((y) => y.groups.length ? !y.groups.some(
|
|
264
264
|
(s) => h.groups.includes(s)
|
|
265
265
|
) : !1) : !0;
|
|
266
266
|
});
|
|
267
267
|
return {
|
|
268
|
-
elementRef:
|
|
268
|
+
elementRef: o,
|
|
269
269
|
registerElement: () => {
|
|
270
|
-
if (!
|
|
270
|
+
if (!o.value) throw new Error("ElementRef is not set");
|
|
271
271
|
e.value.push({
|
|
272
|
-
node:
|
|
272
|
+
node: o.value,
|
|
273
273
|
groups: (t == null ? void 0 : t.groups) ?? [],
|
|
274
274
|
layer: (t == null ? void 0 : t.layer) ?? null,
|
|
275
275
|
defaultLayer: (t == null ? void 0 : t.layer) ?? null,
|
|
276
276
|
events: (t == null ? void 0 : t.events) ?? {},
|
|
277
277
|
data: (t == null ? void 0 : t.data) ?? void 0,
|
|
278
278
|
isVisible: v
|
|
279
|
-
}),
|
|
279
|
+
}), o.value.setAttribute(Fe, "true");
|
|
280
280
|
},
|
|
281
281
|
unregisterElement: () => {
|
|
282
282
|
const h = e.value.findIndex(
|
|
283
|
-
(s) => s.node ===
|
|
283
|
+
(s) => s.node === o.value
|
|
284
284
|
);
|
|
285
285
|
h !== -1 && e.value.splice(h, 1);
|
|
286
286
|
const y = u.value.findIndex(
|
|
287
|
-
(s) => s.node ===
|
|
287
|
+
(s) => s.node === o.value
|
|
288
288
|
);
|
|
289
289
|
y !== -1 && u.value.splice(y, 1);
|
|
290
290
|
},
|
|
291
291
|
isDragging: g,
|
|
292
292
|
isOvered: d,
|
|
293
|
-
isAllowed:
|
|
293
|
+
isAllowed: l,
|
|
294
294
|
isVisible: v
|
|
295
295
|
};
|
|
296
296
|
}, $e = () => {
|
|
297
297
|
let t = "", e = "", n = "";
|
|
298
298
|
const i = () => {
|
|
299
|
-
const
|
|
300
|
-
t =
|
|
299
|
+
const o = document.body;
|
|
300
|
+
t = o.style.userSelect, e = o.style.touchAction, n = o.style.overscrollBehavior, o.style.userSelect = "none", o.style.touchAction = "none", o.style.overscrollBehavior = "none", window.addEventListener("contextmenu", r), window.addEventListener("selectstart", r), window.addEventListener("touchstart", r), window.addEventListener("touchmove", r);
|
|
301
301
|
}, u = () => {
|
|
302
|
-
const
|
|
303
|
-
|
|
304
|
-
}, r = (
|
|
302
|
+
const o = document.body;
|
|
303
|
+
o.style.userSelect = t, o.style.touchAction = e, o.style.overscrollBehavior = n, window.removeEventListener("contextmenu", r), window.removeEventListener("selectstart", r), window.removeEventListener("touchstart", r), window.removeEventListener("touchmove", r);
|
|
304
|
+
}, r = (o) => o.preventDefault();
|
|
305
305
|
return {
|
|
306
306
|
disableInteractions: i,
|
|
307
307
|
enableInteractions: u
|
|
@@ -355,11 +355,11 @@ const M = Se(() => {
|
|
|
355
355
|
x: r.clientX,
|
|
356
356
|
y: r.clientY
|
|
357
357
|
};
|
|
358
|
-
const { pixel:
|
|
358
|
+
const { pixel: o, percent: d } = Ke(t.value, {
|
|
359
359
|
x: r.clientX,
|
|
360
360
|
y: r.clientY
|
|
361
361
|
});
|
|
362
|
-
e.pointerPosition.offset.pixel.value =
|
|
362
|
+
e.pointerPosition.offset.pixel.value = o, e.pointerPosition.offset.percent.value = d;
|
|
363
363
|
},
|
|
364
364
|
onPointerMove: (r) => {
|
|
365
365
|
e.pointerPosition.current.value = {
|
|
@@ -374,7 +374,7 @@ const M = Se(() => {
|
|
|
374
374
|
}, Xe = (t) => {
|
|
375
375
|
const e = M(), { onPointerStart: n, onPointerMove: i, onPointerEnd: u } = We(t);
|
|
376
376
|
let r = null;
|
|
377
|
-
const
|
|
377
|
+
const o = (s) => {
|
|
378
378
|
var E, w;
|
|
379
379
|
const m = e.selectedElements.value.some(
|
|
380
380
|
(x) => x.node === s
|
|
@@ -469,14 +469,14 @@ const M = Se(() => {
|
|
|
469
469
|
e.hovered.element.value = ((j = z[0]) == null ? void 0 : j.element) ?? null, e.hovered.zone.value = ((G = ve[0]) == null ? void 0 : G.zone) ?? null, e.hovered.element.value !== k && ((B = k == null ? void 0 : k.events) != null && B.onLeave && k.events.onLeave(e), (Q = (J = e.hovered.element.value) == null ? void 0 : J.events) != null && Q.onHover && e.hovered.element.value.events.onHover(e)), e.hovered.zone.value !== R && ((ee = R == null ? void 0 : R.events) != null && ee.onLeave && R.events.onLeave(e), (ne = (te = e.hovered.zone.value) == null ? void 0 : te.events) != null && ne.onHover && e.hovered.zone.value.events.onHover(e));
|
|
470
470
|
}, 1e3), g = () => {
|
|
471
471
|
v(), r = requestAnimationFrame(g);
|
|
472
|
-
},
|
|
472
|
+
}, l = () => {
|
|
473
473
|
g();
|
|
474
474
|
}, f = () => {
|
|
475
475
|
r !== null && (cancelAnimationFrame(r), r = null);
|
|
476
476
|
};
|
|
477
477
|
return {
|
|
478
478
|
activate: (s) => {
|
|
479
|
-
e.draggingElements.value =
|
|
479
|
+
e.draggingElements.value = o(t.value), n(s), l();
|
|
480
480
|
},
|
|
481
481
|
track: (s) => {
|
|
482
482
|
i(s);
|
|
@@ -498,33 +498,33 @@ const M = Se(() => {
|
|
|
498
498
|
unregisterElement: i,
|
|
499
499
|
isDragging: u,
|
|
500
500
|
isOvered: r,
|
|
501
|
-
isAllowed:
|
|
501
|
+
isAllowed: o,
|
|
502
502
|
isVisible: d
|
|
503
|
-
} = Ze(t), { disableInteractions: v, enableInteractions: g } = $e(), { activeContainer:
|
|
504
|
-
t != null && t.container && (
|
|
503
|
+
} = Ze(t), { disableInteractions: v, enableInteractions: g } = $e(), { activeContainer: l, pointerPosition: f } = M(), { activate: _, track: h, deactivate: y } = Xe(e), s = (w) => {
|
|
504
|
+
t != null && t.container && (l.component.value = Ie(t.container)), v(), _(w), document.addEventListener("pointermove", m), document.addEventListener("pointerup", E), document.addEventListener("wheel", p);
|
|
505
505
|
}, m = (w) => h(w), p = (w) => h(w), E = () => {
|
|
506
|
-
|
|
506
|
+
l.component.value = null, g(), y(), document.removeEventListener("pointermove", m), document.removeEventListener("pointerup", E), document.removeEventListener("wheel", p);
|
|
507
507
|
};
|
|
508
508
|
return U(n), W(i), {
|
|
509
509
|
pointerPosition: f,
|
|
510
510
|
elementRef: e,
|
|
511
511
|
isDragging: u,
|
|
512
512
|
isOvered: r,
|
|
513
|
-
isAllowed:
|
|
513
|
+
isAllowed: o,
|
|
514
514
|
handleDragStart: s,
|
|
515
515
|
isVisible: d
|
|
516
516
|
};
|
|
517
517
|
}, qe = (t) => {
|
|
518
|
-
const { zones: e, hovered: n, draggingElements: i, isDragging: u } = M(), r = P(null),
|
|
519
|
-
var
|
|
520
|
-
return ((
|
|
518
|
+
const { zones: e, hovered: n, draggingElements: i, isDragging: u } = M(), r = P(null), o = D(() => {
|
|
519
|
+
var l;
|
|
520
|
+
return ((l = n.zone.value) == null ? void 0 : l.node) === r.value;
|
|
521
521
|
}), d = D(() => {
|
|
522
522
|
if (!r.value || !u.value) return !1;
|
|
523
|
-
const
|
|
523
|
+
const l = e.value.find(
|
|
524
524
|
(f) => f.node === r.value
|
|
525
525
|
);
|
|
526
|
-
return
|
|
527
|
-
(_) =>
|
|
526
|
+
return l != null && l.groups.length ? !i.value.some((f) => f.groups.length ? !f.groups.some(
|
|
527
|
+
(_) => l.groups.includes(_)
|
|
528
528
|
) : !1) : !0;
|
|
529
529
|
});
|
|
530
530
|
return { elementRef: r, registerZone: () => {
|
|
@@ -537,43 +537,43 @@ const M = Se(() => {
|
|
|
537
537
|
}), r.value.setAttribute("data-dnd-droppable", "true");
|
|
538
538
|
}, unregisterZone: () => {
|
|
539
539
|
if (!r.value) throw new Error("elementRef is not set");
|
|
540
|
-
const
|
|
540
|
+
const l = e.value.findIndex(
|
|
541
541
|
(f) => f.node === r.value
|
|
542
542
|
);
|
|
543
|
-
|
|
544
|
-
}, isOvered:
|
|
543
|
+
l !== -1 && e.value.splice(l, 1);
|
|
544
|
+
}, isOvered: o, isAllowed: d };
|
|
545
545
|
}, Je = (t) => {
|
|
546
546
|
const { elementRef: e, registerZone: n, unregisterZone: i, isOvered: u, isAllowed: r } = qe(t);
|
|
547
547
|
return U(n), W(i), { elementRef: e, isOvered: u, isAllowed: r };
|
|
548
548
|
}, Qe = (t) => {
|
|
549
549
|
const { selectedElements: e, elements: n } = M(), i = D(
|
|
550
|
-
() => n.value.find((
|
|
550
|
+
() => n.value.find((l) => l.node === t.value)
|
|
551
551
|
), u = D(
|
|
552
|
-
() => e.value.some((
|
|
552
|
+
() => e.value.some((l) => l.node === t.value)
|
|
553
553
|
), r = D(() => t.value ? e.value.some(
|
|
554
|
-
(
|
|
555
|
-
|
|
554
|
+
(l) => l.node && S(
|
|
555
|
+
l.node,
|
|
556
556
|
t.value
|
|
557
557
|
)
|
|
558
|
-
) : !1),
|
|
559
|
-
(
|
|
558
|
+
) : !1), o = D(() => t.value ? e.value.some(
|
|
559
|
+
(l) => l.node && S(
|
|
560
560
|
t.value,
|
|
561
|
-
|
|
561
|
+
l.node
|
|
562
562
|
)
|
|
563
563
|
) : !1), d = () => {
|
|
564
564
|
i.value && (e.value = e.value.filter(
|
|
565
|
-
(
|
|
565
|
+
(l) => l.node !== t.value
|
|
566
566
|
));
|
|
567
567
|
}, v = () => {
|
|
568
568
|
i.value && (r.value && (e.value = e.value.filter(
|
|
569
|
-
(
|
|
570
|
-
|
|
569
|
+
(l) => l.node && !S(
|
|
570
|
+
l.node,
|
|
571
571
|
t.value
|
|
572
572
|
)
|
|
573
|
-
)),
|
|
574
|
-
(
|
|
573
|
+
)), o.value && (e.value = e.value.filter(
|
|
574
|
+
(l) => l.node && !S(
|
|
575
575
|
t.value,
|
|
576
|
-
|
|
576
|
+
l.node
|
|
577
577
|
)
|
|
578
578
|
)), e.value.push(i.value));
|
|
579
579
|
};
|
|
@@ -581,16 +581,14 @@ const M = Se(() => {
|
|
|
581
581
|
handleUnselect: d,
|
|
582
582
|
handleSelect: v,
|
|
583
583
|
handleToggleSelect: () => {
|
|
584
|
-
i.value && (e.value.some((
|
|
584
|
+
i.value && (e.value.some((l) => l.node === t.value) ? d() : v());
|
|
585
585
|
},
|
|
586
586
|
isSelected: u,
|
|
587
587
|
isParentOfSelected: r
|
|
588
588
|
};
|
|
589
589
|
};
|
|
590
590
|
export {
|
|
591
|
-
ie as DragOverlay,
|
|
592
591
|
Ge as default,
|
|
593
|
-
V as getBoundingBox,
|
|
594
592
|
M as useDnDStore,
|
|
595
593
|
Be as useDraggable,
|
|
596
594
|
Je as useDroppable,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue-dnd-kit/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.2-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",
|