fluid-dnd 2.0.0 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/README.md +1 -1
  2. package/dist/{HandlerPublisher-BbQeSll4.js → HandlerPublisher-BYI2bw4n.js} +1 -1
  3. package/dist/{HandlerPublisher-F9_9P96L.cjs → HandlerPublisher-C-jTncuG.cjs} +1 -1
  4. package/dist/core/HandlerPublisher.js +20 -0
  5. package/dist/core/configHandler.d.ts +2 -3
  6. package/dist/core/configHandler.js +33 -0
  7. package/dist/core/dragAndDrop.d.ts +3 -3
  8. package/dist/core/dragAndDrop.js +62 -0
  9. package/dist/core/index.js +2 -0
  10. package/dist/core/useDraggable.d.ts +2 -3
  11. package/dist/core/useDraggable.js +328 -0
  12. package/dist/core/useDroppable.d.ts +2 -3
  13. package/dist/core/useDroppable.js +55 -0
  14. package/dist/core/utils/GetStyles.d.ts +2 -3
  15. package/dist/core/utils/GetStyles.js +138 -0
  16. package/dist/core/utils/ParseStyles.d.ts +2 -3
  17. package/dist/core/utils/ParseStyles.js +40 -0
  18. package/dist/core/utils/SetStyles.d.ts +1 -2
  19. package/dist/core/utils/SetStyles.js +192 -0
  20. package/dist/core/utils/SetTransform.d.ts +2 -3
  21. package/dist/core/utils/SetTransform.js +148 -0
  22. package/dist/core/utils/classes.js +9 -0
  23. package/dist/core/utils/config.d.ts +3 -3
  24. package/dist/core/utils/config.js +55 -0
  25. package/dist/core/utils/dom/classList.js +35 -0
  26. package/dist/core/utils/droppableConfigurator.d.ts +3 -4
  27. package/dist/core/utils/droppableConfigurator.js +106 -0
  28. package/dist/core/utils/events/emitEvents.d.ts +5 -6
  29. package/dist/core/utils/events/emitEvents.js +333 -0
  30. package/dist/core/utils/index.js +9 -0
  31. package/dist/core/utils/observer.js +11 -0
  32. package/dist/core/utils/scroll.d.ts +2 -3
  33. package/dist/core/utils/scroll.js +17 -0
  34. package/dist/core/utils/tempChildren.d.ts +1 -2
  35. package/dist/core/utils/tempChildren.js +146 -0
  36. package/dist/core/utils/touchDevice.js +3 -0
  37. package/dist/core/utils/translate/GetTranslateBeforeDropping.d.ts +2 -3
  38. package/dist/core/utils/translate/GetTranslateBeforeDropping.js +129 -0
  39. package/dist/core/utils/translate/GetTranslationByDraggingAndEvent.d.ts +2 -3
  40. package/dist/core/utils/translate/GetTranslationByDraggingAndEvent.js +48 -0
  41. package/dist/{index-8zYdjZIf.js → index-BQUYvZRn.js} +214 -214
  42. package/dist/index-DNmnvxhi.cjs +1 -0
  43. package/dist/index.cjs +1 -0
  44. package/dist/index.d.ts +4 -0
  45. package/dist/index.js +2 -0
  46. package/dist/index.mjs +4 -0
  47. package/dist/react/index.cjs +1 -1
  48. package/dist/react/index.d.ts +1 -2
  49. package/dist/react/index.js +2 -0
  50. package/dist/react/index.mjs +2 -2
  51. package/dist/react/useDragAndDrop.d.ts +2 -3
  52. package/dist/react/useDragAndDrop.js +28 -0
  53. package/dist/react/utils/ReactLilstConfig.d.ts +3 -4
  54. package/dist/react/utils/ReactLilstConfig.js +64 -0
  55. package/dist/svelte/index.cjs +1 -1
  56. package/dist/svelte/index.d.ts +1 -2
  57. package/dist/svelte/index.js +2 -0
  58. package/dist/svelte/index.mjs +2 -2
  59. package/dist/svelte/useDragAndDrop.d.ts +1 -2
  60. package/dist/svelte/useDragAndDrop.js +25 -0
  61. package/dist/svelte/utils/SvelteListCondig.d.ts +2 -2
  62. package/dist/svelte/utils/SvelteListCondig.js +36 -0
  63. package/dist/vue/index.cjs +1 -1
  64. package/dist/vue/index.d.ts +1 -2
  65. package/dist/vue/index.js +2 -0
  66. package/dist/vue/index.mjs +2 -2
  67. package/dist/vue/useDragAndDrop.d.ts +2 -3
  68. package/dist/vue/useDragAndDrop.js +23 -0
  69. package/dist/vue/utils/DropMethods.d.ts +1 -2
  70. package/dist/vue/utils/DropMethods.js +19 -0
  71. package/dist/vue/utils/VueListCondig.d.ts +3 -3
  72. package/dist/vue/utils/VueListCondig.js +28 -0
  73. package/package.json +5 -8
  74. package/dist/index/index.cjs +0 -1
  75. package/dist/index/index.mjs +0 -4
  76. package/dist/index-C37ab-rG.cjs +0 -1
@@ -0,0 +1 @@
1
+ "use strict";var Ee=Object.defineProperty;var ye=(t,e,n)=>e in t?Ee(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var j=(t,e,n)=>ye(t,typeof e!="symbol"?e+"":e,n);const _="horizontal",et="vertical",U="draggable",Xt="droppable",Mt="handler-class",Ft="dragging",Wt="dragging-handler-class",_t="dropping",oe="grabbing",re="grab",Kt="disable-transition",Ce=(t,e)=>{const n=(l,f)=>t.removeAtEvent(l,f),s=(l,f,g)=>t.insertEvent(l,f,g),o=()=>t.getLength(),r=l=>t.getValue(l),c=l=>l;return{direction:(e==null?void 0:e.direction)??et,handlerSelector:(e==null?void 0:e.handlerSelector)??U,draggingClass:(e==null?void 0:e.draggingClass)??"dragging",droppableClass:(e==null?void 0:e.droppableClass)??"droppable-hover",isDraggable:(e==null?void 0:e.isDraggable)??(()=>!0),onDragStart:(e==null?void 0:e.onDragStart)??(()=>{}),onDragEnd:(e==null?void 0:e.onDragEnd)??(()=>{}),droppableGroup:e==null?void 0:e.droppableGroup,onRemoveAtEvent:n,onInsertEvent:s,onGetLegth:o,onGetValue:r,animationDuration:(e==null?void 0:e.animationDuration)??200,removingClass:(e==null?void 0:e.removingClass)??"removing",insertingFromClass:(e==null?void 0:e.insertingFromClass)??"from-inserting",delayBeforeRemove:(e==null?void 0:e.delayBeforeRemove)??200,delayBeforeInsert:(e==null?void 0:e.delayBeforeInsert)??200,mapFrom:(e==null?void 0:e.mapFrom)??c}},Ae=(t,e)=>{const{config:n,droppable:s}=t,{onInsertEvent:o,onDragEnd:r}=n;return{...n,onDragEnd:f=>{const{index:g,value:m}=f;r({index:g,value:e(m,s)})},onInsertEvent:(f,g)=>o(f,e(g,s),!0)}},st=(t,e)=>t.classList.contains(e),gt=(t,e,n=!1)=>{t.classList.toggle(e,n)},tt=(t,e)=>{t.classList.add(e)},Ct=(t,e)=>{t.classList.remove(e)},xe=(t,e)=>At(e).every(n=>st(t,n)),pt=t=>t?`.${At(t).join(".")}`:"",we=(t,e)=>{if(!e)return;const n=At(e);t.classList.add(...n)},At=t=>t?t.split(" ").filter(e=>e):[],Be=()=>{const{scrollX:t,scrollY:e}=window;return{scrollX:t,scrollY:e}},zt=t=>!t||t.trim().length==0||t=="normal"?0:parseFloat(t),Re=t=>t?parseInt(t):-1,Le=t=>{const e=getComputedStyle(t),n=new DOMMatrixReadOnly(e.transform);return{x:n.m41,y:n.m42}},ie=(t,e)=>t.x1>e.x1?ie(e,t):t.x2<e.x1?0:t.x2>=e.x2?t.x2-t.x1:t.x2-e.x1,ht=(t,e)=>!Me(t,e),Me=(t,e)=>{const n=Ot(t),s=Ot(e),o=Qt(n,s,et),r=Qt(n,s,_);return o>=Math.min(n.height,s.height)/2&&r>=Math.min(n.width,s.width)/2},Qt=(t,e,n)=>{const{before:s,distance:o}=B(n);return ie({x1:t[s],x2:t[s]+t[o]},{x1:e[s],x2:e[s]+e[o]})},M=(t,e)=>t?zt(getComputedStyle(t)[e]):0,Ut=t=>{const{scrollLeft:e,scrollTop:n}=t;return{scrollLeft:e,scrollTop:n}},Ot=t=>t.getBoundingClientRect(),B=t=>{const e=t==_;return{beforeMargin:e?"marginLeft":"marginTop",afterMargin:e?"marginRight":"marginBottom",borderBeforeWidth:e?"borderLeftWidth":"borderTopWidth",before:e?"left":"top",after:e?"right":"down",gap:e?"columnGap":"rowGap",distance:e?"width":"height",axis:e?"x":"y",offset:e?"offsetX":"offsetY",scroll:e?"scrollX":"scrollY",scrollElement:e?"scrollLeft":"scrollTop",page:e?"pageX":"pageY",inner:e?"innerWidth":"innerHeight",offsetElement:e?"offsetLeft":"offsetTop",scrollDistance:e?"scrollWidth":"scrollHeight",clientDistance:e?"clientWidth":"clientHeight",paddingBefore:e?"paddingLeft":"paddingTop",getRect:Ot}},Rt=(t,e)=>Oe(t,e),ce=t=>[...t.children].filter(n=>st(n,U)),Oe=(t,e)=>{const n=[...e.children].filter(o=>st(o,U)&&!o.isEqualNode(t)).toReversed(),s=[...e.children].findLastIndex(o=>o.isEqualNode(t));return[n,s,e]},Ne=t=>{let e=t.parentElement;for(;e;){if(window.getComputedStyle(e).position==="fixed")return e;e=e.parentElement}return null},ae=(t,e)=>{const{before:n,borderBeforeWidth:s}=B(e),o=Ne(t);return o?Ot(o)[n]+M(o,s):0},Tt=t=>window.TouchEvent&&t instanceof TouchEvent,it=t=>t instanceof HTMLElement,le=t=>t instanceof MouseEvent,Fe=["onmouseup","onmousedown","onmousemove"],Pe=(t,e,n)=>{t&&(t.style.height=`${e}px`,t.style.width=`${n}px`)},Et=(t,e,n)=>{!t||!it(t)||(n==0&&e==0?t.style.transform="":t.style.transform=`translate(${n}px,${e}px)`)},$e=(t,e,n,s)=>{t[e]=o=>{if(o.defaultPrevented)return;s&&s(o);const r=Vt(o);n(r)}},It=(t,e,n,s)=>{n&&(Ge(e)?t[e]=n:$e(t,e,n,s))},Ge=t=>Fe.includes(t),Ie=t=>{const{target:e}=t;return{clientX:0,clientY:0,pageX:0,pageY:0,screenX:0,screenY:0,target:e,offsetX:0,offsetY:0}},Ye=(t,e)=>{const n=(s,o)=>We(e,window,o,s);if(le(t)){const{offsetX:s,offsetY:o}=t;return[s,o]}else{const s=t.target;return[n(s,_),n(s,et)]}},Vt=t=>{const e=Xe(t);if(!e)return Ie(t);const[n,s]=Ye(t,e),{clientX:o,clientY:r,pageX:c,pageY:l,screenX:f,screenY:g,target:m}=e;return{clientX:o,clientY:r,pageX:c,pageY:l,screenX:f,screenY:g,target:m,offsetX:n,offsetY:s}},Xe=t=>{if(Tt(t))return t.touches[0]??t.changedTouches[0];if(le(t))return t},We=(t,e,n,s)=>{const{page:o,scroll:r,before:c,borderBeforeWidth:l,getRect:f}=B(n),g=f(s);return t[o]-e[r]-g[c]-M(s,l)},Pt=(t,e,n="ease-out",s="transform")=>{it(t)&&(t.style.transitionDuration=`${e}ms`,t.style.transitionTimingFunction=`${n}`,t.style.transitionProperty=`${s}`)},ue=(t,e,n)=>{!t||!it(t)||(t[e]=()=>{n()})},_e=t=>{var e=t.querySelector("style");if(!e){var n=document.createElement("style");return t.appendChild(n),n}return e},Ve=(t,e)=>{const n=/\.-?[_a-zA-Z0-9-*\s<>():]+/g,[s]=e.match(n)||[];for(const o of t.cssRules){const[r]=o.cssText.match(n)||[];if(s===r)return!0}return!1},He=(t,e)=>{e.forEach(n=>{qe(t,n)})},qe=(t,e)=>{var s;var n=_e(t);n.sheet&&(Ve(n.sheet,e)||(s=n.sheet)==null||s.insertRule(e,n.sheet.cssRules.length))},fe=(t,e={})=>{for(const n of Object.keys(e)){const s=e[n];s!=null&&ze(t,`--${n}`,s)}},ze=(t,e,n)=>t&&t.style.setProperty(e,n),je=(t,e,n)=>{n!=0&&(e==="vertical"?t.scrollBy(0,n):t.scrollBy(n,0))},Ze=(t,e,n)=>{const{scrollDistance:s,clientDistance:o,scrollElement:r}=B(t);return n[r]/(e[s]-e[o])},ke=t=>{let e={offsetX:0,offsetY:0},n={top:0,left:0},s={x:0,y:0};const o=f=>{t.style.transform=`translate( ${f.x}px, ${f.y}px)`},r=f=>{t.style.top=`${f.top}px`,t.style.left=`${f.left}px`};return[(f,g,m,b)=>{const R=y=>{const{beforeMargin:p,borderBeforeWidth:E,before:L,offset:w,scroll:P,page:X,inner:Z,distance:V,axis:H,getRect:$}=B(y),k=m[X],q=window[P],J=window[Z],I=$(f)[V],z=M(f,E),W=M(f,p),Y=k-e[w],nt=ae(f,y);if(Y>=q-I/2&&Y<=q+J){const ot=Y-n[L]-z-W-q-nt;return O(y),ot}return s[H]},O=y=>{if(f&&st(f,Ft)&&y===b){const{before:p,distance:E,axis:L,getRect:w}=B(b),P=w(f)[E],X=w(g),Z=n[p]-X[p]+s[L],H=X[E]-P,$=Z/H,k=P/H,q=.1,J=.2,I=.8;let z=0;const W=ht(f,g);!W&&$<J&&$>-k?z=$/J-1:!W&&$>I&&$<1+k&&(z=1/(1-I)*($-I));const Y=q*P*z;je(g,b,Y)}},F=y=>{const{axis:p}=B(y);s[p]=R(y),o(s)};F(_),F(et)},(f,g)=>{const[m,b,R,O]=Qe(f,g,t);n={top:m,left:b},r(n),e={offsetX:R,offsetY:O}}]},Lt=(t,e,n)=>{const{borderBeforeWidth:s,before:o,getRect:r}=B(t);return r(e)[o]-r(n)[o]-M(n,s)},Je=(t,e)=>{let{offsetX:n,offsetY:s,target:o}=t,r=Ke(o,e);const c=o;return c&&r&&!c.isSameNode(r)&&(n+=Lt(_,c,r),s+=Lt(et,c,r)),r&&e!=o&&(n+=Lt(_,r,e),s+=Lt(et,r,e)),[n,s]},Ke=(t,e)=>{const n=t==null?void 0:t.closest(`.${Mt}`);return n&&n.isSameNode(e)?t:n},te=(t,e,n,s)=>{const{offset:o,beforeMargin:r,page:c,borderBeforeWidth:l,scroll:f}=B(t),g=ae(n,t);return e[c]-s[o]-M(n,r)-M(n,l)-window[f]-g},Qe=(t,e,n)=>{const[s,o]=Je(t,n);return[te(et,t,e,{offsetX:s,offsetY:o}),te(_,t,e,{offsetX:s,offsetY:o}),s,o]},de="startDrag",Nt="drag",jt="startDrop",Ue="drop",at="temp-child",ge="cubic-bezier(0.2, 0, 0, 1)",tn=t=>t===Ue||t===jt,Ht=t=>!t||t.length==0?0:zt(t.replace("px","")),en=(t,e)=>{const n=getComputedStyle(t)[e];if(n.match("%")){const o=zt(n.replace("%","")),{width:r}=t.getBoundingClientRect();return r*(o/100)}return Ht(n)},Zt=(t,e)=>{if(!(t instanceof Element))return[0,!1];const n=en(t,e),s=getComputedStyle(t).display,o=n>0||s==="flex";return[n,o]},nn=t=>{const{top:e,left:n}=getComputedStyle(t);return[Ht(e),Ht(n)]},sn=(t,e)=>{const{gap:n}=B(e),[s,o]=Zt(t,n);return o?s:0};function yt(t,e,n,s,o=t.previousElementSibling,r=t.nextElementSibling){let{height:c,width:l}=on(n,t,o,r);return ht(t,s)&&e==Nt&&(c=0,l=0),{height:c,width:l}}const on=(t,e,n,s)=>{const{afterMargin:o,beforeMargin:r,distance:c,gap:l,getRect:f}=B(t),g=M(e,o),m=M(e,r),b=M(s,r),[R,O]=Zt(e.parentElement,l),F=f(e)[c];if(O)return ee(F,m,g,R,0,t);const[y,p,E]=rn(n,b,g,m,o);return ee(F,p,y,0,E,t)},rn=(t,e,n,s,o)=>{const r=Math.max(e,n);let c=s,l=e;if(t){const f=M(t,o);c=Math.max(f,s),l=Math.max(l,f)}return[r,c,l]},ee=(t,e,n,s,o,r)=>cn(r,t+e+n+s-o),cn=(t,e)=>t==_?{width:e,height:0}:{width:0,height:e},ne=(t,e)=>{const{borderBeforeWidth:n,paddingBefore:s,axis:o,getRect:r}=B(t),c=M(e,n),l=M(e,s),f=r(e)[o];return c+l+f},an=(t,e)=>{const[n,s]=nn(e),o=ne(et,t);return[ne(_,t)-s,o-n]};function ln(t,e,n,s,o,r,c,l,f){let g=0,m=0;const b=!!(n<0&&f);if(n===s&&!b)return se({height:g,width:m},t,o,c,b);const[R,O,F,y]=dn(e,n,s,f);if(b){const[nt,ut]=an(l,f);g+=ut,m+=nt}const{scrollElement:p,beforeMargin:E,afterMargin:L,distance:w,gap:P}=B(t),[X,Z]=Zt(l,P),[V,H,$]=pn(E,L,R,O==null?void 0:O.previousElementSibling,y,Z,b),[k,q,J]=gn(E,L,w,F,X,Z),I=fn(q,k,J,H,V,X),z=b?l[p]:un(p,l,r),Y=(y?I-$:$-I)-z;return t===et?g+=Y:t===_&&(m+=Y),se({height:g,width:m},t,o,c,b)}const un=(t,e,n)=>{const s=e[t],o=n[t];return s-o},fn=(t,e,n,s,o,r)=>{const c=Math.max(e,o);return Math.max(n,s)+t+c+r},dn=(t,e,n,s)=>{const o=e<n,[r,c]=[e,n].toSorted((m,b)=>m-b),l=t[e]??s,f=t[n];let g=o?t.slice(r+1,c+1):t.slice(r,c);return r<0&&s&&(g=t.slice(r+1,c)),[l,f,g,o]},gn=(t,e,n,s,o,r)=>{if(s.length==0)return[0,0,0];const c=M(s[0],t);let l=0,f=-c;for(const[g,m]of s.entries()){const b=m.getBoundingClientRect()[n],R=M(m,t);r&&(l+=R),r&&g>0?l+=o:l=Math.max(l,R),f+=l+b,l=M(m,e)}return[c,f,l]},se=(t,e,n,s,o)=>{const{scroll:r,distance:c}=B(e),l=window[r],f=n[r],g=o?0:f-2*l+s[r];return t[c]+=g,t},pn=(t,e,n,s,o,r,c)=>{const l=o?n.previousElementSibling:s;return hn(t,e,l,n,r,c)},hn=(t,e,n,s,o,r)=>{if(o)return[0,0,0];const c=M(r?null:n,e),l=M(s,t);let f=Math.max(c,l);return[c,l,f]},kt=(t,e,n,s=()=>!0)=>{const o=new MutationObserver(r=>{if(r=r.filter(s),r.length>0){const c=r[0];t(o,c)}});return o.observe(e,n),o},mn="startDrag",pe="cubic-bezier(0.2, 0, 0, 1)",he=50,qt=t=>it(t)?t.classList.contains(at):!1,Sn=(t,e,n)=>{let s=yt(e,mn,n,t);const o=sn(t,n),{distance:r}=B(n);s[r]-=o;const[c,l]=Dn(n,e);return s[l]=c,s},Dn=(t,e)=>{const n=t==_?et:_,{distance:s,getRect:o}=B(n);return[o(e)[s],s]},mt=(t,e,n)=>{Pe(t,e,n),t.style.minWidth=`${n}px`},vn=(t,e,n)=>s=>{e.contains(t)&&(mt(t,n.height,n.width),s.disconnect())},bn=(t,e)=>{if(!e)return;const{droppable:n,config:s,scroll:o}=t,{direction:r}=s,c=Ze(s.direction,n,o)>.99,{scrollDistance:l,clientDistance:f,scrollElement:g}=B(r);c&&(n[g]=n[l]-n[f])},me=(t,e,n,s)=>{if(!n)return;const{droppable:o,config:r}=n,{direction:c,animationDuration:l}=r;if(bn(n,e),o.querySelector(`.${at}`)||!t)return;var f=t.tagName=="LI"?"DIV":t.tagName,g=document.createElement(f);tt(g,at),mt(g,0,0);const m=Sn(o,t,c);return Pt(g,l,pe,"width, min-width, height"),[g,m,o]},Yt=(t,e,n,s,o)=>{const r=me(t,n,s);if(!r)return;const[c,l,f]=r;e.isSameNode(f)&&mt(c,l.height,l.width),kt(vn(c,f,l),f,{childList:!0,subtree:!0}),f.appendChild(c)},Tn=(t,e,n)=>{const s=me(t,e,n);if(!s)return;const[o,r,c]=s;c.appendChild(o),En(o,r)},En=(t,e)=>requestAnimationFrame(()=>{mt(t,e.height,e.width),requestAnimationFrame(()=>{Pt(t,0,pe,"width, min-width, height")})}),yn=(t,e,n,s,o=!0)=>{if(n){var r=document.querySelectorAll(`${pt(n)} > .${at}`);r.forEach(c=>{const l=c.parentElement;if(l!=null&&l.isSameNode(e)||!o&&(l!=null&&l.isSameNode(t)))return;mt(c,0,0),setTimeout(()=>{var g;(g=c.parentNode)==null||g.removeChild(c)},s+he)})}},bt=(t,e,n=!1)=>{var s=t.querySelectorAll(`.${at}`);s.forEach(o=>{const r=o;n?(mt(r,0,0),setTimeout(()=>{t.contains(r)&&t.removeChild(r)},e+he)):t.removeChild(o)})},Cn=50;function An(t,e,n,s,o,r){let c=e;const{direction:l,handlerSelector:f,onRemoveAtEvent:g,animationDuration:m,delayBeforeInsert:b,draggingClass:R}=t,O=(u,a,h,D,C)=>{if(!D)return;const{droppable:T,config:v}=D,A=yt(u,a,v.direction,T);tn(a)?Z(u,a,A,h,D,C):E(u,a,A,D)},F=(u,a,h,D,C)=>{const T=yt(a,"insert",t.direction,h),{onInsertEvent:v}=t,A=ce(h);for(const[N,x]of A.entries())st(x,U)&&N>=u&&X(x,T);C(),setTimeout(()=>{v(u,D),Se(u,h,t),nt(a),W(a,n),bt(n,0,!0)},b)},y=(u,a,h,D)=>{if(!h||!h.droppable||!h.config)return;const{droppable:C,config:T}=h;let[v]=Rt(a,C);v=[a,...v].toReversed();const A=yt(a,"remove",T.direction,C);for(const[N,x]of v.entries())N>=u&&(P(x,A),setTimeout(()=>{D(x)},m))},p=u=>{bt(n,m,!0),setTimeout(()=>{nt(u),W(u,n)},m)},E=(u,a,h,D)=>{const{config:C,droppable:T}=D,[v]=Rt(u,T),A=ht(u,T);v.length==0&&w(h,1,C.direction,v);for(const[N,x]of v.entries()){if(!st(x,U))continue;const G=L(C.direction,u,x,h);if(!A&&G)h=G;else if(!A)continue;const K=v.length-N;w(h,K,C.direction,v),a===de?P(x,h):a===Nt&&X(x,h)}},L=(u,a,h,D)=>{const{before:C,distance:T,axis:v,getRect:A}=B(u),N=A(a),x=A(h),G=N[C],K=x[C],St=x[T],ft=K+St/2,Dt=Le(h)[v],rt=ft-Dt;return G>rt?{height:0,width:0}:D},w=(u,a,h,D)=>{const C=D.filter(v=>st(v,U)).length,{distance:T}=B(h);u[T]==0?c=Math.max(c,a):c=Math.min(c,a-1),c=Math.min(c,C)},P=(u,a)=>{const{width:h,height:D}=a;Et(u,D,h)},X=(u,a)=>{const{width:h,height:D}=a;Et(u,D,h),Pt(u,m,ge)},Z=(u,a,h,D,C,T)=>{const{droppable:v,scroll:A,config:N}=C,[x,G]=Rt(u,v),K=x.toReversed(),St=G===-1?K.length:G;K.splice(St,0,u);const[ft,Dt,rt]=V(u,G,K,v);h=yt(u,a,N.direction,n,ft,Dt);const $t=Be(),xt=ln(N.direction,K,G,rt,$t,A,D,v,u);x.length==0&&H(void 0,h,u,xt);for(const[Gt,wt]of x.toReversed().entries()){let Bt=h;rt-1>=Gt&&(Bt={height:0,width:0}),a===jt&&!st(wt,at)&&H(wt,Bt,u,xt)}$(rt,u,N,v,T)},V=(u,a,h,D)=>{const T=ht(u,D)?a:c,v=()=>a<T?[T,T+1]:a>T?[T-1,T]:[T-1,T+1],[A,N]=v(),x=h[A]??null,G=h[N]??null;return[x,G,T]},H=(u,a,h,D)=>{Et(u,a.height,a.width),Et(h,D.height,D.width)},$=(u,a,h,D,C)=>{const{onInsertEvent:T,onDragEnd:v}=h;tt(a,_t),J(a,n,D,()=>{if(Ct(a,_t),C!=null){const A=g(C,!0);A!=null&&(T(u,A,!0),v({value:A,index:u})),q(a),k()}})},k=()=>{if(s){var u=document.querySelectorAll(`${pt(s)} > .${U}`);for(const a of u)Y(a)}},q=u=>{setTimeout(()=>{Ct(u,R)},Cn)},J=(u,a,h,D)=>{setTimeout(()=>{D&&D(),I(a,h),z(h),nt(u),W(u,a),W(u,h)},m)},I=(u,a)=>{u.isSameNode(a)?bt(u,m):(bt(u,m,!0),bt(a,m))},z=u=>{if(n.isSameNode(u))return;var[a]=n.querySelectorAll(`.${at}`);if(!a)return;const{distance:h}=B(l);it(a)&&(a.style[h]="0px")},W=(u,a)=>{const[h]=Rt(u,a);for(const D of[...h,u])Y(D)},Y=u=>{it(u)&&(u.style.transition="",u.style.transform="")},nt=u=>{r(),ot(u,!1),u.style.transform="",u.style.transition="",u.style.top="",u.style.left="",fe(u,{fixedHeight:"",fixedWidth:""})},ut=(u,a)=>{const h=a.querySelector(f);gt(document.body,oe,u),gt(h||a,Wt,u)},ot=(u,a)=>{gt(u,Ft,a),ut(a,u),o.toggleGrabClass(!a)};return[O,y,F,p,ot]}const xn=t=>t.addedNodes.values().filter(n=>!qt(n)).toArray().length>0,Se=(t,e,n)=>{const{insertingFromClass:s,animationDuration:o}=n,r=kt(()=>{const l=ce(e)[t];tt(l,s),tt(l,Kt),setTimeout(()=>{Ct(l,Kt),Ct(l,s),r.disconnect()},o)},e,{childList:!0},xn)},wn=(t,e,n,s)=>{if(!e)return;const{onInsertEvent:o,delayBeforeInsert:r}=t;setTimeout(()=>{o(n,s),Se(n,e,t)},r)},Q=class Q{static addConfig(e,n){const s=Q.configs.filter(r=>!r.droppable.isSameNode(e)),o=Ut(e);s.push({droppable:e,config:n,scroll:o}),Q.configs=s}static updateScrolls(e,n){for(const s of Q.configs){const{droppable:o}=s;(n&&xe(o,n)||o.isSameNode(e))&&(s.scroll=Ut(o))}}static getConfig(e){return Q.configs.find(({droppable:s})=>s.isSameNode(e))}};j(Q,"configs",[]),j(Q,"removeObsoleteConfigs",()=>{const e=Q.configs.filter(({droppable:n})=>document.contains(n));Q.configs=e});let lt=Q;class Bn{constructor(e,n,s,o,r,c){j(this,"initial");j(this,"current");j(this,"parent");j(this,"draggableElement");j(this,"groupClass");j(this,"dragEvent");j(this,"changeDroppable");j(this,"mapFrom");this.parent=s,this.draggableElement=e,this.groupClass=n,this.dragEvent=o,this.mapFrom=c,this.initial=s?lt.getConfig(s):void 0,this.changeDroppable=r}getDraggableAncestor(e,n,s){return document.elementsFromPoint(e,n).filter(o=>!o.isSameNode(s))}getElementBelow(e,n,s=!0){const o=c=>{const[l]=c.getDraggableAncestor(n.clientX,n.clientY,e);return l};let r=null;return s?(e.hidden=!0,r=o(this),e.hidden=!1):r=o(this),r}getCurrent(e,n,s=!0){const o=this.getElementBelow(e,n,s);return!this.groupClass||!o?void 0:o.closest(pt(this.groupClass))}isOutsideOfAllDroppables(e){return(this.groupClass?Array.from(document.querySelectorAll(pt(this.groupClass))):[this.parent]).every(s=>ht(e,s))}isNotInsideAnotherDroppable(e,n){return!ht(e,n)||this.isOutsideOfAllDroppables(e)}onScrollEvent(){this.dragEvent()}setOnScroll(e){ue(e,"onscroll",()=>{this.onScrollEvent()})}getConfigFrom(e){const n=lt.getConfig(e);if(n)return e.isSameNode(this.parent)?n:{...n,config:Ae(n,this.mapFrom)}}getCurrentConfig(e){var o;const n=this.draggableElement;if(this.current&&this.isNotInsideAnotherDroppable(n,(o=this.current)==null?void 0:o.droppable))return this.current;const s=this.getCurrent(n,e);return s?(it(s)&&!s.onscroll&&this.setOnScroll(s),this.getConfigFrom(s)):this.getConfigFrom(this.parent)}updateConfig(e){const n=this.current;this.current=this.getCurrentConfig(e),this.changeDroppable(this.current,n)}isOutside(e,n=!0){const s=this.draggableElement;return!this.getCurrent(s,e,n)}}function Rn(t,e,n,s,o){const{handlerSelector:r,isDraggable:c,droppableGroup:l,animationDuration:f,delayBeforeRemove:g,draggingClass:m,removingClass:b,onRemoveAtEvent:R,droppableClass:O,onDragStart:F}=n,y=At(l).map(i=>`droppable-group-${i}`).join(" ");let p=0,E={scrollX:0,scrollY:0},L={pageX:0,pageY:0},w,P;const[X,Z]=ke(t),[V,H,$,k,q]=An(n,e,s,y,o,()=>p=0),J=()=>{tt(t,U)},I=i=>{tt(i,Mt),o.addSubscriber(i)},z=()=>{if(c(t)){const i=t.querySelector(r);I(i||t)}},W=()=>{z(),J()},Y=i=>{const d=i==null?void 0:i.querySelector(`.${Mt}`),S=d==null?void 0:d.parentElement;return d&&S&&st(S,Xt)&&!S.isSameNode(s)?null:d},nt=i=>{const d=Y(i)??i;d&&c(i)&&(It(d,"onmousedown",G("mousemove","mouseup")),It(d,"ontouchstart",G("touchmove","touchend"),S=>{P={x:S.touches[0].clientX,y:S.touches[0].clientY}}),ut(d)),i!=null&&i.isSameNode(d)||It(i,"onmousedown",K),tt(s,Xt)},ut=i=>{const d=i.querySelectorAll("img");Array.from(d).forEach(S=>{S.onmousedown=()=>!1})},ot=()=>{if(L.pageX==0&&L.pageY==0||!a.current)return;const{droppable:i,config:d}=a.current;X(t,i,L,d.direction),V(t,Nt,E,a.current)},u=(i,d)=>{d&&p==2&&!(i!=null&&i.droppable.isSameNode(d.droppable))&&V(t,Nt,E,d)},a=new Bn(t,y,s,ot,u,n.mapFrom),h=i=>{if(!a.current)return;const d=y?Array.from(document.querySelectorAll(pt(y))):[s];for(const S of d)S.classList.toggle(O,!i&&S.isSameNode(a.current.droppable))},D=(i,d=!1)=>{a.updateConfig(i);const S=a.isOutside(i);h(S),p===1&&!d?rt(i):p===2&&(C(S),xt(i))},C=(i=!0)=>{if(!a.current)return;const{droppable:d}=a.current;yn(d,s,y,f,i),!i&&Yt(t,s,p==1,a.current)},T=i=>{if(Tt(i)&&P&&p==1){const d=Math.abs(i.touches[0].clientX-P.x),S=Math.abs(i.touches[0].clientY-P.y);if(Math.abs(d)>5&&Math.abs(S)>5)return clearTimeout(w),!1}return!0},v=i=>{clearTimeout(w);const d=Vt(i);if(Tt(i)&&i.cancelable&&i.preventDefault(),Tt(i)&&!i.cancelable||!T(i)){ft("touchmove",i);return}D(d,Tt(i))},A=(i,d)=>{i=="touchmove"?w=setTimeout(()=>{d()},150):d()},N=(i,d)=>{const{clientX:S,clientY:dt}=i,ct=document.elementFromPoint(S,dt),vt=ct==null?void 0:ct.closest(`.${U}`);return vt&&d.isSameNode(vt)},x=i=>{const d=n.onGetValue(e);return{index:e,element:i,value:d}},G=(i,d)=>S=>{if(!N(S,t))return;lt.updateScrolls(s,y);const{scrollX:dt,scrollY:ct}=window;if(E={scrollX:dt,scrollY:ct},p===0){p=1;const vt=x(t);vt&&F(vt),A(i,()=>{i=="touchmove"&&(a.updateConfig(S),h(a.isOutside(S)),rt(S))}),document.addEventListener(i,v,{passive:!1}),Gt(s),document.addEventListener(d,St(i),{once:!0})}},K=i=>a.updateConfig(i),St=i=>d=>{ft(i,d)},ft=(i,d)=>{h(!0);const S=Vt(d);Bt(a.isOutside(S,!1)),clearTimeout(w),document.removeEventListener(i,v),a.updateConfig(S);const dt=a.getCurrentConfig(S);if(dt){const{droppable:ct}=dt;Dt(ct)}s.onscroll=null},Dt=i=>{if(i.onscroll=null,!y)return;const d=Array.from(document.querySelectorAll(pt(y)));for(const S of d)it(S)&&(S.onscroll=null)},rt=i=>{Yt(t,s,p==1,a.current),$t(),V(t,de,E,a.current),De(t),Z(i,t)},$t=()=>{p=2},xt=i=>{const{pageX:d,pageY:S}=i;L={pageX:d,pageY:S},ot()},Gt=i=>ue(i,"onscroll",wt),wt=()=>ot(),Bt=i=>{if(p!==2&&p!==1){p=0;return}p=3,Jt(t),t.classList.contains(Ft)&&V(t,jt,E,i?a.initial:a.current,e)},Jt=i=>{Pt(i,f,ge),Et(i,0,0)},De=i=>{const{height:d,width:S}=i.getBoundingClientRect();fe(i,{fixedHeight:`${d}px`,fixedWidth:`${S}px`}),q(i,!0),gt(i,m,!0),i.style.transition=""},ve=(i,d)=>{Ct(t,b),Yt(t,s,p==1,a.initial),H(i,t,d,S=>{Jt(S),k(t)}),R(e,!0)},be=i=>{if(!a.initial)return;const d=a.initial;i==e&&(tt(t,b),setTimeout(()=>{ve(i,d)},g))},Te=(i,d)=>{(i===e||i===n.onGetLegth()&&e===i-1)&&$(i,t,s,d,()=>{Tn(t,p==1,a.initial)})};return W(),nt(t),[be,Te]}const Ln=(t,e)=>{t&&we(e,t)},Mn=()=>{He(document.body,[`.${U}{touch-action:manipulation;user-select:none;box-sizing:border-box!important;-webkit-user-select:none;}`,`.${Mt}{pointer-events:auto!important;}`,`.${re}{cursor:grab;}`,".temp-child{touch-action:none;pointer-events:none;box-sizing:border-box!important;}",".droppable{box-sizing:border-box!important;}",`.${Ft}{position:fixed;z-index:5000;width:var(--fixedWidth)!important;height:var(--fixedHeight)!important;}`,`.${Wt}{pointer-events:none!important;}`,`.${_t}{pointer-events:none!important;}`,`.${oe}{cursor:grabbing;}`,".disable-transition{transition:none!important;}"])};function On(t,e,n,s="index"){const o=s;let r=[],c=[];const{droppableGroup:l}=t;if(!n)return[r,c];const f=At(l).map(g=>`droppable-group-${g}`).join(" ");Mn(),Ln(f,n);for(const g of n.children){const m=g.getAttribute(o),b=Re(m),R=g;if(R&&b>=0){const[O,F]=Rn(R,b,t,n,e);r.push(O),c.push(F)}}return[r,c]}function Nn(t,e,n,s="index"){let o=[],r=[],c;const l=Ce(t,n),f=p=>{for(const E of o)E(p)},g=(p,E)=>{if(l.onGetLegth()===0)t.insertToListEmpty(l,p,E);else for(const w of r)w(p,E)},m=p=>{const[E,L]=On(l,e,p,s);o=E,r=L},b=p=>{const E=p.addedNodes.values().filter(w=>!qt(w)).toArray(),L=p.removedNodes.values().filter(w=>!qt(w)).toArray();return E.length>0||L.length>0},R=p=>{c=kt(()=>{m(p)},p,{childList:!0},b)},O=p=>{tt(p,Xt)},F=p=>{lt.addConfig(p,l)};return[f,g,p=>{if(p)return O(p),F(p),R(p),m(p),lt.removeObsoleteConfigs(),c}]}exports.GRAB_CLASS=re;exports.addClass=tt;exports.dragAndDrop=Nn;exports.insertToListEmpty=wn;exports.toggleClass=gt;
package/dist/index.cjs ADDED
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-DNmnvxhi.cjs");exports.dragAndDrop=e.dragAndDrop;
@@ -0,0 +1,4 @@
1
+ import { DragEndEventData, DragStartEventData, Direction } from "./core";
2
+ import dragAndDrop from "./core/dragAndDrop";
3
+ export type { DragStartEventData, DragEndEventData, Direction };
4
+ export { dragAndDrop };
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ import dragAndDrop from "./core/dragAndDrop";
2
+ export { dragAndDrop };
package/dist/index.mjs ADDED
@@ -0,0 +1,4 @@
1
+ import { d as o } from "./index-BQUYvZRn.js";
2
+ export {
3
+ o as dragAndDrop
4
+ };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react"),y=require("../HandlerPublisher-F9_9P96L.cjs"),b=require("../index-C37ab-rG.cjs"),S=require("react-dom");function A(a,f){const[e,n]=s.useState(a),i=s.useRef(e);s.useEffect(()=>{i.current=e},[e]);function g(t,r=!1){const c=i.current[t],o=()=>{n(u=>[...u.slice(0,t),...u.slice(t+1)])};return r?S.flushSync(o):o(),c}function d(t,r,c=!1){const o=()=>{n(u=>[...u.slice(0,t),r,...u.slice(t)])};c?S.flushSync(o):o()}function h(){return e.length}function m(t){return e[t]}function l(t,r,c){b.insertToListEmpty(t,f.current,r,c)}return[e,n,{removeAtEvent:g,insertEvent:d,getLength:h,getValue:m,insertToListEmpty:l}]}const D=new y.HandlerPublisher;function E(a,f){const e=s.useRef(null),[n,i,g]=A(a,e),[d,h,m]=s.useMemo(()=>b.dragAndDrop(g,D,f,"data-index"),[n.length]);return s.useEffect(()=>{const l=m(e.current);return()=>{l&&(console.log("disconnect"),l.disconnect())}},[n.length]),[e,n,i,h,d]}exports.useDragAndDrop=E;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react"),y=require("../HandlerPublisher-C-jTncuG.cjs"),b=require("../index-DNmnvxhi.cjs"),S=require("react-dom");function A(a,f){const[e,n]=s.useState(a),i=s.useRef(e);s.useEffect(()=>{i.current=e},[e]);function g(t,r=!1){const c=i.current[t],o=()=>{n(u=>[...u.slice(0,t),...u.slice(t+1)])};return r?S.flushSync(o):o(),c}function d(t,r,c=!1){const o=()=>{n(u=>[...u.slice(0,t),r,...u.slice(t)])};c?S.flushSync(o):o()}function h(){return e.length}function m(t){return e[t]}function l(t,r,c){b.insertToListEmpty(t,f.current,r,c)}return[e,n,{removeAtEvent:g,insertEvent:d,getLength:h,getValue:m,insertToListEmpty:l}]}const D=new y.HandlerPublisher;function E(a,f){const e=s.useRef(null),[n,i,g]=A(a,e),[d,h,m]=s.useMemo(()=>b.dragAndDrop(g,D,f,"data-index"),[n.length]);return s.useEffect(()=>{const l=m(e.current);return()=>{l&&(console.log("disconnect"),l.disconnect())}},[n.length]),[e,n,i,h,d]}exports.useDragAndDrop=E;
@@ -1,3 +1,2 @@
1
- import { default as useDragAndDrop } from './useDragAndDrop';
2
-
1
+ import useDragAndDrop from "./useDragAndDrop";
3
2
  export { useDragAndDrop };
@@ -0,0 +1,2 @@
1
+ import useDragAndDrop from "./useDragAndDrop";
2
+ export { useDragAndDrop };
@@ -1,6 +1,6 @@
1
1
  import { useState as S, useRef as p, useEffect as E, useMemo as b } from "react";
2
- import { H as A } from "../HandlerPublisher-BbQeSll4.js";
3
- import { i as C, d as L } from "../index-8zYdjZIf.js";
2
+ import { H as A } from "../HandlerPublisher-BYI2bw4n.js";
3
+ import { i as C, d as L } from "../index-BQUYvZRn.js";
4
4
  import { flushSync as h } from "react-dom";
5
5
  function v(a, l) {
6
6
  const [t, n] = S(a), i = p(t);
@@ -1,3 +1,2 @@
1
- import { Config } from '../core';
2
-
3
- export default function useDragAndDrop<T, E extends HTMLElement>(items: T[], config?: Config<T>): readonly [import('react').RefObject<E>, T[], import('react').Dispatch<import('react').SetStateAction<T[]>>, (index: number, value: T) => void, (index: number) => void];
1
+ import { Config } from "../core";
2
+ export default function useDragAndDrop<T, E extends HTMLElement>(items: T[], config?: Config<T>): readonly [import("react").RefObject<E>, T[], import("react").Dispatch<import("react").SetStateAction<T[]>>, (index: number, value: T) => void, (index: number) => void];
@@ -0,0 +1,28 @@
1
+ import { useEffect, useMemo, useRef } from "react";
2
+ import HandlerPublisher from "../core/HandlerPublisher";
3
+ import { dragAndDrop } from "../index";
4
+ import { useReactListConfig } from "./utils/ReactLilstConfig";
5
+ /**
6
+ * Create the parent element of the draggable children and all the drag and drop events and styles.
7
+ *
8
+ * @template T - Type of the items.
9
+ * @param items - List of data to drag and drop.
10
+ * @param config - Configuration of drag and drop tool.
11
+ * @returns The reference of the parent element and function to remove an element.
12
+ */
13
+ const handlerPublisher = new HandlerPublisher();
14
+ export default function useDragAndDrop(items, config) {
15
+ const parent = useRef(null);
16
+ const [itemsState, setItemsState, listCondig] = useReactListConfig(items, parent);
17
+ const [removeAt, insertAt, onChangeParent] = useMemo(() => dragAndDrop(listCondig, handlerPublisher, config, 'data-index'), [itemsState.length]);
18
+ useEffect(() => {
19
+ const observer = onChangeParent(parent.current);
20
+ return () => {
21
+ if (observer) {
22
+ console.log('disconnect');
23
+ observer.disconnect();
24
+ }
25
+ };
26
+ }, [itemsState.length]);
27
+ return [parent, itemsState, setItemsState, insertAt, removeAt];
28
+ }
@@ -1,4 +1,3 @@
1
- import { RefObject } from 'react';
2
- import { ListCondig } from '../../core';
3
-
4
- export declare function useReactListConfig<T, E extends HTMLElement>(items: T[], parent: RefObject<E>): readonly [T[], import('react').Dispatch<import('react').SetStateAction<T[]>>, ListCondig<T>];
1
+ import { RefObject } from "react";
2
+ import { ListCondig } from "../../core";
3
+ export declare function useReactListConfig<T, E extends HTMLElement>(items: T[], parent: RefObject<E>): readonly [T[], import("react").Dispatch<import("react").SetStateAction<T[]>>, ListCondig<T>];
@@ -0,0 +1,64 @@
1
+ import { useEffect, useRef, useState } from "react";
2
+ import { insertToListEmpty as insertToListEmptyEvent } from "../../core/utils/events/emitEvents";
3
+ // @ts-ignore
4
+ import { flushSync } from "react-dom";
5
+ export function useReactListConfig(items, parent) {
6
+ const [itemsState, setItemsState] = useState(items);
7
+ const stateRef = useRef(itemsState);
8
+ useEffect(() => {
9
+ stateRef.current = itemsState;
10
+ }, [itemsState]);
11
+ function removeAtEvent(index, sync = false) {
12
+ const deletedItem = stateRef.current[index];
13
+ const removeCallback = () => {
14
+ setItemsState(prevItems => [
15
+ ...prevItems.slice(0, index),
16
+ ...prevItems.slice(index + 1)
17
+ ]);
18
+ };
19
+ if (sync) {
20
+ flushSync(removeCallback);
21
+ }
22
+ else {
23
+ removeCallback();
24
+ }
25
+ return deletedItem;
26
+ }
27
+ ;
28
+ function insertEvent(index, value, sync = false) {
29
+ const insertCallback = () => {
30
+ setItemsState(prevItems => {
31
+ return [
32
+ ...prevItems.slice(0, index),
33
+ value,
34
+ ...prevItems.slice(index)
35
+ ];
36
+ });
37
+ };
38
+ if (sync) {
39
+ flushSync(insertCallback);
40
+ }
41
+ else {
42
+ insertCallback();
43
+ }
44
+ }
45
+ ;
46
+ function getLength() {
47
+ return itemsState.length;
48
+ }
49
+ ;
50
+ function getValue(index) {
51
+ return itemsState[index];
52
+ }
53
+ function insertToListEmpty(config, index, value) {
54
+ insertToListEmptyEvent(config, parent.current, index, value);
55
+ }
56
+ const actions = {
57
+ removeAtEvent,
58
+ insertEvent,
59
+ getLength,
60
+ getValue,
61
+ insertToListEmpty
62
+ };
63
+ return [itemsState, setItemsState, actions];
64
+ }
@@ -1 +1 @@
1
- "use strict";var u=Object.defineProperty;var d=(n,t,e)=>t in n?u(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var s=(n,t,e)=>d(n,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../HandlerPublisher-F9_9P96L.cjs"),o=require("../index-C37ab-rG.cjs");class g{constructor(t){s(this,"items");s(this,"parent");this.items=t}setParent(t){this.parent=t}removeAtEvent(t){const e=this.items;if(e.length<=0)return;const[r]=e.splice(t,1);return r}insertEvent(t,e){this.items.splice(t,0,e)}getLength(){return this.items.length}getValue(t){return this.items[t]}insertToListEmpty(t,e,r){o.insertToListEmpty(t,this.parent,e,r)}}const h=new c.HandlerPublisher;function m(n,t){const e=new g(n),[r,l,a]=o.dragAndDrop(e,h,t,"data-index");return[i=>(e.setParent(i),a(i),{destroy(){}}),l,r]}exports.useDragAndDrop=m;
1
+ "use strict";var u=Object.defineProperty;var d=(n,t,e)=>t in n?u(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var s=(n,t,e)=>d(n,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../HandlerPublisher-C-jTncuG.cjs"),o=require("../index-DNmnvxhi.cjs");class g{constructor(t){s(this,"items");s(this,"parent");this.items=t}setParent(t){this.parent=t}removeAtEvent(t){const e=this.items;if(e.length<=0)return;const[r]=e.splice(t,1);return r}insertEvent(t,e){this.items.splice(t,0,e)}getLength(){return this.items.length}getValue(t){return this.items[t]}insertToListEmpty(t,e,r){o.insertToListEmpty(t,this.parent,e,r)}}const h=new c.HandlerPublisher;function m(n,t){const e=new g(n),[r,l,a]=o.dragAndDrop(e,h,t,"data-index");return[i=>(e.setParent(i),a(i),{destroy(){}}),l,r]}exports.useDragAndDrop=m;
@@ -1,3 +1,2 @@
1
- import { default as useDragAndDrop } from './useDragAndDrop';
2
-
1
+ import useDragAndDrop from "./useDragAndDrop";
3
2
  export { useDragAndDrop };
@@ -0,0 +1,2 @@
1
+ import useDragAndDrop from "./useDragAndDrop";
2
+ export { useDragAndDrop };
@@ -1,8 +1,8 @@
1
1
  var l = Object.defineProperty;
2
2
  var d = (n, t, e) => t in n ? l(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
3
3
  var r = (n, t, e) => d(n, typeof t != "symbol" ? t + "" : t, e);
4
- import { H as c } from "../HandlerPublisher-BbQeSll4.js";
5
- import { i as m, d as u } from "../index-8zYdjZIf.js";
4
+ import { H as c } from "../HandlerPublisher-BYI2bw4n.js";
5
+ import { i as m, d as u } from "../index-BQUYvZRn.js";
6
6
  class h {
7
7
  constructor(t) {
8
8
  r(this, "items");
@@ -1,5 +1,4 @@
1
- import { Config } from '../core';
2
-
1
+ import { Config } from "../core";
3
2
  export default function useDragAndDrop<T>(items: T[], config?: Config<T>): readonly [(parent: HTMLElement) => {
4
3
  destroy(): void;
5
4
  }, (index: number, value: T) => void, (index: number) => void];
@@ -0,0 +1,25 @@
1
+ import HandlerPublisher from "../core/HandlerPublisher";
2
+ import { dragAndDrop } from "../index";
3
+ import { SvelteListCondig } from "./utils/SvelteListCondig";
4
+ /**
5
+ * Create the parent element of the draggable children and all the drag and drop events and styles.
6
+ *
7
+ * @template T - Type of the items.
8
+ * @param items - List of data to drag and drop.
9
+ * @param config - Configuration of drag and drop tool.
10
+ * @returns The reference of the parent element and function to remove an element.
11
+ */
12
+ const handlerPublisher = new HandlerPublisher();
13
+ export default function useDragAndDrop(items, config) {
14
+ const listCondig = new SvelteListCondig(items);
15
+ const [removeAt, insertAt, onChangeParent] = dragAndDrop(listCondig, handlerPublisher, config, 'data-index');
16
+ const dragAndDropAction = (parent) => {
17
+ listCondig.setParent(parent);
18
+ onChangeParent(parent);
19
+ return {
20
+ destroy() {
21
+ }
22
+ };
23
+ };
24
+ return [dragAndDropAction, insertAt, removeAt];
25
+ }
@@ -1,5 +1,5 @@
1
- import { CoreConfig, ListCondig } from '../../core';
2
-
1
+ import { CoreConfig } from "../../core";
2
+ import { ListCondig } from "../../core";
3
3
  export declare class SvelteListCondig<T> implements ListCondig<T> {
4
4
  private items;
5
5
  private parent;
@@ -0,0 +1,36 @@
1
+ import { insertToListEmpty } from "../../core/utils/events/emitEvents";
2
+ export class SvelteListCondig {
3
+ items;
4
+ parent;
5
+ constructor(items) {
6
+ this.items = items;
7
+ }
8
+ setParent(parent) {
9
+ this.parent = parent;
10
+ }
11
+ ;
12
+ removeAtEvent(index) {
13
+ const listValue = this.items;
14
+ if (listValue.length <= 0) {
15
+ return;
16
+ }
17
+ const [deletedItem] = listValue.splice(index, 1);
18
+ return deletedItem;
19
+ }
20
+ ;
21
+ insertEvent(index, value) {
22
+ const listValue = this.items;
23
+ listValue.splice(index, 0, value);
24
+ }
25
+ ;
26
+ getLength() {
27
+ return this.items.length;
28
+ }
29
+ ;
30
+ getValue(index) {
31
+ return this.items[index];
32
+ }
33
+ insertToListEmpty(config, index, value) {
34
+ insertToListEmpty(config, this.parent, index, value);
35
+ }
36
+ }
@@ -1 +1 @@
1
- "use strict";var c=Object.defineProperty;var h=(n,e,t)=>e in n?c(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var s=(n,e,t)=>h(n,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("vue"),g=require("../HandlerPublisher-F9_9P96L.cjs"),u=require("../index-C37ab-rG.cjs"),v=(n,e)=>{const t=n.value;if(t.length<=0)return;const[r]=t.splice(e,1);return r},d=(n,e,t)=>{n.value.splice(e,0,t)},m=n=>n.value.length,p=(n,e)=>n.value[e];class V{constructor(e,t){s(this,"items");s(this,"parent");this.items=e,this.parent=t}removeAtEvent(e){return v(this.items,e)}insertEvent(e,t){return d(this.items,e,t)}getLength(){return m(this.items)}getValue(e){return p(this.items,e)}insertToListEmpty(e,t,r){u.insertToListEmpty(e,this.parent.value,t,r)}}const A=new g.HandlerPublisher;function L(n,e){const t=i.ref();var r=new V(n,t);const[l,o,a]=u.dragAndDrop(r,A,e);return i.watch(t,()=>{a(t.value)}),[t,o,l]}exports.useDragAndDrop=L;
1
+ "use strict";var c=Object.defineProperty;var h=(n,e,t)=>e in n?c(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var s=(n,e,t)=>h(n,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("vue"),g=require("../HandlerPublisher-C-jTncuG.cjs"),u=require("../index-DNmnvxhi.cjs"),v=(n,e)=>{const t=n.value;if(t.length<=0)return;const[r]=t.splice(e,1);return r},d=(n,e,t)=>{n.value.splice(e,0,t)},m=n=>n.value.length,p=(n,e)=>n.value[e];class V{constructor(e,t){s(this,"items");s(this,"parent");this.items=e,this.parent=t}removeAtEvent(e){return v(this.items,e)}insertEvent(e,t){return d(this.items,e,t)}getLength(){return m(this.items)}getValue(e){return p(this.items,e)}insertToListEmpty(e,t,r){u.insertToListEmpty(e,this.parent.value,t,r)}}const A=new g.HandlerPublisher;function L(n,e){const t=i.ref();var r=new V(n,t);const[l,o,a]=u.dragAndDrop(r,A,e);return i.watch(t,()=>{a(t.value)}),[t,o,l]}exports.useDragAndDrop=L;
@@ -1,3 +1,2 @@
1
- import { default as useDragAndDrop } from './useDragAndDrop';
2
-
1
+ import useDragAndDrop from "./useDragAndDrop";
3
2
  export { useDragAndDrop };
@@ -0,0 +1,2 @@
1
+ import useDragAndDrop from "./useDragAndDrop";
2
+ export { useDragAndDrop };
@@ -2,8 +2,8 @@ var l = Object.defineProperty;
2
2
  var u = (n, t, e) => t in n ? l(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
3
3
  var r = (n, t, e) => u(n, typeof t != "symbol" ? t + "" : t, e);
4
4
  import { ref as c, watch as m } from "vue";
5
- import { H as h } from "../HandlerPublisher-BbQeSll4.js";
6
- import { i as p, d as v } from "../index-8zYdjZIf.js";
5
+ import { H as h } from "../HandlerPublisher-BYI2bw4n.js";
6
+ import { i as p, d as v } from "../index-BQUYvZRn.js";
7
7
  const g = (n, t) => {
8
8
  const e = n.value;
9
9
  if (e.length <= 0)
@@ -1,4 +1,3 @@
1
- import { Ref } from 'vue';
2
- import { Config } from '../core';
3
-
1
+ import { Ref } from "vue";
2
+ import { Config } from "../core";
4
3
  export default function useDragAndDrop<T>(items: Ref<T[]>, config?: Config<T>): readonly [Ref<HTMLElement | undefined, HTMLElement | undefined>, (index: number, value: T) => void, (index: number) => void];
@@ -0,0 +1,23 @@
1
+ // @ts-ignore
2
+ import { ref, watch } from "vue";
3
+ import HandlerPublisher from "../core/HandlerPublisher";
4
+ import { VueListCondig } from "./utils/VueListCondig";
5
+ import { dragAndDrop } from "../index";
6
+ /**
7
+ * Create the parent element of the draggable children and all the drag and drop events and styles.
8
+ *
9
+ * @template T - Type of the items.
10
+ * @param items - List of data to drag and drop.
11
+ * @param config - Configuration of drag and drop tool.
12
+ * @returns The reference of the parent element and function to remove an element.
13
+ */
14
+ const handlerPublisher = new HandlerPublisher();
15
+ export default function useDragAndDrop(items, config) {
16
+ const parent = ref();
17
+ var listCondig = new VueListCondig(items, parent);
18
+ const [removeAt, insertAt, onChangeParent] = dragAndDrop(listCondig, handlerPublisher, config);
19
+ watch(parent, () => {
20
+ onChangeParent(parent.value);
21
+ });
22
+ return [parent, insertAt, removeAt];
23
+ }
@@ -1,5 +1,4 @@
1
- import { Ref } from 'vue';
2
-
1
+ import { Ref } from "vue";
3
2
  export declare const removeAtEventOnList: <T>(list: Ref<T[]>, index: number) => T | undefined;
4
3
  export declare const onInsertEventOnList: <T>(list: Ref<T[]>, index: number, value: T) => void;
5
4
  export declare const getLength: <T>(list: Ref<T[]>) => number;
@@ -0,0 +1,19 @@
1
+ export const removeAtEventOnList = (list, index) => {
2
+ const listValue = list.value;
3
+ if (listValue.length <= 0) {
4
+ return;
5
+ }
6
+ const [deletedItem] = listValue.splice(index, 1);
7
+ return deletedItem;
8
+ };
9
+ export const onInsertEventOnList = (list, index, value) => {
10
+ const listValue = list.value;
11
+ listValue.splice(index, 0, value);
12
+ };
13
+ export const getLength = (list) => {
14
+ const listValue = list.value;
15
+ return listValue.length;
16
+ };
17
+ export const getValue = (list, index) => {
18
+ return list.value[index];
19
+ };
@@ -1,6 +1,6 @@
1
- import { CoreConfig, ListCondig } from '../../core';
2
- import { Ref } from 'vue';
3
-
1
+ import { CoreConfig } from "../../core";
2
+ import { ListCondig } from "../../core";
3
+ import { Ref } from "vue";
4
4
  export declare class VueListCondig<T> implements ListCondig<T> {
5
5
  private items;
6
6
  private parent;
@@ -0,0 +1,28 @@
1
+ import { getLength, getValue, onInsertEventOnList, removeAtEventOnList } from "./DropMethods";
2
+ import { insertToListEmpty } from "../../core/utils/events/emitEvents";
3
+ export class VueListCondig {
4
+ items;
5
+ parent;
6
+ constructor(items, parent) {
7
+ this.items = items;
8
+ this.parent = parent;
9
+ }
10
+ removeAtEvent(index) {
11
+ return removeAtEventOnList(this.items, index);
12
+ }
13
+ ;
14
+ insertEvent(index, value) {
15
+ return onInsertEventOnList(this.items, index, value);
16
+ }
17
+ ;
18
+ getLength() {
19
+ return getLength(this.items);
20
+ }
21
+ ;
22
+ getValue(index) {
23
+ return getValue(this.items, index);
24
+ }
25
+ insertToListEmpty(config, index, value) {
26
+ insertToListEmpty(config, this.parent.value, index, value);
27
+ }
28
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fluid-dnd",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
4
4
  "description": "An agnostic drag and drop library to sort all kind of lists. With current support for vue, react and svelte",
5
5
  "type": "module",
6
6
  "homepage": "https://fluid-dnd.netlify.app",
@@ -11,7 +11,7 @@
11
11
  "files": [
12
12
  "dist"
13
13
  ],
14
- "main": ".dist/index.cjs",
14
+ "main": "./dist/index.cjs",
15
15
  "exports": {
16
16
  "./vue": {
17
17
  "types": "./dist/vue/index.d.ts",
@@ -31,10 +31,10 @@
31
31
  ".": {
32
32
  "types": "./dist/index.d.ts",
33
33
  "import": "./dist/index.mjs",
34
- "require": "./dist/index.umd.cjs"
34
+ "require": "./dist/index.cjs"
35
35
  }
36
36
  },
37
- "types": "./index.d.ts",
37
+ "types": "./dist/index.d.ts",
38
38
  "keywords": [
39
39
  "vue",
40
40
  "react",
@@ -58,9 +58,7 @@
58
58
  "license": "MIT",
59
59
  "devDependencies": {
60
60
  "@playwright/test": "^1.43.0",
61
- "eslint-plugin-vue": "^9.33.0",
62
61
  "@types/node": "^20.12.5",
63
- "@vitejs/plugin-vue": "^4.5.2",
64
62
  "@types/react": "^18.3.20",
65
63
  "@types/react-dom": "^19.1.2",
66
64
  "jsdom": "^24.0.0",
@@ -68,14 +66,13 @@
68
66
  "vite": "^5.0.8",
69
67
  "vite-plugin-dts": "^3.7.0",
70
68
  "vitest": "^1.2.2",
71
- "vue-tsc": "^2.2.8",
72
69
  "prettier-plugin-svelte": "^3.3.3",
73
70
  "svelte": "^5.0.0",
74
71
  "vue": ">=3.4.0"
75
72
  },
76
73
  "scripts": {
77
74
  "dev": "cd my-test-examples && vite",
78
- "build": "tsc && vite build",
75
+ "build": "vite build && tsc",
79
76
  "preview": "vite preview",
80
77
  "test": "vitest"
81
78
  }
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../index-C37ab-rG.cjs");exports.dragAndDrop=e.dragAndDrop;
@@ -1,4 +0,0 @@
1
- import { d as o } from "../index-8zYdjZIf.js";
2
- export {
3
- o as dragAndDrop
4
- };
@@ -1 +0,0 @@
1
- "use strict";var Ee=Object.defineProperty;var ye=(t,e,n)=>e in t?Ee(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var j=(t,e,n)=>ye(t,typeof e!="symbol"?e+"":e,n);const U="draggable",Xt="droppable",Mt="handler-class",Ft="dragging",Wt="dragging-handler-class",_t="dropping",oe="grabbing",re="grab",Kt="disable-transition",st=(t,e)=>t.classList.contains(e),gt=(t,e,n=!1)=>{t.classList.toggle(e,n)},tt=(t,e)=>{t.classList.add(e)},Ct=(t,e)=>{t.classList.remove(e)},Ce=(t,e)=>At(e).every(n=>st(t,n)),pt=t=>t?`.${At(t).join(".")}`:"",Ae=(t,e)=>{if(!e)return;const n=At(e);t.classList.add(...n)},At=t=>t?t.split(" ").filter(e=>e):[],_="horizontal",et="vertical",xe=()=>{const{scrollX:t,scrollY:e}=window;return{scrollX:t,scrollY:e}},zt=t=>!t||t.trim().length==0||t=="normal"?0:parseFloat(t),we=t=>t?parseInt(t):-1,Be=t=>{const e=getComputedStyle(t),n=new DOMMatrixReadOnly(e.transform);return{x:n.m41,y:n.m42}},ie=(t,e)=>t.x1>e.x1?ie(e,t):t.x2<e.x1?0:t.x2>=e.x2?t.x2-t.x1:t.x2-e.x1,ht=(t,e)=>!Re(t,e),Re=(t,e)=>{const n=Ot(t),s=Ot(e),o=Qt(n,s,et),r=Qt(n,s,_);return o>=Math.min(n.height,s.height)/2&&r>=Math.min(n.width,s.width)/2},Qt=(t,e,n)=>{const{before:s,distance:o}=B(n);return ie({x1:t[s],x2:t[s]+t[o]},{x1:e[s],x2:e[s]+e[o]})},M=(t,e)=>t?zt(getComputedStyle(t)[e]):0,Ut=t=>{const{scrollLeft:e,scrollTop:n}=t;return{scrollLeft:e,scrollTop:n}},Ot=t=>t.getBoundingClientRect(),B=t=>{const e=t==_;return{beforeMargin:e?"marginLeft":"marginTop",afterMargin:e?"marginRight":"marginBottom",borderBeforeWidth:e?"borderLeftWidth":"borderTopWidth",before:e?"left":"top",after:e?"right":"down",gap:e?"columnGap":"rowGap",distance:e?"width":"height",axis:e?"x":"y",offset:e?"offsetX":"offsetY",scroll:e?"scrollX":"scrollY",scrollElement:e?"scrollLeft":"scrollTop",page:e?"pageX":"pageY",inner:e?"innerWidth":"innerHeight",offsetElement:e?"offsetLeft":"offsetTop",scrollDistance:e?"scrollWidth":"scrollHeight",clientDistance:e?"clientWidth":"clientHeight",paddingBefore:e?"paddingLeft":"paddingTop",getRect:Ot}},Rt=(t,e)=>Le(t,e),ce=t=>[...t.children].filter(n=>st(n,U)),Le=(t,e)=>{const n=[...e.children].filter(o=>st(o,U)&&!o.isEqualNode(t)).toReversed(),s=[...e.children].findLastIndex(o=>o.isEqualNode(t));return[n,s,e]},Me=t=>{let e=t.parentElement;for(;e;){if(window.getComputedStyle(e).position==="fixed")return e;e=e.parentElement}return null},ae=(t,e)=>{const{before:n,borderBeforeWidth:s}=B(e),o=Me(t);return o?Ot(o)[n]+M(o,s):0},Tt=t=>window.TouchEvent&&t instanceof TouchEvent,it=t=>t instanceof HTMLElement,le=t=>t instanceof MouseEvent,Oe=["onmouseup","onmousedown","onmousemove"],Ne=(t,e,n)=>{t&&(t.style.height=`${e}px`,t.style.width=`${n}px`)},Et=(t,e,n)=>{!t||!it(t)||(n==0&&e==0?t.style.transform="":t.style.transform=`translate(${n}px,${e}px)`)},Fe=(t,e,n,s)=>{t[e]=o=>{if(o.defaultPrevented)return;s&&s(o);const r=Vt(o);n(r)}},It=(t,e,n,s)=>{n&&(Pe(e)?t[e]=n:Fe(t,e,n,s))},Pe=t=>Oe.includes(t),$e=t=>{const{target:e}=t;return{clientX:0,clientY:0,pageX:0,pageY:0,screenX:0,screenY:0,target:e,offsetX:0,offsetY:0}},Ge=(t,e)=>{const n=(s,o)=>Ye(e,window,o,s);if(le(t)){const{offsetX:s,offsetY:o}=t;return[s,o]}else{const s=t.target;return[n(s,_),n(s,et)]}},Vt=t=>{const e=Ie(t);if(!e)return $e(t);const[n,s]=Ge(t,e),{clientX:o,clientY:r,pageX:c,pageY:l,screenX:f,screenY:g,target:m}=e;return{clientX:o,clientY:r,pageX:c,pageY:l,screenX:f,screenY:g,target:m,offsetX:n,offsetY:s}},Ie=t=>{if(Tt(t))return t.touches[0]??t.changedTouches[0];if(le(t))return t},Ye=(t,e,n,s)=>{const{page:o,scroll:r,before:c,borderBeforeWidth:l,getRect:f}=B(n),g=f(s);return t[o]-e[r]-g[c]-M(s,l)},Pt=(t,e,n="ease-out",s="transform")=>{it(t)&&(t.style.transitionDuration=`${e}ms`,t.style.transitionTimingFunction=`${n}`,t.style.transitionProperty=`${s}`)},ue=(t,e,n)=>{!t||!it(t)||(t[e]=()=>{n()})},Xe=t=>{var e=t.querySelector("style");if(!e){var n=document.createElement("style");return t.appendChild(n),n}return e},We=(t,e)=>{const n=/\.-?[_a-zA-Z0-9-*\s<>():]+/g,[s]=e.match(n)||[];for(const o of t.cssRules){const[r]=o.cssText.match(n)||[];if(s===r)return!0}return!1},_e=(t,e)=>{e.forEach(n=>{Ve(t,n)})},Ve=(t,e)=>{var s;var n=Xe(t);n.sheet&&(We(n.sheet,e)||(s=n.sheet)==null||s.insertRule(e,n.sheet.cssRules.length))},fe=(t,e={})=>{for(const n of Object.keys(e)){const s=e[n];s!=null&&He(t,`--${n}`,s)}},He=(t,e,n)=>t&&t.style.setProperty(e,n),de="startDrag",Nt="drag",jt="startDrop",qe="drop",at="temp-child",ge="cubic-bezier(0.2, 0, 0, 1)",ze=t=>t===qe||t===jt,Ht=t=>!t||t.length==0?0:zt(t.replace("px","")),je=(t,e)=>{const n=getComputedStyle(t)[e];if(n.match("%")){const o=zt(n.replace("%","")),{width:r}=t.getBoundingClientRect();return r*(o/100)}return Ht(n)},Zt=(t,e)=>{if(!(t instanceof Element))return[0,!1];const n=je(t,e),s=getComputedStyle(t).display,o=n>0||s==="flex";return[n,o]},Ze=t=>{const{top:e,left:n}=getComputedStyle(t);return[Ht(e),Ht(n)]},ke=(t,e)=>{const{gap:n}=B(e),[s,o]=Zt(t,n);return o?s:0};function yt(t,e,n,s,o=t.previousElementSibling,r=t.nextElementSibling){let{height:c,width:l}=Je(n,t,o,r);return ht(t,s)&&e==Nt&&(c=0,l=0),{height:c,width:l}}const Je=(t,e,n,s)=>{const{afterMargin:o,beforeMargin:r,distance:c,gap:l,getRect:f}=B(t),g=M(e,o),m=M(e,r),b=M(s,r),[R,O]=Zt(e.parentElement,l),F=f(e)[c];if(O)return te(F,m,g,R,0,t);const[y,p,E]=Ke(n,b,g,m,o);return te(F,p,y,0,E,t)},Ke=(t,e,n,s,o)=>{const r=Math.max(e,n);let c=s,l=e;if(t){const f=M(t,o);c=Math.max(f,s),l=Math.max(l,f)}return[r,c,l]},te=(t,e,n,s,o,r)=>Qe(r,t+e+n+s-o),Qe=(t,e)=>t==_?{width:e,height:0}:{width:0,height:e},ee=(t,e)=>{const{borderBeforeWidth:n,paddingBefore:s,axis:o,getRect:r}=B(t),c=M(e,n),l=M(e,s),f=r(e)[o];return c+l+f},Ue=(t,e)=>{const[n,s]=Ze(e),o=ee(et,t);return[ee(_,t)-s,o-n]};function tn(t,e,n,s,o,r,c,l,f){let g=0,m=0;const b=!!(n<0&&f);if(n===s&&!b)return ne({height:g,width:m},t,o,c,b);const[R,O,F,y]=sn(e,n,s,f);if(b){const[nt,ut]=Ue(l,f);g+=ut,m+=nt}const{scrollElement:p,beforeMargin:E,afterMargin:L,distance:w,gap:P}=B(t),[X,Z]=Zt(l,P),[V,H,$]=rn(E,L,R,O==null?void 0:O.previousElementSibling,y,Z,b),[k,q,J]=on(E,L,w,F,X,Z),I=nn(q,k,J,H,V,X),z=b?l[p]:en(p,l,r),Y=(y?I-$:$-I)-z;return t===et?g+=Y:t===_&&(m+=Y),ne({height:g,width:m},t,o,c,b)}const en=(t,e,n)=>{const s=e[t],o=n[t];return s-o},nn=(t,e,n,s,o,r)=>{const c=Math.max(e,o);return Math.max(n,s)+t+c+r},sn=(t,e,n,s)=>{const o=e<n,[r,c]=[e,n].toSorted((m,b)=>m-b),l=t[e]??s,f=t[n];let g=o?t.slice(r+1,c+1):t.slice(r,c);return r<0&&s&&(g=t.slice(r+1,c)),[l,f,g,o]},on=(t,e,n,s,o,r)=>{if(s.length==0)return[0,0,0];const c=M(s[0],t);let l=0,f=-c;for(const[g,m]of s.entries()){const b=m.getBoundingClientRect()[n],R=M(m,t);r&&(l+=R),r&&g>0?l+=o:l=Math.max(l,R),f+=l+b,l=M(m,e)}return[c,f,l]},ne=(t,e,n,s,o)=>{const{scroll:r,distance:c}=B(e),l=window[r],f=n[r],g=o?0:f-2*l+s[r];return t[c]+=g,t},rn=(t,e,n,s,o,r,c)=>{const l=o?n.previousElementSibling:s;return cn(t,e,l,n,r,c)},cn=(t,e,n,s,o,r)=>{if(o)return[0,0,0];const c=M(r?null:n,e),l=M(s,t);let f=Math.max(c,l);return[c,l,f]},kt=(t,e,n,s=()=>!0)=>{const o=new MutationObserver(r=>{if(r=r.filter(s),r.length>0){const c=r[0];t(o,c)}});return o.observe(e,n),o},an=(t,e,n)=>{n!=0&&(e==="vertical"?t.scrollBy(0,n):t.scrollBy(n,0))},ln=(t,e,n)=>{const{scrollDistance:s,clientDistance:o,scrollElement:r}=B(t);return n[r]/(e[s]-e[o])},un="startDrag",pe="cubic-bezier(0.2, 0, 0, 1)",he=50,qt=t=>it(t)?t.classList.contains(at):!1,fn=(t,e,n)=>{let s=yt(e,un,n,t);const o=ke(t,n),{distance:r}=B(n);s[r]-=o;const[c,l]=dn(n,e);return s[l]=c,s},dn=(t,e)=>{const n=t==_?et:_,{distance:s,getRect:o}=B(n);return[o(e)[s],s]},mt=(t,e,n)=>{Ne(t,e,n),t.style.minWidth=`${n}px`},gn=(t,e,n)=>s=>{e.contains(t)&&(mt(t,n.height,n.width),s.disconnect())},pn=(t,e)=>{if(!e)return;const{droppable:n,config:s,scroll:o}=t,{direction:r}=s,c=ln(s.direction,n,o)>.99,{scrollDistance:l,clientDistance:f,scrollElement:g}=B(r);c&&(n[g]=n[l]-n[f])},me=(t,e,n,s)=>{if(!n)return;const{droppable:o,config:r}=n,{direction:c,animationDuration:l}=r;if(pn(n,e),o.querySelector(`.${at}`)||!t)return;var f=t.tagName=="LI"?"DIV":t.tagName,g=document.createElement(f);tt(g,at),mt(g,0,0);const m=fn(o,t,c);return Pt(g,l,pe,"width, min-width, height"),[g,m,o]},Yt=(t,e,n,s,o)=>{const r=me(t,n,s);if(!r)return;const[c,l,f]=r;e.isSameNode(f)&&mt(c,l.height,l.width),kt(gn(c,f,l),f,{childList:!0,subtree:!0}),f.appendChild(c)},hn=(t,e,n)=>{const s=me(t,e,n);if(!s)return;const[o,r,c]=s;c.appendChild(o),mn(o,r)},mn=(t,e)=>requestAnimationFrame(()=>{mt(t,e.height,e.width),requestAnimationFrame(()=>{Pt(t,0,pe,"width, min-width, height")})}),Sn=(t,e,n,s,o=!0)=>{if(n){var r=document.querySelectorAll(`${pt(n)} > .${at}`);r.forEach(c=>{const l=c.parentElement;if(l!=null&&l.isSameNode(e)||!o&&(l!=null&&l.isSameNode(t)))return;mt(c,0,0),setTimeout(()=>{var g;(g=c.parentNode)==null||g.removeChild(c)},s+he)})}},bt=(t,e,n=!1)=>{var s=t.querySelectorAll(`.${at}`);s.forEach(o=>{const r=o;n?(mt(r,0,0),setTimeout(()=>{t.contains(r)&&t.removeChild(r)},e+he)):t.removeChild(o)})},Dn=50;function vn(t,e,n,s,o,r){let c=e;const{direction:l,handlerSelector:f,onRemoveAtEvent:g,animationDuration:m,delayBeforeInsert:b,draggingClass:R}=t,O=(u,a,h,D,C)=>{if(!D)return;const{droppable:T,config:v}=D,A=yt(u,a,v.direction,T);ze(a)?Z(u,a,A,h,D,C):E(u,a,A,D)},F=(u,a,h,D,C)=>{const T=yt(a,"insert",t.direction,h),{onInsertEvent:v}=t,A=ce(h);for(const[N,x]of A.entries())st(x,U)&&N>=u&&X(x,T);C(),setTimeout(()=>{v(u,D),Se(u,h,t),nt(a),W(a,n),bt(n,0,!0)},b)},y=(u,a,h,D)=>{if(!h||!h.droppable||!h.config)return;const{droppable:C,config:T}=h;let[v]=Rt(a,C);v=[a,...v].toReversed();const A=yt(a,"remove",T.direction,C);for(const[N,x]of v.entries())N>=u&&(P(x,A),setTimeout(()=>{D(x)},m))},p=u=>{bt(n,m,!0),setTimeout(()=>{nt(u),W(u,n)},m)},E=(u,a,h,D)=>{const{config:C,droppable:T}=D,[v]=Rt(u,T),A=ht(u,T);v.length==0&&w(h,1,C.direction,v);for(const[N,x]of v.entries()){if(!st(x,U))continue;const G=L(C.direction,u,x,h);if(!A&&G)h=G;else if(!A)continue;const K=v.length-N;w(h,K,C.direction,v),a===de?P(x,h):a===Nt&&X(x,h)}},L=(u,a,h,D)=>{const{before:C,distance:T,axis:v,getRect:A}=B(u),N=A(a),x=A(h),G=N[C],K=x[C],St=x[T],ft=K+St/2,Dt=Be(h)[v],rt=ft-Dt;return G>rt?{height:0,width:0}:D},w=(u,a,h,D)=>{const C=D.filter(v=>st(v,U)).length,{distance:T}=B(h);u[T]==0?c=Math.max(c,a):c=Math.min(c,a-1),c=Math.min(c,C)},P=(u,a)=>{const{width:h,height:D}=a;Et(u,D,h)},X=(u,a)=>{const{width:h,height:D}=a;Et(u,D,h),Pt(u,m,ge)},Z=(u,a,h,D,C,T)=>{const{droppable:v,scroll:A,config:N}=C,[x,G]=Rt(u,v),K=x.toReversed(),St=G===-1?K.length:G;K.splice(St,0,u);const[ft,Dt,rt]=V(u,G,K,v);h=yt(u,a,N.direction,n,ft,Dt);const $t=xe(),xt=tn(N.direction,K,G,rt,$t,A,D,v,u);x.length==0&&H(void 0,h,u,xt);for(const[Gt,wt]of x.toReversed().entries()){let Bt=h;rt-1>=Gt&&(Bt={height:0,width:0}),a===jt&&!st(wt,at)&&H(wt,Bt,u,xt)}$(rt,u,N,v,T)},V=(u,a,h,D)=>{const T=ht(u,D)?a:c,v=()=>a<T?[T,T+1]:a>T?[T-1,T]:[T-1,T+1],[A,N]=v(),x=h[A]??null,G=h[N]??null;return[x,G,T]},H=(u,a,h,D)=>{Et(u,a.height,a.width),Et(h,D.height,D.width)},$=(u,a,h,D,C)=>{const{onInsertEvent:T,onDragEnd:v}=h;tt(a,_t),J(a,n,D,()=>{if(Ct(a,_t),C!=null){const A=g(C,!0);A!=null&&(T(u,A,!0),v({value:A,index:u})),q(a),k()}})},k=()=>{if(s){var u=document.querySelectorAll(`${pt(s)} > .${U}`);for(const a of u)Y(a)}},q=u=>{setTimeout(()=>{Ct(u,R)},Dn)},J=(u,a,h,D)=>{setTimeout(()=>{D&&D(),I(a,h),z(h),nt(u),W(u,a),W(u,h)},m)},I=(u,a)=>{u.isSameNode(a)?bt(u,m):(bt(u,m,!0),bt(a,m))},z=u=>{if(n.isSameNode(u))return;var[a]=n.querySelectorAll(`.${at}`);if(!a)return;const{distance:h}=B(l);it(a)&&(a.style[h]="0px")},W=(u,a)=>{const[h]=Rt(u,a);for(const D of[...h,u])Y(D)},Y=u=>{it(u)&&(u.style.transition="",u.style.transform="")},nt=u=>{r(),ot(u,!1),u.style.transform="",u.style.transition="",u.style.top="",u.style.left="",fe(u,{fixedHeight:"",fixedWidth:""})},ut=(u,a)=>{const h=a.querySelector(f);gt(document.body,oe,u),gt(h||a,Wt,u)},ot=(u,a)=>{gt(u,Ft,a),ut(a,u),o.toggleGrabClass(!a)};return[O,y,F,p,ot]}const bn=t=>t.addedNodes.values().filter(n=>!qt(n)).toArray().length>0,Se=(t,e,n)=>{const{insertingFromClass:s,animationDuration:o}=n,r=kt(()=>{const l=ce(e)[t];tt(l,s),tt(l,Kt),setTimeout(()=>{Ct(l,Kt),Ct(l,s),r.disconnect()},o)},e,{childList:!0},bn)},Tn=(t,e,n,s)=>{if(!e)return;const{onInsertEvent:o,delayBeforeInsert:r}=t;setTimeout(()=>{o(n,s),Se(n,e,t)},r)},En=(t,e)=>{const n=(l,f)=>t.removeAtEvent(l,f),s=(l,f,g)=>t.insertEvent(l,f,g),o=()=>t.getLength(),r=l=>t.getValue(l),c=l=>l;return{direction:(e==null?void 0:e.direction)??et,handlerSelector:(e==null?void 0:e.handlerSelector)??U,draggingClass:(e==null?void 0:e.draggingClass)??"dragging",droppableClass:(e==null?void 0:e.droppableClass)??"droppable-hover",isDraggable:(e==null?void 0:e.isDraggable)??(()=>!0),onDragStart:(e==null?void 0:e.onDragStart)??(()=>{}),onDragEnd:(e==null?void 0:e.onDragEnd)??(()=>{}),droppableGroup:e==null?void 0:e.droppableGroup,onRemoveAtEvent:n,onInsertEvent:s,onGetLegth:o,onGetValue:r,animationDuration:(e==null?void 0:e.animationDuration)??200,removingClass:(e==null?void 0:e.removingClass)??"removing",insertingFromClass:(e==null?void 0:e.insertingFromClass)??"from-inserting",delayBeforeRemove:(e==null?void 0:e.delayBeforeRemove)??200,delayBeforeInsert:(e==null?void 0:e.delayBeforeInsert)??200,mapFrom:(e==null?void 0:e.mapFrom)??c}},yn=(t,e)=>{const{config:n,droppable:s}=t,{onInsertEvent:o,onDragEnd:r}=n;return{...n,onDragEnd:f=>{const{index:g,value:m}=f;r({index:g,value:e(m,s)})},onInsertEvent:(f,g)=>o(f,e(g,s),!0)}},Cn=t=>{let e={offsetX:0,offsetY:0},n={top:0,left:0},s={x:0,y:0};const o=f=>{t.style.transform=`translate( ${f.x}px, ${f.y}px)`},r=f=>{t.style.top=`${f.top}px`,t.style.left=`${f.left}px`};return[(f,g,m,b)=>{const R=y=>{const{beforeMargin:p,borderBeforeWidth:E,before:L,offset:w,scroll:P,page:X,inner:Z,distance:V,axis:H,getRect:$}=B(y),k=m[X],q=window[P],J=window[Z],I=$(f)[V],z=M(f,E),W=M(f,p),Y=k-e[w],nt=ae(f,y);if(Y>=q-I/2&&Y<=q+J){const ot=Y-n[L]-z-W-q-nt;return O(y),ot}return s[H]},O=y=>{if(f&&st(f,Ft)&&y===b){const{before:p,distance:E,axis:L,getRect:w}=B(b),P=w(f)[E],X=w(g),Z=n[p]-X[p]+s[L],H=X[E]-P,$=Z/H,k=P/H,q=.1,J=.2,I=.8;let z=0;const W=ht(f,g);!W&&$<J&&$>-k?z=$/J-1:!W&&$>I&&$<1+k&&(z=1/(1-I)*($-I));const Y=q*P*z;an(g,b,Y)}},F=y=>{const{axis:p}=B(y);s[p]=R(y),o(s)};F(_),F(et)},(f,g)=>{const[m,b,R,O]=wn(f,g,t);n={top:m,left:b},r(n),e={offsetX:R,offsetY:O}}]},Lt=(t,e,n)=>{const{borderBeforeWidth:s,before:o,getRect:r}=B(t);return r(e)[o]-r(n)[o]-M(n,s)},An=(t,e)=>{let{offsetX:n,offsetY:s,target:o}=t,r=xn(o,e);const c=o;return c&&r&&!c.isSameNode(r)&&(n+=Lt(_,c,r),s+=Lt(et,c,r)),r&&e!=o&&(n+=Lt(_,r,e),s+=Lt(et,r,e)),[n,s]},xn=(t,e)=>{const n=t==null?void 0:t.closest(`.${Mt}`);return n&&n.isSameNode(e)?t:n},se=(t,e,n,s)=>{const{offset:o,beforeMargin:r,page:c,borderBeforeWidth:l,scroll:f}=B(t),g=ae(n,t);return e[c]-s[o]-M(n,r)-M(n,l)-window[f]-g},wn=(t,e,n)=>{const[s,o]=An(t,n);return[se(et,t,e,{offsetX:s,offsetY:o}),se(_,t,e,{offsetX:s,offsetY:o}),s,o]},Q=class Q{static addConfig(e,n){const s=Q.configs.filter(r=>!r.droppable.isSameNode(e)),o=Ut(e);s.push({droppable:e,config:n,scroll:o}),Q.configs=s}static updateScrolls(e,n){for(const s of Q.configs){const{droppable:o}=s;(n&&Ce(o,n)||o.isSameNode(e))&&(s.scroll=Ut(o))}}static getConfig(e){return Q.configs.find(({droppable:s})=>s.isSameNode(e))}};j(Q,"configs",[]),j(Q,"removeObsoleteConfigs",()=>{const e=Q.configs.filter(({droppable:n})=>document.contains(n));Q.configs=e});let lt=Q;class Bn{constructor(e,n,s,o,r,c){j(this,"initial");j(this,"current");j(this,"parent");j(this,"draggableElement");j(this,"groupClass");j(this,"dragEvent");j(this,"changeDroppable");j(this,"mapFrom");this.parent=s,this.draggableElement=e,this.groupClass=n,this.dragEvent=o,this.mapFrom=c,this.initial=s?lt.getConfig(s):void 0,this.changeDroppable=r}getDraggableAncestor(e,n,s){return document.elementsFromPoint(e,n).filter(o=>!o.isSameNode(s))}getElementBelow(e,n,s=!0){const o=c=>{const[l]=c.getDraggableAncestor(n.clientX,n.clientY,e);return l};let r=null;return s?(e.hidden=!0,r=o(this),e.hidden=!1):r=o(this),r}getCurrent(e,n,s=!0){const o=this.getElementBelow(e,n,s);return!this.groupClass||!o?void 0:o.closest(pt(this.groupClass))}isOutsideOfAllDroppables(e){return(this.groupClass?Array.from(document.querySelectorAll(pt(this.groupClass))):[this.parent]).every(s=>ht(e,s))}isNotInsideAnotherDroppable(e,n){return!ht(e,n)||this.isOutsideOfAllDroppables(e)}onScrollEvent(){this.dragEvent()}setOnScroll(e){ue(e,"onscroll",()=>{this.onScrollEvent()})}getConfigFrom(e){const n=lt.getConfig(e);if(n)return e.isSameNode(this.parent)?n:{...n,config:yn(n,this.mapFrom)}}getCurrentConfig(e){var o;const n=this.draggableElement;if(this.current&&this.isNotInsideAnotherDroppable(n,(o=this.current)==null?void 0:o.droppable))return this.current;const s=this.getCurrent(n,e);return s?(it(s)&&!s.onscroll&&this.setOnScroll(s),this.getConfigFrom(s)):this.getConfigFrom(this.parent)}updateConfig(e){const n=this.current;this.current=this.getCurrentConfig(e),this.changeDroppable(this.current,n)}isOutside(e,n=!0){const s=this.draggableElement;return!this.getCurrent(s,e,n)}}function Rn(t,e,n,s,o){const{handlerSelector:r,isDraggable:c,droppableGroup:l,animationDuration:f,delayBeforeRemove:g,draggingClass:m,removingClass:b,onRemoveAtEvent:R,droppableClass:O,onDragStart:F}=n,y=At(l).map(i=>`droppable-group-${i}`).join(" ");let p=0,E={scrollX:0,scrollY:0},L={pageX:0,pageY:0},w,P;const[X,Z]=Cn(t),[V,H,$,k,q]=vn(n,e,s,y,o,()=>p=0),J=()=>{tt(t,U)},I=i=>{tt(i,Mt),o.addSubscriber(i)},z=()=>{if(c(t)){const i=t.querySelector(r);I(i||t)}},W=()=>{z(),J()},Y=i=>{const d=i==null?void 0:i.querySelector(`.${Mt}`),S=d==null?void 0:d.parentElement;return d&&S&&st(S,Xt)&&!S.isSameNode(s)?null:d},nt=i=>{const d=Y(i)??i;d&&c(i)&&(It(d,"onmousedown",G("mousemove","mouseup")),It(d,"ontouchstart",G("touchmove","touchend"),S=>{P={x:S.touches[0].clientX,y:S.touches[0].clientY}}),ut(d)),i!=null&&i.isSameNode(d)||It(i,"onmousedown",K),tt(s,Xt)},ut=i=>{const d=i.querySelectorAll("img");Array.from(d).forEach(S=>{S.onmousedown=()=>!1})},ot=()=>{if(L.pageX==0&&L.pageY==0||!a.current)return;const{droppable:i,config:d}=a.current;X(t,i,L,d.direction),V(t,Nt,E,a.current)},u=(i,d)=>{d&&p==2&&!(i!=null&&i.droppable.isSameNode(d.droppable))&&V(t,Nt,E,d)},a=new Bn(t,y,s,ot,u,n.mapFrom),h=i=>{if(!a.current)return;const d=y?Array.from(document.querySelectorAll(pt(y))):[s];for(const S of d)S.classList.toggle(O,!i&&S.isSameNode(a.current.droppable))},D=(i,d=!1)=>{a.updateConfig(i);const S=a.isOutside(i);h(S),p===1&&!d?rt(i):p===2&&(C(S),xt(i))},C=(i=!0)=>{if(!a.current)return;const{droppable:d}=a.current;Sn(d,s,y,f,i),!i&&Yt(t,s,p==1,a.current)},T=i=>{if(Tt(i)&&P&&p==1){const d=Math.abs(i.touches[0].clientX-P.x),S=Math.abs(i.touches[0].clientY-P.y);if(Math.abs(d)>5&&Math.abs(S)>5)return clearTimeout(w),!1}return!0},v=i=>{clearTimeout(w);const d=Vt(i);if(Tt(i)&&i.cancelable&&i.preventDefault(),Tt(i)&&!i.cancelable||!T(i)){ft("touchmove",i);return}D(d,Tt(i))},A=(i,d)=>{i=="touchmove"?w=setTimeout(()=>{d()},150):d()},N=(i,d)=>{const{clientX:S,clientY:dt}=i,ct=document.elementFromPoint(S,dt),vt=ct==null?void 0:ct.closest(`.${U}`);return vt&&d.isSameNode(vt)},x=i=>{const d=n.onGetValue(e);return{index:e,element:i,value:d}},G=(i,d)=>S=>{if(!N(S,t))return;lt.updateScrolls(s,y);const{scrollX:dt,scrollY:ct}=window;if(E={scrollX:dt,scrollY:ct},p===0){p=1;const vt=x(t);vt&&F(vt),A(i,()=>{i=="touchmove"&&(a.updateConfig(S),h(a.isOutside(S)),rt(S))}),document.addEventListener(i,v,{passive:!1}),Gt(s),document.addEventListener(d,St(i),{once:!0})}},K=i=>a.updateConfig(i),St=i=>d=>{ft(i,d)},ft=(i,d)=>{h(!0);const S=Vt(d);Bt(a.isOutside(S,!1)),clearTimeout(w),document.removeEventListener(i,v),a.updateConfig(S);const dt=a.getCurrentConfig(S);if(dt){const{droppable:ct}=dt;Dt(ct)}s.onscroll=null},Dt=i=>{if(i.onscroll=null,!y)return;const d=Array.from(document.querySelectorAll(pt(y)));for(const S of d)it(S)&&(S.onscroll=null)},rt=i=>{Yt(t,s,p==1,a.current),$t(),V(t,de,E,a.current),De(t),Z(i,t)},$t=()=>{p=2},xt=i=>{const{pageX:d,pageY:S}=i;L={pageX:d,pageY:S},ot()},Gt=i=>ue(i,"onscroll",wt),wt=()=>ot(),Bt=i=>{if(p!==2&&p!==1){p=0;return}p=3,Jt(t),t.classList.contains(Ft)&&V(t,jt,E,i?a.initial:a.current,e)},Jt=i=>{Pt(i,f,ge),Et(i,0,0)},De=i=>{const{height:d,width:S}=i.getBoundingClientRect();fe(i,{fixedHeight:`${d}px`,fixedWidth:`${S}px`}),q(i,!0),gt(i,m,!0),i.style.transition=""},ve=(i,d)=>{Ct(t,b),Yt(t,s,p==1,a.initial),H(i,t,d,S=>{Jt(S),k(t)}),R(e,!0)},be=i=>{if(!a.initial)return;const d=a.initial;i==e&&(tt(t,b),setTimeout(()=>{ve(i,d)},g))},Te=(i,d)=>{(i===e||i===n.onGetLegth()&&e===i-1)&&$(i,t,s,d,()=>{hn(t,p==1,a.initial)})};return W(),nt(t),[be,Te]}const Ln=(t,e)=>{t&&Ae(e,t)},Mn=()=>{_e(document.body,[`.${U}{touch-action:manipulation;user-select:none;box-sizing:border-box!important;-webkit-user-select:none;}`,`.${Mt}{pointer-events:auto!important;}`,`.${re}{cursor:grab;}`,".temp-child{touch-action:none;pointer-events:none;box-sizing:border-box!important;}",".droppable{box-sizing:border-box!important;}",`.${Ft}{position:fixed;z-index:5000;width:var(--fixedWidth)!important;height:var(--fixedHeight)!important;}`,`.${Wt}{pointer-events:none!important;}`,`.${_t}{pointer-events:none!important;}`,`.${oe}{cursor:grabbing;}`,".disable-transition{transition:none!important;}"])};function On(t,e,n,s="index"){const o=s;let r=[],c=[];const{droppableGroup:l}=t;if(!n)return[r,c];const f=At(l).map(g=>`droppable-group-${g}`).join(" ");Mn(),Ln(f,n);for(const g of n.children){const m=g.getAttribute(o),b=we(m),R=g;if(R&&b>=0){const[O,F]=Rn(R,b,t,n,e);r.push(O),c.push(F)}}return[r,c]}function Nn(t,e,n,s="index"){let o=[],r=[],c;const l=En(t,n),f=p=>{for(const E of o)E(p)},g=(p,E)=>{if(l.onGetLegth()===0)t.insertToListEmpty(l,p,E);else for(const w of r)w(p,E)},m=p=>{const[E,L]=On(l,e,p,s);o=E,r=L},b=p=>{const E=p.addedNodes.values().filter(w=>!qt(w)).toArray(),L=p.removedNodes.values().filter(w=>!qt(w)).toArray();return E.length>0||L.length>0},R=p=>{c=kt(()=>{m(p)},p,{childList:!0},b)},O=p=>{tt(p,Xt)},F=p=>{lt.addConfig(p,l)};return[f,g,p=>{if(p)return O(p),F(p),R(p),m(p),lt.removeObsoleteConfigs(),c}]}exports.GRAB_CLASS=re;exports.addClass=tt;exports.dragAndDrop=Nn;exports.insertToListEmpty=Tn;exports.toggleClass=gt;