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