@vue-dnd-kit/core 2.0.0 → 2.0.2
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.
|
@@ -2,7 +2,7 @@ import { IConstraintsAreaEntity, IDraggableEntity, IDroppableEntity, IEntities,
|
|
|
2
2
|
import { ICoordinates, TPointerState } from './pointer';
|
|
3
3
|
import { IAutoScrollOptions } from './placement';
|
|
4
4
|
import { IHelpers, IHoveredDraggableContext } from './operations';
|
|
5
|
-
import { Component, ComputedRef, CSSProperties, Reactive, Ref, ShallowRef, WritableComputedRef } from 'vue';
|
|
5
|
+
import { Component, ComputedRef, CSSProperties, Reactive, Ref, ShallowRef, VNode, VueElement, WritableComputedRef } from 'vue';
|
|
6
6
|
/** Event object passed to all drag/drop handlers */
|
|
7
7
|
export interface IDragEvent<
|
|
8
8
|
DragT = unknown,
|
|
@@ -91,4 +91,6 @@ export interface IDnDProviderProps {
|
|
|
91
91
|
autoScrollViewport?: IAutoScrollOptions | true | false | null;
|
|
92
92
|
/** Teleport overlay to element: 'body' = defaults, string = element id. false | null | undefined = disabled. */
|
|
93
93
|
overlayTo?: string | false | null;
|
|
94
|
+
style?: any;
|
|
95
|
+
class?: any;
|
|
94
96
|
}
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
|
|
4
4
|
`),`var __fn = ${e.toString()};`,`(${zt.toString()})(__fn);`].join(`
|
|
5
5
|
|
|
6
|
-
`)}function _t(e,t){let s=null,n=null,o=!1,i=0;const r=new Map;try{const u=Ot(e,t?.localDependencies??[]),c=new Blob([u],{type:"application/javascript"});n=URL.createObjectURL(c),s=new Worker(n),o=!0,s.onmessage=l=>{const f=r.get(l.data.callId);f&&(r.delete(l.data.callId),l.data.ok?f.resolve(l.data.result):f.reject(new Error(l.data.error)))},s.onerror=l=>{o=!1;for(const f of r.values())f.reject(new Error(l.message));r.clear(),s?.terminate(),s=null}}catch{o=!1}return{run:u=>{if(!s||!o)try{return Promise.resolve(e(u))}catch(l){return Promise.reject(l instanceof Error?l:new Error(String(l)))}const c=++i;return new Promise((l,f)=>{r.set(c,{resolve:l,reject:f}),s.postMessage({callId:c,data:u})})},terminate:()=>{for(const u of r.values())u.reject(new Error("Worker terminated"));r.clear(),s?.terminate(),s=null,n&&(URL.revokeObjectURL(n),n=null),o=!1},get isSupported(){return o}}}function Ge(e,t,s,n,o,i,r,a){return e<o+r&&e+s>o&&t<i+a&&t+n>i}function He(e,t,s,n,o,i,r,a){const g=Math.max(0,Math.min(e+s,o+r)-Math.max(e,o)),u=Math.max(0,Math.min(t+n,i+a)-Math.max(t,i)),c=g*u,l=s*n,f=r*a;return!l||!f?0:(c/l*100+c/f*100)/2}function q(e,t,s,n,o,i){return o>=e&&o<=e+s&&i>=t&&i<=t+n}function Ft(e){const{containerBox:t,pointer:s,elements:n,elementCount:o,zones:i,zoneCount:r,config:a}=e,{x:g,y:u,width:c,height:l}=t,{x:f,y:m}=s,h=a.minOverlapPercent,p=g+c/2,v=u+l/2,M=q(g,u,c,l,f,m);function w(x,G){const D=[],b=x;for(let y=0;y<G;y++){const S=y*4,C=b[S],k=b[S+1],I=b[S+2],L=b[S+3];if(!Ge(C,k,I,L,g,u,c,l))continue;const be=He(C,k,I,L,g,u,c,l);be<h||D.push({index:y,overlapPercent:be,centerDistance:Math.hypot(p-(C+I/2),v-(k+L/2)),isPointerInElement:q(C,k,I,L,f,m),depth:0})}for(let y=0;y<D.length;y++){const S=D[y].index*4,C=b[S]+b[S+2]/2,k=b[S+1]+b[S+3]/2;for(let I=0;I<D.length;I++){if(y===I)continue;const L=D[I].index*4;q(b[L],b[L+1],b[L+2],b[L+3],C,k)&&D[y].depth++}}return D.sort((y,S)=>{if(M){if(y.isPointerInElement&&S.isPointerInElement)return S.depth-y.depth;if(y.isPointerInElement!==S.isPointerInElement)return y.isPointerInElement?-1:1}return Math.abs(y.overlapPercent-S.overlapPercent)<=1?y.centerDistance-S.centerDistance:S.overlapPercent-y.overlapPercent}),D.map(y=>y.index)}return{elementIndices:w(n,o),zoneIndices:w(i,r)}}let re=null;function Ke(){return re||(re=_t(Ft,{localDependencies:[Ge,He,q]})),re}function xe(e,t){const s=[];for(const n of e){let o=t.get(n);o||(o=n.getBoundingClientRect(),t.set(n,o)),s.push(o.x,o.y,o.width,o.height)}return s}let Ee=0;function Gt(e){const t=Ke(),s=++Ee,n=[...e.entities.allowedDraggableSet].filter(u=>ee(u,e)),o=[...e.entities.allowedDroppableSet].filter(u=>ee(u,e)),i=Fe(e),r=e.pointer.value?.current,a=e.lib.rectCache,g={containerBox:{x:i.x,y:i.y,width:i.width,height:i.height},pointer:{x:r?.x??0,y:r?.y??0},elements:xe(n,a),elementCount:n.length,zones:xe(o,a),zoneCount:o.length,config:{minOverlapPercent:10}};t.run(g).then(u=>{if(s!==Ee||e.state.value!=="dragging")return;const c=u.elementIndices.map(f=>n[f]),l=u.zoneIndices.map(f=>o[f]);V(e,e.hovered,{elements:c,zones:l})})}function fe(e){if(e.collision?.run){const s=e.collision.run(e);V(e,e.hovered,s);return}if(Ke().isSupported)Gt(e);else{const s=te(e);V(e,e.hovered,s)}}function Ht(e,t){const s=e.collision?.throttle?.value??0;if(s<=0){fe(e);return}const n=Date.now();n-t.value>=s&&(t.value=n,fe(e))}async function Ue(e){const t=e.hovered.droppable.keys().next().value;if(!t||Z(t,e))return"accept";const s=e.entities.droppableMap.get(t),n=R(e,t),o=s?.events?.onDrop?.(n);if(o!=null&&typeof o.then=="function"){e.state.value="pending";let r;try{r=await o}catch{const a=e.entities.initiatingDraggable;return U(e,a,"onSelfDragCancel"),P(e,"onDragCancel"),_e(e,e.hovered),"cancel"}return r===!1?(e.state.value="dragging","decline"):"accept"}return o===!1?"decline":"accept"}function Ne(e){const t=e.entities.initiatingDraggable;U(e,t,"onSelfDragEnd"),P(e,"onDragEnd"),bt(e,e.hovered)}function Kt(e){const t=e.entities.selectingArea;if(!t)return;const s=e.entities.selectableAreaMap.get(t),n=[...e.entities.selectedSet];s?.events?.onSelected?.(n)}const Ut=e=>{const t={current:null},s={value:0},n=async()=>{le(),t.current?.cancel(),t.current=null;const a=e.state.value;if(a==="dragging"){const g=await Ue(e);if(g==="accept"&&Ne(e),g==="accept"||g==="cancel"){Q(e),document.removeEventListener("pointerup",n),document.removeEventListener("pointermove",o);return}return}else a==="selecting"&&Kt(e);Q(e),document.removeEventListener("pointerup",n),document.removeEventListener("pointermove",o)},o=a=>{if(e.pointer.value){if(e.pointer.value.current={x:a.clientX,y:a.clientY},nt(e)){oe(e,a,"onSelfDragStart"),P(e,"onDragStart");return}if(e.state.value==="dragging"){Ht(e,s);const g=e.entities.initiatingDraggable;U(e,g,"onSelfDragMove"),P(e,"onDragMove")}e.state.value==="selecting"&&Mt(e)}};return{pointerDown:a=>{document.addEventListener("pointerup",n),document.addEventListener("pointermove",o);const g=a.target,u=g.closest(N.SELECT_AREA),c=g.closest(N.DRAGGABLE);if(e.entities.modifiersSelectableAreaSet.size>0&&e.entities.modifiersSelectableAreaSet.has(u)){ae(),e.pointer.value=ce(a),e.state.value="selecting",e.entities.selectingArea=u;return}if(e.entities.modifiersDraggableSet.size>0&&e.entities.modifiersDraggableSet.has(c)){const l=e.entities.draggableMap.get(c);if(!Be(g,c,l?.dragHandle))return;ae(),e.entities.initiatingDraggable=c;const f=Pe(a,c);e.pointer.value=ce(a,f.x,f.y),l?.activation?.distance||l?.activation?.delay?(e.state.value="activating",l?.activation?.delay&&(e.delay.startTime=Date.now(),t.current=st(e,()=>{J(e),oe(e,a,"onSelfDragStart"),P(e,"onDragStart")}))):(J(e),oe(e,a,"onSelfDragStart"),P(e,"onDragStart"))}},pointerUp:n,pointerMove:o,cleanup:()=>{t.current?.cancel(),document.removeEventListener("pointerup",n),document.removeEventListener("pointermove",o),e.lib.draggableObserver.disconnect(),e.lib.droppableObserver.disconnect(),e.lib.selectableAreaObserver.disconnect(),e.lib.overlaySizeObserver.disconnect()}}},Nt={ArrowUp:{dx:0,dy:-1},ArrowDown:{dx:0,dy:1},ArrowLeft:{dx:-1,dy:0},ArrowRight:{dx:1,dy:0},KeyW:{dx:0,dy:-1},KeyA:{dx:-1,dy:0},KeyS:{dx:0,dy:1},KeyD:{dx:1,dy:0}},Zt=e=>t=>{const{keys:s}=e.keyboard;if(s.pressedKeys.value.add(t.code),e.state.value==="dragging"){if(s.forCancel.includes(t.code)){t.preventDefault(),le(),U(e,e.entities.initiatingDraggable,"onSelfDragCancel"),P(e,"onDragCancel"),_e(e,e.hovered),Q(e);return}if(s.forDrop.includes(t.code)){t.preventDefault(),(async()=>(await Ue(e)&&Ne(e),le(),Q(e)))();return}const o=Nt[t.code];if(o&&s.forMove.includes(t.code)&&e.pointer.value){t.preventDefault();const i=s.forMoveFaster.some(u=>s.pressedKeys.value.has(u)),r=e.keyboard.step*(i?e.keyboard.moveFaster:1);e.pointer.value.current={x:e.pointer.value.current.x+o.dx*r,y:e.pointer.value.current.y+o.dy*r};const g=(e.collision?.run??te)(e);V(e,e.hovered,g),U(e,e.entities.initiatingDraggable,"onSelfDragMove"),P(e,"onDragMove");return}return}if(s.forDrag.includes(t.code)){const o=document.activeElement;if(!o)return;const i=o.closest(N.DRAGGABLE);if(!i||e.entities.modifiersDraggableSet.size===0||!e.entities.modifiersDraggableSet.has(i))return;const r=e.entities.draggableMap.get(i);if(!Be(o,i,r?.dragHandle,!0))return;t.preventDefault(),ae();const a=i.getBoundingClientRect(),g=a.left+a.width/2,u=a.top+a.height/2,c={clientX:g,clientY:u};e.entities.initiatingDraggable=i;const l=Pe(c,i);e.pointer.value=ce(c,l.x,l.y),J(e);const m=(e.collision?.run??te)(e);V(e,e.hovered,m),U(e,i,"onSelfDragStart"),P(e,"onDragStart")}},Yt=e=>t=>{e.keyboard.keys.pressedKeys.value.delete(t.code)},jt=e=>()=>{e.keyboard.keys.pressedKeys.value.clear()},ie={keyDown:Zt,keyUp:Yt,clear:jt},Xt=e=>()=>{e.state.value&&(e.scrollPosition.x=window.scrollX,e.scrollPosition.y=window.scrollY,e.lib.rectCache.clear(),e.state.value==="dragging"&&fe(e))},B=50,Vt=144,Ae=1e3/Vt;function $t(e){return e==null?{top:B,right:B,bottom:B,left:B}:typeof e=="number"?{top:e,right:e,bottom:e,left:e}:{top:e.top??B,right:e.right??B,bottom:e.bottom??B,left:e.left??B}}const Wt={getScrollState(e){return{scrollTop:e.scrollTop,scrollLeft:e.scrollLeft}},setScroll(e,t,s){e.scrollTop=t,e.scrollLeft=s}};function Ze(e,t,s,n=Wt,o){const{speed:i=10,disabled:r=!1}=t,a=$t(t.threshold);let g=null,u=null,c=null,l=0,f=0;const m=M=>{o&&(o.value=M)},h=M=>{const w=e.value,x=s();if(!w||!x||r){m(!1);return}u||(u=M);const G=M-u;if(G<Ae){g=requestAnimationFrame(h);return}const D=i*(G/Ae);u=M;const{scrollTop:b,scrollLeft:y}=n.getScrollState(w);(!c||l!==b||f!==y)&&(c=n.getRect?n.getRect(w):w.getBoundingClientRect(),l=b,f=y);let S=!1,C=b,k=y;a.top>0&&x.y-c.top<a.top?(C=b-D,S=!0):a.bottom>0&&c.bottom-x.y<a.bottom&&(C=b+D,S=!0),a.left>0&&x.x-c.left<a.left?(k=y-D,S=!0):a.right>0&&c.right-x.x<a.right&&(k=y+D,S=!0),S&&n.setScroll(w,C,k),m(S),g=requestAnimationFrame(h)};return{run:()=>{u=null,g=requestAnimationFrame(h)},stop:()=>{g&&(cancelAnimationFrame(g),g=null),c=null,l=0,f=0,u=null,m(!1)}}}const qt={getScrollState(){return{scrollTop:window.scrollY??document.documentElement.scrollTop,scrollLeft:window.scrollX??document.documentElement.scrollLeft}},setScroll(e,t,s){window.scrollTo(s,t)},getRect(){return new DOMRect(0,0,window.innerWidth,window.innerHeight)}},Jt={get value(){return typeof document<"u"?document.documentElement:null}};function Qt(e,t){const s=d.shallowRef(!1),o=Ze(Jt,t??{},()=>{if(e.state.value!=="dragging")return null;const a=e.overlay.position.value,g=e.overlay.size.value;return a?g?.width&&g?.height?{x:a.x+g.width/2,y:a.y+g.height/2}:a:null},qt,s),i=d.watch(()=>e.state.value,a=>{a==="dragging"?o.run():o.stop()}),r=()=>{i(),o.stop()};return d.onScopeDispose(r),{isScrolling:s,stop:r}}const en=e=>{const t=Ut(e),s=ie.keyDown(e),n=ie.keyUp(e),o=ie.clear(e),i=Xt(e);let r=null;d.watch(e.autoScrollViewport,a=>{r?.(),r=null,(a===!0||a&&typeof a=="object")&&(r=Qt(e,a===!0?{}:a).stop)},{immediate:!0}),d.onMounted(()=>{document.addEventListener("pointerdown",t.pointerDown),document.addEventListener("keydown",s),document.addEventListener("keyup",n),document.addEventListener("blur",o),document.addEventListener("scroll",i,!0)}),d.onBeforeUnmount(()=>{document.removeEventListener("pointerdown",t.pointerDown),document.removeEventListener("pointerup",t.pointerUp),document.removeEventListener("pointermove",t.pointerMove),document.removeEventListener("keydown",s),document.removeEventListener("keyup",n),document.removeEventListener("blur",o),document.removeEventListener("scroll",i,!0),r?.(),t.cleanup()})},ne=()=>{const e=d.inject(de);if(!e)throw Error("DnD provider not found");return e},ye=()=>{const e=ne();return{overlay:e.overlay,delay:e.delay,distanceProgress:e.distanceProgress,entities:e.entities,pointer:e.pointer,state:e.state,scrollPosition:e.scrollPosition,keyboard:e.keyboard,hovered:e.hovered,collision:e.collision,autoScrollViewport:e.autoScrollViewport}},tn=d.defineComponent({__name:"DefaultOverlay",setup(e){const{entities:t,state:s,overlay:n}=ye();return(o,i)=>d.unref(s)==="dragging"?(d.openBlock(),d.createElementBlock("div",{key:0,class:"dnd-kit-default-overlay",style:d.normalizeStyle({"--position-x":d.unref(n).position.value.x+"px","--position-y":d.unref(n).position.value.y+"px"})},[(d.openBlock(!0),d.createElementBlock(d.Fragment,null,d.renderList(d.unref(t).draggingMap,([r,a])=>(d.openBlock(),d.createElementBlock(d.Fragment,null,[d.unref(t).draggableMap.get(r)?.render?(d.openBlock(),d.createBlock(d.resolveDynamicComponent(d.unref(t).draggableMap.get(r)?.render),{key:0})):(d.openBlock(),d.createBlock(d.resolveDynamicComponent(r.tagName),{key:1,innerHTML:a.initialOuterHTML,style:d.normalizeStyle({width:a.initialRect.width+"px",height:a.initialRect.height+"px"})},null,8,["innerHTML","style"]))],64))),256))],4)):d.createCommentVNode("",!0)}}),nn=d.defineComponent({__name:"DnDProvider",props:{autoScrollViewport:{type:[Object,Boolean,null]},overlayTo:{type:[String,Boolean,null]}},setup(e){const t=e,s=d.useTemplateRef("overlayRef"),n=lt(s,t);en(n);const o=d.computed(()=>n.overlay.render.value??tn);return d.provide(de,n),(i,r)=>(d.openBlock(),d.createElementBlock(d.Fragment,null,[d.renderSlot(i.$slots,"default"),(d.openBlock(),d.createBlock(d.Teleport,{to:d.unref(n).overlay.to.value||"body"},[d.createElementVNode("div",{ref_key:"overlayRef",ref:s,class:"dnd-kit-overlay-container"},[d.renderSlot(i.$slots,"overlay",{overlay:o.value},()=>[(d.openBlock(),d.createBlock(d.resolveDynamicComponent(o.value)))])],512)],8,["to"]))],64))}});function sn(e,t,s){const n=ne();let o,i,r;typeof t=="function"?(o={},i=t):(o=t??{},i=s);const a=d.computed({get(){const l=E(e);return l?n.entities.selectedSet.has(l):!1},set(l){const f=E(e);f&&n.entities.selectedSet[l?"add":"delete"](f)}}),g=d.computed(()=>{const l=E(e);return l?n.entities.draggingMap.has(l):!1}),u=d.computed(()=>{const l=E(e);return l?n.entities.allowedDraggableSet.has(l):!1}),c=d.computed(()=>{const l=E(e);if(l)return n.entities.draggableMap.get(l)?.hoveredPlacement});return d.onMounted(()=>{r=E(e),r&&(r.addEventListener("dragstart",A),r.addEventListener("drag",A),r.addEventListener("dragend",A),r.setAttribute(F.DRAGGABLE,""),n.lib.draggableObserver.observe(r),n.entities.draggableMap.set(r,{render:o.render,disabled:o.disabled??!1,groups:o.groups??[],modifier:o.modifier,events:o.events,payload:i,dragHandle:o.dragHandle,activation:o.activation,placementMargins:o.placementMargins,hoveredPlacement:void 0}))}),d.onBeforeUnmount(()=>{r&&(n.lib.draggableObserver.unobserve(r),n.entities.visibleDraggableSet.delete(r),n.entities.draggableMap.delete(r),n.entities.modifiersDraggableSet.delete(r))}),{selected:a,isDragging:g,isAllowed:u,isDragOver:c}}const on=(e,t)=>{const s=ne(),n=d.computed(()=>e.value===s.entities.selectingArea);let o=null;d.onMounted(()=>{o=E(e),o&&(o.setAttribute(F.SELECT_AREA,""),s.lib.selectableAreaObserver.observe(o),s.entities.selectableAreaMap.set(o,{modifier:t?.modifier??{keys:["ControlLeft"],method:"every"},events:t?.events,disabled:t?.disabled??!1,groups:t?.groups??[]}))}),d.onBeforeUnmount(()=>{o&&(s.lib.selectableAreaObserver.unobserve(o),s.entities.visibleSelectableAreaSet.delete(o),s.entities.modifiersSelectableAreaSet.delete(o),s.entities.selectableAreaMap.delete(o))});const i=d.computed(()=>{s.scrollPosition.x,s.scrollPosition.y;const r=s.pointer.value;return!r||s.state.value!=="selecting"||!o||!n.value?{}:Dt(r.start,r.current,o)});return{isSelecting:n,style:i}};function rn(e,t){const s=d.inject(de);if(!s)throw Error("DnD provider not found");let n=null;return d.onMounted(()=>{n=E(e),n&&(n.setAttribute(F.CONSTRAINT_AREA,""),s.entities.constraintsAreaMap.set(n,{axis:t?.axis||"both",restrictToArea:t?.restrictToArea||!1}))}),d.onBeforeUnmount(()=>{n&&s.entities.constraintsAreaMap.delete(n)}),{}}function an(e,t,s){const n=ne();let o=null,i,r;typeof t=="function"?(i={},r=t):(i=t??{},r=s);const a=d.computed(()=>{const u=E(e);return u?n.entities.allowedDroppableSet.has(u):!1}),g=d.computed(()=>{const u=E(e);if(u)return n.entities.droppableMap.get(u)?.hoveredPlacement});return d.onMounted(()=>{o=E(e),o&&(o.setAttribute(F.DROPPABLE,""),n.lib.droppableObserver.observe(o),n.entities.droppableMap.set(o,{disabled:i.disabled??!1,groups:i.groups??[],events:i.events,payload:r,hoveredPlacement:void 0}))}),d.onBeforeUnmount(()=>{o&&(n.lib.droppableObserver.unobserve(o),n.entities.visibleDroppableSet.delete(o),n.entities.droppableMap.delete(o))}),{isAllowed:a,isDragOver:g}}const ln=(e,t)=>{const s=ye(),n=d.shallowRef(!1),i=Ze(e,t??{},()=>{if(s.state.value!=="dragging")return null;const r=s.overlay.position.value,a=s.overlay.size.value;return r?a?.width&&a?.height?{x:r.x+a.width/2,y:r.y+a.height/2}:r:null},void 0,n);return d.watch(()=>s.state.value,r=>{r==="dragging"?i.run():i.stop()}),{isScrolling:n}};function Ce(e,t){return t<=0?e:Math.round(e/t)*t}function cn(e,t){const s=t&&"grid"in t&&t.grid!=null,n=t?s?t.grid:t.gridX:1,o=t?s?t.grid:t.gridY:1;return d.computed(()=>{const{x:i,y:r}=e.value;return{x:Ce(i,n),y:Ce(r,o)}})}const ke=()=>!0,Ie=()=>0,un="separate",gn=()=>{const e={filterElements:ke,filterZones:ke,sortElements:Ie,sortZones:Ie,mergeStrategy:un,pickClosestBetweenFirst:!1},t=(n,o,i,r,a,g,u)=>{const c=r instanceof Set?r:new Set(r),l={containerBox:o,pointer:i},f=e.minOverlapPercent,m=[];for(const h of c){if(!a(h,n))continue;const p=K(h);if(!u(p,l))continue;const v=ue(p,o);if(f!==void 0&&v<f)continue;let M=0;for(const w of c)w!==h&&O(w,h)&&M++;m.push({node:h,box:p,meta:{isPointerInElement:ge(p,i.x,i.y),overlapPercent:v,depth:M,centerDistance:kt(X(o),X(p))}})}return m.sort((h,p)=>g(h,p,l)),m},s={container(n){return e.container=n,s},containerBox(n){return e.containerBox=n,s},elements(n){return e.elements=n,s},zones(n){return e.zones=n,s},filterElements(n){return e.filterElements=n,s},filterZones(n){return e.filterZones=n,s},collision(n){return e.collision=n,s},sortElements(n){return e.sortElements=n,s},sortZones(n){return e.sortZones=n,s},mergeStrategy(n){return e.mergeStrategy=n,s},pickClosestBetweenFirst(n){return e.pickClosestBetweenFirst=n,s},minOverlapPercent(n){return e.minOverlapPercent=n,s},build(){const n=e;if(!n.container||!n.elements||!n.zones||!n.collision)throw new Error("sensor: container, elements, zones, collision are required");return o=>{const i=n.container(o);if(!i)return{elements:[],zones:[]};const r=n.containerBox?n.containerBox(o):K(i),a=o.pointer.value?.current??{x:0,y:0},g=t(o,r,a,n.elements(o),n.filterElements,n.sortElements,n.collision),u=t(o,r,a,n.zones(o),n.filterZones,n.sortZones,n.collision);if(n.mergeStrategy==="unified-closest"){const c=[...g.map(f=>({node:f.node,box:f.box,isZone:!1,distance:0})),...u.map(f=>({node:f.node,box:f.box,isZone:!0,distance:0}))];if(c.length===0)return{elements:[],zones:[]};for(const f of c){const m=X(f.box);f.distance=Math.hypot(a.x-m.x,a.y-m.y)}const l=c.reduce((f,m)=>m.distance<f.distance?m:f);return l.isZone?{elements:[],zones:[l.node]}:{elements:[l.node],zones:[]}}if(n.pickClosestBetweenFirst&&g[0]&&u[0]){const c=X(u[0].box),l=X(g[0].box),f=Math.hypot(a.x-c.x,a.y-c.y);return Math.hypot(a.x-l.x,a.y-l.y)<f?{elements:g.map(h=>h.node),zones:[]}:{elements:[],zones:u.map(h=>h.node)}}return{elements:g.map(c=>c.node),zones:u.map(c=>c.node)}}}};return s},fn=()=>gn();exports.DnDProvider=nn;exports.createSensor=fn;exports.defaultCollisionDetection=te;exports.makeAutoScroll=ln;exports.makeConstraintArea=rn;exports.makeDraggable=sn;exports.makeDroppable=an;exports.makeSelectionArea=on;exports.makeSnappedOverlayPosition=cn;exports.useDnDProvider=ye;
|
|
6
|
+
`)}function _t(e,t){let s=null,n=null,o=!1,i=0;const r=new Map;try{const u=Ot(e,t?.localDependencies??[]),c=new Blob([u],{type:"application/javascript"});n=URL.createObjectURL(c),s=new Worker(n),o=!0,s.onmessage=l=>{const f=r.get(l.data.callId);f&&(r.delete(l.data.callId),l.data.ok?f.resolve(l.data.result):f.reject(new Error(l.data.error)))},s.onerror=l=>{o=!1;for(const f of r.values())f.reject(new Error(l.message));r.clear(),s?.terminate(),s=null}}catch{o=!1}return{run:u=>{if(!s||!o)try{return Promise.resolve(e(u))}catch(l){return Promise.reject(l instanceof Error?l:new Error(String(l)))}const c=++i;return new Promise((l,f)=>{r.set(c,{resolve:l,reject:f}),s.postMessage({callId:c,data:u})})},terminate:()=>{for(const u of r.values())u.reject(new Error("Worker terminated"));r.clear(),s?.terminate(),s=null,n&&(URL.revokeObjectURL(n),n=null),o=!1},get isSupported(){return o}}}function Ge(e,t,s,n,o,i,r,a){return e<o+r&&e+s>o&&t<i+a&&t+n>i}function He(e,t,s,n,o,i,r,a){const g=Math.max(0,Math.min(e+s,o+r)-Math.max(e,o)),u=Math.max(0,Math.min(t+n,i+a)-Math.max(t,i)),c=g*u,l=s*n,f=r*a;return!l||!f?0:(c/l*100+c/f*100)/2}function q(e,t,s,n,o,i){return o>=e&&o<=e+s&&i>=t&&i<=t+n}function Ft(e){const{containerBox:t,pointer:s,elements:n,elementCount:o,zones:i,zoneCount:r,config:a}=e,{x:g,y:u,width:c,height:l}=t,{x:f,y:m}=s,h=a.minOverlapPercent,p=g+c/2,v=u+l/2,M=q(g,u,c,l,f,m);function w(x,G){const D=[],b=x;for(let y=0;y<G;y++){const S=y*4,C=b[S],k=b[S+1],I=b[S+2],L=b[S+3];if(!Ge(C,k,I,L,g,u,c,l))continue;const be=He(C,k,I,L,g,u,c,l);be<h||D.push({index:y,overlapPercent:be,centerDistance:Math.hypot(p-(C+I/2),v-(k+L/2)),isPointerInElement:q(C,k,I,L,f,m),depth:0})}for(let y=0;y<D.length;y++){const S=D[y].index*4,C=b[S]+b[S+2]/2,k=b[S+1]+b[S+3]/2;for(let I=0;I<D.length;I++){if(y===I)continue;const L=D[I].index*4;q(b[L],b[L+1],b[L+2],b[L+3],C,k)&&D[y].depth++}}return D.sort((y,S)=>{if(M){if(y.isPointerInElement&&S.isPointerInElement)return S.depth-y.depth;if(y.isPointerInElement!==S.isPointerInElement)return y.isPointerInElement?-1:1}return Math.abs(y.overlapPercent-S.overlapPercent)<=1?y.centerDistance-S.centerDistance:S.overlapPercent-y.overlapPercent}),D.map(y=>y.index)}return{elementIndices:w(n,o),zoneIndices:w(i,r)}}let re=null;function Ke(){return re||(re=_t(Ft,{localDependencies:[Ge,He,q]})),re}function xe(e,t){const s=[];for(const n of e){let o=t.get(n);o||(o=n.getBoundingClientRect(),t.set(n,o)),s.push(o.x,o.y,o.width,o.height)}return s}let Ee=0;function Gt(e){const t=Ke(),s=++Ee,n=[...e.entities.allowedDraggableSet].filter(u=>ee(u,e)),o=[...e.entities.allowedDroppableSet].filter(u=>ee(u,e)),i=Fe(e),r=e.pointer.value?.current,a=e.lib.rectCache,g={containerBox:{x:i.x,y:i.y,width:i.width,height:i.height},pointer:{x:r?.x??0,y:r?.y??0},elements:xe(n,a),elementCount:n.length,zones:xe(o,a),zoneCount:o.length,config:{minOverlapPercent:10}};t.run(g).then(u=>{if(s!==Ee||e.state.value!=="dragging")return;const c=u.elementIndices.map(f=>n[f]),l=u.zoneIndices.map(f=>o[f]);V(e,e.hovered,{elements:c,zones:l})})}function fe(e){if(e.collision?.run){const s=e.collision.run(e);V(e,e.hovered,s);return}if(Ke().isSupported)Gt(e);else{const s=te(e);V(e,e.hovered,s)}}function Ht(e,t){const s=e.collision?.throttle?.value??0;if(s<=0){fe(e);return}const n=Date.now();n-t.value>=s&&(t.value=n,fe(e))}async function Ue(e){const t=e.hovered.droppable.keys().next().value;if(!t||Z(t,e))return"accept";const s=e.entities.droppableMap.get(t),n=R(e,t),o=s?.events?.onDrop?.(n);if(o!=null&&typeof o.then=="function"){e.state.value="pending";let r;try{r=await o}catch{const a=e.entities.initiatingDraggable;return U(e,a,"onSelfDragCancel"),P(e,"onDragCancel"),_e(e,e.hovered),"cancel"}return r===!1?(e.state.value="dragging","decline"):"accept"}return o===!1?"decline":"accept"}function Ne(e){const t=e.entities.initiatingDraggable;U(e,t,"onSelfDragEnd"),P(e,"onDragEnd"),bt(e,e.hovered)}function Kt(e){const t=e.entities.selectingArea;if(!t)return;const s=e.entities.selectableAreaMap.get(t),n=[...e.entities.selectedSet];s?.events?.onSelected?.(n)}const Ut=e=>{const t={current:null},s={value:0},n=async()=>{le(),t.current?.cancel(),t.current=null;const a=e.state.value;if(a==="dragging"){const g=await Ue(e);if(g==="accept"&&Ne(e),g==="accept"||g==="cancel"){Q(e),document.removeEventListener("pointerup",n),document.removeEventListener("pointermove",o);return}return}else a==="selecting"&&Kt(e);Q(e),document.removeEventListener("pointerup",n),document.removeEventListener("pointermove",o)},o=a=>{if(e.pointer.value){if(e.pointer.value.current={x:a.clientX,y:a.clientY},nt(e)){oe(e,a,"onSelfDragStart"),P(e,"onDragStart");return}if(e.state.value==="dragging"){Ht(e,s);const g=e.entities.initiatingDraggable;U(e,g,"onSelfDragMove"),P(e,"onDragMove")}e.state.value==="selecting"&&Mt(e)}};return{pointerDown:a=>{document.addEventListener("pointerup",n),document.addEventListener("pointermove",o);const g=a.target,u=g.closest(N.SELECT_AREA),c=g.closest(N.DRAGGABLE);if(e.entities.modifiersSelectableAreaSet.size>0&&e.entities.modifiersSelectableAreaSet.has(u)){ae(),e.pointer.value=ce(a),e.state.value="selecting",e.entities.selectingArea=u;return}if(e.entities.modifiersDraggableSet.size>0&&e.entities.modifiersDraggableSet.has(c)){const l=e.entities.draggableMap.get(c);if(!Be(g,c,l?.dragHandle))return;ae(),e.entities.initiatingDraggable=c;const f=Pe(a,c);e.pointer.value=ce(a,f.x,f.y),l?.activation?.distance||l?.activation?.delay?(e.state.value="activating",l?.activation?.delay&&(e.delay.startTime=Date.now(),t.current=st(e,()=>{J(e),oe(e,a,"onSelfDragStart"),P(e,"onDragStart")}))):(J(e),oe(e,a,"onSelfDragStart"),P(e,"onDragStart"))}},pointerUp:n,pointerMove:o,cleanup:()=>{t.current?.cancel(),document.removeEventListener("pointerup",n),document.removeEventListener("pointermove",o),e.lib.draggableObserver.disconnect(),e.lib.droppableObserver.disconnect(),e.lib.selectableAreaObserver.disconnect(),e.lib.overlaySizeObserver.disconnect()}}},Nt={ArrowUp:{dx:0,dy:-1},ArrowDown:{dx:0,dy:1},ArrowLeft:{dx:-1,dy:0},ArrowRight:{dx:1,dy:0},KeyW:{dx:0,dy:-1},KeyA:{dx:-1,dy:0},KeyS:{dx:0,dy:1},KeyD:{dx:1,dy:0}},Zt=e=>t=>{const{keys:s}=e.keyboard;if(s.pressedKeys.value.add(t.code),e.state.value==="dragging"){if(s.forCancel.includes(t.code)){t.preventDefault(),le(),U(e,e.entities.initiatingDraggable,"onSelfDragCancel"),P(e,"onDragCancel"),_e(e,e.hovered),Q(e);return}if(s.forDrop.includes(t.code)){t.preventDefault(),(async()=>(await Ue(e)&&Ne(e),le(),Q(e)))();return}const o=Nt[t.code];if(o&&s.forMove.includes(t.code)&&e.pointer.value){t.preventDefault();const i=s.forMoveFaster.some(u=>s.pressedKeys.value.has(u)),r=e.keyboard.step*(i?e.keyboard.moveFaster:1);e.pointer.value.current={x:e.pointer.value.current.x+o.dx*r,y:e.pointer.value.current.y+o.dy*r};const g=(e.collision?.run??te)(e);V(e,e.hovered,g),U(e,e.entities.initiatingDraggable,"onSelfDragMove"),P(e,"onDragMove");return}return}if(s.forDrag.includes(t.code)){const o=document.activeElement;if(!o)return;const i=o.closest(N.DRAGGABLE);if(!i||e.entities.modifiersDraggableSet.size===0||!e.entities.modifiersDraggableSet.has(i))return;const r=e.entities.draggableMap.get(i);if(!Be(o,i,r?.dragHandle,!0))return;t.preventDefault(),ae();const a=i.getBoundingClientRect(),g=a.left+a.width/2,u=a.top+a.height/2,c={clientX:g,clientY:u};e.entities.initiatingDraggable=i;const l=Pe(c,i);e.pointer.value=ce(c,l.x,l.y),J(e);const m=(e.collision?.run??te)(e);V(e,e.hovered,m),U(e,i,"onSelfDragStart"),P(e,"onDragStart")}},Yt=e=>t=>{e.keyboard.keys.pressedKeys.value.delete(t.code)},jt=e=>()=>{e.keyboard.keys.pressedKeys.value.clear()},ie={keyDown:Zt,keyUp:Yt,clear:jt},Xt=e=>()=>{e.state.value&&(e.scrollPosition.x=window.scrollX,e.scrollPosition.y=window.scrollY,e.lib.rectCache.clear(),e.state.value==="dragging"&&fe(e))},B=50,Vt=144,Ae=1e3/Vt;function $t(e){return e==null?{top:B,right:B,bottom:B,left:B}:typeof e=="number"?{top:e,right:e,bottom:e,left:e}:{top:e.top??B,right:e.right??B,bottom:e.bottom??B,left:e.left??B}}const Wt={getScrollState(e){return{scrollTop:e.scrollTop,scrollLeft:e.scrollLeft}},setScroll(e,t,s){e.scrollTop=t,e.scrollLeft=s}};function Ze(e,t,s,n=Wt,o){const{speed:i=10,disabled:r=!1}=t,a=$t(t.threshold);let g=null,u=null,c=null,l=0,f=0;const m=M=>{o&&(o.value=M)},h=M=>{const w=e.value,x=s();if(!w||!x||r){m(!1);return}u||(u=M);const G=M-u;if(G<Ae){g=requestAnimationFrame(h);return}const D=i*(G/Ae);u=M;const{scrollTop:b,scrollLeft:y}=n.getScrollState(w);(!c||l!==b||f!==y)&&(c=n.getRect?n.getRect(w):w.getBoundingClientRect(),l=b,f=y);let S=!1,C=b,k=y;a.top>0&&x.y-c.top<a.top?(C=b-D,S=!0):a.bottom>0&&c.bottom-x.y<a.bottom&&(C=b+D,S=!0),a.left>0&&x.x-c.left<a.left?(k=y-D,S=!0):a.right>0&&c.right-x.x<a.right&&(k=y+D,S=!0),S&&n.setScroll(w,C,k),m(S),g=requestAnimationFrame(h)};return{run:()=>{u=null,g=requestAnimationFrame(h)},stop:()=>{g&&(cancelAnimationFrame(g),g=null),c=null,l=0,f=0,u=null,m(!1)}}}const qt={getScrollState(){return{scrollTop:window.scrollY??document.documentElement.scrollTop,scrollLeft:window.scrollX??document.documentElement.scrollLeft}},setScroll(e,t,s){window.scrollTo(s,t)},getRect(){return new DOMRect(0,0,window.innerWidth,window.innerHeight)}},Jt={get value(){return typeof document<"u"?document.documentElement:null}};function Qt(e,t){const s=d.shallowRef(!1),o=Ze(Jt,t??{},()=>{if(e.state.value!=="dragging")return null;const a=e.overlay.position.value,g=e.overlay.size.value;return a?g?.width&&g?.height?{x:a.x+g.width/2,y:a.y+g.height/2}:a:null},qt,s),i=d.watch(()=>e.state.value,a=>{a==="dragging"?o.run():o.stop()}),r=()=>{i(),o.stop()};return d.onScopeDispose(r),{isScrolling:s,stop:r}}const en=e=>{const t=Ut(e),s=ie.keyDown(e),n=ie.keyUp(e),o=ie.clear(e),i=Xt(e);let r=null;d.watch(e.autoScrollViewport,a=>{r?.(),r=null,(a===!0||a&&typeof a=="object")&&(r=Qt(e,a===!0?{}:a).stop)},{immediate:!0}),d.onMounted(()=>{document.addEventListener("pointerdown",t.pointerDown),document.addEventListener("keydown",s),document.addEventListener("keyup",n),document.addEventListener("blur",o),document.addEventListener("scroll",i,!0)}),d.onBeforeUnmount(()=>{document.removeEventListener("pointerdown",t.pointerDown),document.removeEventListener("pointerup",t.pointerUp),document.removeEventListener("pointermove",t.pointerMove),document.removeEventListener("keydown",s),document.removeEventListener("keyup",n),document.removeEventListener("blur",o),document.removeEventListener("scroll",i,!0),r?.(),t.cleanup()})},ne=()=>{const e=d.inject(de);if(!e)throw Error("DnD provider not found");return e},ye=()=>{const e=ne();return{overlay:e.overlay,delay:e.delay,distanceProgress:e.distanceProgress,entities:e.entities,pointer:e.pointer,state:e.state,scrollPosition:e.scrollPosition,keyboard:e.keyboard,hovered:e.hovered,collision:e.collision,autoScrollViewport:e.autoScrollViewport}},tn=d.defineComponent({__name:"DefaultOverlay",setup(e){const{entities:t,state:s,overlay:n}=ye();return(o,i)=>d.unref(s)==="dragging"?(d.openBlock(),d.createElementBlock("div",{key:0,class:"dnd-kit-default-overlay",style:d.normalizeStyle({"--position-x":d.unref(n).position.value.x+"px","--position-y":d.unref(n).position.value.y+"px"})},[(d.openBlock(!0),d.createElementBlock(d.Fragment,null,d.renderList(d.unref(t).draggingMap,([r,a])=>(d.openBlock(),d.createElementBlock(d.Fragment,null,[d.unref(t).draggableMap.get(r)?.render?(d.openBlock(),d.createBlock(d.resolveDynamicComponent(d.unref(t).draggableMap.get(r)?.render),{key:0})):(d.openBlock(),d.createBlock(d.resolveDynamicComponent(r.tagName),{key:1,innerHTML:a.initialOuterHTML,style:d.normalizeStyle({width:a.initialRect.width+"px",height:a.initialRect.height+"px"})},null,8,["innerHTML","style"]))],64))),256))],4)):d.createCommentVNode("",!0)}}),nn=d.defineComponent({__name:"DnDProvider",props:{autoScrollViewport:{type:[Object,Boolean,null]},overlayTo:{type:[String,Boolean,null]},style:{},class:{}},setup(e){const t=e,s=d.useTemplateRef("overlayRef"),n=lt(s,t);en(n);const o=d.computed(()=>n.overlay.render.value??tn);return d.provide(de,n),(i,r)=>(d.openBlock(),d.createElementBlock(d.Fragment,null,[d.renderSlot(i.$slots,"default"),(d.openBlock(),d.createBlock(d.Teleport,{to:d.unref(n).overlay.to.value||"body"},[d.createElementVNode("div",d.mergeProps({ref_key:"overlayRef",ref:s,class:"dnd-kit-overlay-container"},t),[d.renderSlot(i.$slots,"overlay",{overlay:o.value},()=>[(d.openBlock(),d.createBlock(d.resolveDynamicComponent(o.value)))])],16)],8,["to"]))],64))}});function sn(e,t,s){const n=ne();let o,i,r;typeof t=="function"?(o={},i=t):(o=t??{},i=s);const a=d.computed({get(){const l=E(e);return l?n.entities.selectedSet.has(l):!1},set(l){const f=E(e);f&&n.entities.selectedSet[l?"add":"delete"](f)}}),g=d.computed(()=>{const l=E(e);return l?n.entities.draggingMap.has(l):!1}),u=d.computed(()=>{const l=E(e);return l?n.entities.allowedDraggableSet.has(l):!1}),c=d.computed(()=>{const l=E(e);if(l)return n.entities.draggableMap.get(l)?.hoveredPlacement});return d.onMounted(()=>{r=E(e),r&&(r.addEventListener("dragstart",A),r.addEventListener("drag",A),r.addEventListener("dragend",A),r.setAttribute(F.DRAGGABLE,""),n.lib.draggableObserver.observe(r),n.entities.draggableMap.set(r,{render:o.render,disabled:o.disabled??!1,groups:o.groups??[],modifier:o.modifier,events:o.events,payload:i,dragHandle:o.dragHandle,activation:o.activation,placementMargins:o.placementMargins,hoveredPlacement:void 0}))}),d.onBeforeUnmount(()=>{r&&(n.lib.draggableObserver.unobserve(r),n.entities.visibleDraggableSet.delete(r),n.entities.draggableMap.delete(r),n.entities.modifiersDraggableSet.delete(r))}),{selected:a,isDragging:g,isAllowed:u,isDragOver:c}}const on=(e,t)=>{const s=ne(),n=d.computed(()=>e.value===s.entities.selectingArea);let o=null;d.onMounted(()=>{o=E(e),o&&(o.setAttribute(F.SELECT_AREA,""),s.lib.selectableAreaObserver.observe(o),s.entities.selectableAreaMap.set(o,{modifier:t?.modifier??{keys:["ControlLeft"],method:"every"},events:t?.events,disabled:t?.disabled??!1,groups:t?.groups??[]}))}),d.onBeforeUnmount(()=>{o&&(s.lib.selectableAreaObserver.unobserve(o),s.entities.visibleSelectableAreaSet.delete(o),s.entities.modifiersSelectableAreaSet.delete(o),s.entities.selectableAreaMap.delete(o))});const i=d.computed(()=>{s.scrollPosition.x,s.scrollPosition.y;const r=s.pointer.value;return!r||s.state.value!=="selecting"||!o||!n.value?{}:Dt(r.start,r.current,o)});return{isSelecting:n,style:i}};function rn(e,t){const s=d.inject(de);if(!s)throw Error("DnD provider not found");let n=null;return d.onMounted(()=>{n=E(e),n&&(n.setAttribute(F.CONSTRAINT_AREA,""),s.entities.constraintsAreaMap.set(n,{axis:t?.axis||"both",restrictToArea:t?.restrictToArea||!1}))}),d.onBeforeUnmount(()=>{n&&s.entities.constraintsAreaMap.delete(n)}),{}}function an(e,t,s){const n=ne();let o=null,i,r;typeof t=="function"?(i={},r=t):(i=t??{},r=s);const a=d.computed(()=>{const u=E(e);return u?n.entities.allowedDroppableSet.has(u):!1}),g=d.computed(()=>{const u=E(e);if(u)return n.entities.droppableMap.get(u)?.hoveredPlacement});return d.onMounted(()=>{o=E(e),o&&(o.setAttribute(F.DROPPABLE,""),n.lib.droppableObserver.observe(o),n.entities.droppableMap.set(o,{disabled:i.disabled??!1,groups:i.groups??[],events:i.events,payload:r,hoveredPlacement:void 0}))}),d.onBeforeUnmount(()=>{o&&(n.lib.droppableObserver.unobserve(o),n.entities.visibleDroppableSet.delete(o),n.entities.droppableMap.delete(o))}),{isAllowed:a,isDragOver:g}}const ln=(e,t)=>{const s=ye(),n=d.shallowRef(!1),i=Ze(e,t??{},()=>{if(s.state.value!=="dragging")return null;const r=s.overlay.position.value,a=s.overlay.size.value;return r?a?.width&&a?.height?{x:r.x+a.width/2,y:r.y+a.height/2}:r:null},void 0,n);return d.watch(()=>s.state.value,r=>{r==="dragging"?i.run():i.stop()}),{isScrolling:n}};function Ce(e,t){return t<=0?e:Math.round(e/t)*t}function cn(e,t){const s=t&&"grid"in t&&t.grid!=null,n=t?s?t.grid:t.gridX:1,o=t?s?t.grid:t.gridY:1;return d.computed(()=>{const{x:i,y:r}=e.value;return{x:Ce(i,n),y:Ce(r,o)}})}const ke=()=>!0,Ie=()=>0,un="separate",gn=()=>{const e={filterElements:ke,filterZones:ke,sortElements:Ie,sortZones:Ie,mergeStrategy:un,pickClosestBetweenFirst:!1},t=(n,o,i,r,a,g,u)=>{const c=r instanceof Set?r:new Set(r),l={containerBox:o,pointer:i},f=e.minOverlapPercent,m=[];for(const h of c){if(!a(h,n))continue;const p=K(h);if(!u(p,l))continue;const v=ue(p,o);if(f!==void 0&&v<f)continue;let M=0;for(const w of c)w!==h&&O(w,h)&&M++;m.push({node:h,box:p,meta:{isPointerInElement:ge(p,i.x,i.y),overlapPercent:v,depth:M,centerDistance:kt(X(o),X(p))}})}return m.sort((h,p)=>g(h,p,l)),m},s={container(n){return e.container=n,s},containerBox(n){return e.containerBox=n,s},elements(n){return e.elements=n,s},zones(n){return e.zones=n,s},filterElements(n){return e.filterElements=n,s},filterZones(n){return e.filterZones=n,s},collision(n){return e.collision=n,s},sortElements(n){return e.sortElements=n,s},sortZones(n){return e.sortZones=n,s},mergeStrategy(n){return e.mergeStrategy=n,s},pickClosestBetweenFirst(n){return e.pickClosestBetweenFirst=n,s},minOverlapPercent(n){return e.minOverlapPercent=n,s},build(){const n=e;if(!n.container||!n.elements||!n.zones||!n.collision)throw new Error("sensor: container, elements, zones, collision are required");return o=>{const i=n.container(o);if(!i)return{elements:[],zones:[]};const r=n.containerBox?n.containerBox(o):K(i),a=o.pointer.value?.current??{x:0,y:0},g=t(o,r,a,n.elements(o),n.filterElements,n.sortElements,n.collision),u=t(o,r,a,n.zones(o),n.filterZones,n.sortZones,n.collision);if(n.mergeStrategy==="unified-closest"){const c=[...g.map(f=>({node:f.node,box:f.box,isZone:!1,distance:0})),...u.map(f=>({node:f.node,box:f.box,isZone:!0,distance:0}))];if(c.length===0)return{elements:[],zones:[]};for(const f of c){const m=X(f.box);f.distance=Math.hypot(a.x-m.x,a.y-m.y)}const l=c.reduce((f,m)=>m.distance<f.distance?m:f);return l.isZone?{elements:[],zones:[l.node]}:{elements:[l.node],zones:[]}}if(n.pickClosestBetweenFirst&&g[0]&&u[0]){const c=X(u[0].box),l=X(g[0].box),f=Math.hypot(a.x-c.x,a.y-c.y);return Math.hypot(a.x-l.x,a.y-l.y)<f?{elements:g.map(h=>h.node),zones:[]}:{elements:[],zones:u.map(h=>h.node)}}return{elements:g.map(c=>c.node),zones:u.map(c=>c.node)}}}};return s},fn=()=>gn();exports.DnDProvider=nn;exports.createSensor=fn;exports.defaultCollisionDetection=te;exports.makeAutoScroll=ln;exports.makeConstraintArea=rn;exports.makeDraggable=sn;exports.makeDroppable=an;exports.makeSelectionArea=on;exports.makeSnappedOverlayPosition=cn;exports.useDnDProvider=ye;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(".dnd-kit-default-overlay{transform:translate3d(var(--position-x),var(--position-y),0)}.dnd-kit-overlay-container{position:fixed;top:0;left:0;pointer-events:none;cursor:grabbing;z-index:9999}")),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();
|
|
2
|
-
import { ref as ne, watch as ue, shallowRef as re, reactive as Q, computed as M, onScopeDispose as at, onMounted as q, onBeforeUnmount as J, inject as Ze, defineComponent as Ue, unref as F, openBlock as z, createElementBlock as se, normalizeStyle as ke, Fragment as ye, renderList as lt, createBlock as ie, resolveDynamicComponent as be, createCommentVNode as ct, useTemplateRef as ut, provide as gt, renderSlot as Pe, Teleport as ft, createElementVNode as dt } from "vue";
|
|
2
|
+
import { ref as ne, watch as ue, shallowRef as re, reactive as Q, computed as M, onScopeDispose as at, onMounted as q, onBeforeUnmount as J, inject as Ze, defineComponent as Ue, unref as F, openBlock as z, createElementBlock as se, normalizeStyle as ke, Fragment as ye, renderList as lt, createBlock as ie, resolveDynamicComponent as be, createCommentVNode as ct, useTemplateRef as ut, provide as gt, renderSlot as Pe, Teleport as ft, createElementVNode as dt, mergeProps as mt } from "vue";
|
|
3
3
|
const H = {
|
|
4
4
|
SELECT_AREA: "data-dnd-kit-select-area",
|
|
5
5
|
DRAGGABLE: "data-dnd-kit-draggable",
|
|
@@ -22,13 +22,13 @@ const H = {
|
|
|
22
22
|
g[u]((l) => s.value.has(l)) && o.add(i);
|
|
23
23
|
}), o;
|
|
24
24
|
};
|
|
25
|
-
let Ye = "",
|
|
26
|
-
const E = (e) => e.value ? e.value instanceof HTMLElement ? e.value : e.value.$el : null, _ = (e, t) => e !== t && e.contains(t),
|
|
25
|
+
let Ye = "", ht = "", yt = "";
|
|
26
|
+
const E = (e) => e.value ? e.value instanceof HTMLElement ? e.value : e.value.$el : null, _ = (e, t) => e !== t && e.contains(t), bt = (e, t) => !(e.right < t.left || e.left > t.right || e.bottom < t.top || e.top > t.bottom), pe = () => {
|
|
27
27
|
const e = document.body;
|
|
28
28
|
Ye = e.style.userSelect, e.style.userSelect = "none", window.addEventListener("contextmenu", A), window.addEventListener("selectstart", A), window.addEventListener("touchstart", A), window.addEventListener("touchmove", A);
|
|
29
29
|
}, Se = () => {
|
|
30
30
|
const e = document.body;
|
|
31
|
-
e.style.userSelect = Ye, e.style.touchAction =
|
|
31
|
+
e.style.userSelect = Ye, e.style.touchAction = ht, e.style.overscrollBehavior = yt, window.removeEventListener("contextmenu", A), window.removeEventListener("selectstart", A), window.removeEventListener("touchstart", A), window.removeEventListener("touchmove", A);
|
|
32
32
|
}, A = (e) => e.preventDefault(), Ae = (e, t) => {
|
|
33
33
|
if (t.entities.draggableMap.get(e)?.disabled) return !0;
|
|
34
34
|
for (const n of t.entities.visibleDraggableSet)
|
|
@@ -44,7 +44,7 @@ const E = (e) => e.value ? e.value instanceof HTMLElement ? e.value : e.value.$e
|
|
|
44
44
|
const s = new Set(t);
|
|
45
45
|
return e.some((n) => s.has(n));
|
|
46
46
|
};
|
|
47
|
-
function
|
|
47
|
+
function pt(e, t, s, n) {
|
|
48
48
|
const o = /* @__PURE__ */ new Set();
|
|
49
49
|
for (const a of t.keys()) {
|
|
50
50
|
const g = s.get(a);
|
|
@@ -57,7 +57,7 @@ function bt(e, t, s, n) {
|
|
|
57
57
|
}
|
|
58
58
|
return r;
|
|
59
59
|
}
|
|
60
|
-
function
|
|
60
|
+
function St(e, t, s) {
|
|
61
61
|
const n = /* @__PURE__ */ new Set();
|
|
62
62
|
for (const r of t.keys()) {
|
|
63
63
|
const a = s.get(r);
|
|
@@ -82,7 +82,7 @@ const fe = (e) => {
|
|
|
82
82
|
unobserve: (s) => t.unobserve(s),
|
|
83
83
|
disconnect: () => t.disconnect()
|
|
84
84
|
};
|
|
85
|
-
},
|
|
85
|
+
}, Dt = (e) => {
|
|
86
86
|
const t = new ResizeObserver((s) => {
|
|
87
87
|
const n = s[0];
|
|
88
88
|
if (!n) return;
|
|
@@ -94,8 +94,8 @@ const fe = (e) => {
|
|
|
94
94
|
unobserve: (s) => t.unobserve(s),
|
|
95
95
|
disconnect: () => t.disconnect()
|
|
96
96
|
};
|
|
97
|
-
},
|
|
98
|
-
const t = ne(null), s =
|
|
97
|
+
}, Mt = (e) => {
|
|
98
|
+
const t = ne(null), s = Dt(t), n = ue(
|
|
99
99
|
e,
|
|
100
100
|
(i) => {
|
|
101
101
|
s.disconnect(), i && s.observe(i);
|
|
@@ -127,34 +127,34 @@ function je(e, t) {
|
|
|
127
127
|
initialOuterHTML: e.outerHTML
|
|
128
128
|
};
|
|
129
129
|
}
|
|
130
|
-
function
|
|
130
|
+
function wt(e, t, s) {
|
|
131
131
|
e.forEach((n) => {
|
|
132
132
|
const o = t.get(n);
|
|
133
133
|
s.set(n, je(n, o));
|
|
134
134
|
}), e.clear();
|
|
135
135
|
}
|
|
136
|
-
function
|
|
136
|
+
function vt(e, t, s) {
|
|
137
137
|
s.clear();
|
|
138
138
|
const n = t.get(e);
|
|
139
139
|
s.set(e, je(e, n));
|
|
140
140
|
}
|
|
141
141
|
function ae(e) {
|
|
142
|
-
e.entities.initiatingDraggable && (e.state.value = "dragging",
|
|
142
|
+
e.entities.initiatingDraggable && (e.state.value = "dragging", xt(
|
|
143
143
|
e.entities.initiatingDraggable,
|
|
144
144
|
e.entities.selectedSet,
|
|
145
145
|
e.entities.draggableMap,
|
|
146
146
|
e.entities.draggingMap
|
|
147
147
|
));
|
|
148
148
|
}
|
|
149
|
-
function
|
|
150
|
-
t.has(e) ?
|
|
149
|
+
function xt(e, t, s, n) {
|
|
150
|
+
t.has(e) ? wt(t, s, n) : (t.clear(), vt(e, s, n));
|
|
151
151
|
}
|
|
152
152
|
function Ve(e, t, s, n) {
|
|
153
153
|
if (n || !s) return !0;
|
|
154
154
|
const o = e.closest(s);
|
|
155
155
|
return o ? t.contains(o) : !1;
|
|
156
156
|
}
|
|
157
|
-
function
|
|
157
|
+
function Et(e, t) {
|
|
158
158
|
if (!e || !t) return 1;
|
|
159
159
|
const s = Math.abs(e.current.x - e.start.x), n = Math.abs(e.current.y - e.start.y);
|
|
160
160
|
if (typeof t == "number") {
|
|
@@ -175,7 +175,7 @@ function $e(e, t, s) {
|
|
|
175
175
|
const n = s.distance != null, o = s.delay != null;
|
|
176
176
|
return !n && !o ? !0 : n && !o ? e >= 1 : !n && o ? t >= 1 : (s.condition ?? "both") === "both" ? e >= 1 && t >= 1 : e >= 1 || t >= 1;
|
|
177
177
|
}
|
|
178
|
-
function
|
|
178
|
+
function At(e) {
|
|
179
179
|
if (e.state.value !== "activating" || !e.entities.initiatingDraggable)
|
|
180
180
|
return !1;
|
|
181
181
|
const t = e.entities.draggableMap.get(
|
|
@@ -187,7 +187,7 @@ function Et(e) {
|
|
|
187
187
|
t?.activation
|
|
188
188
|
) ? (ae(e), !0) : !1;
|
|
189
189
|
}
|
|
190
|
-
function
|
|
190
|
+
function Ct(e, t) {
|
|
191
191
|
let s = null;
|
|
192
192
|
const n = () => {
|
|
193
193
|
if (e.state.value !== "activating" || !e.entities.initiatingDraggable) {
|
|
@@ -216,7 +216,7 @@ function At(e, t) {
|
|
|
216
216
|
}
|
|
217
217
|
};
|
|
218
218
|
}
|
|
219
|
-
function
|
|
219
|
+
function It(e, t) {
|
|
220
220
|
const s = e.closest(
|
|
221
221
|
Y.CONSTRAINT_AREA
|
|
222
222
|
);
|
|
@@ -225,10 +225,10 @@ function Ct(e, t) {
|
|
|
225
225
|
entity: t.get(s)
|
|
226
226
|
};
|
|
227
227
|
}
|
|
228
|
-
function
|
|
228
|
+
function Lt(e, t, s, n) {
|
|
229
229
|
return s === "x" ? { x: e, y: n.top } : s === "y" ? { x: n.left, y: t } : { x: e, y: t };
|
|
230
230
|
}
|
|
231
|
-
function
|
|
231
|
+
function kt(e, t, s, n, o) {
|
|
232
232
|
let i = e, r = t;
|
|
233
233
|
return s !== "y" && (i = Math.max(
|
|
234
234
|
n.left,
|
|
@@ -238,23 +238,23 @@ function Lt(e, t, s, n, o) {
|
|
|
238
238
|
Math.min(n.bottom - o.height, t)
|
|
239
239
|
)), { x: i, y: r };
|
|
240
240
|
}
|
|
241
|
-
function
|
|
241
|
+
function Pt(e, t, s, n, o) {
|
|
242
242
|
if (!e || !t)
|
|
243
243
|
return { x: 0, y: 0 };
|
|
244
244
|
const i = t.getBoundingClientRect(), r = i.width || o?.width || 0, a = i.height || o?.height || 0;
|
|
245
245
|
let g = e.current.x - r * e.offset.x, u = e.current.y - a * e.offset.y;
|
|
246
246
|
if (!s)
|
|
247
247
|
return { x: g, y: u };
|
|
248
|
-
const c =
|
|
248
|
+
const c = It(s, n);
|
|
249
249
|
if (!c)
|
|
250
250
|
return { x: g, y: u };
|
|
251
|
-
const { element: l, entity: f } = c, d = l.getBoundingClientRect(), m = s.getBoundingClientRect(), h =
|
|
251
|
+
const { element: l, entity: f } = c, d = l.getBoundingClientRect(), m = s.getBoundingClientRect(), h = Lt(
|
|
252
252
|
g,
|
|
253
253
|
u,
|
|
254
254
|
f.axis || "both",
|
|
255
255
|
m
|
|
256
256
|
);
|
|
257
|
-
return f.restrictToArea ?
|
|
257
|
+
return f.restrictToArea ? kt(
|
|
258
258
|
h.x,
|
|
259
259
|
h.y,
|
|
260
260
|
f.axis || "both",
|
|
@@ -278,7 +278,7 @@ const V = {
|
|
|
278
278
|
],
|
|
279
279
|
forMoveFaster: ["ShiftLeft", "ShiftRight"]
|
|
280
280
|
};
|
|
281
|
-
function
|
|
281
|
+
function Rt(e, t) {
|
|
282
282
|
const s = re(), n = ne(), i = {
|
|
283
283
|
keys: {
|
|
284
284
|
pressedKeys: ne(/* @__PURE__ */ new Set()),
|
|
@@ -299,13 +299,13 @@ function Pt(e, t) {
|
|
|
299
299
|
selectingArea: void 0,
|
|
300
300
|
draggingMap: /* @__PURE__ */ new Map(),
|
|
301
301
|
selectedSet: /* @__PURE__ */ new Set(),
|
|
302
|
-
allowedDroppableSet: M(() => s.value ?
|
|
302
|
+
allowedDroppableSet: M(() => s.value ? pt(
|
|
303
303
|
r.visibleDroppableSet,
|
|
304
304
|
r.draggingMap,
|
|
305
305
|
r.draggableMap,
|
|
306
306
|
r.droppableMap
|
|
307
307
|
) : /* @__PURE__ */ new Set()),
|
|
308
|
-
allowedDraggableSet: M(() => s.value ?
|
|
308
|
+
allowedDraggableSet: M(() => s.value ? St(
|
|
309
309
|
r.visibleDraggableSet,
|
|
310
310
|
r.draggingMap,
|
|
311
311
|
r.draggableMap
|
|
@@ -338,16 +338,16 @@ function Pt(e, t) {
|
|
|
338
338
|
}), l = M(() => {
|
|
339
339
|
if (!n.value || !r.initiatingDraggable) return 0;
|
|
340
340
|
const b = r.draggableMap.get(r.initiatingDraggable)?.activation?.distance;
|
|
341
|
-
return b ?
|
|
341
|
+
return b ? Et(n.value, b) : 1;
|
|
342
342
|
}), f = fe(
|
|
343
343
|
r.visibleDraggableSet
|
|
344
344
|
), d = fe(
|
|
345
345
|
r.visibleDroppableSet
|
|
346
346
|
), m = fe(
|
|
347
347
|
r.visibleSelectableAreaSet
|
|
348
|
-
), { overlaySize: h, overlaySizeObserver: w } =
|
|
348
|
+
), { overlaySize: h, overlaySizeObserver: w } = Mt(e), D = ne(), v = M(() => {
|
|
349
349
|
const S = r.initiatingDraggable;
|
|
350
|
-
return
|
|
350
|
+
return Pt(
|
|
351
351
|
n.value,
|
|
352
352
|
e.value,
|
|
353
353
|
S || null,
|
|
@@ -456,7 +456,7 @@ function qe(e, t) {
|
|
|
456
456
|
}
|
|
457
457
|
return { targetIndex: c, mode: l, targetArr: r };
|
|
458
458
|
}
|
|
459
|
-
function
|
|
459
|
+
function Tt(e, t = "vertical") {
|
|
460
460
|
const { draggedItems: s } = e;
|
|
461
461
|
if (!s.length) return null;
|
|
462
462
|
const n = qe(e, t);
|
|
@@ -474,7 +474,7 @@ function Rt(e, t = "vertical") {
|
|
|
474
474
|
return { sourceItems: l, targetItems: f, draggedItems: g, sourceIndexes: a, targetIndex: r, mode: i, sameList: !1 };
|
|
475
475
|
}
|
|
476
476
|
}
|
|
477
|
-
function
|
|
477
|
+
function zt(e) {
|
|
478
478
|
const { draggedItems: t, hoveredDraggable: s } = e;
|
|
479
479
|
if (!t.length || !s) return null;
|
|
480
480
|
const n = t.map((c) => c.index), o = s.index, i = t.map((c) => c.item), r = s.item, a = t[0].items, g = s.items, u = a === g;
|
|
@@ -505,7 +505,7 @@ function Tt(e) {
|
|
|
505
505
|
}
|
|
506
506
|
}
|
|
507
507
|
}
|
|
508
|
-
function
|
|
508
|
+
function Bt(e, t = "vertical") {
|
|
509
509
|
const { draggedItems: s } = e;
|
|
510
510
|
if (!s.length) return null;
|
|
511
511
|
const n = qe(e, t);
|
|
@@ -513,13 +513,13 @@ function zt(e, t = "vertical") {
|
|
|
513
513
|
const { targetArr: o, targetIndex: i, mode: r } = n, a = s.map((u) => u.item);
|
|
514
514
|
return { targetItems: B(o, i, a), copiedItems: a, targetIndex: i, mode: r };
|
|
515
515
|
}
|
|
516
|
-
function
|
|
516
|
+
function Ot(e) {
|
|
517
517
|
const { draggedItems: t } = e;
|
|
518
518
|
if (!t.length) return null;
|
|
519
519
|
const s = t.map((r) => r.index), n = t.map((r) => r.item), o = t[0].items;
|
|
520
520
|
return { sourceItems: j(o, s), removedItems: n, sourceIndexes: s };
|
|
521
521
|
}
|
|
522
|
-
function
|
|
522
|
+
function _t(e) {
|
|
523
523
|
return {
|
|
524
524
|
// Low-level array ops
|
|
525
525
|
insertAt: B,
|
|
@@ -531,16 +531,16 @@ function Ot(e) {
|
|
|
531
531
|
isAtZoneStart: (t, s) => O.isAtZoneStart(t, s),
|
|
532
532
|
isAtZoneEnd: (t, s) => O.isAtZoneEnd(t, s),
|
|
533
533
|
// High-level (event-bound)
|
|
534
|
-
suggestSort: (t) =>
|
|
535
|
-
suggestSwap: () =>
|
|
536
|
-
suggestCopy: (t) =>
|
|
537
|
-
suggestRemove: () =>
|
|
534
|
+
suggestSort: (t) => Tt(e, t),
|
|
535
|
+
suggestSwap: () => zt(e),
|
|
536
|
+
suggestCopy: (t) => Bt(e, t),
|
|
537
|
+
suggestRemove: () => Ot(e)
|
|
538
538
|
};
|
|
539
539
|
}
|
|
540
|
-
const G = (e) => e.keys().next().value,
|
|
540
|
+
const G = (e) => e.keys().next().value, Ft = (e) => e.target.closest(
|
|
541
541
|
Y.DRAGGABLE
|
|
542
542
|
);
|
|
543
|
-
function
|
|
543
|
+
function Gt(e) {
|
|
544
544
|
const t = e.entities.initiatingDraggable;
|
|
545
545
|
if (!t) return [];
|
|
546
546
|
const n = (e.entities.draggingMap.get(t) ?? e.entities.draggableMap.get(t))?.payload;
|
|
@@ -570,7 +570,7 @@ function Ft(e) {
|
|
|
570
570
|
}), [...c.values()].sort((l, f) => l.index - f.index);
|
|
571
571
|
}
|
|
572
572
|
const R = (e, t) => {
|
|
573
|
-
const s =
|
|
573
|
+
const s = Gt(e);
|
|
574
574
|
let n, o;
|
|
575
575
|
if (t) {
|
|
576
576
|
const r = e.entities.droppableMap.get(t)?.payload;
|
|
@@ -612,7 +612,7 @@ const R = (e, t) => {
|
|
|
612
612
|
dropZone: n,
|
|
613
613
|
hoveredDraggable: o,
|
|
614
614
|
provider: e,
|
|
615
|
-
helpers:
|
|
615
|
+
helpers: _t({ draggedItems: s, dropZone: n, hoveredDraggable: o })
|
|
616
616
|
};
|
|
617
617
|
}, U = (e, t, s) => {
|
|
618
618
|
if (!t) return;
|
|
@@ -623,7 +623,7 @@ const R = (e, t) => {
|
|
|
623
623
|
e.entities.draggingMap.forEach((n) => {
|
|
624
624
|
n.disabled || n.events?.[t]?.(s);
|
|
625
625
|
});
|
|
626
|
-
},
|
|
626
|
+
}, Ht = (e, t, s) => {
|
|
627
627
|
if (t !== s) {
|
|
628
628
|
if (t && !X(t, e)) {
|
|
629
629
|
const n = R(e, t);
|
|
@@ -634,7 +634,7 @@ const R = (e, t) => {
|
|
|
634
634
|
e.entities.droppableMap.get(s)?.events?.onEnter?.(n);
|
|
635
635
|
}
|
|
636
636
|
}
|
|
637
|
-
},
|
|
637
|
+
}, Kt = (e, t, s) => {
|
|
638
638
|
if (t !== s) {
|
|
639
639
|
const n = R(e);
|
|
640
640
|
if (t) {
|
|
@@ -647,19 +647,19 @@ const R = (e, t) => {
|
|
|
647
647
|
}
|
|
648
648
|
}
|
|
649
649
|
}, de = (e, t, s) => {
|
|
650
|
-
const n =
|
|
650
|
+
const n = Ft(t);
|
|
651
651
|
!n || !e.entities.draggingMap.has(n) || e.entities.draggingMap.get(n)?.events?.[s]?.(R(e));
|
|
652
|
-
},
|
|
652
|
+
}, Nt = (e, t) => {
|
|
653
653
|
const s = G(t.droppable);
|
|
654
654
|
s && !X(s, e) && e.entities.droppableMap.get(s)?.events?.onLeave?.(R(e, s));
|
|
655
655
|
}, Je = (e, t) => {
|
|
656
656
|
const s = G(t.droppable);
|
|
657
657
|
s && !X(s, e) && e.entities.droppableMap.get(s)?.events?.onLeave?.(R(e, s));
|
|
658
658
|
};
|
|
659
|
-
function
|
|
659
|
+
function Zt(e) {
|
|
660
660
|
return e.parentElement?.closest(Y.SELECT_AREA) ?? null;
|
|
661
661
|
}
|
|
662
|
-
const
|
|
662
|
+
const Ut = (e, t, s) => {
|
|
663
663
|
if (!s) return {};
|
|
664
664
|
const n = s.getBoundingClientRect(), o = Math.max(n.left, Math.min(e.x, t.x)), i = Math.max(n.top, Math.min(e.y, t.y)), r = Math.min(n.right, Math.max(e.x, t.x)), a = Math.min(n.bottom, Math.max(e.y, t.y)), g = Math.max(0, r - o), u = Math.max(0, a - i);
|
|
665
665
|
return {
|
|
@@ -672,15 +672,15 @@ const Zt = (e, t, s) => {
|
|
|
672
672
|
border: "1px solid #3b82f6",
|
|
673
673
|
backgroundColor: "#3b82f61a"
|
|
674
674
|
};
|
|
675
|
-
},
|
|
675
|
+
}, Yt = (e) => {
|
|
676
676
|
if (!e.pointer.value || !e.entities.selectingArea) return;
|
|
677
|
-
const { selectingArea: t } = e.entities, s =
|
|
677
|
+
const { selectingArea: t } = e.entities, s = Xt(
|
|
678
678
|
e.pointer.value.start,
|
|
679
679
|
e.pointer.value.current
|
|
680
680
|
), n = e.entities.selectableAreaMap.get(t)?.groups ?? [], o = e.lib.rectCache;
|
|
681
681
|
e.entities.visibleDraggableSet.forEach((i) => {
|
|
682
682
|
if (i === t || !t.contains(i)) return;
|
|
683
|
-
const r =
|
|
683
|
+
const r = Zt(i);
|
|
684
684
|
if (r && r !== t) {
|
|
685
685
|
e.entities.selectedSet.delete(i);
|
|
686
686
|
return;
|
|
@@ -695,12 +695,12 @@ const Zt = (e, t, s) => {
|
|
|
695
695
|
return;
|
|
696
696
|
}
|
|
697
697
|
let u = o.get(i);
|
|
698
|
-
u || (u = i.getBoundingClientRect(), o.set(i, u)),
|
|
698
|
+
u || (u = i.getBoundingClientRect(), o.set(i, u)), bt(s, u) ? e.entities.selectedSet.add(i) : e.entities.selectedSet.delete(i);
|
|
699
699
|
});
|
|
700
|
-
},
|
|
700
|
+
}, Xt = (e, t) => {
|
|
701
701
|
const s = Math.min(e.x, t.x), n = Math.min(e.y, t.y), o = Math.max(e.x, t.x), i = Math.max(e.y, t.y), r = o - s, a = i - n;
|
|
702
702
|
return new DOMRect(s, n, r, a);
|
|
703
|
-
},
|
|
703
|
+
}, jt = (e, t, s = 5) => {
|
|
704
704
|
const n = s / 2;
|
|
705
705
|
return {
|
|
706
706
|
left: e - n,
|
|
@@ -708,9 +708,9 @@ const Zt = (e, t, s) => {
|
|
|
708
708
|
width: s,
|
|
709
709
|
height: s
|
|
710
710
|
};
|
|
711
|
-
},
|
|
711
|
+
}, Vt = (e) => {
|
|
712
712
|
const t = e.pointer.value?.current, s = t?.x ?? 0, n = t?.y ?? 0;
|
|
713
|
-
return
|
|
713
|
+
return jt(s, n, 5);
|
|
714
714
|
}, N = (e, t, s) => {
|
|
715
715
|
const n = e.left + e.width / 2, o = e.top + e.height / 2;
|
|
716
716
|
if (s) {
|
|
@@ -732,28 +732,28 @@ const Zt = (e, t, s) => {
|
|
|
732
732
|
right: n > i,
|
|
733
733
|
center: !1
|
|
734
734
|
};
|
|
735
|
-
},
|
|
735
|
+
}, $t = (e) => ({
|
|
736
736
|
x: e.left + e.width / 2,
|
|
737
737
|
y: e.top + e.height / 2
|
|
738
738
|
}), Te = (e, t) => {
|
|
739
|
-
const s =
|
|
739
|
+
const s = $t(t);
|
|
740
740
|
return Math.hypot(e.x - s.x, e.y - s.y);
|
|
741
741
|
};
|
|
742
|
-
function
|
|
742
|
+
function Wt(e, t) {
|
|
743
743
|
return e === t ? !0 : !e || !t ? !1 : e.top === t.top && e.right === t.right && e.bottom === t.bottom && e.left === t.left && e.center === t.center;
|
|
744
744
|
}
|
|
745
745
|
function ee(e, t) {
|
|
746
|
-
|
|
746
|
+
Wt(e.hoveredPlacement, t) || (e.hoveredPlacement = t);
|
|
747
747
|
}
|
|
748
|
-
const
|
|
748
|
+
const qt = (e, t) => e.find((s) => s !== t && _(t, s)), W = (e, t, s) => {
|
|
749
749
|
const n = G(t.droppable), o = G(t.draggable);
|
|
750
750
|
o && t.draggable.delete(o), n && t.droppable.delete(n);
|
|
751
|
-
const i =
|
|
751
|
+
const i = Vt(e), r = s.zones[0], a = s.elements[0];
|
|
752
752
|
if (r && a && r === a && e.entities.droppableMap.has(r) && r) {
|
|
753
753
|
const l = r.getBoundingClientRect(), f = e.entities.draggableMap.get(r)?.placementMargins, d = N(i, l, f);
|
|
754
754
|
if (d.center) {
|
|
755
755
|
t.droppable.set(r, d);
|
|
756
|
-
const m =
|
|
756
|
+
const m = qt(s.elements, r);
|
|
757
757
|
if (m) {
|
|
758
758
|
const h = m.getBoundingClientRect();
|
|
759
759
|
t.draggable.set(
|
|
@@ -812,7 +812,7 @@ const Wt = (e, t) => e.find((s) => s !== t && _(t, s)), W = (e, t, s) => {
|
|
|
812
812
|
const l = e.entities.droppableMap.get(u);
|
|
813
813
|
l && ee(l, t.droppable.get(u));
|
|
814
814
|
}
|
|
815
|
-
|
|
815
|
+
Ht(e, n, u), Kt(e, o, c);
|
|
816
816
|
}, ze = (e, t) => e.x < t.x + t.width && e.x + e.width > t.x && e.y < t.y + t.height && e.y + e.height > t.y, Z = (e) => {
|
|
817
817
|
if (!e)
|
|
818
818
|
return { x: 0, y: 0, width: 0, height: 0, top: 0, left: 0, right: 0, bottom: 0 };
|
|
@@ -830,7 +830,7 @@ const Wt = (e, t) => e.find((s) => s !== t && _(t, s)), W = (e, t, s) => {
|
|
|
830
830
|
}, $ = (e) => ({
|
|
831
831
|
x: e.x + e.width / 2,
|
|
832
832
|
y: e.y + e.height / 2
|
|
833
|
-
}),
|
|
833
|
+
}), Jt = (e, t) => Math.hypot(t.x - e.x, t.y - e.y), Me = (e, t) => {
|
|
834
834
|
const s = Math.max(
|
|
835
835
|
0,
|
|
836
836
|
Math.min(e.x + e.width, t.x + t.width) - Math.max(e.x, t.x)
|
|
@@ -839,7 +839,7 @@ const Wt = (e, t) => e.find((s) => s !== t && _(t, s)), W = (e, t, s) => {
|
|
|
839
839
|
Math.min(e.y + e.height, t.y + t.height) - Math.max(e.y, t.y)
|
|
840
840
|
), o = s * n, i = e.width * e.height, r = t.width * t.height;
|
|
841
841
|
return i === 0 || r === 0 ? 0 : (o / i * 100 + o / r * 100) / 2;
|
|
842
|
-
}, we = (e, t, s) => t >= e.x && t <= e.x + e.width && s >= e.y && s <= e.y + e.height,
|
|
842
|
+
}, we = (e, t, s) => t >= e.x && t <= e.x + e.width && s >= e.y && s <= e.y + e.height, Qt = (e) => e.overlay.ref?.value ?? null, Qe = (e) => {
|
|
843
843
|
const t = e.overlay.position?.value ?? { x: 0, y: 0 }, { x: s, y: n } = t, o = e.overlay.size?.value;
|
|
844
844
|
let i, r;
|
|
845
845
|
if (o)
|
|
@@ -858,9 +858,9 @@ const Wt = (e, t) => e.find((s) => s !== t && _(t, s)), W = (e, t, s) => {
|
|
|
858
858
|
right: s + i,
|
|
859
859
|
bottom: n + r
|
|
860
860
|
};
|
|
861
|
-
},
|
|
861
|
+
}, en = (e) => e.entities.allowedDraggableSet, tn = (e) => e.entities.allowedDroppableSet, nn = (e, t) => !t.entities.draggingMap.has(e), sn = (e, t) => ![...t.entities.draggingMap.keys()].some(
|
|
862
862
|
(s) => _(s, e)
|
|
863
|
-
),
|
|
863
|
+
), on = (e, t) => t.entities.draggableMap.has(e) ? !Ae(e, t) : t.entities.droppableMap.has(e) ? !X(e, t) : !0, ce = (e, t) => nn(e, t) && sn(e, t) && on(e, t), Be = 10;
|
|
864
864
|
function te(e, t) {
|
|
865
865
|
return Math.hypot(
|
|
866
866
|
t.x - (e.x + e.width / 2),
|
|
@@ -874,10 +874,10 @@ function Oe(e) {
|
|
|
874
874
|
});
|
|
875
875
|
}
|
|
876
876
|
const ve = (e) => {
|
|
877
|
-
if (!
|
|
878
|
-
const s = Qe(e), n = e.pointer.value?.current ?? { x: 0, y: 0 }, o = [...
|
|
877
|
+
if (!Qt(e)) return { elements: [], zones: [] };
|
|
878
|
+
const s = Qe(e), n = e.pointer.value?.current ?? { x: 0, y: 0 }, o = [...en(e)].filter(
|
|
879
879
|
(c) => ce(c, e)
|
|
880
|
-
), i = [...
|
|
880
|
+
), i = [...tn(e)].filter(
|
|
881
881
|
(c) => ce(c, e)
|
|
882
882
|
), r = o.filter(
|
|
883
883
|
(c) => we(Z(c), n.x, n.y)
|
|
@@ -896,7 +896,7 @@ const ve = (e) => {
|
|
|
896
896
|
).sort((c, l) => te(c.box, n) - te(l.box, n)).map(({ n: c }) => c);
|
|
897
897
|
return { elements: g, zones: u };
|
|
898
898
|
};
|
|
899
|
-
function
|
|
899
|
+
function rn(e) {
|
|
900
900
|
globalThis.onmessage = (t) => {
|
|
901
901
|
const { callId: s, data: n } = t.data;
|
|
902
902
|
try {
|
|
@@ -907,22 +907,22 @@ function on(e) {
|
|
|
907
907
|
}
|
|
908
908
|
};
|
|
909
909
|
}
|
|
910
|
-
function
|
|
910
|
+
function an(e, t) {
|
|
911
911
|
return [
|
|
912
912
|
t.map((n) => n.toString()).join(`
|
|
913
913
|
|
|
914
914
|
`),
|
|
915
915
|
`var __fn = ${e.toString()};`,
|
|
916
|
-
`(${
|
|
916
|
+
`(${rn.toString()})(__fn);`
|
|
917
917
|
].join(`
|
|
918
918
|
|
|
919
919
|
`);
|
|
920
920
|
}
|
|
921
|
-
function
|
|
921
|
+
function ln(e, t) {
|
|
922
922
|
let s = null, n = null, o = !1, i = 0;
|
|
923
923
|
const r = /* @__PURE__ */ new Map();
|
|
924
924
|
try {
|
|
925
|
-
const u =
|
|
925
|
+
const u = an(e, t?.localDependencies ?? []), c = new Blob([u], { type: "application/javascript" });
|
|
926
926
|
n = URL.createObjectURL(c), s = new Worker(n), o = !0, s.onmessage = (l) => {
|
|
927
927
|
const f = r.get(l.data.callId);
|
|
928
928
|
f && (r.delete(l.data.callId), l.data.ok ? f.resolve(l.data.result) : f.reject(new Error(l.data.error)));
|
|
@@ -966,7 +966,7 @@ function tt(e, t, s, n, o, i, r, a) {
|
|
|
966
966
|
function oe(e, t, s, n, o, i) {
|
|
967
967
|
return o >= e && o <= e + s && i >= t && i <= t + n;
|
|
968
968
|
}
|
|
969
|
-
function
|
|
969
|
+
function cn(e) {
|
|
970
970
|
const { containerBox: t, pointer: s, elements: n, elementCount: o, zones: i, zoneCount: r, config: a } = e, { x: g, y: u, width: c, height: l } = t, { x: f, y: d } = s, m = a.minOverlapPercent, h = g + c / 2, w = u + l / 2, D = oe(g, u, c, l, f, d);
|
|
971
971
|
function v(x, K) {
|
|
972
972
|
const S = [], b = x;
|
|
@@ -1005,7 +1005,7 @@ function ln(e) {
|
|
|
1005
1005
|
}
|
|
1006
1006
|
let me = null;
|
|
1007
1007
|
function nt() {
|
|
1008
|
-
return me || (me =
|
|
1008
|
+
return me || (me = ln(cn, {
|
|
1009
1009
|
localDependencies: [et, tt, oe]
|
|
1010
1010
|
})), me;
|
|
1011
1011
|
}
|
|
@@ -1018,7 +1018,7 @@ function _e(e, t) {
|
|
|
1018
1018
|
return s;
|
|
1019
1019
|
}
|
|
1020
1020
|
let Fe = 0;
|
|
1021
|
-
function
|
|
1021
|
+
function un(e) {
|
|
1022
1022
|
const t = nt(), s = ++Fe, n = [...e.entities.allowedDraggableSet].filter(
|
|
1023
1023
|
(u) => ce(u, e)
|
|
1024
1024
|
), o = [...e.entities.allowedDroppableSet].filter(
|
|
@@ -1057,13 +1057,13 @@ function xe(e) {
|
|
|
1057
1057
|
return;
|
|
1058
1058
|
}
|
|
1059
1059
|
if (nt().isSupported)
|
|
1060
|
-
|
|
1060
|
+
un(e);
|
|
1061
1061
|
else {
|
|
1062
1062
|
const s = ve(e);
|
|
1063
1063
|
W(e, e.hovered, s);
|
|
1064
1064
|
}
|
|
1065
1065
|
}
|
|
1066
|
-
function
|
|
1066
|
+
function gn(e, t) {
|
|
1067
1067
|
const s = e.collision?.throttle?.value ?? 0;
|
|
1068
1068
|
if (s <= 0) {
|
|
1069
1069
|
xe(e);
|
|
@@ -1091,15 +1091,15 @@ async function st(e) {
|
|
|
1091
1091
|
}
|
|
1092
1092
|
function ot(e) {
|
|
1093
1093
|
const t = e.entities.initiatingDraggable;
|
|
1094
|
-
U(e, t, "onSelfDragEnd"), P(e, "onDragEnd"),
|
|
1094
|
+
U(e, t, "onSelfDragEnd"), P(e, "onDragEnd"), Nt(e, e.hovered);
|
|
1095
1095
|
}
|
|
1096
|
-
function
|
|
1096
|
+
function fn(e) {
|
|
1097
1097
|
const t = e.entities.selectingArea;
|
|
1098
1098
|
if (!t) return;
|
|
1099
1099
|
const s = e.entities.selectableAreaMap.get(t), n = [...e.entities.selectedSet];
|
|
1100
1100
|
s?.events?.onSelected?.(n);
|
|
1101
1101
|
}
|
|
1102
|
-
const
|
|
1102
|
+
const dn = (e) => {
|
|
1103
1103
|
const t = {
|
|
1104
1104
|
current: null
|
|
1105
1105
|
}, s = { value: 0 }, n = async () => {
|
|
@@ -1112,20 +1112,20 @@ const fn = (e) => {
|
|
|
1112
1112
|
return;
|
|
1113
1113
|
}
|
|
1114
1114
|
return;
|
|
1115
|
-
} else a === "selecting" &&
|
|
1115
|
+
} else a === "selecting" && fn(e);
|
|
1116
1116
|
le(e), document.removeEventListener("pointerup", n), document.removeEventListener("pointermove", o);
|
|
1117
1117
|
}, o = (a) => {
|
|
1118
1118
|
if (e.pointer.value) {
|
|
1119
|
-
if (e.pointer.value.current = { x: a.clientX, y: a.clientY },
|
|
1119
|
+
if (e.pointer.value.current = { x: a.clientX, y: a.clientY }, At(e)) {
|
|
1120
1120
|
de(e, a, "onSelfDragStart"), P(e, "onDragStart");
|
|
1121
1121
|
return;
|
|
1122
1122
|
}
|
|
1123
1123
|
if (e.state.value === "dragging") {
|
|
1124
|
-
|
|
1124
|
+
gn(e, s);
|
|
1125
1125
|
const g = e.entities.initiatingDraggable;
|
|
1126
1126
|
U(e, g, "onSelfDragMove"), P(e, "onDragMove");
|
|
1127
1127
|
}
|
|
1128
|
-
e.state.value === "selecting" &&
|
|
1128
|
+
e.state.value === "selecting" && Yt(e);
|
|
1129
1129
|
}
|
|
1130
1130
|
};
|
|
1131
1131
|
return { pointerDown: (a) => {
|
|
@@ -1145,14 +1145,14 @@ const fn = (e) => {
|
|
|
1145
1145
|
return;
|
|
1146
1146
|
pe(), e.entities.initiatingDraggable = c;
|
|
1147
1147
|
const f = Xe(a, c);
|
|
1148
|
-
e.pointer.value = De(a, f.x, f.y), l?.activation?.distance || l?.activation?.delay ? (e.state.value = "activating", l?.activation?.delay && (e.delay.startTime = Date.now(), t.current =
|
|
1148
|
+
e.pointer.value = De(a, f.x, f.y), l?.activation?.distance || l?.activation?.delay ? (e.state.value = "activating", l?.activation?.delay && (e.delay.startTime = Date.now(), t.current = Ct(e, () => {
|
|
1149
1149
|
ae(e), de(e, a, "onSelfDragStart"), P(e, "onDragStart");
|
|
1150
1150
|
}))) : (ae(e), de(e, a, "onSelfDragStart"), P(e, "onDragStart"));
|
|
1151
1151
|
}
|
|
1152
1152
|
}, pointerUp: n, pointerMove: o, cleanup: () => {
|
|
1153
1153
|
t.current?.cancel(), document.removeEventListener("pointerup", n), document.removeEventListener("pointermove", o), e.lib.draggableObserver.disconnect(), e.lib.droppableObserver.disconnect(), e.lib.selectableAreaObserver.disconnect(), e.lib.overlaySizeObserver.disconnect();
|
|
1154
1154
|
} };
|
|
1155
|
-
},
|
|
1155
|
+
}, mn = {
|
|
1156
1156
|
ArrowUp: { dx: 0, dy: -1 },
|
|
1157
1157
|
ArrowDown: { dx: 0, dy: 1 },
|
|
1158
1158
|
ArrowLeft: { dx: -1, dy: 0 },
|
|
@@ -1161,7 +1161,7 @@ const fn = (e) => {
|
|
|
1161
1161
|
KeyA: { dx: -1, dy: 0 },
|
|
1162
1162
|
KeyS: { dx: 0, dy: 1 },
|
|
1163
1163
|
KeyD: { dx: 1, dy: 0 }
|
|
1164
|
-
},
|
|
1164
|
+
}, hn = (e) => (t) => {
|
|
1165
1165
|
const { keys: s } = e.keyboard;
|
|
1166
1166
|
if (s.pressedKeys.value.add(t.code), e.state.value === "dragging") {
|
|
1167
1167
|
if (s.forCancel.includes(t.code)) {
|
|
@@ -1176,7 +1176,7 @@ const fn = (e) => {
|
|
|
1176
1176
|
t.preventDefault(), (async () => (await st(e) && ot(e), Se(), le(e)))();
|
|
1177
1177
|
return;
|
|
1178
1178
|
}
|
|
1179
|
-
const o =
|
|
1179
|
+
const o = mn[t.code];
|
|
1180
1180
|
if (o && s.forMove.includes(t.code) && e.pointer.value) {
|
|
1181
1181
|
t.preventDefault();
|
|
1182
1182
|
const i = s.forMoveFaster.some(
|
|
@@ -1222,18 +1222,18 @@ const fn = (e) => {
|
|
|
1222
1222
|
const d = (e.collision?.run ?? ve)(e);
|
|
1223
1223
|
W(e, e.hovered, d), U(e, i, "onSelfDragStart"), P(e, "onDragStart");
|
|
1224
1224
|
}
|
|
1225
|
-
},
|
|
1225
|
+
}, yn = (e) => (t) => {
|
|
1226
1226
|
e.keyboard.keys.pressedKeys.value.delete(t.code);
|
|
1227
|
-
},
|
|
1227
|
+
}, bn = (e) => () => {
|
|
1228
1228
|
e.keyboard.keys.pressedKeys.value.clear();
|
|
1229
1229
|
}, he = {
|
|
1230
|
-
keyDown:
|
|
1231
|
-
keyUp:
|
|
1232
|
-
clear:
|
|
1233
|
-
},
|
|
1230
|
+
keyDown: hn,
|
|
1231
|
+
keyUp: yn,
|
|
1232
|
+
clear: bn
|
|
1233
|
+
}, pn = (e) => () => {
|
|
1234
1234
|
e.state.value && (e.scrollPosition.x = window.scrollX, e.scrollPosition.y = window.scrollY, e.lib.rectCache.clear(), e.state.value === "dragging" && xe(e));
|
|
1235
|
-
}, T = 50,
|
|
1236
|
-
function
|
|
1235
|
+
}, T = 50, Sn = 144, Ge = 1e3 / Sn;
|
|
1236
|
+
function Dn(e) {
|
|
1237
1237
|
return e == null ? {
|
|
1238
1238
|
top: T,
|
|
1239
1239
|
right: T,
|
|
@@ -1251,7 +1251,7 @@ function Sn(e) {
|
|
|
1251
1251
|
left: e.left ?? T
|
|
1252
1252
|
};
|
|
1253
1253
|
}
|
|
1254
|
-
const
|
|
1254
|
+
const Mn = {
|
|
1255
1255
|
getScrollState(e) {
|
|
1256
1256
|
return {
|
|
1257
1257
|
scrollTop: e.scrollTop,
|
|
@@ -1262,8 +1262,8 @@ const Dn = {
|
|
|
1262
1262
|
e.scrollTop = t, e.scrollLeft = s;
|
|
1263
1263
|
}
|
|
1264
1264
|
};
|
|
1265
|
-
function rt(e, t, s, n =
|
|
1266
|
-
const { speed: i = 10, disabled: r = !1 } = t, a =
|
|
1265
|
+
function rt(e, t, s, n = Mn, o) {
|
|
1266
|
+
const { speed: i = 10, disabled: r = !1 } = t, a = Dn(t.threshold);
|
|
1267
1267
|
let g = null, u = null, c = null, l = 0, f = 0;
|
|
1268
1268
|
const d = (D) => {
|
|
1269
1269
|
o && (o.value = D);
|
|
@@ -1292,7 +1292,7 @@ function rt(e, t, s, n = Dn, o) {
|
|
|
1292
1292
|
g && (cancelAnimationFrame(g), g = null), c = null, l = 0, f = 0, u = null, d(!1);
|
|
1293
1293
|
} };
|
|
1294
1294
|
}
|
|
1295
|
-
const
|
|
1295
|
+
const wn = {
|
|
1296
1296
|
getScrollState() {
|
|
1297
1297
|
return {
|
|
1298
1298
|
scrollTop: window.scrollY ?? document.documentElement.scrollTop,
|
|
@@ -1305,14 +1305,14 @@ const Mn = {
|
|
|
1305
1305
|
getRect() {
|
|
1306
1306
|
return new DOMRect(0, 0, window.innerWidth, window.innerHeight);
|
|
1307
1307
|
}
|
|
1308
|
-
},
|
|
1308
|
+
}, vn = {
|
|
1309
1309
|
get value() {
|
|
1310
1310
|
return typeof document < "u" ? document.documentElement : null;
|
|
1311
1311
|
}
|
|
1312
1312
|
};
|
|
1313
|
-
function
|
|
1313
|
+
function xn(e, t) {
|
|
1314
1314
|
const s = re(!1), o = rt(
|
|
1315
|
-
|
|
1315
|
+
vn,
|
|
1316
1316
|
t ?? {},
|
|
1317
1317
|
() => {
|
|
1318
1318
|
if (e.state.value !== "dragging") return null;
|
|
@@ -1322,7 +1322,7 @@ function vn(e, t) {
|
|
|
1322
1322
|
y: a.y + g.height / 2
|
|
1323
1323
|
} : a : null;
|
|
1324
1324
|
},
|
|
1325
|
-
|
|
1325
|
+
wn,
|
|
1326
1326
|
s
|
|
1327
1327
|
), i = ue(
|
|
1328
1328
|
() => e.state.value,
|
|
@@ -1334,13 +1334,13 @@ function vn(e, t) {
|
|
|
1334
1334
|
};
|
|
1335
1335
|
return at(r), { isScrolling: s, stop: r };
|
|
1336
1336
|
}
|
|
1337
|
-
const
|
|
1338
|
-
const t =
|
|
1337
|
+
const En = (e) => {
|
|
1338
|
+
const t = dn(e), s = he.keyDown(e), n = he.keyUp(e), o = he.clear(e), i = pn(e);
|
|
1339
1339
|
let r = null;
|
|
1340
1340
|
ue(
|
|
1341
1341
|
e.autoScrollViewport,
|
|
1342
1342
|
(a) => {
|
|
1343
|
-
r?.(), r = null, (a === !0 || a && typeof a == "object") && (r =
|
|
1343
|
+
r?.(), r = null, (a === !0 || a && typeof a == "object") && (r = xn(
|
|
1344
1344
|
e,
|
|
1345
1345
|
a === !0 ? {} : a
|
|
1346
1346
|
).stop);
|
|
@@ -1370,7 +1370,7 @@ const xn = (e) => {
|
|
|
1370
1370
|
collision: e.collision,
|
|
1371
1371
|
autoScrollViewport: e.autoScrollViewport
|
|
1372
1372
|
};
|
|
1373
|
-
},
|
|
1373
|
+
}, An = /* @__PURE__ */ Ue({
|
|
1374
1374
|
__name: "DefaultOverlay",
|
|
1375
1375
|
setup(e) {
|
|
1376
1376
|
const { entities: t, state: s, overlay: n } = it();
|
|
@@ -1394,37 +1394,39 @@ const xn = (e) => {
|
|
|
1394
1394
|
], 64))), 256))
|
|
1395
1395
|
], 4)) : ct("", !0);
|
|
1396
1396
|
}
|
|
1397
|
-
}),
|
|
1397
|
+
}), kn = /* @__PURE__ */ Ue({
|
|
1398
1398
|
__name: "DnDProvider",
|
|
1399
1399
|
props: {
|
|
1400
1400
|
autoScrollViewport: { type: [Object, Boolean, null] },
|
|
1401
|
-
overlayTo: { type: [String, Boolean, null] }
|
|
1401
|
+
overlayTo: { type: [String, Boolean, null] },
|
|
1402
|
+
style: {},
|
|
1403
|
+
class: {}
|
|
1402
1404
|
},
|
|
1403
1405
|
setup(e) {
|
|
1404
|
-
const t = e, s = ut("overlayRef"), n =
|
|
1405
|
-
|
|
1406
|
+
const t = e, s = ut("overlayRef"), n = Rt(s, t);
|
|
1407
|
+
En(n);
|
|
1406
1408
|
const o = M(
|
|
1407
|
-
() => n.overlay.render.value ??
|
|
1409
|
+
() => n.overlay.render.value ?? An
|
|
1408
1410
|
);
|
|
1409
1411
|
return gt(Ee, n), (i, r) => (z(), se(ye, null, [
|
|
1410
1412
|
Pe(i.$slots, "default"),
|
|
1411
1413
|
(z(), ie(ft, {
|
|
1412
1414
|
to: F(n).overlay.to.value || "body"
|
|
1413
1415
|
}, [
|
|
1414
|
-
dt("div", {
|
|
1416
|
+
dt("div", mt({
|
|
1415
1417
|
ref_key: "overlayRef",
|
|
1416
1418
|
ref: s,
|
|
1417
1419
|
class: "dnd-kit-overlay-container"
|
|
1418
|
-
}, [
|
|
1420
|
+
}, t), [
|
|
1419
1421
|
Pe(i.$slots, "overlay", { overlay: o.value }, () => [
|
|
1420
1422
|
(z(), ie(be(o.value)))
|
|
1421
1423
|
])
|
|
1422
|
-
],
|
|
1424
|
+
], 16)
|
|
1423
1425
|
], 8, ["to"]))
|
|
1424
1426
|
], 64));
|
|
1425
1427
|
}
|
|
1426
1428
|
});
|
|
1427
|
-
function
|
|
1429
|
+
function Pn(e, t, s) {
|
|
1428
1430
|
const n = ge();
|
|
1429
1431
|
let o, i, r;
|
|
1430
1432
|
typeof t == "function" ? (o = {}, i = t) : (o = t ?? {}, i = s);
|
|
@@ -1470,7 +1472,7 @@ function kn(e, t, s) {
|
|
|
1470
1472
|
isDragOver: c
|
|
1471
1473
|
};
|
|
1472
1474
|
}
|
|
1473
|
-
const
|
|
1475
|
+
const Rn = (e, t) => {
|
|
1474
1476
|
const s = ge(), n = M(() => e.value === s.entities.selectingArea);
|
|
1475
1477
|
let o = null;
|
|
1476
1478
|
q(() => {
|
|
@@ -1489,14 +1491,14 @@ const Pn = (e, t) => {
|
|
|
1489
1491
|
const i = M(() => {
|
|
1490
1492
|
s.scrollPosition.x, s.scrollPosition.y;
|
|
1491
1493
|
const r = s.pointer.value;
|
|
1492
|
-
return !r || s.state.value !== "selecting" || !o || !n.value ? {} :
|
|
1494
|
+
return !r || s.state.value !== "selecting" || !o || !n.value ? {} : Ut(r.start, r.current, o);
|
|
1493
1495
|
});
|
|
1494
1496
|
return {
|
|
1495
1497
|
isSelecting: n,
|
|
1496
1498
|
style: i
|
|
1497
1499
|
};
|
|
1498
1500
|
};
|
|
1499
|
-
function
|
|
1501
|
+
function Tn(e, t) {
|
|
1500
1502
|
const s = Ze(Ee);
|
|
1501
1503
|
if (!s) throw Error("DnD provider not found");
|
|
1502
1504
|
let n = null;
|
|
@@ -1509,7 +1511,7 @@ function Rn(e, t) {
|
|
|
1509
1511
|
n && s.entities.constraintsAreaMap.delete(n);
|
|
1510
1512
|
}), {};
|
|
1511
1513
|
}
|
|
1512
|
-
function
|
|
1514
|
+
function zn(e, t, s) {
|
|
1513
1515
|
const n = ge();
|
|
1514
1516
|
let o = null, i, r;
|
|
1515
1517
|
typeof t == "function" ? (i = {}, r = t) : (i = t ?? {}, r = s);
|
|
@@ -1536,7 +1538,7 @@ function Tn(e, t, s) {
|
|
|
1536
1538
|
isDragOver: g
|
|
1537
1539
|
};
|
|
1538
1540
|
}
|
|
1539
|
-
const
|
|
1541
|
+
const Bn = (e, t) => {
|
|
1540
1542
|
const s = it(), n = re(!1), i = rt(
|
|
1541
1543
|
e,
|
|
1542
1544
|
t ?? {},
|
|
@@ -1561,7 +1563,7 @@ const zn = (e, t) => {
|
|
|
1561
1563
|
function He(e, t) {
|
|
1562
1564
|
return t <= 0 ? e : Math.round(e / t) * t;
|
|
1563
1565
|
}
|
|
1564
|
-
function
|
|
1566
|
+
function On(e, t) {
|
|
1565
1567
|
const s = t && "grid" in t && t.grid != null, n = t ? s ? t.grid : t.gridX : 1, o = t ? s ? t.grid : t.gridY : 1;
|
|
1566
1568
|
return M(() => {
|
|
1567
1569
|
const { x: i, y: r } = e.value;
|
|
@@ -1571,13 +1573,13 @@ function Bn(e, t) {
|
|
|
1571
1573
|
};
|
|
1572
1574
|
});
|
|
1573
1575
|
}
|
|
1574
|
-
const Ke = () => !0, Ne = () => 0,
|
|
1576
|
+
const Ke = () => !0, Ne = () => 0, Cn = "separate", In = () => {
|
|
1575
1577
|
const e = {
|
|
1576
1578
|
filterElements: Ke,
|
|
1577
1579
|
filterZones: Ke,
|
|
1578
1580
|
sortElements: Ne,
|
|
1579
1581
|
sortZones: Ne,
|
|
1580
|
-
mergeStrategy:
|
|
1582
|
+
mergeStrategy: Cn,
|
|
1581
1583
|
pickClosestBetweenFirst: !1
|
|
1582
1584
|
}, t = (n, o, i, r, a, g, u) => {
|
|
1583
1585
|
const c = r instanceof Set ? r : new Set(r), l = { containerBox: o, pointer: i }, f = e.minOverlapPercent, d = [];
|
|
@@ -1597,7 +1599,7 @@ const Ke = () => !0, Ne = () => 0, An = "separate", Cn = () => {
|
|
|
1597
1599
|
isPointerInElement: we(h, i.x, i.y),
|
|
1598
1600
|
overlapPercent: w,
|
|
1599
1601
|
depth: D,
|
|
1600
|
-
centerDistance:
|
|
1602
|
+
centerDistance: Jt(
|
|
1601
1603
|
$(o),
|
|
1602
1604
|
$(h)
|
|
1603
1605
|
)
|
|
@@ -1714,16 +1716,16 @@ const Ke = () => !0, Ne = () => 0, An = "separate", Cn = () => {
|
|
|
1714
1716
|
}
|
|
1715
1717
|
};
|
|
1716
1718
|
return s;
|
|
1717
|
-
},
|
|
1719
|
+
}, _n = () => In();
|
|
1718
1720
|
export {
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
+
kn as DnDProvider,
|
|
1722
|
+
_n as createSensor,
|
|
1721
1723
|
ve as defaultCollisionDetection,
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1724
|
+
Bn as makeAutoScroll,
|
|
1725
|
+
Tn as makeConstraintArea,
|
|
1726
|
+
Pn as makeDraggable,
|
|
1727
|
+
zn as makeDroppable,
|
|
1728
|
+
Rn as makeSelectionArea,
|
|
1729
|
+
On as makeSnappedOverlayPosition,
|
|
1728
1730
|
it as useDnDProvider
|
|
1729
1731
|
};
|
package/package.json
CHANGED