@vue-dnd-kit/core 0.0.40-beta → 0.0.41-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.
|
@@ -1771,7 +1771,7 @@ export declare const useDnDStore: () => {
|
|
|
1771
1771
|
onDrop?: ((store: import('../types').IDnDStore) => void) | undefined;
|
|
1772
1772
|
};
|
|
1773
1773
|
}[]>;
|
|
1774
|
-
visibleElements: import('vue').ComputedRef<
|
|
1774
|
+
visibleElements: import('vue').ComputedRef<number[]>;
|
|
1775
1775
|
hovered: {
|
|
1776
1776
|
zone: import('vue').Ref<{
|
|
1777
1777
|
node: Element | HTMLElement | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("vue");function ee(t){return n.getCurrentScope()?(n.onScopeDispose(t),!0):!1}function te(t){let e=!1,r;const i=n.effectScope(!0);return(...c)=>(e||(r=i.run(()=>t(...c)),e=!0),r)}const ne=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const re=t=>t!=null,b=()=>{};function oe(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 le(...t){let e=0,r,i=!0,c=b,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=b)};return D=>{const p=n.toValue(s),E=Date.now()-e,a=()=>o=D();return l(),p<=0?(e=Date.now(),a()):(E>p&&(f||!i)?(e=Date.now(),a()):v&&(o=new Promise((m,y)=>{c=h?y:m,r=setTimeout(()=>{e=Date.now(),i=!0,m(a()),l()},Math.max(0,p-E))})),!f&&!r&&(r=setTimeout(()=>i=!0,p)),i=!1,o)}}function se(t){return Array.isArray(t)?t:[t]}function ie(t,e=200,r=!1,i=!0,c=!1){return oe(le(e,r,i,c),t)}function ae(t,e,r){const i=n.watch(t,(...c)=>(n.nextTick(()=>i()),e(...c)),r);return i}const K=ne?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 ue(){const t=n.shallowRef(!1),e=n.getCurrentInstance();return e&&n.onMounted(()=>{t.value=!0},e),t}function ce(t){const e=ue();return n.computed(()=>(e.value,!!t()))}function de(t,e,r={}){const{root:i,rootMargin:c="0px",threshold:o=0,window:s=K,immediate:v=!0}=r,f=ce(()=>s&&"IntersectionObserver"in s),h=n.computed(()=>{const E=n.toValue(t);return se(E).map(H).filter(re)});let l=b;const g=n.shallowRef(v),D=f.value?n.watch(()=>[h.value,H(i),g.value],([E,a])=>{if(l(),!g.value||!E.length)return;const m=new IntersectionObserver(e,{root:H(a),rootMargin:c,threshold:o});E.forEach(y=>y&&m.observe(y)),l=()=>{m.disconnect(),l=b}},{immediate:v,flush:"post"}):b,p=()=>{l(),D(),g.value=!1};return ee(p),{isSupported:f,isActive:g,pause(){l(),g.value=!1},resume(){g.value=!0},stop:p}}function ve(t,e={}){const{window:r=K,scrollTarget:i,threshold:c=0,rootMargin:o,once:s=!1}=e,v=n.shallowRef(!1),{stop:f}=de(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&&ae(v,()=>{f()})},{root:i,window:r,threshold:c,rootMargin:n.toValue(o)});return v}const I=te(()=>{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.filter(h=>{var l;return((l=h.isVisible)==null?void 0:l.value)||h.isVisible})),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}}),fe=()=>{const t=n.ref(null),{draggingElements:e,pointerPosition:r,isDragging:i,activeContainer:c}=I();return n.onMounted(()=>{c.ref=t}),n.onBeforeUnmount(()=>{c.ref.value=null}),{elementRef:t,draggingElements:e,pointerPosition:r,isDragging:i}},ge=["innerHTML"],me=n.defineComponent({__name:"DefaultOverlay",setup(t){const{elementRef:e,pointerPosition:r,isDragging:i,draggingElements:c}=fe(),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,ge)}),128))],4)):n.createCommentVNode("",!0)}}),he=n.defineComponent({__name:"DragOverlay",setup(t){const{activeContainer:e}=I(),r=n.computed(()=>e.component.value??me);return(i,c)=>(n.openBlock(),n.createBlock(n.resolveDynamicComponent(r.value)))}}),pe="data-dnd-draggable",ye=t=>{const{elements:e,draggingElements:r,hovered:i,selectedElements:c,isDragging:o}=I(),s=n.ref(null),v=n.computed(()=>{var p;return((p=i.element.value)==null?void 0:p.node)===s.value}),f=ve(s),h=n.computed(()=>r.value.some(p=>p.node===s.value)),l=n.computed(()=>{if(!s.value||!o.value)return!1;const p=e.value.find(E=>E.node===s.value);return p!=null&&p.groups.length?!r.value.some(E=>E.groups.length?!E.groups.some(a=>p.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.setAttribute(pe,"true")},unregisterElement:()=>{const p=e.value.findIndex(a=>a.node===s.value);p!==-1&&e.value.splice(p,1);const E=c.value.findIndex(a=>a.node===s.value);E!==-1&&c.value.splice(E,1)},isDragging:h,isOvered:v,isAllowed:l,isVisible:f}},Ee=()=>{let t="",e="",r="";const i=()=>{const s=document.body;t=s.style.userSelect,e=s.style.touchAction,r=s.style.overscrollBehavior,s.style.userSelect="none",s.style.touchAction="none",s.style.overscrollBehavior="none",window.addEventListener("contextmenu",o),window.addEventListener("selectstart",o),window.addEventListener("touchstart",o),window.addEventListener("touchmove",o)},c=()=>{const s=document.body;s.style.userSelect=t,s.style.touchAction=e,s.style.overscrollBehavior=r,window.removeEventListener("contextmenu",o),window.removeEventListener("selectstart",o),window.removeEventListener("touchstart",o),window.removeEventListener("touchmove",o)},o=s=>s.preventDefault();return{disableInteractions:i,enableInteractions:c}},N=(t,e)=>t.x<e.x+e.width&&t.x+t.width>e.x&&t.y<e.y+e.height&&t.y+t.height>e.y,O=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}},A=t=>({x:t.x+t.width/2,y:t.y+t.height/2}),we=(t,e)=>{const r=O(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,i=e.y-t.y;return Math.sqrt(r*r+i*i)},C=(t,e)=>t?e.contains(t):!1,Pe=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:s,percent:v}=we(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}}},De=t=>{const e=I(),{onPointerStart:r,onPointerMove:i,onPointerEnd:c}=Pe(t);let o=null;const s=a=>{var w,P;const m=e.selectedElements.value.some(x=>x.node===a);if(e.selectedElements.value.length&&m)return e.selectedElements.value.map(x=>{var L,z;return{...x,initialHTML:((L=x.node)==null?void 0:L.outerHTML)??"",initialRect:(z=x.node)==null?void 0:z.getBoundingClientRect()}});e.selectedElements.value=[];const y=e.elements.value.find(x=>x.node===a);return y?[{...y,initialHTML:((w=y.node)==null?void 0:w.outerHTML)??"",initialRect:(P=y.node)==null?void 0:P.getBoundingClientRect()}]:[]},v=(a,m)=>{const y=Math.max(0,Math.min(a.x+a.width,m.x+m.width)-Math.max(a.x,m.x)),w=Math.max(0,Math.min(a.y+a.height,m.y+m.height)-Math.max(a.y,m.y)),P=y*w,x=a.width*a.height,L=m.width*m.height;return(P/x*100+P/L*100)/2},f=ie(()=>{var F,U,Z,$,W,X,Y,j,q,G;const a=O(e.activeContainer.ref.value),m=A(a),y=((F=e.pointerPosition.current.value)==null?void 0:F.x)??0,w=((U=e.pointerPosition.current.value)==null?void 0:U.y)??0,x=!(a&&y>=a.x&&y<=a.x+a.width&&w>=a.y&&w<=a.y+a.height),L=e.draggingElements.value.map(u=>u.node),z=e.visibleElements.value.map(u=>e.elements.value[u]).filter(u=>{if(!u.node||L.some(S=>S&&C(u.node,S))||u.groups.length&&!!e.draggingElements.value.some(M=>M.groups.length?!M.groups.some(_=>u.groups.includes(_)):!1))return!1;const d=O(u.node);return d&&a&&N(d,a)}).map(u=>{const d=O(u.node),S=A(d),M=y>=d.x&&y<=d.x+d.width&&w>=d.y&&w<=d.y+d.height,_=v(d,a),V=J(m,S),B=e.elements.value.filter(k=>k!==u&&k.node&&u.node&&C(u.node,k.node)).length;return{element:u,isPointerInElement:M,overlapPercent:_,depth:B,centerDistance:V}}).sort((u,d)=>{if(!x){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}),Q=e.zones.value.filter(u=>{if(!u.node||L.some(S=>S&&C(u.node,S))||u.groups.length&&!!e.draggingElements.value.some(M=>M.groups.length?!M.groups.some(_=>u.groups.includes(_)):!1))return!1;const d=O(u.node);return d&&a&&N(d,a)}).map(u=>{const d=O(u.node),S=A(d),M=y>=d.x&&y<=d.x+d.width&&w>=d.y&&w<=d.y+d.height,_=v(d,a),V=J(m,S),B=e.zones.value.filter(k=>k!==u&&k.node&&u.node&&C(u.node,k.node)).length;return{zone:u,isPointerInElement:M,overlapPercent:_,depth:B,centerDistance:V}}).sort((u,d)=>{if(!x){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}),T=e.hovered.element.value,R=e.hovered.zone.value;e.hovered.element.value=((Z=z[0])==null?void 0:Z.element)??null,e.hovered.zone.value=(($=Q[0])==null?void 0:$.zone)??null,e.hovered.element.value!==T&&((W=T==null?void 0:T.events)!=null&&W.onLeave&&T.events.onLeave(e),(Y=(X=e.hovered.element.value)==null?void 0:X.events)!=null&&Y.onHover&&e.hovered.element.value.events.onHover(e)),e.hovered.zone.value!==R&&((j=R==null?void 0:R.events)!=null&&j.onLeave&&R.events.onLeave(e),(G=(q=e.hovered.zone.value)==null?void 0:q.events)!=null&&G.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(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:i,isDragging:c,isOvered:o,isAllowed:s,isVisible:v}=ye(t),{disableInteractions:f,enableInteractions:h}=Ee(),{activeContainer:l,pointerPosition:g}=I(),{activate:D,track:p,deactivate:E}=De(e),a=P=>{t!=null&&t.container&&(l.component.value=n.markRaw(t.container)),f(),D(P),document.addEventListener("pointermove",m),document.addEventListener("pointerup",w),document.addEventListener("wheel",y)},m=P=>p(P),y=P=>p(P),w=()=>{l.component.value=null,h(),E(),document.removeEventListener("pointermove",m),document.removeEventListener("pointerup",w),document.removeEventListener("wheel",y)};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}=I(),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}},Me=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}},Ie=t=>{const{selectedElements:e,elements:r}=I(),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&&C(l.node,t.value)):!1),s=n.computed(()=>t.value?e.value.some(l=>l.node&&C(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&&!C(l.node,t.value))),s.value&&(e.value=e.value.filter(l=>l.node&&!C(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.DragOverlay=he;exports.getBoundingBox=O;exports.useDnDStore=I;exports.useDraggable=xe;exports.useDroppable=Me;exports.useSelection=Ie;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("vue");function ee(t){return n.getCurrentScope()?(n.onScopeDispose(t),!0):!1}function te(t){let e=!1,r;const i=n.effectScope(!0);return(...c)=>(e||(r=i.run(()=>t(...c)),e=!0),r)}const ne=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const re=t=>t!=null,b=()=>{};function oe(t,e){function r(...i){return new Promise((c,l)=>{Promise.resolve(t(()=>e.apply(this,i),{fn:e,thisArg:this,args:i})).then(c).catch(l)})}return r}function le(...t){let e=0,r,i=!0,c=b,l,s,v,f,g;!n.isRef(t[0])&&typeof t[0]=="object"?{delay:s,trailing:v=!0,leading:f=!0,rejectOnCancel:g=!1}=t[0]:[s,v=!0,f=!0,g=!1]=t;const o=()=>{r&&(clearTimeout(r),r=void 0,c(),c=b)};return D=>{const p=n.toValue(s),E=Date.now()-e,a=()=>l=D();return o(),p<=0?(e=Date.now(),a()):(E>p&&(f||!i)?(e=Date.now(),a()):v&&(l=new Promise((h,y)=>{c=g?y:h,r=setTimeout(()=>{e=Date.now(),i=!0,h(a()),o()},Math.max(0,p-E))})),!f&&!r&&(r=setTimeout(()=>i=!0,p)),i=!1,l)}}function se(t){return Array.isArray(t)?t:[t]}function ie(t,e=200,r=!1,i=!0,c=!1){return oe(le(e,r,i,c),t)}function ae(t,e,r){const i=n.watch(t,(...c)=>(n.nextTick(()=>i()),e(...c)),r);return i}const K=ne?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 ue(){const t=n.shallowRef(!1),e=n.getCurrentInstance();return e&&n.onMounted(()=>{t.value=!0},e),t}function ce(t){const e=ue();return n.computed(()=>(e.value,!!t()))}function de(t,e,r={}){const{root:i,rootMargin:c="0px",threshold:l=0,window:s=K,immediate:v=!0}=r,f=ce(()=>s&&"IntersectionObserver"in s),g=n.computed(()=>{const E=n.toValue(t);return se(E).map(H).filter(re)});let o=b;const m=n.shallowRef(v),D=f.value?n.watch(()=>[g.value,H(i),m.value],([E,a])=>{if(o(),!m.value||!E.length)return;const h=new IntersectionObserver(e,{root:H(a),rootMargin:c,threshold:l});E.forEach(y=>y&&h.observe(y)),o=()=>{h.disconnect(),o=b}},{immediate:v,flush:"post"}):b,p=()=>{o(),D(),m.value=!1};return ee(p),{isSupported:f,isActive:m,pause(){o(),m.value=!1},resume(){m.value=!0},stop:p}}function ve(t,e={}){const{window:r=K,scrollTarget:i,threshold:c=0,rootMargin:l,once:s=!1}=e,v=n.shallowRef(!1),{stop:f}=de(t,g=>{let o=v.value,m=0;for(const D of g)D.time>=m&&(m=D.time,o=D.isIntersecting);v.value=o,s&&ae(v,()=>{f()})},{root:i,window:r,threshold:c,rootMargin:n.toValue(l)});return v}const I=te(()=>{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.filter(g=>{var o;return((o=g.isVisible)==null?void 0:o.value)||g.isVisible}).map((g,o)=>o)),l=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:l,zones:s,visibleElements:c,hovered:v,pointerPosition:f}}),fe=()=>{const t=n.ref(null),{draggingElements:e,pointerPosition:r,isDragging:i,activeContainer:c}=I();return n.onMounted(()=>{c.ref=t}),n.onBeforeUnmount(()=>{c.ref.value=null}),{elementRef:t,draggingElements:e,pointerPosition:r,isDragging:i}},ge=["innerHTML"],me=n.defineComponent({__name:"DefaultOverlay",setup(t){const{elementRef:e,pointerPosition:r,isDragging:i,draggingElements:c}=fe(),l=n.computed(()=>{var s,v,f,g;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)-(((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(s,v)=>n.unref(i)?(n.openBlock(),n.createElementBlock("div",{key:0,ref_key:"elementRef",ref:e,style:n.normalizeStyle(l.value)},[(n.openBlock(!0),n.createElementBlock(n.Fragment,null,n.renderList(n.unref(c),(f,g)=>{var o,m;return n.openBlock(),n.createElementBlock("div",{key:g,innerHTML:f.initialHTML,style:n.normalizeStyle({width:`${(o=f.initialRect)==null?void 0:o.width}px`,height:`${(m=f.initialRect)==null?void 0:m.height}px`})},null,12,ge)}),128))],4)):n.createCommentVNode("",!0)}}),he=n.defineComponent({__name:"DragOverlay",setup(t){const{activeContainer:e}=I(),r=n.computed(()=>e.component.value??me);return(i,c)=>(n.openBlock(),n.createBlock(n.resolveDynamicComponent(r.value)))}}),pe="data-dnd-draggable",ye=t=>{const{elements:e,draggingElements:r,hovered:i,selectedElements:c,isDragging:l}=I(),s=n.ref(null),v=n.computed(()=>{var p;return((p=i.element.value)==null?void 0:p.node)===s.value}),f=ve(s),g=n.computed(()=>r.value.some(p=>p.node===s.value)),o=n.computed(()=>{if(!s.value||!l.value)return!1;const p=e.value.find(E=>E.node===s.value);return p!=null&&p.groups.length?!r.value.some(E=>E.groups.length?!E.groups.some(a=>p.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.setAttribute(pe,"true")},unregisterElement:()=>{const p=e.value.findIndex(a=>a.node===s.value);p!==-1&&e.value.splice(p,1);const E=c.value.findIndex(a=>a.node===s.value);E!==-1&&c.value.splice(E,1)},isDragging:g,isOvered:v,isAllowed:o,isVisible:f}},Ee=()=>{let t="",e="",r="";const i=()=>{const s=document.body;t=s.style.userSelect,e=s.style.touchAction,r=s.style.overscrollBehavior,s.style.userSelect="none",s.style.touchAction="none",s.style.overscrollBehavior="none",window.addEventListener("contextmenu",l),window.addEventListener("selectstart",l),window.addEventListener("touchstart",l),window.addEventListener("touchmove",l)},c=()=>{const s=document.body;s.style.userSelect=t,s.style.touchAction=e,s.style.overscrollBehavior=r,window.removeEventListener("contextmenu",l),window.removeEventListener("selectstart",l),window.removeEventListener("touchstart",l),window.removeEventListener("touchmove",l)},l=s=>s.preventDefault();return{disableInteractions:i,enableInteractions:c}},N=(t,e)=>t.x<e.x+e.width&&t.x+t.width>e.x&&t.y<e.y+e.height&&t.y+t.height>e.y,O=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}},A=t=>({x:t.x+t.width/2,y:t.y+t.height/2}),we=(t,e)=>{const r=O(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,i=e.y-t.y;return Math.sqrt(r*r+i*i)},C=(t,e)=>t?e.contains(t):!1,Pe=t=>{const e=I();return{onPointerStart:l=>{e.pointerPosition.start.value={x:l.clientX,y:l.clientY},e.pointerPosition.current.value={x:l.clientX,y:l.clientY};const{pixel:s,percent:v}=we(t.value,{x:l.clientX,y:l.clientY});e.pointerPosition.offset.pixel.value=s,e.pointerPosition.offset.percent.value=v},onPointerMove:l=>{e.pointerPosition.current.value={x:l.clientX,y:l.clientY}},onPointerEnd:()=>{e.pointerPosition.current.value=null,e.pointerPosition.start.value=null,e.pointerPosition.offset.pixel.value=null,e.pointerPosition.offset.percent.value=null}}},De=t=>{const e=I(),{onPointerStart:r,onPointerMove:i,onPointerEnd:c}=Pe(t);let l=null;const s=a=>{var w,P;const h=e.selectedElements.value.some(x=>x.node===a);if(e.selectedElements.value.length&&h)return e.selectedElements.value.map(x=>{var L,z;return{...x,initialHTML:((L=x.node)==null?void 0:L.outerHTML)??"",initialRect:(z=x.node)==null?void 0:z.getBoundingClientRect()}});e.selectedElements.value=[];const y=e.elements.value.find(x=>x.node===a);return y?[{...y,initialHTML:((w=y.node)==null?void 0:w.outerHTML)??"",initialRect:(P=y.node)==null?void 0:P.getBoundingClientRect()}]:[]},v=(a,h)=>{const y=Math.max(0,Math.min(a.x+a.width,h.x+h.width)-Math.max(a.x,h.x)),w=Math.max(0,Math.min(a.y+a.height,h.y+h.height)-Math.max(a.y,h.y)),P=y*w,x=a.width*a.height,L=h.width*h.height;return(P/x*100+P/L*100)/2},f=ie(()=>{var F,U,Z,$,W,X,Y,j,q,G;const a=O(e.activeContainer.ref.value),h=A(a),y=((F=e.pointerPosition.current.value)==null?void 0:F.x)??0,w=((U=e.pointerPosition.current.value)==null?void 0:U.y)??0,x=!(a&&y>=a.x&&y<=a.x+a.width&&w>=a.y&&w<=a.y+a.height),L=e.draggingElements.value.map(u=>u.node),z=e.visibleElements.value.map(u=>e.elements.value[u]).filter(u=>{if(!u.node||L.some(S=>S&&C(u.node,S))||u.groups.length&&!!e.draggingElements.value.some(M=>M.groups.length?!M.groups.some(_=>u.groups.includes(_)):!1))return!1;const d=O(u.node);return d&&a&&N(d,a)}).map(u=>{const d=O(u.node),S=A(d),M=y>=d.x&&y<=d.x+d.width&&w>=d.y&&w<=d.y+d.height,_=v(d,a),V=J(h,S),B=e.elements.value.filter(k=>k!==u&&k.node&&u.node&&C(u.node,k.node)).length;return{element:u,isPointerInElement:M,overlapPercent:_,depth:B,centerDistance:V}}).sort((u,d)=>{if(!x){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}),Q=e.zones.value.filter(u=>{if(!u.node||L.some(S=>S&&C(u.node,S))||u.groups.length&&!!e.draggingElements.value.some(M=>M.groups.length?!M.groups.some(_=>u.groups.includes(_)):!1))return!1;const d=O(u.node);return d&&a&&N(d,a)}).map(u=>{const d=O(u.node),S=A(d),M=y>=d.x&&y<=d.x+d.width&&w>=d.y&&w<=d.y+d.height,_=v(d,a),V=J(h,S),B=e.zones.value.filter(k=>k!==u&&k.node&&u.node&&C(u.node,k.node)).length;return{zone:u,isPointerInElement:M,overlapPercent:_,depth:B,centerDistance:V}}).sort((u,d)=>{if(!x){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}),T=e.hovered.element.value,R=e.hovered.zone.value;e.hovered.element.value=((Z=z[0])==null?void 0:Z.element)??null,e.hovered.zone.value=(($=Q[0])==null?void 0:$.zone)??null,e.hovered.element.value!==T&&((W=T==null?void 0:T.events)!=null&&W.onLeave&&T.events.onLeave(e),(Y=(X=e.hovered.element.value)==null?void 0:X.events)!=null&&Y.onHover&&e.hovered.element.value.events.onHover(e)),e.hovered.zone.value!==R&&((j=R==null?void 0:R.events)!=null&&j.onLeave&&R.events.onLeave(e),(G=(q=e.hovered.zone.value)==null?void 0:q.events)!=null&&G.onHover&&e.hovered.zone.value.events.onHover(e))},1e3),g=()=>{f(),l=requestAnimationFrame(g)},o=()=>{g()},m=()=>{l!==null&&(cancelAnimationFrame(l),l=null)};return{activate:a=>{e.draggingElements.value=s(t.value),r(a),o()},track:a=>{i(a)},deactivate:()=>{var a,h;c(),e.hovered.zone.value?(h=(a=e.hovered.zone.value.events).onDrop)==null||h.call(a,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:i,isDragging:c,isOvered:l,isAllowed:s,isVisible:v}=ye(t),{disableInteractions:f,enableInteractions:g}=Ee(),{activeContainer:o,pointerPosition:m}=I(),{activate:D,track:p,deactivate:E}=De(e),a=P=>{t!=null&&t.container&&(o.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=()=>{o.component.value=null,g(),E(),document.removeEventListener("pointermove",h),document.removeEventListener("pointerup",w),document.removeEventListener("wheel",y)};return n.onMounted(r),n.onBeforeUnmount(i),{pointerPosition:m,elementRef:e,isDragging:c,isOvered:l,isAllowed:s,handleDragStart:a,isVisible:v}},Se=t=>{const{zones:e,hovered:r,draggingElements:i,isDragging:c}=I(),l=n.ref(null),s=n.computed(()=>{var o;return((o=r.zone.value)==null?void 0:o.node)===l.value}),v=n.computed(()=>{if(!l.value||!c.value)return!1;const o=e.value.find(m=>m.node===l.value);return o!=null&&o.groups.length?!i.value.some(m=>m.groups.length?!m.groups.some(D=>o.groups.includes(D)):!1):!0});return{elementRef:l,registerZone:()=>{if(!l.value)throw new Error("elementRef is not set");e.value.push({node:l.value,groups:(t==null?void 0:t.groups)??[],events:(t==null?void 0:t.events)??{},data:(t==null?void 0:t.data)??void 0}),l.value.setAttribute("data-dnd-droppable","true")},unregisterZone:()=>{if(!l.value)throw new Error("elementRef is not set");const o=e.value.findIndex(m=>m.node===l.value);o!==-1&&e.value.splice(o,1)},isOvered:s,isAllowed:v}},Me=t=>{const{elementRef:e,registerZone:r,unregisterZone:i,isOvered:c,isAllowed:l}=Se(t);return n.onMounted(r),n.onBeforeUnmount(i),{elementRef:e,isOvered:c,isAllowed:l}},Ie=t=>{const{selectedElements:e,elements:r}=I(),i=n.computed(()=>r.value.find(o=>o.node===t.value)),c=n.computed(()=>e.value.some(o=>o.node===t.value)),l=n.computed(()=>t.value?e.value.some(o=>o.node&&C(o.node,t.value)):!1),s=n.computed(()=>t.value?e.value.some(o=>o.node&&C(t.value,o.node)):!1),v=()=>{i.value&&(e.value=e.value.filter(o=>o.node!==t.value))},f=()=>{i.value&&(l.value&&(e.value=e.value.filter(o=>o.node&&!C(o.node,t.value))),s.value&&(e.value=e.value.filter(o=>o.node&&!C(t.value,o.node))),e.value.push(i.value))};return{handleUnselect:v,handleSelect:f,handleToggleSelect:()=>{i.value&&(e.value.some(o=>o.node===t.value)?v():f())},isSelected:c,isParentOfSelected:l}};exports.DragOverlay=he;exports.getBoundingBox=O;exports.useDnDStore=I;exports.useDraggable=xe;exports.useDroppable=Me;exports.useSelection=Ie;
|
|
@@ -13,25 +13,25 @@ const Se = (t) => t != null, H = () => {
|
|
|
13
13
|
};
|
|
14
14
|
function Le(t, e) {
|
|
15
15
|
function n(...s) {
|
|
16
|
-
return new Promise((u,
|
|
17
|
-
Promise.resolve(t(() => e.apply(this, s), { fn: e, thisArg: this, args: s })).then(u).catch(
|
|
16
|
+
return new Promise((u, o) => {
|
|
17
|
+
Promise.resolve(t(() => e.apply(this, s), { fn: e, thisArg: this, args: s })).then(u).catch(o);
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
20
|
return n;
|
|
21
21
|
}
|
|
22
22
|
function Ce(...t) {
|
|
23
|
-
let e = 0, n, s = !0, u = H,
|
|
24
|
-
!fe(t[0]) && typeof t[0] == "object" ? { delay: l, trailing: v = !0, leading: d = !0, rejectOnCancel:
|
|
25
|
-
const
|
|
23
|
+
let e = 0, n, s = !0, u = H, o, l, v, d, f;
|
|
24
|
+
!fe(t[0]) && typeof t[0] == "object" ? { delay: l, trailing: v = !0, leading: d = !0, rejectOnCancel: f = !1 } = t[0] : [l, v = !0, d = !0, f = !1] = t;
|
|
25
|
+
const r = () => {
|
|
26
26
|
n && (clearTimeout(n), n = void 0, u(), u = H);
|
|
27
27
|
};
|
|
28
28
|
return (D) => {
|
|
29
|
-
const m = V(l), y = Date.now() - e, i = () =>
|
|
30
|
-
return
|
|
31
|
-
u =
|
|
32
|
-
e = Date.now(), s = !0,
|
|
29
|
+
const m = V(l), y = Date.now() - e, i = () => o = D();
|
|
30
|
+
return r(), m <= 0 ? (e = Date.now(), i()) : (y > m && (d || !s) ? (e = Date.now(), i()) : v && (o = new Promise((h, p) => {
|
|
31
|
+
u = f ? p : h, n = setTimeout(() => {
|
|
32
|
+
e = Date.now(), s = !0, h(i()), r();
|
|
33
33
|
}, Math.max(0, m - y));
|
|
34
|
-
})), !d && !n && (n = setTimeout(() => s = !0, m)), s = !1,
|
|
34
|
+
})), !d && !n && (n = setTimeout(() => s = !0, m)), s = !1, o);
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
37
|
function _e(t) {
|
|
@@ -67,43 +67,43 @@ function Re(t, e, n = {}) {
|
|
|
67
67
|
const {
|
|
68
68
|
root: s,
|
|
69
69
|
rootMargin: u = "0px",
|
|
70
|
-
threshold:
|
|
70
|
+
threshold: o = 0,
|
|
71
71
|
window: l = ue,
|
|
72
72
|
immediate: v = !0
|
|
73
|
-
} = n, d = ze(() => l && "IntersectionObserver" in l),
|
|
73
|
+
} = n, d = ze(() => l && "IntersectionObserver" in l), f = x(() => {
|
|
74
74
|
const y = V(t);
|
|
75
75
|
return _e(y).map(X).filter(Se);
|
|
76
76
|
});
|
|
77
|
-
let
|
|
78
|
-
const
|
|
79
|
-
() => [
|
|
77
|
+
let r = H;
|
|
78
|
+
const g = U(v), D = d.value ? ie(
|
|
79
|
+
() => [f.value, X(s), g.value],
|
|
80
80
|
([y, i]) => {
|
|
81
|
-
if (
|
|
81
|
+
if (r(), !g.value || !y.length)
|
|
82
82
|
return;
|
|
83
|
-
const
|
|
83
|
+
const h = new IntersectionObserver(
|
|
84
84
|
e,
|
|
85
85
|
{
|
|
86
86
|
root: X(i),
|
|
87
87
|
rootMargin: u,
|
|
88
|
-
threshold:
|
|
88
|
+
threshold: o
|
|
89
89
|
}
|
|
90
90
|
);
|
|
91
|
-
y.forEach((p) => p &&
|
|
92
|
-
|
|
91
|
+
y.forEach((p) => p && h.observe(p)), r = () => {
|
|
92
|
+
h.disconnect(), r = H;
|
|
93
93
|
};
|
|
94
94
|
},
|
|
95
95
|
{ immediate: v, flush: "post" }
|
|
96
96
|
) : H, m = () => {
|
|
97
|
-
|
|
97
|
+
r(), D(), g.value = !1;
|
|
98
98
|
};
|
|
99
99
|
return De(m), {
|
|
100
100
|
isSupported: d,
|
|
101
|
-
isActive:
|
|
101
|
+
isActive: g,
|
|
102
102
|
pause() {
|
|
103
|
-
|
|
103
|
+
r(), g.value = !1;
|
|
104
104
|
},
|
|
105
105
|
resume() {
|
|
106
|
-
|
|
106
|
+
g.value = !0;
|
|
107
107
|
},
|
|
108
108
|
stop: m
|
|
109
109
|
};
|
|
@@ -113,15 +113,15 @@ function He(t, e = {}) {
|
|
|
113
113
|
window: n = ue,
|
|
114
114
|
scrollTarget: s,
|
|
115
115
|
threshold: u = 0,
|
|
116
|
-
rootMargin:
|
|
116
|
+
rootMargin: o,
|
|
117
117
|
once: l = !1
|
|
118
118
|
} = e, v = U(!1), { stop: d } = Re(
|
|
119
119
|
t,
|
|
120
|
-
(
|
|
121
|
-
let
|
|
122
|
-
for (const D of
|
|
123
|
-
D.time >=
|
|
124
|
-
v.value =
|
|
120
|
+
(f) => {
|
|
121
|
+
let r = v.value, g = 0;
|
|
122
|
+
for (const D of f)
|
|
123
|
+
D.time >= g && (g = D.time, r = D.isIntersecting);
|
|
124
|
+
v.value = r, l && Te(v, () => {
|
|
125
125
|
d();
|
|
126
126
|
});
|
|
127
127
|
},
|
|
@@ -129,7 +129,7 @@ function He(t, e = {}) {
|
|
|
129
129
|
root: s,
|
|
130
130
|
window: n,
|
|
131
131
|
threshold: u,
|
|
132
|
-
rootMargin: V(
|
|
132
|
+
rootMargin: V(o)
|
|
133
133
|
}
|
|
134
134
|
);
|
|
135
135
|
return v;
|
|
@@ -139,11 +139,11 @@ const C = Ie(() => {
|
|
|
139
139
|
component: P(null),
|
|
140
140
|
ref: P(null)
|
|
141
141
|
}, s = P([]), u = x(
|
|
142
|
-
() => s.value.filter((
|
|
143
|
-
var
|
|
144
|
-
return ((
|
|
145
|
-
})
|
|
146
|
-
),
|
|
142
|
+
() => s.value.filter((f) => {
|
|
143
|
+
var r;
|
|
144
|
+
return ((r = f.isVisible) == null ? void 0 : r.value) || f.isVisible;
|
|
145
|
+
}).map((f, r) => r)
|
|
146
|
+
), o = P([]), l = P([]), v = {
|
|
147
147
|
zone: P(null),
|
|
148
148
|
element: P(null)
|
|
149
149
|
}, d = {
|
|
@@ -159,7 +159,7 @@ const C = Ie(() => {
|
|
|
159
159
|
activeContainer: n,
|
|
160
160
|
elements: s,
|
|
161
161
|
draggingElements: t,
|
|
162
|
-
selectedElements:
|
|
162
|
+
selectedElements: o,
|
|
163
163
|
zones: l,
|
|
164
164
|
visibleElements: u,
|
|
165
165
|
hovered: v,
|
|
@@ -180,10 +180,10 @@ const C = Ie(() => {
|
|
|
180
180
|
}, be = ["innerHTML"], Ve = /* @__PURE__ */ ae({
|
|
181
181
|
__name: "DefaultOverlay",
|
|
182
182
|
setup(t) {
|
|
183
|
-
const { elementRef: e, pointerPosition: n, isDragging: s, draggingElements: u } = Ae(),
|
|
184
|
-
var l, v, d,
|
|
183
|
+
const { elementRef: e, pointerPosition: n, isDragging: s, draggingElements: u } = Ae(), o = x(() => {
|
|
184
|
+
var l, v, d, f;
|
|
185
185
|
return {
|
|
186
|
-
transform: `translate3d(${(((l = n.current.value) == null ? void 0 : l.x) ?? 0) - (((v = n.offset.pixel.value) == null ? void 0 : v.x) ?? 0)}px, ${(((d = n.current.value) == null ? void 0 : d.y) ?? 0) - (((
|
|
186
|
+
transform: `translate3d(${(((l = n.current.value) == null ? void 0 : l.x) ?? 0) - (((v = n.offset.pixel.value) == null ? void 0 : v.x) ?? 0)}px, ${(((d = n.current.value) == null ? void 0 : d.y) ?? 0) - (((f = n.offset.pixel.value) == null ? void 0 : f.y) ?? 0)}px, 0)`,
|
|
187
187
|
zIndex: 1e3,
|
|
188
188
|
position: "fixed",
|
|
189
189
|
top: 0,
|
|
@@ -195,16 +195,16 @@ const C = Ie(() => {
|
|
|
195
195
|
key: 0,
|
|
196
196
|
ref_key: "elementRef",
|
|
197
197
|
ref: e,
|
|
198
|
-
style: oe(
|
|
198
|
+
style: oe(o.value)
|
|
199
199
|
}, [
|
|
200
|
-
(b(!0), W(ye, null, Ee(re(u), (d,
|
|
201
|
-
var
|
|
200
|
+
(b(!0), W(ye, null, Ee(re(u), (d, f) => {
|
|
201
|
+
var r, g;
|
|
202
202
|
return b(), W("div", {
|
|
203
|
-
key:
|
|
203
|
+
key: f,
|
|
204
204
|
innerHTML: d.initialHTML,
|
|
205
205
|
style: oe({
|
|
206
|
-
width: `${(
|
|
207
|
-
height: `${(
|
|
206
|
+
width: `${(r = d.initialRect) == null ? void 0 : r.width}px`,
|
|
207
|
+
height: `${(g = d.initialRect) == null ? void 0 : g.height}px`
|
|
208
208
|
})
|
|
209
209
|
}, null, 12, be);
|
|
210
210
|
}), 128))
|
|
@@ -224,16 +224,16 @@ const C = Ie(() => {
|
|
|
224
224
|
draggingElements: n,
|
|
225
225
|
hovered: s,
|
|
226
226
|
selectedElements: u,
|
|
227
|
-
isDragging:
|
|
227
|
+
isDragging: o
|
|
228
228
|
} = C(), l = P(null), v = x(
|
|
229
229
|
() => {
|
|
230
230
|
var m;
|
|
231
231
|
return ((m = s.element.value) == null ? void 0 : m.node) === l.value;
|
|
232
232
|
}
|
|
233
|
-
), d = He(l),
|
|
233
|
+
), d = He(l), f = x(
|
|
234
234
|
() => n.value.some((m) => m.node === l.value)
|
|
235
|
-
),
|
|
236
|
-
if (!l.value || !
|
|
235
|
+
), r = x(() => {
|
|
236
|
+
if (!l.value || !o.value) return !1;
|
|
237
237
|
const m = e.value.find(
|
|
238
238
|
(y) => y.node === l.value
|
|
239
239
|
);
|
|
@@ -265,20 +265,20 @@ const C = Ie(() => {
|
|
|
265
265
|
);
|
|
266
266
|
y !== -1 && u.value.splice(y, 1);
|
|
267
267
|
},
|
|
268
|
-
isDragging:
|
|
268
|
+
isDragging: f,
|
|
269
269
|
isOvered: v,
|
|
270
|
-
isAllowed:
|
|
270
|
+
isAllowed: r,
|
|
271
271
|
isVisible: d
|
|
272
272
|
};
|
|
273
273
|
}, $e = () => {
|
|
274
274
|
let t = "", e = "", n = "";
|
|
275
275
|
const s = () => {
|
|
276
276
|
const l = document.body;
|
|
277
|
-
t = l.style.userSelect, e = l.style.touchAction, n = l.style.overscrollBehavior, l.style.userSelect = "none", l.style.touchAction = "none", l.style.overscrollBehavior = "none", window.addEventListener("contextmenu",
|
|
277
|
+
t = l.style.userSelect, e = l.style.touchAction, n = 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);
|
|
278
278
|
}, u = () => {
|
|
279
279
|
const l = document.body;
|
|
280
|
-
l.style.userSelect = t, l.style.touchAction = e, l.style.overscrollBehavior = n, window.removeEventListener("contextmenu",
|
|
281
|
-
},
|
|
280
|
+
l.style.userSelect = t, l.style.touchAction = e, l.style.overscrollBehavior = n, window.removeEventListener("contextmenu", o), window.removeEventListener("selectstart", o), window.removeEventListener("touchstart", o), window.removeEventListener("touchmove", o);
|
|
281
|
+
}, o = (l) => l.preventDefault();
|
|
282
282
|
return {
|
|
283
283
|
disableInteractions: s,
|
|
284
284
|
enableInteractions: u
|
|
@@ -327,21 +327,21 @@ const C = Ie(() => {
|
|
|
327
327
|
}, L = (t, e) => t ? e.contains(t) : !1, Xe = (t) => {
|
|
328
328
|
const e = C();
|
|
329
329
|
return {
|
|
330
|
-
onPointerStart: (
|
|
331
|
-
e.pointerPosition.start.value = { x:
|
|
332
|
-
x:
|
|
333
|
-
y:
|
|
330
|
+
onPointerStart: (o) => {
|
|
331
|
+
e.pointerPosition.start.value = { x: o.clientX, y: o.clientY }, e.pointerPosition.current.value = {
|
|
332
|
+
x: o.clientX,
|
|
333
|
+
y: o.clientY
|
|
334
334
|
};
|
|
335
335
|
const { pixel: l, percent: v } = We(t.value, {
|
|
336
|
-
x:
|
|
337
|
-
y:
|
|
336
|
+
x: o.clientX,
|
|
337
|
+
y: o.clientY
|
|
338
338
|
});
|
|
339
339
|
e.pointerPosition.offset.pixel.value = l, e.pointerPosition.offset.percent.value = v;
|
|
340
340
|
},
|
|
341
|
-
onPointerMove: (
|
|
341
|
+
onPointerMove: (o) => {
|
|
342
342
|
e.pointerPosition.current.value = {
|
|
343
|
-
x:
|
|
344
|
-
y:
|
|
343
|
+
x: o.clientX,
|
|
344
|
+
y: o.clientY
|
|
345
345
|
};
|
|
346
346
|
},
|
|
347
347
|
onPointerEnd: () => {
|
|
@@ -350,13 +350,13 @@ const C = Ie(() => {
|
|
|
350
350
|
};
|
|
351
351
|
}, Ye = (t) => {
|
|
352
352
|
const e = C(), { onPointerStart: n, onPointerMove: s, onPointerEnd: u } = Xe(t);
|
|
353
|
-
let
|
|
353
|
+
let o = null;
|
|
354
354
|
const l = (i) => {
|
|
355
355
|
var E, w;
|
|
356
|
-
const
|
|
356
|
+
const h = e.selectedElements.value.some(
|
|
357
357
|
(I) => I.node === i
|
|
358
358
|
);
|
|
359
|
-
if (e.selectedElements.value.length &&
|
|
359
|
+
if (e.selectedElements.value.length && h)
|
|
360
360
|
return e.selectedElements.value.map((I) => {
|
|
361
361
|
var _, A;
|
|
362
362
|
return {
|
|
@@ -376,18 +376,18 @@ const C = Ie(() => {
|
|
|
376
376
|
initialRect: (w = p.node) == null ? void 0 : w.getBoundingClientRect()
|
|
377
377
|
}
|
|
378
378
|
] : [];
|
|
379
|
-
}, v = (i,
|
|
379
|
+
}, v = (i, h) => {
|
|
380
380
|
const p = Math.max(
|
|
381
381
|
0,
|
|
382
|
-
Math.min(i.x + i.width,
|
|
382
|
+
Math.min(i.x + i.width, h.x + h.width) - Math.max(i.x, h.x)
|
|
383
383
|
), E = Math.max(
|
|
384
384
|
0,
|
|
385
|
-
Math.min(i.y + i.height,
|
|
386
|
-
), w = p * E, I = i.width * i.height, _ =
|
|
385
|
+
Math.min(i.y + i.height, h.y + h.height) - Math.max(i.y, h.y)
|
|
386
|
+
), w = p * E, I = i.width * i.height, _ = h.width * h.height;
|
|
387
387
|
return (w / I * 100 + w / _ * 100) / 2;
|
|
388
388
|
}, d = Oe(() => {
|
|
389
389
|
var G, N, q, B, J, K, Q, ee, te, ne;
|
|
390
|
-
const i = k(e.activeContainer.ref.value),
|
|
390
|
+
const i = k(e.activeContainer.ref.value), h = Y(i), p = ((G = e.pointerPosition.current.value) == null ? void 0 : G.x) ?? 0, E = ((N = e.pointerPosition.current.value) == null ? void 0 : N.y) ?? 0, I = !(i && p >= i.x && p <= i.x + i.width && E >= i.y && E <= i.y + i.height), _ = e.draggingElements.value.map((a) => a.node), A = e.visibleElements.value.map((a) => e.elements.value[a]).filter((a) => {
|
|
391
391
|
if (!a.node || _.some(
|
|
392
392
|
(M) => M && L(a.node, M)
|
|
393
393
|
) || a.groups.length && !!e.draggingElements.value.some(
|
|
@@ -399,7 +399,7 @@ const C = Ie(() => {
|
|
|
399
399
|
const c = k(a.node);
|
|
400
400
|
return c && i && le(c, i);
|
|
401
401
|
}).map((a) => {
|
|
402
|
-
const c = k(a.node), M = Y(c), S = p >= c.x && p <= c.x + c.width && E >= c.y && E <= c.y + c.height, O = v(c, i), Z = se(
|
|
402
|
+
const c = k(a.node), M = Y(c), S = p >= c.x && p <= c.x + c.width && E >= c.y && E <= c.y + c.height, O = v(c, i), Z = se(h, M), $ = e.elements.value.filter(
|
|
403
403
|
(T) => T !== a && T.node && a.node && L(
|
|
404
404
|
a.node,
|
|
405
405
|
T.node
|
|
@@ -428,7 +428,7 @@ const C = Ie(() => {
|
|
|
428
428
|
const c = k(a.node);
|
|
429
429
|
return c && i && le(c, i);
|
|
430
430
|
}).map((a) => {
|
|
431
|
-
const c = k(a.node), M = Y(c), S = p >= c.x && p <= c.x + c.width && E >= c.y && E <= c.y + c.height, O = v(c, i), Z = se(
|
|
431
|
+
const c = k(a.node), M = Y(c), S = p >= c.x && p <= c.x + c.width && E >= c.y && E <= c.y + c.height, O = v(c, i), Z = se(h, M), $ = e.zones.value.filter(
|
|
432
432
|
(T) => T !== a && T.node && a.node && L(a.node, T.node)
|
|
433
433
|
).length;
|
|
434
434
|
return {
|
|
@@ -448,28 +448,28 @@ const C = Ie(() => {
|
|
|
448
448
|
return Math.abs(a.overlapPercent - c.overlapPercent) <= 1 ? a.centerDistance - c.centerDistance : c.overlapPercent - a.overlapPercent;
|
|
449
449
|
}), z = e.hovered.element.value, R = e.hovered.zone.value;
|
|
450
450
|
e.hovered.element.value = ((q = A[0]) == null ? void 0 : q.element) ?? null, e.hovered.zone.value = ((B = ce[0]) == null ? void 0 : B.zone) ?? null, e.hovered.element.value !== z && ((J = z == null ? void 0 : z.events) != null && J.onLeave && z.events.onLeave(e), (Q = (K = e.hovered.element.value) == null ? void 0 : K.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));
|
|
451
|
-
}, 1e3),
|
|
452
|
-
d(),
|
|
453
|
-
},
|
|
454
|
-
|
|
455
|
-
},
|
|
456
|
-
|
|
451
|
+
}, 1e3), f = () => {
|
|
452
|
+
d(), o = requestAnimationFrame(f);
|
|
453
|
+
}, r = () => {
|
|
454
|
+
f();
|
|
455
|
+
}, g = () => {
|
|
456
|
+
o !== null && (cancelAnimationFrame(o), o = null);
|
|
457
457
|
};
|
|
458
458
|
return {
|
|
459
459
|
activate: (i) => {
|
|
460
|
-
e.draggingElements.value = l(t.value), n(i),
|
|
460
|
+
e.draggingElements.value = l(t.value), n(i), r();
|
|
461
461
|
},
|
|
462
462
|
track: (i) => {
|
|
463
463
|
s(i);
|
|
464
464
|
},
|
|
465
465
|
deactivate: () => {
|
|
466
|
-
var i,
|
|
467
|
-
u(), e.hovered.zone.value ? (
|
|
466
|
+
var i, h;
|
|
467
|
+
u(), e.hovered.zone.value ? (h = (i = e.hovered.zone.value.events).onDrop) == null || h.call(i, e) : e.draggingElements.value.forEach(
|
|
468
468
|
(p) => {
|
|
469
469
|
var E, w;
|
|
470
470
|
return (w = (E = p.events).onEnd) == null ? void 0 : w.call(E, e);
|
|
471
471
|
}
|
|
472
|
-
), e.draggingElements.value = [], e.selectedElements.value = [], e.hovered.zone.value = null, e.hovered.element.value = null,
|
|
472
|
+
), e.draggingElements.value = [], e.selectedElements.value = [], e.hovered.zone.value = null, e.hovered.element.value = null, g();
|
|
473
473
|
}
|
|
474
474
|
};
|
|
475
475
|
}, Ne = (t) => {
|
|
@@ -478,83 +478,83 @@ const C = Ie(() => {
|
|
|
478
478
|
registerElement: n,
|
|
479
479
|
unregisterElement: s,
|
|
480
480
|
isDragging: u,
|
|
481
|
-
isOvered:
|
|
481
|
+
isOvered: o,
|
|
482
482
|
isAllowed: l,
|
|
483
483
|
isVisible: v
|
|
484
|
-
} = Ze(t), { disableInteractions: d, enableInteractions:
|
|
485
|
-
t != null && t.container && (
|
|
486
|
-
},
|
|
487
|
-
|
|
484
|
+
} = Ze(t), { disableInteractions: d, enableInteractions: f } = $e(), { activeContainer: r, pointerPosition: g } = C(), { activate: D, track: m, deactivate: y } = Ye(e), i = (w) => {
|
|
485
|
+
t != null && t.container && (r.component.value = xe(t.container)), d(), D(w), document.addEventListener("pointermove", h), document.addEventListener("pointerup", E), document.addEventListener("wheel", p);
|
|
486
|
+
}, h = (w) => m(w), p = (w) => m(w), E = () => {
|
|
487
|
+
r.component.value = null, f(), y(), document.removeEventListener("pointermove", h), document.removeEventListener("pointerup", E), document.removeEventListener("wheel", p);
|
|
488
488
|
};
|
|
489
489
|
return F(n), j(s), {
|
|
490
|
-
pointerPosition:
|
|
490
|
+
pointerPosition: g,
|
|
491
491
|
elementRef: e,
|
|
492
492
|
isDragging: u,
|
|
493
|
-
isOvered:
|
|
493
|
+
isOvered: o,
|
|
494
494
|
isAllowed: l,
|
|
495
495
|
handleDragStart: i,
|
|
496
496
|
isVisible: v
|
|
497
497
|
};
|
|
498
498
|
}, Ue = (t) => {
|
|
499
|
-
const { zones: e, hovered: n, draggingElements: s, isDragging: u } = C(),
|
|
500
|
-
var
|
|
501
|
-
return ((
|
|
499
|
+
const { zones: e, hovered: n, draggingElements: s, isDragging: u } = C(), o = P(null), l = x(() => {
|
|
500
|
+
var r;
|
|
501
|
+
return ((r = n.zone.value) == null ? void 0 : r.node) === o.value;
|
|
502
502
|
}), v = x(() => {
|
|
503
|
-
if (!
|
|
504
|
-
const
|
|
505
|
-
(
|
|
503
|
+
if (!o.value || !u.value) return !1;
|
|
504
|
+
const r = e.value.find(
|
|
505
|
+
(g) => g.node === o.value
|
|
506
506
|
);
|
|
507
|
-
return
|
|
508
|
-
(D) =>
|
|
507
|
+
return r != null && r.groups.length ? !s.value.some((g) => g.groups.length ? !g.groups.some(
|
|
508
|
+
(D) => r.groups.includes(D)
|
|
509
509
|
) : !1) : !0;
|
|
510
510
|
});
|
|
511
|
-
return { elementRef:
|
|
512
|
-
if (!
|
|
511
|
+
return { elementRef: o, registerZone: () => {
|
|
512
|
+
if (!o.value) throw new Error("elementRef is not set");
|
|
513
513
|
e.value.push({
|
|
514
|
-
node:
|
|
514
|
+
node: o.value,
|
|
515
515
|
groups: (t == null ? void 0 : t.groups) ?? [],
|
|
516
516
|
events: (t == null ? void 0 : t.events) ?? {},
|
|
517
517
|
data: (t == null ? void 0 : t.data) ?? void 0
|
|
518
|
-
}),
|
|
518
|
+
}), o.value.setAttribute("data-dnd-droppable", "true");
|
|
519
519
|
}, unregisterZone: () => {
|
|
520
|
-
if (!
|
|
521
|
-
const
|
|
522
|
-
(
|
|
520
|
+
if (!o.value) throw new Error("elementRef is not set");
|
|
521
|
+
const r = e.value.findIndex(
|
|
522
|
+
(g) => g.node === o.value
|
|
523
523
|
);
|
|
524
|
-
|
|
524
|
+
r !== -1 && e.value.splice(r, 1);
|
|
525
525
|
}, isOvered: l, isAllowed: v };
|
|
526
526
|
}, qe = (t) => {
|
|
527
|
-
const { elementRef: e, registerZone: n, unregisterZone: s, isOvered: u, isAllowed:
|
|
528
|
-
return F(n), j(s), { elementRef: e, isOvered: u, isAllowed:
|
|
527
|
+
const { elementRef: e, registerZone: n, unregisterZone: s, isOvered: u, isAllowed: o } = Ue(t);
|
|
528
|
+
return F(n), j(s), { elementRef: e, isOvered: u, isAllowed: o };
|
|
529
529
|
}, Be = (t) => {
|
|
530
530
|
const { selectedElements: e, elements: n } = C(), s = x(
|
|
531
|
-
() => n.value.find((
|
|
531
|
+
() => n.value.find((r) => r.node === t.value)
|
|
532
532
|
), u = x(
|
|
533
|
-
() => e.value.some((
|
|
534
|
-
),
|
|
535
|
-
(
|
|
536
|
-
|
|
533
|
+
() => e.value.some((r) => r.node === t.value)
|
|
534
|
+
), o = x(() => t.value ? e.value.some(
|
|
535
|
+
(r) => r.node && L(
|
|
536
|
+
r.node,
|
|
537
537
|
t.value
|
|
538
538
|
)
|
|
539
539
|
) : !1), l = x(() => t.value ? e.value.some(
|
|
540
|
-
(
|
|
540
|
+
(r) => r.node && L(
|
|
541
541
|
t.value,
|
|
542
|
-
|
|
542
|
+
r.node
|
|
543
543
|
)
|
|
544
544
|
) : !1), v = () => {
|
|
545
545
|
s.value && (e.value = e.value.filter(
|
|
546
|
-
(
|
|
546
|
+
(r) => r.node !== t.value
|
|
547
547
|
));
|
|
548
548
|
}, d = () => {
|
|
549
|
-
s.value && (
|
|
550
|
-
(
|
|
551
|
-
|
|
549
|
+
s.value && (o.value && (e.value = e.value.filter(
|
|
550
|
+
(r) => r.node && !L(
|
|
551
|
+
r.node,
|
|
552
552
|
t.value
|
|
553
553
|
)
|
|
554
554
|
)), l.value && (e.value = e.value.filter(
|
|
555
|
-
(
|
|
555
|
+
(r) => r.node && !L(
|
|
556
556
|
t.value,
|
|
557
|
-
|
|
557
|
+
r.node
|
|
558
558
|
)
|
|
559
559
|
)), e.value.push(s.value));
|
|
560
560
|
};
|
|
@@ -562,10 +562,10 @@ const C = Ie(() => {
|
|
|
562
562
|
handleUnselect: v,
|
|
563
563
|
handleSelect: d,
|
|
564
564
|
handleToggleSelect: () => {
|
|
565
|
-
s.value && (e.value.some((
|
|
565
|
+
s.value && (e.value.some((r) => r.node === t.value) ? v() : d());
|
|
566
566
|
},
|
|
567
567
|
isSelected: u,
|
|
568
|
-
isParentOfSelected:
|
|
568
|
+
isParentOfSelected: o
|
|
569
569
|
};
|
|
570
570
|
};
|
|
571
571
|
export {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue-dnd-kit/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.41-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",
|