@vue-dnd-kit/core 0.1.2-beta → 0.1.3-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.
|
@@ -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 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,m;!n.isRef(t[0])&&typeof t[0]=="object"?{delay:l,trailing:v=!0,leading:f=!0,rejectOnCancel:m=!1}=t[0]:[l,v=!0,f=!0,m=!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=m?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),m=n.computed(()=>{const E=n.toValue(t);return se(E).map(H).filter(oe)});let i=R;const g=n.shallowRef(v),D=f.value?n.watch(()=>[m.value,H(s),g.value],([E,u])=>{if(i(),!g.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(),g.value=!1};return te(p),{isSupported:f,isActive:g,pause(){i(),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:l=!1}=e,v=n.shallowRef(!1),{stop:f}=ve(t,m=>{let i=v.value,g=0;for(const D of m)D.time>=g&&(g=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((m,i)=>{var g;if((g=m.isVisible)!=null&&g.value||m.isVisible&&i)return i}).filter(m=>m!==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}}),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 l,v,f,m;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)-(((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(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,m)=>{var i,g;return n.openBlock(),n.createElementBlock("div",{key:m,innerHTML:f.initialHTML,style:n.normalizeStyle({width:`${(i=f.initialRect)==null?void 0:i.width}px`,height:`${(g=f.initialRect)==null?void 0:g.height}px`})},null,12,me)}),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-vue-dnd-kit-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),m=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"),l.value.setAttribute("draggable","false")},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:m,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,k=t=>{if(!t)return{x:0,y:0,width:0,height:0,bottom:0,left:0,right:0,top:0};const e=t.getBoundingClientRect();return{bottom:e.bottom,left:e.left,right:e.right,top:e.top,x:e.x,y:e.y,width:e.width,height:e.height}},U=t=>({x:t.x+t.width/2,y:t.y+t.height/2}),Pe=(t,e)=>{const r=k(t);return{pixel:{x:e.x-r.x,y:e.y-r.y},percent:{x:(e.x-r.x)/r.width*100,y:(e.y-r.y)/r.height*100}}},J=(t,e)=>{const r=e.x-t.x,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,b;return{..._,initialHTML:((L=_.node)==null?void 0:L.outerHTML)??"",initialRect:(b=_.node)==null?void 0:b.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=k(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),b=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=k(a.node);return d&&u&&G(d,u)}).map(a=>{const d=k(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),A=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:A}}).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=k(a.node);return d&&u&&G(d,u)}).map(a=>{const d=k(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),A=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:A}}).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}),T=e.hovered.element.value,V=e.hovered.zone.value;e.hovered.element.value=((N=b[0])==null?void 0:N.element)??null,e.hovered.zone.value=((F=ee[0])==null?void 0:F.zone)??null,e.hovered.element.value!==T&&((Z=T==null?void 0:T.events)!=null&&Z.onLeave&&T.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),m=()=>{f(),o=requestAnimationFrame(m)},i=()=>{m()},g=()=>{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,g()}}},xe=t=>{const{elementRef:e,registerElement:r,unregisterElement:s,isDragging:c,isOvered:o,isAllowed:l,isVisible:v}=Ee(t),{disableInteractions:f,enableInteractions:m}=we(),{activeContainer:i,pointerPosition:g}=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,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: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(g=>g.node===o.value);return i!=null&&i.groups.length?!s.value.some(g=>g.groups.length?!g.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(g=>g.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,4 +1,4 @@
|
|
|
1
|
-
import { effectScope as fe, watch as ue, nextTick as ge, isRef as me, getCurrentScope as he, onScopeDispose as pe, toValue as
|
|
1
|
+
import { effectScope as fe, watch as ue, nextTick as ge, isRef as me, getCurrentScope as he, onScopeDispose as pe, toValue as H, shallowRef as K, computed as D, getCurrentInstance as ye, onMounted as U, ref as P, onBeforeUnmount as W, defineComponent as ce, createElementBlock as F, createCommentVNode as Ee, unref as re, openBlock as b, normalizeStyle as oe, Fragment as we, renderList as Pe, createBlock as De, resolveDynamicComponent as _e, createVNode as xe, render as le, markRaw as Ie } from "vue";
|
|
2
2
|
function Le(t) {
|
|
3
3
|
return he() ? (pe(t), !0) : !1;
|
|
4
4
|
}
|
|
@@ -20,18 +20,18 @@ 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, o,
|
|
24
|
-
!me(t[0]) && typeof t[0] == "object" ? { delay: o, trailing:
|
|
23
|
+
let e = 0, n, i = !0, u = A, r, o, v, d, g;
|
|
24
|
+
!me(t[0]) && typeof t[0] == "object" ? { delay: o, trailing: v = !0, leading: d = !0, rejectOnCancel: g = !1 } = t[0] : [o, v = !0, d = !0, g = !1] = t;
|
|
25
25
|
const l = () => {
|
|
26
26
|
n && (clearTimeout(n), n = void 0, u(), u = A);
|
|
27
27
|
};
|
|
28
28
|
return (_) => {
|
|
29
|
-
const h =
|
|
30
|
-
return l(), h <= 0 ? (e = Date.now(), s()) : (y > h && (
|
|
29
|
+
const h = H(o), y = Date.now() - e, s = () => r = _();
|
|
30
|
+
return l(), h <= 0 ? (e = Date.now(), s()) : (y > h && (d || !i) ? (e = Date.now(), s()) : v && (r = new Promise((m, p) => {
|
|
31
31
|
u = g ? p : m, n = setTimeout(() => {
|
|
32
32
|
e = Date.now(), i = !0, m(s()), l();
|
|
33
33
|
}, Math.max(0, h - y));
|
|
34
|
-
})), !
|
|
34
|
+
})), !d && !n && (n = setTimeout(() => i = !0, h)), i = !1, r);
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
37
|
function Ve(t) {
|
|
@@ -47,10 +47,10 @@ function Re(t, e, n) {
|
|
|
47
47
|
const i = ue(t, (...u) => (ge(() => i()), e(...u)), n);
|
|
48
48
|
return i;
|
|
49
49
|
}
|
|
50
|
-
const
|
|
50
|
+
const ve = Me ? window : void 0;
|
|
51
51
|
function Z(t) {
|
|
52
52
|
var e;
|
|
53
|
-
const n =
|
|
53
|
+
const n = H(t);
|
|
54
54
|
return (e = n == null ? void 0 : n.$el) != null ? e : n;
|
|
55
55
|
}
|
|
56
56
|
function Ae() {
|
|
@@ -63,19 +63,19 @@ function ze(t) {
|
|
|
63
63
|
const e = Ae();
|
|
64
64
|
return D(() => (e.value, !!t()));
|
|
65
65
|
}
|
|
66
|
-
function
|
|
66
|
+
function be(t, e, n = {}) {
|
|
67
67
|
const {
|
|
68
68
|
root: i,
|
|
69
69
|
rootMargin: u = "0px",
|
|
70
70
|
threshold: r = 0,
|
|
71
|
-
window: o =
|
|
72
|
-
immediate:
|
|
73
|
-
} = n,
|
|
74
|
-
const y =
|
|
71
|
+
window: o = ve,
|
|
72
|
+
immediate: v = !0
|
|
73
|
+
} = n, d = ze(() => o && "IntersectionObserver" in o), g = D(() => {
|
|
74
|
+
const y = H(t);
|
|
75
75
|
return Ve(y).map(Z).filter(Ce);
|
|
76
76
|
});
|
|
77
77
|
let l = A;
|
|
78
|
-
const f = K(
|
|
78
|
+
const f = K(v), _ = d.value ? ue(
|
|
79
79
|
() => [g.value, Z(i), f.value],
|
|
80
80
|
([y, s]) => {
|
|
81
81
|
if (l(), !f.value || !y.length)
|
|
@@ -92,12 +92,12 @@ function He(t, e, n = {}) {
|
|
|
92
92
|
m.disconnect(), l = A;
|
|
93
93
|
};
|
|
94
94
|
},
|
|
95
|
-
{ immediate:
|
|
95
|
+
{ immediate: v, flush: "post" }
|
|
96
96
|
) : A, h = () => {
|
|
97
97
|
l(), _(), f.value = !1;
|
|
98
98
|
};
|
|
99
99
|
return Le(h), {
|
|
100
|
-
isSupported:
|
|
100
|
+
isSupported: d,
|
|
101
101
|
isActive: f,
|
|
102
102
|
pause() {
|
|
103
103
|
l(), f.value = !1;
|
|
@@ -108,31 +108,31 @@ function He(t, e, n = {}) {
|
|
|
108
108
|
stop: h
|
|
109
109
|
};
|
|
110
110
|
}
|
|
111
|
-
function
|
|
111
|
+
function He(t, e = {}) {
|
|
112
112
|
const {
|
|
113
|
-
window: n =
|
|
113
|
+
window: n = ve,
|
|
114
114
|
scrollTarget: i,
|
|
115
115
|
threshold: u = 0,
|
|
116
116
|
rootMargin: r,
|
|
117
117
|
once: o = !1
|
|
118
|
-
} = e,
|
|
118
|
+
} = e, v = K(!1), { stop: d } = be(
|
|
119
119
|
t,
|
|
120
120
|
(g) => {
|
|
121
|
-
let l =
|
|
121
|
+
let l = v.value, f = 0;
|
|
122
122
|
for (const _ of g)
|
|
123
123
|
_.time >= f && (f = _.time, l = _.isIntersecting);
|
|
124
|
-
|
|
125
|
-
|
|
124
|
+
v.value = l, o && Re(v, () => {
|
|
125
|
+
d();
|
|
126
126
|
});
|
|
127
127
|
},
|
|
128
128
|
{
|
|
129
129
|
root: i,
|
|
130
130
|
window: n,
|
|
131
131
|
threshold: u,
|
|
132
|
-
rootMargin:
|
|
132
|
+
rootMargin: H(r)
|
|
133
133
|
}
|
|
134
134
|
);
|
|
135
|
-
return
|
|
135
|
+
return v;
|
|
136
136
|
}
|
|
137
137
|
const M = Se(() => {
|
|
138
138
|
const t = P([]), e = D(() => t.value.length > 0), n = {
|
|
@@ -144,10 +144,10 @@ const M = Se(() => {
|
|
|
144
144
|
if ((f = g.isVisible) != null && f.value || g.isVisible && l)
|
|
145
145
|
return l;
|
|
146
146
|
}).filter((g) => g !== void 0)
|
|
147
|
-
), r = P([]), o = P([]),
|
|
147
|
+
), r = P([]), o = 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: {
|
|
@@ -163,8 +163,8 @@ const M = Se(() => {
|
|
|
163
163
|
selectedElements: r,
|
|
164
164
|
zones: o,
|
|
165
165
|
visibleElements: u,
|
|
166
|
-
hovered:
|
|
167
|
-
pointerPosition:
|
|
166
|
+
hovered: v,
|
|
167
|
+
pointerPosition: d
|
|
168
168
|
};
|
|
169
169
|
}), Ue = () => {
|
|
170
170
|
const t = P(null), { draggingElements: e, pointerPosition: n, isDragging: i, activeContainer: u } = M();
|
|
@@ -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 o,
|
|
185
|
+
var o, v, d, g;
|
|
186
186
|
return {
|
|
187
|
-
transform: `translate3d(${(((o = n.current.value) == null ? void 0 : o.x) ?? 0) - (((
|
|
187
|
+
transform: `translate3d(${(((o = n.current.value) == null ? void 0 : o.x) ?? 0) - (((v = n.offset.pixel.value) == null ? void 0 : v.x) ?? 0)}px, ${(((d = n.current.value) == null ? void 0 : d.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,20 +192,20 @@ const M = Se(() => {
|
|
|
192
192
|
transition: "0.3s cubic-bezier(0.165, 0.84, 0.44, 1)"
|
|
193
193
|
};
|
|
194
194
|
});
|
|
195
|
-
return (o,
|
|
195
|
+
return (o, v) => re(i) ? (b(), 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
|
+
(b(!0), F(we, null, Pe(re(u), (d, g) => {
|
|
202
202
|
var l, f;
|
|
203
|
-
return
|
|
203
|
+
return b(), F("div", {
|
|
204
204
|
key: g,
|
|
205
|
-
innerHTML:
|
|
205
|
+
innerHTML: d.initialHTML,
|
|
206
206
|
style: oe({
|
|
207
|
-
width: `${(l =
|
|
208
|
-
height: `${(f =
|
|
207
|
+
width: `${(l = d.initialRect) == null ? void 0 : l.width}px`,
|
|
208
|
+
height: `${(f = d.initialRect) == null ? void 0 : f.height}px`
|
|
209
209
|
})
|
|
210
210
|
}, null, 12, Ye);
|
|
211
211
|
}), 128))
|
|
@@ -217,7 +217,7 @@ const M = Se(() => {
|
|
|
217
217
|
const { activeContainer: e } = M(), n = D(
|
|
218
218
|
() => e.component.value ?? Ne
|
|
219
219
|
);
|
|
220
|
-
return (i, u) => (
|
|
220
|
+
return (i, u) => (b(), De(_e(n.value)));
|
|
221
221
|
}
|
|
222
222
|
}), Ge = {
|
|
223
223
|
install(t) {
|
|
@@ -228,10 +228,10 @@ const M = Se(() => {
|
|
|
228
228
|
if (r && r instanceof Element && !r.querySelector("#vue-dnd-kit-overlay")) {
|
|
229
229
|
const o = document.createElement("div");
|
|
230
230
|
o.id = "vue-dnd-kit-overlay", o.style.pointerEvents = "none", r.appendChild(o);
|
|
231
|
-
const
|
|
232
|
-
le(
|
|
231
|
+
const v = xe(ie);
|
|
232
|
+
le(v, o), t.__VUE_DND_KIT_OVERLAY__ = {
|
|
233
233
|
container: o,
|
|
234
|
-
vnode:
|
|
234
|
+
vnode: v
|
|
235
235
|
};
|
|
236
236
|
}
|
|
237
237
|
return u;
|
|
@@ -241,19 +241,19 @@ const M = Se(() => {
|
|
|
241
241
|
return t.__VUE_DND_KIT_OVERLAY__ && (le(null, t.__VUE_DND_KIT_OVERLAY__.container), delete t.__VUE_DND_KIT_OVERLAY__), n.call(this);
|
|
242
242
|
};
|
|
243
243
|
}
|
|
244
|
-
}, Fe = "data-dnd-draggable", Ze = (t) => {
|
|
244
|
+
}, Fe = "data-vue-dnd-kit-draggable", Ze = (t) => {
|
|
245
245
|
const {
|
|
246
246
|
elements: e,
|
|
247
247
|
draggingElements: n,
|
|
248
248
|
hovered: i,
|
|
249
249
|
selectedElements: u,
|
|
250
250
|
isDragging: r
|
|
251
|
-
} = M(), o = P(null),
|
|
251
|
+
} = M(), o = P(null), v = D(
|
|
252
252
|
() => {
|
|
253
253
|
var h;
|
|
254
254
|
return ((h = i.element.value) == null ? void 0 : h.node) === o.value;
|
|
255
255
|
}
|
|
256
|
-
),
|
|
256
|
+
), d = He(o), g = D(
|
|
257
257
|
() => n.value.some((h) => h.node === o.value)
|
|
258
258
|
), l = D(() => {
|
|
259
259
|
if (!o.value || !r.value) return !1;
|
|
@@ -275,8 +275,8 @@ const M = Se(() => {
|
|
|
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
|
-
isVisible:
|
|
279
|
-
}), o.value.setAttribute(Fe, "true");
|
|
278
|
+
isVisible: d
|
|
279
|
+
}), o.value.setAttribute(Fe, "true"), o.value.setAttribute("draggable", "false");
|
|
280
280
|
},
|
|
281
281
|
unregisterElement: () => {
|
|
282
282
|
const h = e.value.findIndex(
|
|
@@ -289,9 +289,9 @@ const M = Se(() => {
|
|
|
289
289
|
y !== -1 && u.value.splice(y, 1);
|
|
290
290
|
},
|
|
291
291
|
isDragging: g,
|
|
292
|
-
isOvered:
|
|
292
|
+
isOvered: v,
|
|
293
293
|
isAllowed: l,
|
|
294
|
-
isVisible:
|
|
294
|
+
isVisible: d
|
|
295
295
|
};
|
|
296
296
|
}, $e = () => {
|
|
297
297
|
let t = "", e = "", n = "";
|
|
@@ -355,11 +355,11 @@ const M = Se(() => {
|
|
|
355
355
|
x: r.clientX,
|
|
356
356
|
y: r.clientY
|
|
357
357
|
};
|
|
358
|
-
const { pixel: o, percent:
|
|
358
|
+
const { pixel: o, percent: v } = Ke(t.value, {
|
|
359
359
|
x: r.clientX,
|
|
360
360
|
y: r.clientY
|
|
361
361
|
});
|
|
362
|
-
e.pointerPosition.offset.pixel.value = o, e.pointerPosition.offset.percent.value =
|
|
362
|
+
e.pointerPosition.offset.pixel.value = o, e.pointerPosition.offset.percent.value = v;
|
|
363
363
|
},
|
|
364
364
|
onPointerMove: (r) => {
|
|
365
365
|
e.pointerPosition.current.value = {
|
|
@@ -399,7 +399,7 @@ const M = Se(() => {
|
|
|
399
399
|
initialRect: (w = p.node) == null ? void 0 : w.getBoundingClientRect()
|
|
400
400
|
}
|
|
401
401
|
] : [];
|
|
402
|
-
},
|
|
402
|
+
}, v = (s, m) => {
|
|
403
403
|
const p = Math.max(
|
|
404
404
|
0,
|
|
405
405
|
Math.min(s.x + s.width, m.x + m.width) - Math.max(s.x, m.x)
|
|
@@ -408,7 +408,7 @@ const M = Se(() => {
|
|
|
408
408
|
Math.min(s.y + s.height, m.y + m.height) - Math.max(s.y, m.y)
|
|
409
409
|
), w = p * E, x = s.width * s.height, C = m.width * m.height;
|
|
410
410
|
return (w / x * 100 + w / C * 100) / 2;
|
|
411
|
-
},
|
|
411
|
+
}, d = ke(() => {
|
|
412
412
|
var X, q, j, G, B, J, Q, ee, te, ne;
|
|
413
413
|
const s = V(e.activeContainer.ref.value), m = $(s), p = ((X = e.pointerPosition.current.value) == null ? void 0 : X.x) ?? 0, E = ((q = e.pointerPosition.current.value) == null ? void 0 : q.y) ?? 0, x = !(s && p >= s.x && p <= s.x + s.width && E >= s.y && E <= s.y + s.height), C = e.draggingElements.value.map((a) => a.node), z = e.visibleElements.value.map((a) => e.elements.value[a]).filter((a) => {
|
|
414
414
|
if (!a.node || C.some(
|
|
@@ -422,7 +422,7 @@ const M = Se(() => {
|
|
|
422
422
|
const c = V(a.node);
|
|
423
423
|
return c && s && se(c, s);
|
|
424
424
|
}).map((a) => {
|
|
425
|
-
const c = V(a.node), I = $(c), L = p >= c.x && p <= c.x + c.width && E >= c.y && E <= c.y + c.height, O =
|
|
425
|
+
const c = V(a.node), I = $(c), L = p >= c.x && p <= c.x + c.width && E >= c.y && E <= c.y + c.height, O = v(c, s), Y = ae(m, I), N = e.elements.value.filter(
|
|
426
426
|
(T) => T !== a && T.node && a.node && S(
|
|
427
427
|
a.node,
|
|
428
428
|
T.node
|
|
@@ -441,7 +441,7 @@ const M = Se(() => {
|
|
|
441
441
|
if (a.isPointerInElement !== c.isPointerInElement) return a.isPointerInElement ? -1 : 1;
|
|
442
442
|
}
|
|
443
443
|
return Math.abs(a.overlapPercent - c.overlapPercent) <= 1 ? a.centerDistance - c.centerDistance : c.overlapPercent - a.overlapPercent;
|
|
444
|
-
}),
|
|
444
|
+
}), de = e.zones.value.filter((a) => {
|
|
445
445
|
if (!a.node || C.some(
|
|
446
446
|
(I) => I && S(a.node, I)
|
|
447
447
|
) || a.groups.length && !!e.draggingElements.value.some((L) => L.groups.length ? !L.groups.some((O) => a.groups.includes(O)) : !1))
|
|
@@ -449,7 +449,7 @@ const M = Se(() => {
|
|
|
449
449
|
const c = V(a.node);
|
|
450
450
|
return c && s && se(c, s);
|
|
451
451
|
}).map((a) => {
|
|
452
|
-
const c = V(a.node), I = $(c), L = p >= c.x && p <= c.x + c.width && E >= c.y && E <= c.y + c.height, O =
|
|
452
|
+
const c = V(a.node), I = $(c), L = p >= c.x && p <= c.x + c.width && E >= c.y && E <= c.y + c.height, O = v(c, s), Y = ae(m, I), N = e.zones.value.filter(
|
|
453
453
|
(T) => T !== a && T.node && a.node && S(a.node, T.node)
|
|
454
454
|
).length;
|
|
455
455
|
return {
|
|
@@ -466,9 +466,9 @@ const M = Se(() => {
|
|
|
466
466
|
}
|
|
467
467
|
return Math.abs(a.overlapPercent - c.overlapPercent) <= 1 ? a.centerDistance - c.centerDistance : c.overlapPercent - a.overlapPercent;
|
|
468
468
|
}), k = e.hovered.element.value, R = e.hovered.zone.value;
|
|
469
|
-
e.hovered.element.value = ((j = z[0]) == null ? void 0 : j.element) ?? null, e.hovered.zone.value = ((G =
|
|
469
|
+
e.hovered.element.value = ((j = z[0]) == null ? void 0 : j.element) ?? null, e.hovered.zone.value = ((G = de[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
|
+
d(), r = requestAnimationFrame(g);
|
|
472
472
|
}, l = () => {
|
|
473
473
|
g();
|
|
474
474
|
}, f = () => {
|
|
@@ -499,9 +499,9 @@ const M = Se(() => {
|
|
|
499
499
|
isDragging: u,
|
|
500
500
|
isOvered: r,
|
|
501
501
|
isAllowed: o,
|
|
502
|
-
isVisible:
|
|
503
|
-
} = Ze(t), { disableInteractions:
|
|
504
|
-
t != null && t.container && (l.component.value = Ie(t.container)),
|
|
502
|
+
isVisible: v
|
|
503
|
+
} = Ze(t), { disableInteractions: d, 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)), d(), _(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
|
};
|
|
@@ -512,13 +512,13 @@ const M = Se(() => {
|
|
|
512
512
|
isOvered: r,
|
|
513
513
|
isAllowed: o,
|
|
514
514
|
handleDragStart: s,
|
|
515
|
-
isVisible:
|
|
515
|
+
isVisible: v
|
|
516
516
|
};
|
|
517
517
|
}, qe = (t) => {
|
|
518
518
|
const { zones: e, hovered: n, draggingElements: i, isDragging: u } = M(), r = P(null), o = D(() => {
|
|
519
519
|
var l;
|
|
520
520
|
return ((l = n.zone.value) == null ? void 0 : l.node) === r.value;
|
|
521
|
-
}),
|
|
521
|
+
}), v = D(() => {
|
|
522
522
|
if (!r.value || !u.value) return !1;
|
|
523
523
|
const l = e.value.find(
|
|
524
524
|
(f) => f.node === r.value
|
|
@@ -541,7 +541,7 @@ const M = Se(() => {
|
|
|
541
541
|
(f) => f.node === r.value
|
|
542
542
|
);
|
|
543
543
|
l !== -1 && e.value.splice(l, 1);
|
|
544
|
-
}, isOvered: o, isAllowed:
|
|
544
|
+
}, isOvered: o, isAllowed: v };
|
|
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 };
|
|
@@ -560,11 +560,11 @@ const M = Se(() => {
|
|
|
560
560
|
t.value,
|
|
561
561
|
l.node
|
|
562
562
|
)
|
|
563
|
-
) : !1),
|
|
563
|
+
) : !1), v = () => {
|
|
564
564
|
i.value && (e.value = e.value.filter(
|
|
565
565
|
(l) => l.node !== t.value
|
|
566
566
|
));
|
|
567
|
-
},
|
|
567
|
+
}, d = () => {
|
|
568
568
|
i.value && (r.value && (e.value = e.value.filter(
|
|
569
569
|
(l) => l.node && !S(
|
|
570
570
|
l.node,
|
|
@@ -578,10 +578,10 @@ const M = Se(() => {
|
|
|
578
578
|
)), e.value.push(i.value));
|
|
579
579
|
};
|
|
580
580
|
return {
|
|
581
|
-
handleUnselect:
|
|
582
|
-
handleSelect:
|
|
581
|
+
handleUnselect: v,
|
|
582
|
+
handleSelect: d,
|
|
583
583
|
handleToggleSelect: () => {
|
|
584
|
-
i.value && (e.value.some((l) => l.node === t.value) ?
|
|
584
|
+
i.value && (e.value.some((l) => l.node === t.value) ? v() : d());
|
|
585
585
|
},
|
|
586
586
|
isSelected: u,
|
|
587
587
|
isParentOfSelected: r
|
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.3-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",
|