@vue-dnd-kit/core 2.0.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/vue-dnd-kit-core.cjs.js +2 -2
- package/dist/vue-dnd-kit-core.es.js +162 -162
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
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
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("vue"),F={SELECT_AREA:"data-dnd-kit-select-area",DRAGGABLE:"data-dnd-kit-draggable",DROPPABLE:"data-dnd-kit-droppable",CONSTRAINT_AREA:"data-dnd-kit-constraint-area"},N={SELECT_AREA:`[${F.SELECT_AREA}]`,DRAGGABLE:`[${F.DRAGGABLE}]`,CONSTRAINT_AREA:`[${F.CONSTRAINT_AREA}]`},de="VueDnDKitProvider",Se=(e,t,s,n)=>{const o=new Set;return t.forEach(i=>{const r=e.get(i),a=n?n(i):r?.disabled;if(!r||a)return;const g=r.modifier?.keys,u=r.modifier?.method;if(!g||!u||g.length===0){o.add(i);return}g[u](l=>s.value.has(l))&&o.add(i)}),o};let Le="",Ye="",je="";const E=e=>e.value?e.value instanceof HTMLElement?e.value:e.value.$el:null,O=(e,t)=>e!==t&&e.contains(t),Xe=(e,t)=>!(e.right<t.left||e.left>t.right||e.bottom<t.top||e.top>t.bottom),ae=()=>{const e=document.body;Le=e.style.userSelect,e.style.userSelect="none",window.addEventListener("contextmenu",A),window.addEventListener("selectstart",A),window.addEventListener("touchstart",A),window.addEventListener("touchmove",A)},le=()=>{const e=document.body;e.style.userSelect=Le,e.style.touchAction=Ye,e.style.overscrollBehavior=je,window.removeEventListener("contextmenu",A),window.removeEventListener("selectstart",A),window.removeEventListener("touchstart",A),window.removeEventListener("touchmove",A)},A=e=>e.preventDefault(),me=(e,t)=>{if(t.entities.draggableMap.get(e)?.disabled)return!0;for(const n of t.entities.visibleDraggableSet)if(t.entities.draggableMap.get(n)?.disabled&&O(n,e))return!0;return!1},Z=(e,t)=>{if(t.entities.droppableMap.get(e)?.disabled)return!0;for(const n of t.entities.visibleDroppableSet)if(t.entities.droppableMap.get(n)?.disabled&&O(n,e))return!0;return!1},he=(e,t)=>{if(!e.length||!t.length)return!0;const s=new Set(t);return e.some(n=>s.has(n))};function Ve(e,t,s,n){const o=new Set;for(const a of t.keys()){const g=s.get(a);for(const u of g?.groups??[])o.add(u)}const i=[...o],r=new Set;for(const a of e){const u=n.get(a)?.groups??[];he(i,u)&&r.add(a)}return r}function $e(e,t,s){const n=new Set;for(const r of t.keys()){const a=s.get(r);for(const g of a?.groups??[])n.add(g)}const o=[...n],i=new Set;for(const r of e){const g=s.get(r)?.groups??[];he(o,g)&&i.add(r)}return i}const se=e=>{const t=new IntersectionObserver(s=>{s.forEach(n=>{const o=n.target;e[n.isIntersecting?"add":"delete"](o)})});return{observe:s=>t.observe(s),unobserve:s=>t.unobserve(s),disconnect:()=>t.disconnect()}},We=e=>{const t=new ResizeObserver(s=>{const n=s[0];if(!n)return;const{width:o,height:i}=n.contentRect;e.value={width:o,height:i}});return{observe:s=>t.observe(s),unobserve:s=>t.unobserve(s),disconnect:()=>t.disconnect()}},qe=e=>{const t=d.ref(null),s=We(t),n=d.watch(e,i=>{s.disconnect(),i&&s.observe(i)},{immediate:!0});return{overlaySize:t,overlaySizeObserver:{disconnect:()=>{n(),s.disconnect()}}}};function ce(e,t=0,s=0){return{start:{x:e.clientX,y:e.clientY},current:{x:e.clientX,y:e.clientY},offset:{x:t,y:s}}}function Pe(e,t){const s=t.getBoundingClientRect(),n=s.width>0?(e.clientX-s.left)/s.width:.5,o=s.height>0?(e.clientY-s.top)/s.height:.5;return{x:n,y:o}}function Re(e,t){return{...t,initialHTML:e.innerHTML,initialRect:e.getBoundingClientRect(),initialOuterHTML:e.outerHTML}}function Je(e,t,s){e.forEach(n=>{const o=t.get(n);s.set(n,Re(n,o))}),e.clear()}function Qe(e,t,s){s.clear();const n=t.get(e);s.set(e,Re(e,n))}function J(e){e.entities.initiatingDraggable&&(e.state.value="dragging",et(e.entities.initiatingDraggable,e.entities.selectedSet,e.entities.draggableMap,e.entities.draggingMap))}function et(e,t,s,n){t.has(e)?Je(t,s,n):(t.clear(),Qe(e,s,n))}function Be(e,t,s,n){if(n||!s)return!0;const o=e.closest(s);return o?t.contains(o):!1}function tt(e,t){if(!e||!t)return 1;const s=Math.abs(e.current.x-e.start.x),n=Math.abs(e.current.y-e.start.y);if(typeof t=="number"){const u=Math.sqrt(s*s+n*n);return Math.min(u/t,1)}const{x:o=0,y:i=0,condition:r="any"}=t;if(o===0&&i===0)return 1;const a=o>0?Math.min(s/o,1):1,g=i>0?Math.min(n/i,1):1;return r==="both"?Math.min(a,g):Math.max(a,g)}function Te(e,t,s){if(!s)return!0;const n=s.distance!=null,o=s.delay!=null;return!n&&!o?!0:n&&!o?e>=1:!n&&o?t>=1:(s.condition??"both")==="both"?e>=1&&t>=1:e>=1||t>=1}function nt(e){if(e.state.value!=="activating"||!e.entities.initiatingDraggable)return!1;const t=e.entities.draggableMap.get(e.entities.initiatingDraggable);return Te(e.distanceProgress.value,e.delay.progress,t?.activation)?(J(e),!0):!1}function st(e,t){let s=null;const n=()=>{if(e.state.value!=="activating"||!e.entities.initiatingDraggable){s=null;return}const o=e.entities.draggableMap.get(e.entities.initiatingDraggable),i=o?.activation?.delay;if(!i){s=null;return}e.delay.progress=Math.min((Date.now()-e.delay.startTime)/(i*1e3),1),Te(e.distanceProgress.value,e.delay.progress,o?.activation)?(t(),s=null):s=requestAnimationFrame(n)};return s=requestAnimationFrame(n),{cancel:()=>{s!==null&&(cancelAnimationFrame(s),s=null)}}}function ot(e,t){const s=e.closest(N.CONSTRAINT_AREA);return!s||!t.has(s)?null:{element:s,entity:t.get(s)}}function rt(e,t,s,n){return s==="x"?{x:e,y:n.top}:s==="y"?{x:n.left,y:t}:{x:e,y:t}}function it(e,t,s,n,o){let i=e,r=t;return s!=="y"&&(i=Math.max(n.left,Math.min(n.right-o.width,e))),s!=="x"&&(r=Math.max(n.top,Math.min(n.bottom-o.height,t))),{x:i,y:r}}function at(e,t,s,n,o){if(!e||!t)return{x:0,y:0};const i=t.getBoundingClientRect(),r=i.width||o?.width||0,a=i.height||o?.height||0;let g=e.current.x-r*e.offset.x,u=e.current.y-a*e.offset.y;if(!s)return{x:g,y:u};const c=ot(s,n);if(!c)return{x:g,y:u};const{element:l,entity:f}=c,m=l.getBoundingClientRect(),h=s.getBoundingClientRect(),p=rt(g,u,f.axis||"both",h);return f.restrictToArea?it(p.x,p.y,f.axis||"both",m,i):p}const j={forDrag:["Enter","Space"],forCancel:["Escape"],forDrop:["Enter","Space"],forMove:["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","KeyW","KeyA","KeyS","KeyD"],forMoveFaster:["ShiftLeft","ShiftRight"]};function lt(e,t){const s=d.shallowRef(),n=d.ref(),i={keys:{pressedKeys:d.ref(new Set),forDrag:[...j.forDrag],forCancel:[...j.forCancel],forDrop:[...j.forDrop],forMove:[...j.forMove],forMoveFaster:[...j.forMoveFaster]},step:8,moveFaster:4},r=d.reactive({draggableMap:new Map,droppableMap:new Map,selectableAreaMap:new Map,constraintsAreaMap:new Map,initiatingDraggable:void 0,selectingArea:void 0,draggingMap:new Map,selectedSet:new Set,allowedDroppableSet:d.computed(()=>s.value?Ve(r.visibleDroppableSet,r.draggingMap,r.draggableMap,r.droppableMap):new Set),allowedDraggableSet:d.computed(()=>s.value?$e(r.visibleDraggableSet,r.draggingMap,r.draggableMap):new Set),modifiersSelectableAreaSet:d.computed(()=>Se(r.selectableAreaMap,r.visibleSelectableAreaSet,i.keys.pressedKeys)),modifiersDraggableSet:d.computed(()=>Se(r.draggableMap,r.visibleDraggableSet,i.keys.pressedKeys,b=>me(b,{entities:r}))),visibleDraggableSet:new Set,visibleDroppableSet:new Set,visibleSelectableAreaSet:new Set}),a=d.reactive({draggable:new Map,droppable:new Map}),g={throttle:d.shallowRef(0)},u=d.reactive({x:window.scrollX,y:window.scrollY}),c=d.reactive({progress:0,startTime:0}),l=d.computed(()=>{if(!n.value||!r.initiatingDraggable)return 0;const b=r.draggableMap.get(r.initiatingDraggable)?.activation?.distance;return b?tt(n.value,b):1}),f=se(r.visibleDraggableSet),m=se(r.visibleDroppableSet),h=se(r.visibleSelectableAreaSet),{overlaySize:p,overlaySizeObserver:v}=qe(e),M=d.ref(),w=d.computed(()=>{const D=r.initiatingDraggable;return at(n.value,e.value,D||null,r.constraintsAreaMap,p.value)}),x=d.computed({get:()=>t?.overlayTo,set:D=>x.value=D}),G=d.computed(()=>t?.autoScrollViewport);return{state:s,pointer:n,entities:r,keyboard:i,scrollPosition:u,delay:c,distanceProgress:l,hovered:a,collision:g,overlay:{size:p,position:w,render:M,ref:e,to:x},lib:{draggableObserver:f,droppableObserver:m,selectableAreaObserver:h,overlaySizeObserver:v,rectCache:new Map},autoScrollViewport:G}}const Q=e=>{const t=e.hovered.draggable.keys().next().value;if(t){const n=e.entities.draggableMap.get(t);n&&(n.hoveredPlacement=void 0)}const s=e.hovered.droppable.keys().next().value;if(s){const n=e.entities.droppableMap.get(s);n&&(n.hoveredPlacement=void 0)}e.lib.rectCache.clear(),e.pointer.value=void 0,e.state.value=void 0,e.entities.selectingArea=void 0,e.entities.initiatingDraggable=void 0,e.delay.progress=0,e.delay.startTime=0,e.entities.draggingMap.clear(),e.hovered.draggable.clear(),e.hovered.droppable.clear()};function T(e,t,s){const n=Math.max(0,Math.min(t,e.length));return[...e.slice(0,n),...s,...e.slice(n)]}function pe(e,t,s=1){const n=Math.max(0,Math.min(t,e.length-1)),o=Math.max(0,Math.min(s,e.length-n));return[...e.slice(0,n),...e.slice(n+o)]}function Y(e,t){const s=[...new Set(t)].filter(o=>o>=0&&o<e.length).sort((o,i)=>i-o);let n=e;for(const o of s)n=pe(n,o,1);return n}function ze(e,t,s){if(t===s||t<0||s<0||t>=e.length||s>=e.length)return e;const n=[...e];return[n[t],n[s]]=[n[s],n[t]],n}const z={getInsertSide(e,t){return e?t==="vertical"?e.top&&!e.bottom?"before":e.bottom&&!e.top?"after":e.top?"before":null:e.left&&!e.right?"before":e.right&&!e.left?"after":e.left?"before":null:null},isAtZoneStart(e,t){return z.getInsertSide(e,t)==="before"&&!e?.center},isAtZoneEnd(e,t){return z.getInsertSide(e,t)==="after"&&!e?.center}};function Oe(e,t){const{draggedItems:s,dropZone:n,hoveredDraggable:o}=e;if(!s.length)return null;const i=o?.placement.center===!0&&n!=null&&n.items!==o.items,r=i?n.items:o?.items??n?.items;if(!r)return null;const a=s[0].items,g=s.map(f=>f.index),u=r.length;let c,l;if(o&&!i){const f=o.items===a&&g.includes(o.index);if(f&&s.length===1){const m=z.isAtZoneStart(n?.placement,t);c=m?0:u,l=m?"prepend":"append"}else{if(f)return null;{const m=z.getInsertSide(o.placement,t),h=o.index;m==="before"?(c=Math.max(0,h),l="insert"):m==="after"?(c=Math.min(u,h+1),l="insert"):(c=u,l="append")}}}else{if(!n)return null;const f=z.isAtZoneStart(n.placement,t);c=f?0:u,l=f?"prepend":"append"}return{targetIndex:c,mode:l,targetArr:r}}function ct(e,t="vertical"){const{draggedItems:s}=e;if(!s.length)return null;const n=Oe(e,t);if(!n)return null;const{targetArr:o,mode:i}=n;let{targetIndex:r}=n;const a=s.map(l=>l.index),g=s.map(l=>l.item),u=s[0].items;if(u===o){const l=a.filter(m=>m<r).length;r=Math.max(0,r-l);const f=T(Y(u,a),r,g);return{sourceItems:f,targetItems:f,draggedItems:g,sourceIndexes:a,targetIndex:r,mode:i,sameList:!0}}else{const l=Y(u,a),f=T(o,r,g);return{sourceItems:l,targetItems:f,draggedItems:g,sourceIndexes:a,targetIndex:r,mode:i,sameList:!1}}}function ut(e){const{draggedItems:t,hoveredDraggable:s}=e;if(!t.length||!s)return null;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;if(u&&n.includes(o))return null;if(t.length===1){const c=n[0];if(u){const l=ze(a,c,o);return{sourceItems:l,targetItems:l,sourceIndexes:n,targetIndex:o,sameList:!0}}else{const l=[...a],f=[...g];return l[c]=g[o],f[o]=a[c],{sourceItems:l,targetItems:f,sourceIndexes:n,targetIndex:o,sameList:!1}}}else{const c=Math.min(...n);if(u){const l=n.filter(M=>M<o).length,f=Math.max(0,o-l),m=n.filter(M=>M<c).length,h=Math.max(0,c-m);let p=Y(a,n);p=T(p,f,i);const v=h>=f?h+i.length:h;return p=T(p,v,[r]),{sourceItems:p,targetItems:p,sourceIndexes:n,targetIndex:f,sameList:!0}}else{const l=n.filter(p=>p<c).length,f=Math.max(0,c-l);let m=Y(a,n);m=T(m,f,[r]);let h=pe(g,o);return h=T(h,o,i),{sourceItems:m,targetItems:h,sourceIndexes:n,targetIndex:o,sameList:!1}}}}function gt(e,t="vertical"){const{draggedItems:s}=e;if(!s.length)return null;const n=Oe(e,t);if(!n)return null;const{targetArr:o,targetIndex:i,mode:r}=n,a=s.map(u=>u.item);return{targetItems:T(o,i,a),copiedItems:a,targetIndex:i,mode:r}}function ft(e){const{draggedItems:t}=e;if(!t.length)return null;const s=t.map(r=>r.index),n=t.map(r=>r.item),o=t[0].items;return{sourceItems:Y(o,s),removedItems:n,sourceIndexes:s}}function dt(e){return{insertAt:T,removeAt:pe,removeIndexes:Y,swapAt:ze,getInsertSide:(t,s)=>z.getInsertSide(t,s),isAtZoneStart:(t,s)=>z.isAtZoneStart(t,s),isAtZoneEnd:(t,s)=>z.isAtZoneEnd(t,s),suggestSort:t=>ct(e,t),suggestSwap:()=>ut(e),suggestCopy:t=>gt(e,t),suggestRemove:()=>ft(e)}}const _=e=>e.keys().next().value,mt=e=>e.target.closest(N.DRAGGABLE);function ht(e){const t=e.entities.initiatingDraggable;if(!t)return[];const n=(e.entities.draggingMap.get(t)??e.entities.draggableMap.get(t))?.payload;if(!n)return[];const o=n();if(!Array.isArray(o)||o.length<2)return[];const[i,r,a]=o,g=Number(i),u=r,c=new Map;return c.set(g,{index:g,item:u[g],items:u,dropData:a}),e.entities.draggingMap.forEach((l,f)=>{const h=e.entities.draggableMap.get(f)?.payload;if(!h)return;const p=h();if(!Array.isArray(p)||p.length<2)return;const[v,M,w]=p;if(M!==u)return;const x=Number(v);c.has(x)||c.set(x,{index:x,item:M[x],items:u,dropData:w})}),[...c.values()].sort((l,f)=>l.index-f.index)}const R=(e,t)=>{const s=ht(e);let n,o;if(t){const r=e.entities.droppableMap.get(t)?.payload;if(r){const u=r();Array.isArray(u)&&u.length>=1&&(n={items:Array.isArray(u[0])?u[0]:[],userData:u[1],placement:e.hovered.droppable.get(t)})}const a=_(e.hovered.draggable);if(a&&(a===t||t.contains(a))&&a){const c=e.entities.draggableMap.get(a)?.payload,l=e.hovered.draggable.get(a);if(c){const f=c();if(Array.isArray(f)&&f.length>=2){const[m,h,p]=f,v=Number(m);o={element:a,placement:l??{top:!1,right:!1,bottom:!1,left:!1,center:!1},index:v,item:h[v],items:h,dropData:p}}}}}return{draggedItems:s,dropZone:n,hoveredDraggable:o,provider:e,helpers:dt({draggedItems:s,dropZone:n,hoveredDraggable:o})}},U=(e,t,s)=>{if(!t)return;const n=e.entities.draggingMap.get(t)??e.entities.draggableMap.get(t);!n||n.disabled||n.events?.[s]?.(R(e))},P=(e,t)=>{const s=R(e);e.entities.draggingMap.forEach(n=>{n.disabled||n.events?.[t]?.(s)})},pt=(e,t,s)=>{if(t!==s){if(t&&!Z(t,e)){const n=R(e,t);e.entities.droppableMap.get(t)?.events?.onLeave?.(n)}if(s&&!Z(s,e)){const n=R(e,s);e.entities.droppableMap.get(s)?.events?.onEnter?.(n)}}},yt=(e,t,s)=>{if(t!==s){const n=R(e);if(t){const o=e.entities.draggableMap.get(t);o&&!o.disabled&&o.events?.onLeave?.(n)}if(s){const o=e.entities.draggableMap.get(s);o&&!o.disabled&&o.events?.onHover?.(n)}}},oe=(e,t,s)=>{const n=mt(t);!n||!e.entities.draggingMap.has(n)||e.entities.draggingMap.get(n)?.events?.[s]?.(R(e))},bt=(e,t)=>{const s=_(t.droppable);s&&!Z(s,e)&&e.entities.droppableMap.get(s)?.events?.onLeave?.(R(e,s))},_e=(e,t)=>{const s=_(t.droppable);s&&!Z(s,e)&&e.entities.droppableMap.get(s)?.events?.onLeave?.(R(e,s))};function St(e){return e.parentElement?.closest(N.SELECT_AREA)??null}const Dt=(e,t,s)=>{if(!s)return{};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);return{left:`${o}px`,top:`${i}px`,width:`${g}px`,height:`${u}px`,position:"fixed",pointerEvents:"none",border:"1px solid #3b82f6",backgroundColor:"#3b82f61a"}},Mt=e=>{if(!e.pointer.value||!e.entities.selectingArea)return;const{selectingArea:t}=e.entities,s=vt(e.pointer.value.start,e.pointer.value.current),n=e.entities.selectableAreaMap.get(t)?.groups??[],o=e.lib.rectCache;e.entities.visibleDraggableSet.forEach(i=>{if(i===t||!t.contains(i))return;const r=St(i);if(r&&r!==t){e.entities.selectedSet.delete(i);return}if(me(i,e)){e.entities.selectedSet.delete(i);return}const g=e.entities.draggableMap.get(i)?.groups??[];if(!he(n,g)){e.entities.selectedSet.delete(i);return}let u=o.get(i);u||(u=i.getBoundingClientRect(),o.set(i,u)),Xe(s,u)?e.entities.selectedSet.add(i):e.entities.selectedSet.delete(i)})},vt=(e,t)=>{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;return new DOMRect(s,n,r,a)},wt=(e,t,s=5)=>{const n=s/2;return{left:e-n,top:t-n,width:s,height:s}},xt=e=>{const t=e.pointer.value?.current,s=t?.x??0,n=t?.y??0;return wt(s,n,5)},H=(e,t,s)=>{const n=e.left+e.width/2,o=e.top+e.height/2;if(s){const a=s.top??0,g=s.right??0,u=s.bottom??0,c=s.left??0,l=t.left+c,f=t.right-g,m=t.top+a,h=t.bottom-u;if(l<f&&m<h&&n>=l&&n<=f&&o>=m&&o<=h)return{top:!1,right:!1,bottom:!1,left:!1,center:!0}}const i=t.left+t.width/2,r=t.top+t.height/2;return{top:o<=r,bottom:o>r,left:n<=i,right:n>i,center:!1}},Et=e=>({x:e.left+e.width/2,y:e.top+e.height/2}),De=(e,t)=>{const s=Et(t);return Math.hypot(e.x-s.x,e.y-s.y)};function At(e,t){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}function $(e,t){At(e.hoveredPlacement,t)||(e.hoveredPlacement=t)}const Ct=(e,t)=>e.find(s=>s!==t&&O(t,s)),V=(e,t,s)=>{const n=_(t.droppable),o=_(t.draggable);o&&t.draggable.delete(o),n&&t.droppable.delete(n);const i=xt(e),r=s.zones[0],a=s.elements[0];if(r&&a&&r===a&&e.entities.droppableMap.has(r)&&r){const l=r.getBoundingClientRect(),f=e.entities.draggableMap.get(r)?.placementMargins,m=H(i,l,f);if(m.center){t.droppable.set(r,m);const h=Ct(s.elements,r);if(h){const p=h.getBoundingClientRect();t.draggable.set(h,H(i,p,void 0))}}else t.draggable.set(a,m)}else{if(r){const l=r.getBoundingClientRect();t.droppable.set(r,H(i,l))}if(a)if(r)if(O(r,a)){const l=a.getBoundingClientRect(),f=e.entities.draggableMap.get(a)?.placementMargins;t.draggable.set(a,H(i,l,f))}else{const l=e.pointer.value?.current??{x:0,y:0},f=r.getBoundingClientRect(),m=a.getBoundingClientRect(),h=De(l,f);if(De(l,m)<h){t.droppable.clear();const v=e.entities.draggableMap.get(a)?.placementMargins;t.draggable.set(a,H(i,m,v))}}else{const l=a.getBoundingClientRect(),f=e.entities.draggableMap.get(a)?.placementMargins;t.draggable.set(a,H(i,l,f))}}const u=_(t.droppable),c=_(t.draggable);if(o&&o!==c){const l=e.entities.draggableMap.get(o);l&&$(l,void 0)}if(n&&n!==u){const l=e.entities.droppableMap.get(n);l&&$(l,void 0)}if(c){const l=e.entities.draggableMap.get(c);l&&$(l,t.draggable.get(c))}if(u){const l=e.entities.droppableMap.get(u);l&&$(l,t.droppable.get(u))}pt(e,n,u),yt(e,o,c)},Me=(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,K=e=>{if(!e)return{x:0,y:0,width:0,height:0,top:0,left:0,right:0,bottom:0};const t=e.getBoundingClientRect();return{x:t.x,y:t.y,width:t.width,height:t.height,top:t.top,left:t.left,right:t.right,bottom:t.bottom}},X=e=>({x:e.x+e.width/2,y:e.y+e.height/2}),kt=(e,t)=>Math.hypot(t.x-e.x,t.y-e.y),ue=(e,t)=>{const s=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),n=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y)),o=s*n,i=e.width*e.height,r=t.width*t.height;return i===0||r===0?0:(o/i*100+o/r*100)/2},ge=(e,t,s)=>t>=e.x&&t<=e.x+e.width&&s>=e.y&&s<=e.y+e.height,It=e=>e.overlay.ref?.value??null,Fe=e=>{const t=e.overlay.position?.value??{x:0,y:0},{x:s,y:n}=t,o=e.overlay.size?.value;let i,r;if(o)i=o.width,r=o.height;else{const a=e.overlay.ref?.value?.getBoundingClientRect();i=a?.width??0,r=a?.height??0}return{x:s,y:n,width:i,height:r,top:n,left:s,right:s+i,bottom:n+r}},Lt=e=>e.entities.allowedDraggableSet,Pt=e=>e.entities.allowedDroppableSet,Rt=(e,t)=>!t.entities.draggingMap.has(e),Bt=(e,t)=>![...t.entities.draggingMap.keys()].some(s=>O(s,e)),Tt=(e,t)=>t.entities.draggableMap.has(e)?!me(e,t):t.entities.droppableMap.has(e)?!Z(e,t):!0,ee=(e,t)=>Rt(e,t)&&Bt(e,t)&&Tt(e,t),ve=10;function W(e,t){return Math.hypot(t.x-(e.x+e.width/2),t.y-(e.y+e.height/2))}function we(e){return[...e].sort((t,s)=>{const n=e.filter(i=>i!==t&&O(i,t)).length;return e.filter(i=>i!==s&&O(i,s)).length-n})}const te=e=>{if(!It(e))return{elements:[],zones:[]};const s=Fe(e),n=e.pointer.value?.current??{x:0,y:0},o=[...Lt(e)].filter(c=>ee(c,e)),i=[...Pt(e)].filter(c=>ee(c,e)),r=o.filter(c=>ge(K(c),n.x,n.y)),a=i.filter(c=>ge(K(c),n.x,n.y));if(r.length>0||a.length>0)return{elements:we(r),zones:we(a)};const g=o.map(c=>({n:c,box:K(c)})).filter(({box:c})=>Me(c,s)&&ue(c,s)>=ve).sort((c,l)=>W(c.box,n)-W(l.box,n)).map(({n:c})=>c),u=i.map(c=>({n:c,box:K(c)})).filter(({box:c})=>Me(c,s)&&ue(c,s)>=ve).sort((c,l)=>W(c.box,n)-W(l.box,n)).map(({n:c})=>c);return{elements:g,zones:u}};function zt(e){globalThis.onmessage=t=>{const{callId:s,data:n}=t.data;try{const o=e(n);globalThis.postMessage({callId:s,ok:!0,result:o})}catch(o){globalThis.postMessage({callId:s,ok:!1,error:String(o)})}}}function Ot(e,t){return[t.map(n=>n.toString()).join(`
|
|
2
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("vue"),F={SELECT_AREA:"data-dnd-kit-select-area",DRAGGABLE:"data-dnd-kit-draggable",DROPPABLE:"data-dnd-kit-droppable",CONSTRAINT_AREA:"data-dnd-kit-constraint-area"},N={SELECT_AREA:`[${F.SELECT_AREA}]`,DRAGGABLE:`[${F.DRAGGABLE}]`,CONSTRAINT_AREA:`[${F.CONSTRAINT_AREA}]`},de="VueDnDKitProvider",Se=(e,t,s,n)=>{const o=new Set;return t.forEach(i=>{const r=e.get(i),a=n?n(i):r?.disabled;if(!r||a)return;const g=r.modifier?.keys,u=r.modifier?.method;if(!g||!u||g.length===0){o.add(i);return}g[u](l=>s.value.has(l))&&o.add(i)}),o};let Le="",Ye="",je="";const E=e=>e.value?e.value instanceof HTMLElement?e.value:e.value.$el:null,O=(e,t)=>e!==t&&e.contains(t),Xe=(e,t)=>!(e.right<t.left||e.left>t.right||e.bottom<t.top||e.top>t.bottom),ae=()=>{const e=document.body;Le=e.style.userSelect,e.style.userSelect="none",window.addEventListener("contextmenu",A),window.addEventListener("selectstart",A),window.addEventListener("touchstart",A),window.addEventListener("touchmove",A)},le=()=>{const e=document.body;e.style.userSelect=Le,e.style.touchAction=Ye,e.style.overscrollBehavior=je,window.removeEventListener("contextmenu",A),window.removeEventListener("selectstart",A),window.removeEventListener("touchstart",A),window.removeEventListener("touchmove",A)},A=e=>e.preventDefault(),me=(e,t)=>{if(t.entities.draggableMap.get(e)?.disabled)return!0;for(const n of t.entities.visibleDraggableSet)if(t.entities.draggableMap.get(n)?.disabled&&O(n,e))return!0;return!1},Z=(e,t)=>{if(t.entities.droppableMap.get(e)?.disabled)return!0;for(const n of t.entities.visibleDroppableSet)if(t.entities.droppableMap.get(n)?.disabled&&O(n,e))return!0;return!1},he=(e,t)=>{if(!e.length||!t.length)return!0;const s=new Set(t);return e.some(n=>s.has(n))};function $e(e,t,s,n){const o=new Set;for(const a of t.keys()){const g=s.get(a);for(const u of g?.groups??[])o.add(u)}const i=[...o],r=new Set;for(const a of e){const u=n.get(a)?.groups??[];he(i,u)&&r.add(a)}return r}function Ve(e,t,s){const n=new Set;for(const r of t.keys()){const a=s.get(r);for(const g of a?.groups??[])n.add(g)}const o=[...n],i=new Set;for(const r of e){const g=s.get(r)?.groups??[];he(o,g)&&i.add(r)}return i}const se=e=>{const t=new IntersectionObserver(s=>{s.forEach(n=>{const o=n.target;e[n.isIntersecting?"add":"delete"](o)})});return{observe:s=>t.observe(s),unobserve:s=>t.unobserve(s),disconnect:()=>t.disconnect()}},We=e=>{const t=new ResizeObserver(s=>{const n=s[0];if(!n)return;const{width:o,height:i}=n.contentRect;e.value={width:o,height:i}});return{observe:s=>t.observe(s),unobserve:s=>t.unobserve(s),disconnect:()=>t.disconnect()}},qe=e=>{const t=d.ref(null),s=We(t),n=d.watch(e,i=>{s.disconnect(),i&&s.observe(i)},{immediate:!0});return{overlaySize:t,overlaySizeObserver:{disconnect:()=>{n(),s.disconnect()}}}};function ce(e,t=0,s=0){return{start:{x:e.clientX,y:e.clientY},current:{x:e.clientX,y:e.clientY},offset:{x:t,y:s}}}function Pe(e,t){const s=t.getBoundingClientRect(),n=s.width>0?(e.clientX-s.left)/s.width:.5,o=s.height>0?(e.clientY-s.top)/s.height:.5;return{x:n,y:o}}function Re(e,t){return{...t,initialHTML:e.innerHTML,initialRect:e.getBoundingClientRect(),initialOuterHTML:e.outerHTML}}function Je(e,t,s){e.forEach(n=>{const o=t.get(n);s.set(n,Re(n,o))}),e.clear()}function Qe(e,t,s){s.clear();const n=t.get(e);s.set(e,Re(e,n))}function J(e){e.entities.initiatingDraggable&&(e.state.value="dragging",et(e.entities.initiatingDraggable,e.entities.selectedSet,e.entities.draggableMap,e.entities.draggingMap))}function et(e,t,s,n){t.has(e)?Je(t,s,n):(t.clear(),Qe(e,s,n))}function Be(e,t,s,n){if(n||!s)return!0;const o=e.closest(s);return o?t.contains(o):!1}function tt(e,t){if(!e||!t)return 1;const s=Math.abs(e.current.x-e.start.x),n=Math.abs(e.current.y-e.start.y);if(typeof t=="number"){const u=Math.sqrt(s*s+n*n);return Math.min(u/t,1)}const{x:o=0,y:i=0,condition:r="any"}=t;if(o===0&&i===0)return 1;const a=o>0?Math.min(s/o,1):1,g=i>0?Math.min(n/i,1):1;return r==="both"?Math.min(a,g):Math.max(a,g)}function Te(e,t,s){if(!s)return!0;const n=s.distance!=null,o=s.delay!=null;return!n&&!o?!0:n&&!o?e>=1:!n&&o?t>=1:(s.condition??"both")==="both"?e>=1&&t>=1:e>=1||t>=1}function nt(e){if(e.state.value!=="activating"||!e.entities.initiatingDraggable)return!1;const t=e.entities.draggableMap.get(e.entities.initiatingDraggable);return Te(e.distanceProgress.value,e.delay.progress,t?.activation)?(J(e),!0):!1}function st(e,t){let s=null;const n=()=>{if(e.state.value!=="activating"||!e.entities.initiatingDraggable){s=null;return}const o=e.entities.draggableMap.get(e.entities.initiatingDraggable),i=o?.activation?.delay;if(!i){s=null;return}e.delay.progress=Math.min((Date.now()-e.delay.startTime)/(i*1e3),1),Te(e.distanceProgress.value,e.delay.progress,o?.activation)?(t(),s=null):s=requestAnimationFrame(n)};return s=requestAnimationFrame(n),{cancel:()=>{s!==null&&(cancelAnimationFrame(s),s=null)}}}function ot(e,t){const s=e.closest(N.CONSTRAINT_AREA);return!s||!t.has(s)?null:{element:s,entity:t.get(s)}}function rt(e,t,s,n){return s==="x"?{x:e,y:n.top}:s==="y"?{x:n.left,y:t}:{x:e,y:t}}function it(e,t,s,n,o){let i=e,r=t;return s!=="y"&&(i=Math.max(n.left,Math.min(n.right-o.width,e))),s!=="x"&&(r=Math.max(n.top,Math.min(n.bottom-o.height,t))),{x:i,y:r}}function at(e,t,s,n,o){if(!e||!t)return{x:0,y:0};const i=t.getBoundingClientRect(),r=i.width||o?.width||0,a=i.height||o?.height||0;let g=e.current.x-r*e.offset.x,u=e.current.y-a*e.offset.y;if(!s)return{x:g,y:u};const c=ot(s,n);if(!c)return{x:g,y:u};const{element:l,entity:f}=c,m=l.getBoundingClientRect(),h=s.getBoundingClientRect(),p=rt(g,u,f.axis||"both",h);return f.restrictToArea?it(p.x,p.y,f.axis||"both",m,i):p}const j={forDrag:["Enter","Space"],forCancel:["Escape"],forDrop:["Enter","Space"],forMove:["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","KeyW","KeyA","KeyS","KeyD"],forMoveFaster:["ShiftLeft","ShiftRight"]};function lt(e,t){const s=d.shallowRef(),n=d.ref(),i={keys:{pressedKeys:d.ref(new Set),forDrag:[...j.forDrag],forCancel:[...j.forCancel],forDrop:[...j.forDrop],forMove:[...j.forMove],forMoveFaster:[...j.forMoveFaster]},step:8,moveFaster:4},r=d.reactive({draggableMap:new Map,droppableMap:new Map,selectableAreaMap:new Map,constraintsAreaMap:new Map,initiatingDraggable:void 0,selectingArea:void 0,draggingMap:new Map,selectedSet:new Set,allowedDroppableSet:d.computed(()=>s.value?$e(r.visibleDroppableSet,r.draggingMap,r.draggableMap,r.droppableMap):new Set),allowedDraggableSet:d.computed(()=>s.value?Ve(r.visibleDraggableSet,r.draggingMap,r.draggableMap):new Set),modifiersSelectableAreaSet:d.computed(()=>Se(r.selectableAreaMap,r.visibleSelectableAreaSet,i.keys.pressedKeys)),modifiersDraggableSet:d.computed(()=>Se(r.draggableMap,r.visibleDraggableSet,i.keys.pressedKeys,b=>me(b,{entities:r}))),visibleDraggableSet:new Set,visibleDroppableSet:new Set,visibleSelectableAreaSet:new Set}),a=d.reactive({draggable:new Map,droppable:new Map}),g={throttle:d.shallowRef(0)},u=d.reactive({x:window.scrollX,y:window.scrollY}),c=d.reactive({progress:0,startTime:0}),l=d.computed(()=>{if(!n.value||!r.initiatingDraggable)return 0;const b=r.draggableMap.get(r.initiatingDraggable)?.activation?.distance;return b?tt(n.value,b):1}),f=se(r.visibleDraggableSet),m=se(r.visibleDroppableSet),h=se(r.visibleSelectableAreaSet),{overlaySize:p,overlaySizeObserver:v}=qe(e),M=d.ref(),w=d.computed(()=>{const D=r.initiatingDraggable;return at(n.value,e.value,D||null,r.constraintsAreaMap,p.value)}),x=d.computed({get:()=>t?.overlayTo,set:D=>x.value=D}),G=d.computed(()=>t?.autoScrollViewport);return{state:s,pointer:n,entities:r,keyboard:i,scrollPosition:u,delay:c,distanceProgress:l,hovered:a,collision:g,overlay:{size:p,position:w,render:M,ref:e,to:x},lib:{draggableObserver:f,droppableObserver:m,selectableAreaObserver:h,overlaySizeObserver:v,rectCache:new Map},autoScrollViewport:G}}const Q=e=>{const t=e.hovered.draggable.keys().next().value;if(t){const n=e.entities.draggableMap.get(t);n&&(n.hoveredPlacement=void 0)}const s=e.hovered.droppable.keys().next().value;if(s){const n=e.entities.droppableMap.get(s);n&&(n.hoveredPlacement=void 0)}e.lib.rectCache.clear(),e.pointer.value=void 0,e.state.value=void 0,e.entities.selectingArea=void 0,e.entities.initiatingDraggable=void 0,e.delay.progress=0,e.delay.startTime=0,e.entities.draggingMap.clear(),e.hovered.draggable.clear(),e.hovered.droppable.clear()};function T(e,t,s){const n=Math.max(0,Math.min(t,e.length));return[...e.slice(0,n),...s,...e.slice(n)]}function pe(e,t,s=1){const n=Math.max(0,Math.min(t,e.length-1)),o=Math.max(0,Math.min(s,e.length-n));return[...e.slice(0,n),...e.slice(n+o)]}function Y(e,t){const s=[...new Set(t)].filter(o=>o>=0&&o<e.length).sort((o,i)=>i-o);let n=e;for(const o of s)n=pe(n,o,1);return n}function ze(e,t,s){if(t===s||t<0||s<0||t>=e.length||s>=e.length)return e;const n=[...e];return[n[t],n[s]]=[n[s],n[t]],n}const z={getInsertSide(e,t){return e?t==="vertical"?e.top&&!e.bottom?"before":e.bottom&&!e.top?"after":e.top?"before":null:e.left&&!e.right?"before":e.right&&!e.left?"after":e.left?"before":null:null},isAtZoneStart(e,t){return z.getInsertSide(e,t)==="before"&&!e?.center},isAtZoneEnd(e,t){return z.getInsertSide(e,t)==="after"&&!e?.center}};function Oe(e,t){const{draggedItems:s,dropZone:n,hoveredDraggable:o}=e;if(!s.length)return null;const i=o?.placement.center===!0&&n!=null&&n.items!==o.items,r=i?n.items:o?.items??n?.items;if(!r)return null;const a=s[0].items,g=s.map(f=>f.index),u=r.length;let c,l;if(o&&!i){const f=o.items===a&&g.includes(o.index);if(f&&s.length===1){const m=z.isAtZoneStart(n?.placement,t);c=m?0:u,l=m?"prepend":"append"}else{if(f)return null;{const m=z.getInsertSide(o.placement,t),h=o.index;m==="before"?(c=Math.max(0,h),l="insert"):m==="after"?(c=Math.min(u,h+1),l="insert"):(c=u,l="append")}}}else{if(!n)return null;const f=z.isAtZoneStart(n.placement,t);c=f?0:u,l=f?"prepend":"append"}return{targetIndex:c,mode:l,targetArr:r}}function ct(e,t="vertical"){const{draggedItems:s}=e;if(!s.length)return null;const n=Oe(e,t);if(!n)return null;const{targetArr:o,mode:i}=n;let{targetIndex:r}=n;const a=s.map(l=>l.index),g=s.map(l=>l.item),u=s[0].items;if(u===o){const l=a.filter(m=>m<r).length;r=Math.max(0,r-l);const f=T(Y(u,a),r,g);return{sourceItems:f,targetItems:f,draggedItems:g,sourceIndexes:a,targetIndex:r,mode:i,sameList:!0}}else{const l=Y(u,a),f=T(o,r,g);return{sourceItems:l,targetItems:f,draggedItems:g,sourceIndexes:a,targetIndex:r,mode:i,sameList:!1}}}function ut(e){const{draggedItems:t,hoveredDraggable:s}=e;if(!t.length||!s)return null;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;if(u&&n.includes(o))return null;if(t.length===1){const c=n[0];if(u){const l=ze(a,c,o);return{sourceItems:l,targetItems:l,sourceIndexes:n,targetIndex:o,sameList:!0}}else{const l=[...a],f=[...g];return l[c]=g[o],f[o]=a[c],{sourceItems:l,targetItems:f,sourceIndexes:n,targetIndex:o,sameList:!1}}}else{const c=Math.min(...n);if(u){const l=n.filter(M=>M<o).length,f=Math.max(0,o-l),m=n.filter(M=>M<c).length,h=Math.max(0,c-m);let p=Y(a,n);p=T(p,f,i);const v=h>=f?h+i.length:h;return p=T(p,v,[r]),{sourceItems:p,targetItems:p,sourceIndexes:n,targetIndex:f,sameList:!0}}else{const l=n.filter(p=>p<c).length,f=Math.max(0,c-l);let m=Y(a,n);m=T(m,f,[r]);let h=pe(g,o);return h=T(h,o,i),{sourceItems:m,targetItems:h,sourceIndexes:n,targetIndex:o,sameList:!1}}}}function gt(e,t="vertical"){const{draggedItems:s}=e;if(!s.length)return null;const n=Oe(e,t);if(!n)return null;const{targetArr:o,targetIndex:i,mode:r}=n,a=s.map(u=>u.item);return{targetItems:T(o,i,a),copiedItems:a,targetIndex:i,mode:r}}function ft(e){const{draggedItems:t}=e;if(!t.length)return null;const s=t.map(r=>r.index),n=t.map(r=>r.item),o=t[0].items;return{sourceItems:Y(o,s),removedItems:n,sourceIndexes:s}}function dt(e){return{insertAt:T,removeAt:pe,removeIndexes:Y,swapAt:ze,getInsertSide:(t,s)=>z.getInsertSide(t,s),isAtZoneStart:(t,s)=>z.isAtZoneStart(t,s),isAtZoneEnd:(t,s)=>z.isAtZoneEnd(t,s),suggestSort:t=>ct(e,t),suggestSwap:()=>ut(e),suggestCopy:t=>gt(e,t),suggestRemove:()=>ft(e)}}const _=e=>e.keys().next().value,mt=e=>e.target.closest(N.DRAGGABLE);function ht(e){const t=e.entities.initiatingDraggable;if(!t)return[];const n=(e.entities.draggingMap.get(t)??e.entities.draggableMap.get(t))?.payload;if(!n)return[];const o=n();if(!Array.isArray(o)||o.length<2)return[];const[i,r,a]=o,g=Number(i),u=r,c=new Map;return c.set(g,{index:g,item:u[g],items:u,dropData:a}),e.entities.draggingMap.forEach((l,f)=>{const h=e.entities.draggableMap.get(f)?.payload;if(!h)return;const p=h();if(!Array.isArray(p)||p.length<2)return;const[v,M,w]=p;if(M!==u)return;const x=Number(v);c.has(x)||c.set(x,{index:x,item:M[x],items:u,dropData:w})}),[...c.values()].sort((l,f)=>l.index-f.index)}const R=(e,t)=>{const s=ht(e);let n,o;if(t){const r=e.entities.droppableMap.get(t)?.payload;if(r){const u=r();Array.isArray(u)&&u.length>=1&&(n={items:Array.isArray(u[0])?u[0]:[],userData:u[1],placement:e.hovered.droppable.get(t)})}const a=_(e.hovered.draggable);if(a&&(a===t||t.contains(a))&&a){const c=e.entities.draggableMap.get(a)?.payload,l=e.hovered.draggable.get(a);if(c){const f=c();if(Array.isArray(f)&&f.length>=2){const[m,h,p]=f,v=Number(m);o={element:a,placement:l??{top:!1,right:!1,bottom:!1,left:!1,center:!1},index:v,item:h[v],items:h,dropData:p}}}}}return{draggedItems:s,dropZone:n,hoveredDraggable:o,provider:e,helpers:dt({draggedItems:s,dropZone:n,hoveredDraggable:o})}},U=(e,t,s)=>{if(!t)return;const n=e.entities.draggingMap.get(t)??e.entities.draggableMap.get(t);!n||n.disabled||n.events?.[s]?.(R(e))},P=(e,t)=>{const s=R(e);e.entities.draggingMap.forEach(n=>{n.disabled||n.events?.[t]?.(s)})},pt=(e,t,s)=>{if(t!==s){if(t&&!Z(t,e)){const n=R(e,t);e.entities.droppableMap.get(t)?.events?.onLeave?.(n)}if(s&&!Z(s,e)){const n=R(e,s);e.entities.droppableMap.get(s)?.events?.onEnter?.(n)}}},yt=(e,t,s)=>{if(t!==s){const n=R(e);if(t){const o=e.entities.draggableMap.get(t);o&&!o.disabled&&o.events?.onLeave?.(n)}if(s){const o=e.entities.draggableMap.get(s);o&&!o.disabled&&o.events?.onHover?.(n)}}},oe=(e,t,s)=>{const n=mt(t);!n||!e.entities.draggingMap.has(n)||e.entities.draggingMap.get(n)?.events?.[s]?.(R(e))},bt=(e,t)=>{const s=_(t.droppable);s&&!Z(s,e)&&e.entities.droppableMap.get(s)?.events?.onLeave?.(R(e,s))},_e=(e,t)=>{const s=_(t.droppable);s&&!Z(s,e)&&e.entities.droppableMap.get(s)?.events?.onLeave?.(R(e,s))};function St(e){return e.parentElement?.closest(N.SELECT_AREA)??null}const Dt=(e,t,s)=>{if(!s)return{};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);return{left:`${o}px`,top:`${i}px`,width:`${g}px`,height:`${u}px`,position:"fixed",pointerEvents:"none",border:"1px solid #3b82f6",backgroundColor:"#3b82f61a"}},Mt=e=>{if(!e.pointer.value||!e.entities.selectingArea)return;const{selectingArea:t}=e.entities,s=vt(e.pointer.value.start,e.pointer.value.current),n=e.entities.selectableAreaMap.get(t)?.groups??[],o=e.lib.rectCache;e.entities.visibleDraggableSet.forEach(i=>{if(i===t||!t.contains(i))return;const r=St(i);if(r&&r!==t){e.entities.selectedSet.delete(i);return}if(me(i,e)){e.entities.selectedSet.delete(i);return}const g=e.entities.draggableMap.get(i)?.groups??[];if(!he(n,g)){e.entities.selectedSet.delete(i);return}let u=o.get(i);u||(u=i.getBoundingClientRect(),o.set(i,u)),Xe(s,u)?e.entities.selectedSet.add(i):e.entities.selectedSet.delete(i)})},vt=(e,t)=>{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;return new DOMRect(s,n,r,a)},wt=(e,t,s=5)=>{const n=s/2;return{left:e-n,top:t-n,width:s,height:s}},xt=e=>{const t=e.pointer.value?.current,s=t?.x??0,n=t?.y??0;return wt(s,n,5)},H=(e,t,s)=>{const n=e.left+e.width/2,o=e.top+e.height/2;if(s){const a=s.top??0,g=s.right??0,u=s.bottom??0,c=s.left??0,l=t.left+c,f=t.right-g,m=t.top+a,h=t.bottom-u;if(l<f&&m<h&&n>=l&&n<=f&&o>=m&&o<=h)return{top:!1,right:!1,bottom:!1,left:!1,center:!0}}const i=t.left+t.width/2,r=t.top+t.height/2;return{top:o<=r,bottom:o>r,left:n<=i,right:n>i,center:!1}},Et=e=>({x:e.left+e.width/2,y:e.top+e.height/2}),De=(e,t)=>{const s=Et(t);return Math.hypot(e.x-s.x,e.y-s.y)};function At(e,t){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}function V(e,t){At(e.hoveredPlacement,t)||(e.hoveredPlacement=t)}const Ct=(e,t)=>e.find(s=>s!==t&&O(t,s)),$=(e,t,s)=>{const n=_(t.droppable),o=_(t.draggable);o&&t.draggable.delete(o),n&&t.droppable.delete(n);const i=xt(e),r=s.zones[0],a=s.elements[0];if(r&&a&&r===a&&e.entities.droppableMap.has(r)&&r){const l=r.getBoundingClientRect(),f=e.entities.draggableMap.get(r)?.placementMargins,m=H(i,l,f);if(m.center){t.droppable.set(r,m);const h=Ct(s.elements,r);if(h){const p=h.getBoundingClientRect();t.draggable.set(h,H(i,p,void 0))}}else t.draggable.set(a,m)}else{if(r){const l=r.getBoundingClientRect();t.droppable.set(r,H(i,l))}if(a)if(r)if(O(r,a)){const l=a.getBoundingClientRect(),f=e.entities.draggableMap.get(a)?.placementMargins;t.draggable.set(a,H(i,l,f))}else{const l=e.pointer.value?.current??{x:0,y:0},f=r.getBoundingClientRect(),m=a.getBoundingClientRect(),h=De(l,f);if(De(l,m)<h){t.droppable.clear();const v=e.entities.draggableMap.get(a)?.placementMargins;t.draggable.set(a,H(i,m,v))}}else{const l=a.getBoundingClientRect(),f=e.entities.draggableMap.get(a)?.placementMargins;t.draggable.set(a,H(i,l,f))}}const u=_(t.droppable),c=_(t.draggable);if(o&&o!==c){const l=e.entities.draggableMap.get(o);l&&V(l,void 0)}if(n&&n!==u){const l=e.entities.droppableMap.get(n);l&&V(l,void 0)}if(c){const l=e.entities.draggableMap.get(c);l&&V(l,t.draggable.get(c))}if(u){const l=e.entities.droppableMap.get(u);l&&V(l,t.droppable.get(u))}pt(e,n,u),yt(e,o,c)},Me=(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,K=e=>{if(!e)return{x:0,y:0,width:0,height:0,top:0,left:0,right:0,bottom:0};const t=e.getBoundingClientRect();return{x:t.x,y:t.y,width:t.width,height:t.height,top:t.top,left:t.left,right:t.right,bottom:t.bottom}},X=e=>({x:e.x+e.width/2,y:e.y+e.height/2}),kt=(e,t)=>Math.hypot(t.x-e.x,t.y-e.y),ue=(e,t)=>{const s=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),n=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y)),o=s*n,i=e.width*e.height,r=t.width*t.height;return i===0||r===0?0:(o/i*100+o/r*100)/2},ge=(e,t,s)=>t>=e.x&&t<=e.x+e.width&&s>=e.y&&s<=e.y+e.height,It=e=>e.overlay.ref?.value??null,Fe=e=>{const t=e.overlay.position?.value??{x:0,y:0},{x:s,y:n}=t,o=e.overlay.size?.value;let i,r;if(o)i=o.width,r=o.height;else{const a=e.overlay.ref?.value?.getBoundingClientRect();i=a?.width??0,r=a?.height??0}return{x:s,y:n,width:i,height:r,top:n,left:s,right:s+i,bottom:n+r}},Lt=e=>e.entities.allowedDraggableSet,Pt=e=>e.entities.allowedDroppableSet,Rt=(e,t)=>!t.entities.draggingMap.has(e),Bt=(e,t)=>![...t.entities.draggingMap.keys()].some(s=>O(s,e)),Tt=(e,t)=>t.entities.draggableMap.has(e)?!me(e,t):t.entities.droppableMap.has(e)?!Z(e,t):!0,ee=(e,t)=>Rt(e,t)&&Bt(e,t)&&Tt(e,t),ve=10;function W(e,t){return Math.hypot(t.x-(e.x+e.width/2),t.y-(e.y+e.height/2))}function we(e){return[...e].sort((t,s)=>{const n=e.filter(i=>i!==t&&O(i,t)).length;return e.filter(i=>i!==s&&O(i,s)).length-n})}const te=e=>{if(!It(e))return{elements:[],zones:[]};const s=Fe(e),n=e.pointer.value?.current??{x:0,y:0},o=[...Lt(e)].filter(c=>ee(c,e)),i=[...Pt(e)].filter(c=>ee(c,e)),r=o.filter(c=>ge(K(c),n.x,n.y)),a=i.filter(c=>ge(K(c),n.x,n.y));if(r.length>0||a.length>0)return{elements:we(r),zones:we(a)};const g=o.map(c=>({n:c,box:K(c)})).filter(({box:c})=>Me(c,s)&&ue(c,s)>=ve).sort((c,l)=>W(c.box,n)-W(l.box,n)).map(({n:c})=>c),u=i.map(c=>({n:c,box:K(c)})).filter(({box:c})=>Me(c,s)&&ue(c,s)>=ve).sort((c,l)=>W(c.box,n)-W(l.box,n)).map(({n:c})=>c);return{elements:g,zones:u}};function zt(e){globalThis.onmessage=t=>{const{callId:s,data:n}=t.data;try{const o=e(n);globalThis.postMessage({callId:s,ok:!0,result:o})}catch(o){globalThis.postMessage({callId:s,ok:!1,error:String(o)})}}}function Ot(e,t){return[t.map(n=>n.toString()).join(`
|
|
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]);$(e,e.hovered,{elements:c,zones:l})})}function fe(e){if(e.collision?.run){const s=e.collision.run(e);$(e,e.hovered,s);return}if(Ke().isSupported)Gt(e);else{const s=te(e);$(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);$(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);$(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,$t=144,Ae=1e3/$t;function Vt(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=Vt(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",d.mergeProps({ref_key:"overlayRef",ref:s,class:"dnd-kit-overlay-container"},i.$attrs),[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);
|
|
@@ -119,7 +119,7 @@ function Xe(e, t) {
|
|
|
119
119
|
const s = t.getBoundingClientRect(), n = s.width > 0 ? (e.clientX - s.left) / s.width : 0.5, o = s.height > 0 ? (e.clientY - s.top) / s.height : 0.5;
|
|
120
120
|
return { x: n, y: o };
|
|
121
121
|
}
|
|
122
|
-
function
|
|
122
|
+
function $e(e, t) {
|
|
123
123
|
return {
|
|
124
124
|
...t,
|
|
125
125
|
initialHTML: e.innerHTML,
|
|
@@ -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
|
-
s.set(n,
|
|
133
|
+
s.set(n, $e(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
|
-
s.set(e,
|
|
139
|
+
s.set(e, $e(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
|
-
function
|
|
152
|
+
function je(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") {
|
|
@@ -170,24 +170,24 @@ function xt(e, t) {
|
|
|
170
170
|
const a = o > 0 ? Math.min(s / o, 1) : 1, g = i > 0 ? Math.min(n / i, 1) : 1;
|
|
171
171
|
return r === "both" ? Math.min(a, g) : Math.max(a, g);
|
|
172
172
|
}
|
|
173
|
-
function
|
|
173
|
+
function Ve(e, t, s) {
|
|
174
174
|
if (!s) return !0;
|
|
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(
|
|
182
182
|
e.entities.initiatingDraggable
|
|
183
183
|
);
|
|
184
|
-
return
|
|
184
|
+
return Ve(
|
|
185
185
|
e.distanceProgress.value,
|
|
186
186
|
e.delay.progress,
|
|
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) {
|
|
@@ -204,7 +204,7 @@ function At(e, t) {
|
|
|
204
204
|
e.delay.progress = Math.min(
|
|
205
205
|
(Date.now() - e.delay.startTime) / (i * 1e3),
|
|
206
206
|
1
|
|
207
|
-
),
|
|
207
|
+
), Ve(
|
|
208
208
|
e.distanceProgress.value,
|
|
209
209
|
e.delay.progress,
|
|
210
210
|
o?.activation
|
|
@@ -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",
|
|
@@ -262,7 +262,7 @@ function kt(e, t, s, n, o) {
|
|
|
262
262
|
i
|
|
263
263
|
) : h;
|
|
264
264
|
}
|
|
265
|
-
const
|
|
265
|
+
const j = {
|
|
266
266
|
forDrag: ["Enter", "Space"],
|
|
267
267
|
forCancel: ["Escape"],
|
|
268
268
|
forDrop: ["Enter", "Space"],
|
|
@@ -278,15 +278,15 @@ 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()),
|
|
285
|
-
forDrag: [...
|
|
286
|
-
forCancel: [...
|
|
287
|
-
forDrop: [...
|
|
288
|
-
forMove: [...
|
|
289
|
-
forMoveFaster: [...
|
|
285
|
+
forDrag: [...j.forDrag],
|
|
286
|
+
forCancel: [...j.forCancel],
|
|
287
|
+
forDrop: [...j.forDrop],
|
|
288
|
+
forMove: [...j.forMove],
|
|
289
|
+
forMoveFaster: [...j.forMoveFaster]
|
|
290
290
|
},
|
|
291
291
|
step: 8,
|
|
292
292
|
moveFaster: 4
|
|
@@ -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,
|
|
@@ -406,7 +406,7 @@ function Ie(e, t, s = 1) {
|
|
|
406
406
|
const n = Math.max(0, Math.min(t, e.length - 1)), o = Math.max(0, Math.min(s, e.length - n));
|
|
407
407
|
return [...e.slice(0, n), ...e.slice(n + o)];
|
|
408
408
|
}
|
|
409
|
-
function
|
|
409
|
+
function $(e, t) {
|
|
410
410
|
const s = [...new Set(t)].filter((o) => o >= 0 && o < e.length).sort((o, i) => i - o);
|
|
411
411
|
let n = e;
|
|
412
412
|
for (const o of s) n = Ie(n, o, 1);
|
|
@@ -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);
|
|
@@ -467,14 +467,14 @@ function Rt(e, t = "vertical") {
|
|
|
467
467
|
if (u === o) {
|
|
468
468
|
const l = a.filter((d) => d < r).length;
|
|
469
469
|
r = Math.max(0, r - l);
|
|
470
|
-
const f = B(
|
|
470
|
+
const f = B($(u, a), r, g);
|
|
471
471
|
return { sourceItems: f, targetItems: f, draggedItems: g, sourceIndexes: a, targetIndex: r, mode: i, sameList: !0 };
|
|
472
472
|
} else {
|
|
473
|
-
const l =
|
|
473
|
+
const l = $(u, a), f = B(o, r, g);
|
|
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;
|
|
@@ -492,20 +492,20 @@ function Tt(e) {
|
|
|
492
492
|
const c = Math.min(...n);
|
|
493
493
|
if (u) {
|
|
494
494
|
const l = n.filter((D) => D < o).length, f = Math.max(0, o - l), d = n.filter((D) => D < c).length, m = Math.max(0, c - d);
|
|
495
|
-
let h =
|
|
495
|
+
let h = $(a, n);
|
|
496
496
|
h = B(h, f, i);
|
|
497
497
|
const w = m >= f ? m + i.length : m;
|
|
498
498
|
return h = B(h, w, [r]), { sourceItems: h, targetItems: h, sourceIndexes: n, targetIndex: f, sameList: !0 };
|
|
499
499
|
} else {
|
|
500
500
|
const l = n.filter((h) => h < c).length, f = Math.max(0, c - l);
|
|
501
|
-
let d =
|
|
501
|
+
let d = $(a, n);
|
|
502
502
|
d = B(d, f, [r]);
|
|
503
503
|
let m = Ie(g, o);
|
|
504
504
|
return m = B(m, o, i), { sourceItems: d, targetItems: m, sourceIndexes: n, targetIndex: o, sameList: !1 };
|
|
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,34 +513,34 @@ 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
|
-
return { sourceItems:
|
|
520
|
+
return { sourceItems: $(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,
|
|
526
526
|
removeAt: Ie,
|
|
527
|
-
removeIndexes:
|
|
527
|
+
removeIndexes: $,
|
|
528
528
|
swapAt: We,
|
|
529
529
|
// Placement helpers
|
|
530
530
|
getInsertSide: (t, s) => O.getInsertSide(t, s),
|
|
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
|
+
}, $t = (e, t, s = 5) => {
|
|
704
704
|
const n = s / 2;
|
|
705
705
|
return {
|
|
706
706
|
left: e - n,
|
|
@@ -710,7 +710,7 @@ const Zt = (e, t, s) => {
|
|
|
710
710
|
};
|
|
711
711
|
}, jt = (e) => {
|
|
712
712
|
const t = e.pointer.value?.current, s = t?.x ?? 0, n = t?.y ?? 0;
|
|
713
|
-
return
|
|
713
|
+
return $t(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) {
|
|
@@ -739,13 +739,13 @@ const Zt = (e, t, s) => {
|
|
|
739
739
|
const s = Vt(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
751
|
const i = jt(e), r = s.zones[0], a = s.elements[0];
|
|
@@ -753,7 +753,7 @@ const Wt = (e, t) => e.find((s) => s !== t && _(t, s)), W = (e, t, s) => {
|
|
|
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 };
|
|
@@ -827,10 +827,10 @@ const Wt = (e, t) => e.find((s) => s !== t && _(t, s)), W = (e, t, s) => {
|
|
|
827
827
|
right: t.right,
|
|
828
828
|
bottom: t.bottom
|
|
829
829
|
};
|
|
830
|
-
},
|
|
830
|
+
}, V = (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) => {
|
|
@@ -1141,18 +1141,18 @@ const fn = (e) => {
|
|
|
1141
1141
|
}
|
|
1142
1142
|
if (e.entities.modifiersDraggableSet.size > 0 && e.entities.modifiersDraggableSet.has(c)) {
|
|
1143
1143
|
const l = e.entities.draggableMap.get(c);
|
|
1144
|
-
if (!
|
|
1144
|
+
if (!je(g, c, l?.dragHandle))
|
|
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(
|
|
@@ -1205,7 +1205,7 @@ const fn = (e) => {
|
|
|
1205
1205
|
if (!i || e.entities.modifiersDraggableSet.size === 0 || !e.entities.modifiersDraggableSet.has(i))
|
|
1206
1206
|
return;
|
|
1207
1207
|
const r = e.entities.draggableMap.get(i);
|
|
1208
|
-
if (!
|
|
1208
|
+
if (!je(o, i, r?.dragHandle, !0))
|
|
1209
1209
|
return;
|
|
1210
1210
|
t.preventDefault(), pe();
|
|
1211
1211
|
const a = i.getBoundingClientRect(), g = a.left + a.width / 2, u = a.top + a.height / 2, c = {
|
|
@@ -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,37 @@ 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
1401
|
overlayTo: { type: [String, Boolean, null] }
|
|
1402
1402
|
},
|
|
1403
1403
|
setup(e) {
|
|
1404
|
-
const t = e, s = ut("overlayRef"), n =
|
|
1405
|
-
|
|
1404
|
+
const t = e, s = ut("overlayRef"), n = Rt(s, t);
|
|
1405
|
+
En(n);
|
|
1406
1406
|
const o = M(
|
|
1407
|
-
() => n.overlay.render.value ??
|
|
1407
|
+
() => n.overlay.render.value ?? An
|
|
1408
1408
|
);
|
|
1409
1409
|
return gt(Ee, n), (i, r) => (z(), se(ye, null, [
|
|
1410
1410
|
Pe(i.$slots, "default"),
|
|
1411
1411
|
(z(), ie(ft, {
|
|
1412
1412
|
to: F(n).overlay.to.value || "body"
|
|
1413
1413
|
}, [
|
|
1414
|
-
dt("div", {
|
|
1414
|
+
dt("div", mt({
|
|
1415
1415
|
ref_key: "overlayRef",
|
|
1416
1416
|
ref: s,
|
|
1417
1417
|
class: "dnd-kit-overlay-container"
|
|
1418
|
-
}, [
|
|
1418
|
+
}, i.$attrs), [
|
|
1419
1419
|
Pe(i.$slots, "overlay", { overlay: o.value }, () => [
|
|
1420
1420
|
(z(), ie(be(o.value)))
|
|
1421
1421
|
])
|
|
1422
|
-
],
|
|
1422
|
+
], 16)
|
|
1423
1423
|
], 8, ["to"]))
|
|
1424
1424
|
], 64));
|
|
1425
1425
|
}
|
|
1426
1426
|
});
|
|
1427
|
-
function
|
|
1427
|
+
function Pn(e, t, s) {
|
|
1428
1428
|
const n = ge();
|
|
1429
1429
|
let o, i, r;
|
|
1430
1430
|
typeof t == "function" ? (o = {}, i = t) : (o = t ?? {}, i = s);
|
|
@@ -1470,7 +1470,7 @@ function kn(e, t, s) {
|
|
|
1470
1470
|
isDragOver: c
|
|
1471
1471
|
};
|
|
1472
1472
|
}
|
|
1473
|
-
const
|
|
1473
|
+
const Rn = (e, t) => {
|
|
1474
1474
|
const s = ge(), n = M(() => e.value === s.entities.selectingArea);
|
|
1475
1475
|
let o = null;
|
|
1476
1476
|
q(() => {
|
|
@@ -1489,14 +1489,14 @@ const Pn = (e, t) => {
|
|
|
1489
1489
|
const i = M(() => {
|
|
1490
1490
|
s.scrollPosition.x, s.scrollPosition.y;
|
|
1491
1491
|
const r = s.pointer.value;
|
|
1492
|
-
return !r || s.state.value !== "selecting" || !o || !n.value ? {} :
|
|
1492
|
+
return !r || s.state.value !== "selecting" || !o || !n.value ? {} : Ut(r.start, r.current, o);
|
|
1493
1493
|
});
|
|
1494
1494
|
return {
|
|
1495
1495
|
isSelecting: n,
|
|
1496
1496
|
style: i
|
|
1497
1497
|
};
|
|
1498
1498
|
};
|
|
1499
|
-
function
|
|
1499
|
+
function Tn(e, t) {
|
|
1500
1500
|
const s = Ze(Ee);
|
|
1501
1501
|
if (!s) throw Error("DnD provider not found");
|
|
1502
1502
|
let n = null;
|
|
@@ -1509,7 +1509,7 @@ function Rn(e, t) {
|
|
|
1509
1509
|
n && s.entities.constraintsAreaMap.delete(n);
|
|
1510
1510
|
}), {};
|
|
1511
1511
|
}
|
|
1512
|
-
function
|
|
1512
|
+
function zn(e, t, s) {
|
|
1513
1513
|
const n = ge();
|
|
1514
1514
|
let o = null, i, r;
|
|
1515
1515
|
typeof t == "function" ? (i = {}, r = t) : (i = t ?? {}, r = s);
|
|
@@ -1536,7 +1536,7 @@ function Tn(e, t, s) {
|
|
|
1536
1536
|
isDragOver: g
|
|
1537
1537
|
};
|
|
1538
1538
|
}
|
|
1539
|
-
const
|
|
1539
|
+
const Bn = (e, t) => {
|
|
1540
1540
|
const s = it(), n = re(!1), i = rt(
|
|
1541
1541
|
e,
|
|
1542
1542
|
t ?? {},
|
|
@@ -1561,7 +1561,7 @@ const zn = (e, t) => {
|
|
|
1561
1561
|
function He(e, t) {
|
|
1562
1562
|
return t <= 0 ? e : Math.round(e / t) * t;
|
|
1563
1563
|
}
|
|
1564
|
-
function
|
|
1564
|
+
function On(e, t) {
|
|
1565
1565
|
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
1566
|
return M(() => {
|
|
1567
1567
|
const { x: i, y: r } = e.value;
|
|
@@ -1571,13 +1571,13 @@ function Bn(e, t) {
|
|
|
1571
1571
|
};
|
|
1572
1572
|
});
|
|
1573
1573
|
}
|
|
1574
|
-
const Ke = () => !0, Ne = () => 0,
|
|
1574
|
+
const Ke = () => !0, Ne = () => 0, Cn = "separate", In = () => {
|
|
1575
1575
|
const e = {
|
|
1576
1576
|
filterElements: Ke,
|
|
1577
1577
|
filterZones: Ke,
|
|
1578
1578
|
sortElements: Ne,
|
|
1579
1579
|
sortZones: Ne,
|
|
1580
|
-
mergeStrategy:
|
|
1580
|
+
mergeStrategy: Cn,
|
|
1581
1581
|
pickClosestBetweenFirst: !1
|
|
1582
1582
|
}, t = (n, o, i, r, a, g, u) => {
|
|
1583
1583
|
const c = r instanceof Set ? r : new Set(r), l = { containerBox: o, pointer: i }, f = e.minOverlapPercent, d = [];
|
|
@@ -1597,9 +1597,9 @@ const Ke = () => !0, Ne = () => 0, An = "separate", Cn = () => {
|
|
|
1597
1597
|
isPointerInElement: we(h, i.x, i.y),
|
|
1598
1598
|
overlapPercent: w,
|
|
1599
1599
|
depth: D,
|
|
1600
|
-
centerDistance:
|
|
1601
|
-
|
|
1602
|
-
|
|
1600
|
+
centerDistance: Jt(
|
|
1601
|
+
V(o),
|
|
1602
|
+
V(h)
|
|
1603
1603
|
)
|
|
1604
1604
|
}
|
|
1605
1605
|
});
|
|
@@ -1685,7 +1685,7 @@ const Ke = () => !0, Ne = () => 0, An = "separate", Cn = () => {
|
|
|
1685
1685
|
];
|
|
1686
1686
|
if (c.length === 0) return { elements: [], zones: [] };
|
|
1687
1687
|
for (const f of c) {
|
|
1688
|
-
const d =
|
|
1688
|
+
const d = V(f.box);
|
|
1689
1689
|
f.distance = Math.hypot(
|
|
1690
1690
|
a.x - d.x,
|
|
1691
1691
|
a.y - d.y
|
|
@@ -1697,7 +1697,7 @@ const Ke = () => !0, Ne = () => 0, An = "separate", Cn = () => {
|
|
|
1697
1697
|
return l.isZone ? { elements: [], zones: [l.node] } : { elements: [l.node], zones: [] };
|
|
1698
1698
|
}
|
|
1699
1699
|
if (n.pickClosestBetweenFirst && g[0] && u[0]) {
|
|
1700
|
-
const c =
|
|
1700
|
+
const c = V(u[0].box), l = V(g[0].box), f = Math.hypot(
|
|
1701
1701
|
a.x - c.x,
|
|
1702
1702
|
a.y - c.y
|
|
1703
1703
|
);
|
|
@@ -1714,16 +1714,16 @@ const Ke = () => !0, Ne = () => 0, An = "separate", Cn = () => {
|
|
|
1714
1714
|
}
|
|
1715
1715
|
};
|
|
1716
1716
|
return s;
|
|
1717
|
-
},
|
|
1717
|
+
}, _n = () => In();
|
|
1718
1718
|
export {
|
|
1719
|
-
|
|
1720
|
-
|
|
1719
|
+
kn as DnDProvider,
|
|
1720
|
+
_n as createSensor,
|
|
1721
1721
|
ve as defaultCollisionDetection,
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1722
|
+
Bn as makeAutoScroll,
|
|
1723
|
+
Tn as makeConstraintArea,
|
|
1724
|
+
Pn as makeDraggable,
|
|
1725
|
+
zn as makeDroppable,
|
|
1726
|
+
Rn as makeSelectionArea,
|
|
1727
|
+
On as makeSnappedOverlayPosition,
|
|
1728
1728
|
it as useDnDProvider
|
|
1729
1729
|
};
|
package/package.json
CHANGED