fluid-dnd 1.1.2-beta.0 → 1.2.1-beta.0

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 (43) hide show
  1. package/README.md +6 -1
  2. package/dist/{HandlerPublisher-CAhfY7Ch.js → HandlerPublisher-CIc7wXW-.js} +1 -1
  3. package/dist/{HandlerPublisher-BttKXTeA.cjs → HandlerPublisher-DiGO5iOY.cjs} +1 -1
  4. package/dist/core/configHandler.d.ts +3 -2
  5. package/dist/core/dragAndDrop.d.ts +4 -4
  6. package/dist/core/index.d.ts +6 -6
  7. package/dist/core/useDraggable.d.ts +3 -2
  8. package/dist/core/useDroppable.d.ts +3 -2
  9. package/dist/core/utils/GetStyles.d.ts +3 -2
  10. package/dist/core/utils/ParseStyles.d.ts +3 -2
  11. package/dist/core/utils/SetStyles.d.ts +2 -1
  12. package/dist/core/utils/SetTransform.d.ts +3 -2
  13. package/dist/core/utils/config.d.ts +3 -3
  14. package/dist/core/utils/droppableConfigurator.d.ts +4 -3
  15. package/dist/core/utils/events/emitEvents.d.ts +7 -6
  16. package/dist/core/utils/scroll.d.ts +3 -2
  17. package/dist/core/utils/tempChildren.d.ts +2 -1
  18. package/dist/core/utils/translate/GetTranslateBeforeDropping.d.ts +3 -2
  19. package/dist/core/utils/translate/GetTranslationByDraggingAndEvent.d.ts +3 -2
  20. package/dist/index/index.cjs +1 -1
  21. package/dist/index/index.mjs +1 -1
  22. package/dist/index-BDu6-Hq8.js +1283 -0
  23. package/dist/index-Tde6DOzb.cjs +1 -0
  24. package/dist/react/index.cjs +1 -0
  25. package/dist/react/index.d.ts +3 -0
  26. package/dist/react/index.mjs +55 -0
  27. package/dist/react/useDragAndDrop.d.ts +3 -0
  28. package/dist/react/utils/ReactLilstConfig.d.ts +4 -0
  29. package/dist/svelte/index.cjs +1 -1
  30. package/dist/svelte/index.d.ts +2 -1
  31. package/dist/svelte/index.mjs +2 -2
  32. package/dist/svelte/useDragAndDrop.d.ts +2 -1
  33. package/dist/svelte/utils/SvelteListCondig.d.ts +2 -2
  34. package/dist/vue/index.cjs +1 -1
  35. package/dist/vue/index.d.ts +2 -1
  36. package/dist/vue/index.mjs +2 -2
  37. package/dist/vue/useDragAndDrop.d.ts +3 -2
  38. package/dist/vue/utils/DropMethods.d.ts +2 -1
  39. package/dist/vue/utils/VueListCondig.d.ts +3 -3
  40. package/package.json +12 -8
  41. package/dist/index-BnYdI35p.js +0 -1281
  42. package/dist/index-LwQqhkeh.cjs +0 -1
  43. package/dist/index.d.ts +0 -4
@@ -1 +0,0 @@
1
- "use strict";var De=Object.defineProperty;var ve=(e,t,n)=>t in e?De(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var k=(e,t,n)=>ve(e,typeof t!="symbol"?t+"":t,n);const Q="draggable",It="droppable",Ot="handler-class",Ht="dragging",Yt="dragging-handler-class",Wt="dropping",se="grabbing",oe="grab",Zt="disable-transition",nt=(e,t)=>e.classList.contains(t),gt=(e,t,n=!1)=>{e.classList.toggle(t,n)},U=(e,t)=>{e.classList.add(t)},Ct=(e,t)=>{e.classList.remove(t)},be=(e,t)=>yt(t).every(n=>nt(e,n)),pt=e=>e?`.${yt(e).join(".")}`:"",Te=(e,t)=>{if(!t)return;const n=yt(t);e.classList.add(...n)},yt=e=>e?e.split(" ").filter(t=>t):[],V="horizontal",tt="vertical",Ee=()=>{const{scrollX:e,scrollY:t}=window;return{scrollX:e,scrollY:t}},qt=e=>!e||e.trim().length==0||e=="normal"?0:parseFloat(e),Ce=e=>e?parseInt(e):-1,ye=e=>{const t=getComputedStyle(e),n=new DOMMatrixReadOnly(t.transform);return{x:n.m41,y:n.m42}},re=(e,t)=>e.x1>t.x1?re(t,e):e.x2<t.x1?0:e.x2>=t.x2?e.x2-e.x1:e.x2-t.x1,ht=(e,t)=>!Ae(e,t),Ae=(e,t)=>{const n=Mt(e),s=Mt(t),o=Jt(n,s,tt),r=Jt(n,s,V);return o>=Math.min(n.height,s.height)/2&&r>=Math.min(n.width,s.width)/2},Jt=(e,t,n)=>{const{before:s,distance:o}=w(n);return re({x1:e[s],x2:e[s]+e[o]},{x1:t[s],x2:t[s]+t[o]})},L=(e,t)=>e?qt(getComputedStyle(e)[t]):0,Kt=e=>{const{scrollLeft:t,scrollTop:n}=e;return{scrollLeft:t,scrollTop:n}},Mt=e=>e.getBoundingClientRect(),w=e=>{const t=e==V;return{beforeMargin:t?"marginLeft":"marginTop",afterMargin:t?"marginRight":"marginBottom",borderBeforeWidth:t?"borderLeftWidth":"borderTopWidth",before:t?"left":"top",after:t?"right":"down",gap:t?"columnGap":"rowGap",distance:t?"width":"height",axis:t?"x":"y",offset:t?"offsetX":"offsetY",scroll:t?"scrollX":"scrollY",scrollElement:t?"scrollLeft":"scrollTop",page:t?"pageX":"pageY",inner:t?"innerWidth":"innerHeight",offsetElement:t?"offsetLeft":"offsetTop",scrollDistance:t?"scrollWidth":"scrollHeight",clientDistance:t?"clientWidth":"clientHeight",paddingBefore:t?"paddingLeft":"paddingTop",getRect:Mt}},Rt=(e,t)=>xe(e,t),ie=e=>[...e.children].filter(n=>nt(n,Q)),xe=(e,t)=>{const n=[...t.children].filter(o=>nt(o,Q)&&!o.isEqualNode(e)).toReversed(),s=[...t.children].findLastIndex(o=>o.isEqualNode(e));return[n,s,t]},we=e=>{let t=e.parentElement;for(;t;){if(window.getComputedStyle(t).position==="fixed")return t;t=t.parentElement}return null},ce=(e,t)=>{const{before:n,borderBeforeWidth:s}=w(t),o=we(e);return o?Mt(o)[n]+L(o,s):0},Xt=e=>window.TouchEvent&&e instanceof TouchEvent,it=e=>e instanceof HTMLElement,ae=e=>e instanceof MouseEvent,Be=["onmouseup","onmousedown","onmousemove"],Re=(e,t,n)=>{e&&(e.style.height=`${t}px`,e.style.width=`${n}px`)},Tt=(e,t,n)=>{!e||!it(e)||(n==0&&t==0?e.style.transform="":e.style.transform=`translate(${n}px,${t}px)`)},Le=(e,t,n)=>{e[t]=s=>{if(s.defaultPrevented)return;const o=_t(s);n(o)}},$t=(e,t,n)=>{n&&(Oe(t)?e[t]=n:Le(e,t,n))},Oe=e=>Be.includes(e),Me=e=>{const{target:t}=e;return{clientX:0,clientY:0,pageX:0,pageY:0,screenX:0,screenY:0,target:t,offsetX:0,offsetY:0}},Ne=(e,t)=>{const n=(s,o)=>Pe(t,window,o,s);if(ae(e)){const{offsetX:s,offsetY:o}=e;return[s,o]}else{const s=e.target;return[n(s,V),n(s,tt)]}},_t=e=>{const t=Fe(e);if(!t)return Me(e);const[n,s]=Ne(e,t),{clientX:o,clientY:r,pageX:c,pageY:l,screenX:u,screenY:d,target:m}=t;return{clientX:o,clientY:r,pageX:c,pageY:l,screenX:u,screenY:d,target:m,offsetX:n,offsetY:s}},Fe=e=>{if(Xt(e))return e.touches[0]??e.changedTouches[0];if(ae(e))return e},Pe=(e,t,n,s)=>{const{page:o,scroll:r,before:c,borderBeforeWidth:l,getRect:u}=w(n),d=u(s);return e[o]-t[r]-d[c]-L(s,l)},Ft=(e,t,n="ease-out",s="transform")=>{it(e)&&(e.style.transitionDuration=`${t}ms`,e.style.transitionTimingFunction=`${n}`,e.style.transitionProperty=`${s}`)},le=(e,t,n)=>{!e||!it(e)||(e[t]=()=>{n()})},$e=e=>{var t=e.querySelector("style");if(!t){var n=document.createElement("style");return e.appendChild(n),n}return t},Ge=(e,t)=>{const n=/\.-?[_a-zA-Z0-9-*\s<>():]+/g,[s]=t.match(n)||[];for(const o of e.cssRules){const[r]=o.cssText.match(n)||[];if(s===r)return!0}return!1},Ie=(e,t)=>{t.forEach(n=>{Ye(e,n)})},Ye=(e,t)=>{var s;var n=$e(e);n.sheet&&(Ge(n.sheet,t)||(s=n.sheet)==null||s.insertRule(t,n.sheet.cssRules.length))},ue=(e,t={})=>{for(const n of Object.keys(t)){const s=t[n];s!=null&&We(e,`--${n}`,s)}},We=(e,t,n)=>e&&e.style.setProperty(t,n),fe="startDrag",Nt="drag",zt="startDrop",Xe="drop",at="temp-child",de="cubic-bezier(0.2, 0, 0, 1)",_e=e=>e===Xe||e===zt,Vt=e=>!e||e.length==0?0:qt(e.replace("px","")),Ve=(e,t)=>{const n=getComputedStyle(e)[t];if(n.match("%")){const o=qt(n.replace("%","")),{width:r}=e.getBoundingClientRect();return r*(o/100)}return Vt(n)},jt=(e,t)=>{if(!(e instanceof Element))return[0,!1];const n=Ve(e,t),s=getComputedStyle(e).display,o=n>0||s==="flex";return[n,o]},He=e=>{const{top:t,left:n}=getComputedStyle(e);return[Vt(t),Vt(n)]},qe=(e,t)=>{const{gap:n}=w(t),[s,o]=jt(e,n);return o?s:0};function Et(e,t,n,s,o=e.previousElementSibling,r=e.nextElementSibling){let{height:c,width:l}=ze(n,e,o,r);return ht(e,s)&&t==Nt&&(c=0,l=0),{height:c,width:l}}const ze=(e,t,n,s)=>{const{afterMargin:o,beforeMargin:r,distance:c,gap:l,getRect:u}=w(e),d=L(t,o),m=L(t,r),v=L(s,r),[B,O]=jt(t.parentElement,l),F=u(t)[c];if(O)return Qt(F,m,d,B,0,e);const[h,S,y]=je(n,v,d,m,o);return Qt(F,S,h,0,y,e)},je=(e,t,n,s,o)=>{const r=Math.max(t,n);let c=s,l=t;if(e){const u=L(e,o);c=Math.max(u,s),l=Math.max(l,u)}return[r,c,l]},Qt=(e,t,n,s,o,r)=>ke(r,e+t+n+s-o),ke=(e,t)=>e==V?{width:t,height:0}:{width:0,height:t},Ut=(e,t)=>{const{borderBeforeWidth:n,paddingBefore:s,axis:o,getRect:r}=w(e),c=L(t,n),l=L(t,s),u=r(t)[o];return c+l+u},Ze=(e,t)=>{const[n,s]=He(t),o=Ut(tt,e);return[Ut(V,e)-s,o-n]};function Je(e,t,n,s,o,r,c,l,u){let d=0,m=0;const v=!!(n<0&&u);if(n===s&&!v)return te({height:d,width:m},e,o,c,v);const[B,O,F,h]=Ue(t,n,s,u);if(v){const[et,ot]=Ze(l,u);d+=ot,m+=et}const{scrollElement:S,beforeMargin:y,afterMargin:R,distance:I,gap:Y}=w(e),[W,P]=jt(l,Y),[st,H,N]=en(y,R,B,O==null?void 0:O.previousElementSibling,h,P,v),[Z,q,z]=tn(y,R,I,F,W,P),X=Qe(q,Z,z,H,st,W),j=v?l[S]:Ke(S,l,r),$=(h?X-N:N-X)-j;return e===tt?d+=$:e===V&&(m+=$),te({height:d,width:m},e,o,c,v)}const Ke=(e,t,n)=>{const s=t[e],o=n[e];return s-o},Qe=(e,t,n,s,o,r)=>{const c=Math.max(t,o);return Math.max(n,s)+e+c+r},Ue=(e,t,n,s)=>{const o=t<n,[r,c]=[t,n].toSorted((m,v)=>m-v),l=e[t]??s,u=e[n];let d=o?e.slice(r+1,c+1):e.slice(r,c);return r<0&&s&&(d=e.slice(r+1,c)),[l,u,d,o]},tn=(e,t,n,s,o,r)=>{if(s.length==0)return[0,0,0];const c=L(s[0],e);let l=0,u=-c;for(const[d,m]of s.entries()){const v=m.getBoundingClientRect()[n],B=L(m,e);r&&(l+=B),r&&d>0?l+=o:l=Math.max(l,B),u+=l+v,l=L(m,t)}return[c,u,l]},te=(e,t,n,s,o)=>{const{scroll:r,distance:c}=w(t),l=window[r],u=n[r],d=o?0:u-2*l+s[r];return e[c]+=d,e},en=(e,t,n,s,o,r,c)=>{const l=o?n.previousElementSibling:s;return nn(e,t,l,n,r,c)},nn=(e,t,n,s,o,r)=>{if(o)return[0,0,0];const c=L(r?null:n,t),l=L(s,e);let u=Math.max(c,l);return[c,l,u]},kt=(e,t,n,s=()=>!0)=>{const o=new MutationObserver(r=>{if(r=r.filter(s),r.length>0){const c=r[0];e(o,c)}});return o.observe(t,n),o},sn=(e,t,n)=>{n!=0&&(t==="vertical"?e.scrollBy(0,n):e.scrollBy(n,0))},on=(e,t,n)=>{const{scrollDistance:s,clientDistance:o,scrollElement:r}=w(e);return n[r]/(t[s]-t[o])},rn="startDrag",ge="cubic-bezier(0.2, 0, 0, 1)",pe=50,ee=e=>it(e)?e.classList.contains(at):!1,cn=(e,t,n)=>{let s=Et(t,rn,n,e);const o=qe(e,n),{distance:r}=w(n);s[r]-=o;const[c,l]=an(n,t);return s[l]=c,s},an=(e,t)=>{const n=e==V?tt:V,{distance:s,getRect:o}=w(n);return[o(t)[s],s]},mt=(e,t,n)=>{Re(e,t,n),e.style.minWidth=`${n}px`},ln=(e,t,n)=>s=>{t.contains(e)&&(mt(e,n.height,n.width),s.disconnect())},un=(e,t)=>{if(!t)return;const{droppable:n,config:s,scroll:o}=e,{direction:r}=s,c=on(s.direction,n,o)>.99,{scrollDistance:l,clientDistance:u,scrollElement:d}=w(r);c&&(n[d]=n[l]-n[u])},he=(e,t,n,s)=>{if(!n)return;const{droppable:o,config:r}=n,{direction:c,animationDuration:l}=r;if(un(n,t),o.querySelector(`.${at}`)||!e)return;var u=e.tagName=="LI"?"DIV":e.tagName,d=document.createElement(u);U(d,at),mt(d,0,0);const m=cn(o,e,c);return Ft(d,l,ge,"width, min-width, height"),[d,m,o]},Gt=(e,t,n,s,o)=>{const r=he(e,n,s);if(!r)return;const[c,l,u]=r;t.isSameNode(u)&&mt(c,l.height,l.width),kt(ln(c,u,l),u,{childList:!0,subtree:!0}),u.appendChild(c)},fn=(e,t,n)=>{const s=he(e,t,n);if(!s)return;const[o,r,c]=s;c.appendChild(o),dn(o,r)},dn=(e,t)=>requestAnimationFrame(()=>{mt(e,t.height,t.width),requestAnimationFrame(()=>{Ft(e,0,ge,"width, min-width, height")})}),gn=(e,t,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(t)||!o&&(l!=null&&l.isSameNode(e)))return;mt(c,0,0),setTimeout(()=>{var d;(d=c.parentNode)==null||d.removeChild(c)},s+pe)})}},bt=(e,t,n=!1)=>{var s=e.querySelectorAll(`.${at}`);s.forEach(o=>{const r=o;n?(mt(r,0,0),setTimeout(()=>{e.contains(r)&&e.removeChild(r)},t+pe)):e.removeChild(o)})},pn=50;function hn(e,t,n,s,o,r){let c=t;const{direction:l,handlerSelector:u,onRemoveAtEvent:d,animationDuration:m,delayBeforeInsert:v,draggingClass:B}=e,O=(i,f,g,D,C)=>{if(!D)return;const{droppable:b,config:T}=D,A=Et(i,f,T.direction,b);_e(f)?P(i,f,A,g,D,C):y(i,f,A,D)},F=(i,f,g,D,C)=>{const b=Et(f,"insert",e.direction,g),{onInsertEvent:T}=e,A=ie(g);for(const[M,x]of A.entries())nt(x,Q)&&M>=i&&W(x,b);C(),setTimeout(()=>{T(i,D),bt(n,0,!0),me(i,g,e),et(f),_(f,n)},v)},h=(i,f,g,D)=>{if(!g||!g.droppable||!g.config)return;const{droppable:C,config:b}=g;let[T]=Rt(f,C);T=[f,...T].toReversed();const A=Et(f,"remove",b.direction,C);for(const[M,x]of T.entries())M>=i&&(Y(x,A),setTimeout(()=>{D(x)},m))},S=i=>{bt(n,m,!0),setTimeout(()=>{et(i),_(i,n)},m)},y=(i,f,g,D)=>{const{config:C,droppable:b}=D,[T]=Rt(i,b),A=ht(i,b);T.length==0&&I(g,1,C.direction,T);for(const[M,x]of T.entries()){if(!nt(x,Q))continue;const G=R(C.direction,i,x,g);if(!A&&G)g=G;else if(!A)continue;const J=T.length-M;I(g,J,C.direction,T),f===fe?Y(x,g):f===Nt&&W(x,g)}},R=(i,f,g,D)=>{const{before:C,distance:b,axis:T,getRect:A}=w(i),M=A(f),x=A(g),G=M[C],J=x[C],ft=x[b],St=J+ft/2,Dt=ye(g)[T],ct=St-Dt;return G>ct?{height:0,width:0}:D},I=(i,f,g,D)=>{const C=D.filter(T=>nt(T,Q)).length,{distance:b}=w(g);i[b]==0?c=Math.max(c,f):c=Math.min(c,f-1),c=Math.min(c,C)},Y=(i,f)=>{const{width:g,height:D}=f;Tt(i,D,g)},W=(i,f)=>{const{width:g,height:D}=f;Tt(i,D,g),Ft(i,m,de)},P=(i,f,g,D,C,b)=>{const{droppable:T,scroll:A,config:M}=C,[x,G]=Rt(i,T),J=x.toReversed(),ft=G===-1?J.length:G;J.splice(ft,0,i);const[St,Dt,ct]=st(i,G,J,T);g=Et(i,f,M.direction,n,St,Dt);const Pt=Ee(),At=Je(M.direction,J,G,ct,Pt,A,D,T,i);x.length==0&&H(void 0,g,i,At);for(const[xt,wt]of x.toReversed().entries()){let Bt=g;ct-1>=xt&&(Bt={height:0,width:0}),f===zt&&!nt(wt,at)&&H(wt,Bt,i,At)}N(ct,i,M,T,b)},st=(i,f,g,D)=>{const b=ht(i,D)?f:c,T=()=>f<b?[b,b+1]:f>b?[b-1,b]:[b-1,b+1],[A,M]=T(),x=g[A]??null,G=g[M]??null;return[x,G,b]},H=(i,f,g,D)=>{Tt(i,f.height,f.width),Tt(g,D.height,D.width)},N=(i,f,g,D,C)=>{const{onInsertEvent:b,onDragEnd:T}=g;U(f,Wt),z(f,n,D,()=>{if(Ct(f,Wt),C!=null){const A=d(C);A!=null&&(b(i,A),T({value:A,index:i})),q(f),Z()}})},Z=()=>{if(s){var i=document.querySelectorAll(`${pt(s)} > .${Q}`);for(const f of i)$(f)}},q=i=>{setTimeout(()=>{Ct(i,B)},pn)},z=(i,f,g,D)=>{setTimeout(()=>{D&&D(),X(f,g),j(g),et(i),_(i,f),_(i,g)},m)},X=(i,f)=>{i.isSameNode(f)?bt(i,m):(bt(i,m,!0),bt(f,m))},j=i=>{if(n.isSameNode(i))return;var[f]=n.querySelectorAll(`.${at}`);if(!f)return;const{distance:g}=w(l);it(f)&&(f.style[g]="0px")},_=(i,f)=>{const[g]=Rt(i,f);for(const D of[...g,i])$(D)},$=i=>{it(i)&&(i.style.transition="",i.style.transform="")},et=i=>{r(),ut(i,!1),i.style.transform="",i.style.transition="",i.style.top="",i.style.left="",ue(i,{fixedHeight:"",fixedWidth:""})},ot=(i,f)=>{const g=f.querySelector(u);gt(document.body,se,i),gt(g||f,Yt,i)},ut=(i,f)=>{gt(i,Ht,f),ot(f,i),o.toggleGrabClass(!f)};return[O,h,F,S,ut]}const me=(e,t,n)=>{const{insertingFromClass:s,animationDuration:o}=n,r=kt(()=>{const l=ie(t)[e];U(l,s),U(l,Zt),setTimeout(()=>{Ct(l,Zt),Ct(l,s),r.disconnect()},o)},t,{childList:!0})},mn=(e,t,n,s)=>{if(!t)return;const{onInsertEvent:o,delayBeforeInsert:r}=e;setTimeout(()=>{o(n,s),me(n,t,e)},r)},Sn=(e,t)=>{const n=l=>e.removeAtEvent(l),s=(l,u)=>e.insertEvent(l,u),o=()=>e.getLength(),r=l=>e.getValue(l),c=l=>l;return{direction:(t==null?void 0:t.direction)??tt,handlerSelector:(t==null?void 0:t.handlerSelector)??Q,draggingClass:(t==null?void 0:t.draggingClass)??"dragging",droppableClass:(t==null?void 0:t.droppableClass)??"droppable-hover",isDraggable:(t==null?void 0:t.isDraggable)??(()=>!0),onDragStart:(t==null?void 0:t.onDragStart)??(()=>{}),onDragEnd:(t==null?void 0:t.onDragEnd)??(()=>{}),droppableGroup:t==null?void 0:t.droppableGroup,onRemoveAtEvent:n,onInsertEvent:s,onGetLegth:o,onGetValue:r,animationDuration:(t==null?void 0:t.animationDuration)??200,removingClass:(t==null?void 0:t.removingClass)??"removing",insertingFromClass:(t==null?void 0:t.insertingFromClass)??"from-inserting",delayBeforeRemove:(t==null?void 0:t.delayBeforeRemove)??200,delayBeforeInsert:(t==null?void 0:t.delayBeforeInsert)??200,mapFrom:(t==null?void 0:t.mapFrom)??c}},Dn=(e,t)=>{const{config:n,droppable:s}=e,{onInsertEvent:o,onDragEnd:r}=n;return{...n,onDragEnd:u=>{const{index:d,value:m}=u;r({index:d,value:t(m,s)})},onInsertEvent:(u,d)=>o(u,t(d,s))}},vn=e=>{let t={offsetX:0,offsetY:0},n={top:0,left:0},s={x:0,y:0};const o=u=>{e.style.transform=`translate( ${u.x}px, ${u.y}px)`},r=u=>{e.style.top=`${u.top}px`,e.style.left=`${u.left}px`};return[(u,d,m,v)=>{const B=h=>{const{beforeMargin:S,borderBeforeWidth:y,before:R,offset:I,scroll:Y,page:W,inner:P,distance:st,axis:H,getRect:N}=w(h),Z=m[W],q=window[Y],z=window[P],X=N(u)[st],j=L(u,y),_=L(u,S),$=Z-t[I],et=ce(u,h);if($>=q-X/2&&$<=q+z){const ut=$-n[R]-j-_-q-et;return O(h),ut}return s[H]},O=h=>{if(u&&nt(u,Ht)&&h===v){const{before:S,distance:y,axis:R,getRect:I}=w(v),Y=I(u)[y],W=I(d),P=n[S]-W[S]+s[R],H=W[y]-Y,N=P/H,Z=Y/H,q=.1,z=.2,X=.8;let j=0;const _=ht(u,d);!_&&N<z&&N>-Z?j=N/z-1:!_&&N>X&&N<1+Z&&(j=1/(1-X)*(N-X));const $=q*Y*j;sn(d,v,$)}},F=h=>{const{axis:S}=w(h);s[S]=B(h),o(s)};F(V),F(tt)},(u,d)=>{const[m,v,B,O]=En(u,d,e);n={top:m,left:v},r(n),t={offsetX:B,offsetY:O}}]},Lt=(e,t,n)=>{const{borderBeforeWidth:s,before:o,getRect:r}=w(e);return r(t)[o]-r(n)[o]-L(n,s)},bn=(e,t)=>{let{offsetX:n,offsetY:s,target:o}=e,r=Tn(o,t);const c=o;return c&&r&&!c.isSameNode(r)&&(n+=Lt(V,c,r),s+=Lt(tt,c,r)),r&&t!=o&&(n+=Lt(V,r,t),s+=Lt(tt,r,t)),[n,s]},Tn=(e,t)=>{const n=e==null?void 0:e.closest(`.${Ot}`);return n&&n.isSameNode(t)?e:n},ne=(e,t,n,s)=>{const{offset:o,beforeMargin:r,page:c,borderBeforeWidth:l,scroll:u}=w(e),d=ce(n,e);return t[c]-s[o]-L(n,r)-L(n,l)-window[u]-d},En=(e,t,n)=>{const[s,o]=bn(e,n);return[ne(tt,e,t,{offsetX:s,offsetY:o}),ne(V,e,t,{offsetX:s,offsetY:o}),s,o]},K=class K{static addConfig(t,n){const s=K.configs.filter(r=>!r.droppable.isSameNode(t)),o=Kt(t);s.push({droppable:t,config:n,scroll:o}),K.configs=s}static updateScrolls(t,n){for(const s of K.configs){const{droppable:o}=s;(n&&be(o,n)||o.isSameNode(t))&&(s.scroll=Kt(o))}}static getConfig(t){return K.configs.find(({droppable:s})=>s.isSameNode(t))}};k(K,"configs",[]),k(K,"removeObsoleteConfigs",()=>{const t=K.configs.filter(({droppable:n})=>document.contains(n));K.configs=t});let lt=K;class Cn{constructor(t,n,s,o,r,c){k(this,"initial");k(this,"current");k(this,"parent");k(this,"draggableElement");k(this,"groupClass");k(this,"dragEvent");k(this,"changeDroppable");k(this,"mapFrom");this.parent=s,this.draggableElement=t,this.groupClass=n,this.dragEvent=o,this.mapFrom=c,this.initial=s?lt.getConfig(s):void 0,this.changeDroppable=r}getDraggableAncestor(t,n,s){return document.elementsFromPoint(t,n).filter(o=>!o.isSameNode(s))}getElementBelow(t,n,s=!0){const o=c=>{const[l]=c.getDraggableAncestor(n.clientX,n.clientY,t);return l};let r=null;return s?(t.hidden=!0,r=o(this),t.hidden=!1):r=o(this),r}getCurrent(t,n,s=!0){const o=this.getElementBelow(t,n,s);return!this.groupClass||!o?void 0:o.closest(pt(this.groupClass))}isOutsideOfAllDroppables(t){return(this.groupClass?Array.from(document.querySelectorAll(pt(this.groupClass))):[this.parent]).every(s=>ht(t,s))}isNotInsideAnotherDroppable(t,n){return!ht(t,n)||this.isOutsideOfAllDroppables(t)}onScrollEvent(){this.dragEvent()}setOnScroll(t){le(t,"onscroll",()=>{this.onScrollEvent()})}getConfigFrom(t){const n=lt.getConfig(t);if(n)return t.isSameNode(this.parent)?n:{...n,config:Dn(n,this.mapFrom)}}getCurrentConfig(t){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,t);return s?(it(s)&&!s.onscroll&&this.setOnScroll(s),this.getConfigFrom(s)):this.getConfigFrom(this.parent)}updateConfig(t){const n=this.current;this.current=this.getCurrentConfig(t),this.changeDroppable(this.current,n)}isOutside(t,n=!0){const s=this.draggableElement;return!this.getCurrent(s,t,n)}}function yn(e,t,n,s,o){const{handlerSelector:r,isDraggable:c,droppableGroup:l,animationDuration:u,delayBeforeRemove:d,draggingClass:m,removingClass:v,onRemoveAtEvent:B,droppableClass:O,onDragStart:F}=n,h=yt(l).map(a=>`droppable-group-${a}`).join(" ");let S=0,y={scrollX:0,scrollY:0},R={pageX:0,pageY:0},I;const[Y,W]=vn(e),[P,st,H,N,Z]=hn(n,t,s,h,o,()=>S=0),q=()=>{U(e,Q)},z=a=>{U(a,Ot),o.addSubscriber(a)},X=()=>{if(c(e)){const a=e.querySelector(r);z(a||e)}},j=()=>{X(),q()},_=a=>{const p=a==null?void 0:a.querySelector(`.${Ot}`),E=p==null?void 0:p.parentElement;return p&&E&&nt(E,It)&&!E.isSameNode(s)?null:p},$=a=>{const p=_(a)??a;p&&c(a)&&($t(p,"onmousedown",M("mousemove","mouseup")),$t(p,"ontouchstart",M("touchmove","touchend")),et(p)),a!=null&&a.isSameNode(p)||$t(a,"onmousedown",x),U(s,It)},et=a=>{const p=a.querySelectorAll("img");Array.from(p).forEach(E=>{E.onmousedown=()=>!1})},ot=()=>{if(R.pageX==0&&R.pageY==0||!i.current)return;const{droppable:a,config:p}=i.current;Y(e,a,R,p.direction),P(e,Nt,y,i.current)},ut=(a,p)=>{p&&S==2&&!(a!=null&&a.droppable.isSameNode(p.droppable))&&P(e,Nt,y,p)},i=new Cn(e,h,s,ot,ut,n.mapFrom),f=a=>{if(!i.current)return;const p=h?Array.from(document.querySelectorAll(pt(h))):[s];for(const E of p)E.classList.toggle(O,!a&&E.isSameNode(i.current.droppable))},g=a=>{i.updateConfig(a);const p=i.isOutside(a);f(p),S===1?ft(a):S===2&&(D(p),Dt(a))},D=(a=!0)=>{if(!i.current)return;const{droppable:p}=i.current;gn(p,s,h,u,a),!a&&Gt(e,s,S==1,i.current)},C=a=>{if(Xt(a)&&a.cancelable)a.preventDefault();else if(Xt(a))return;const p=_t(a);g(p)},b=(a,p)=>{a=="touchmove"?I=setTimeout(()=>{p()},200):p()},T=(a,p)=>{const{clientX:E,clientY:dt}=a,rt=document.elementFromPoint(E,dt),vt=rt==null?void 0:rt.closest(`.${Q}`);return rt&&p&&vt&&!p.isSameNode(vt)},A=a=>{const p=n.onGetValue(t);return{index:t,element:a,value:p}},M=(a,p)=>E=>{if(T(E,e))return;lt.updateScrolls(s,h);const{scrollX:dt,scrollY:rt}=window;if(y={scrollX:dt,scrollY:rt},S===0){S=1;const vt=A(e);vt&&F(vt),b(a,()=>{a=="touchmove"&&(i.updateConfig(E),f(i.isOutside(E)),ft(E)),document.addEventListener(a,C,{passive:!1})}),ct(s),document.addEventListener(p,G(a),{once:!0})}},x=a=>i.updateConfig(a),G=a=>p=>{f(!0);const E=_t(p);clearTimeout(I),At(i.isOutside(E,!1)),document.removeEventListener(a,C),i.updateConfig(E);const dt=i.getCurrentConfig(E);if(dt){const{droppable:rt}=dt;J(rt)}s.onscroll=null},J=a=>{if(a.onscroll=null,!h)return;const p=Array.from(document.querySelectorAll(pt(h)));for(const E of p)it(E)&&(E.onscroll=null)},ft=a=>{Gt(e,s,S==1,i.current),St(),P(e,fe,y,i.current),wt(e),W(a,e)},St=()=>{S=2},Dt=a=>{const{pageX:p,pageY:E}=a;R={pageX:p,pageY:E},ot()},ct=a=>le(a,"onscroll",Pt),Pt=()=>ot(),At=a=>{if(S!==2){S=0;return}S=3,xt(e),P(e,zt,y,a?i.initial:i.current,t)},xt=a=>{Ft(a,u,de),Tt(a,0,0)},wt=a=>{const{height:p,width:E}=a.getBoundingClientRect();ue(a,{fixedHeight:`${p}px`,fixedWidth:`${E}px`}),Z(a,!0),gt(a,m,!0),a.style.transition=""},Bt=a=>{if(!i.initial)return;const p=i.initial;a==t&&(U(e,v),setTimeout(()=>{B(t),Ct(e,v),Gt(e,s,S==1,i.initial),st(a,e,p,E=>{xt(E),N(e)})},d))},Se=(a,p)=>{(a===t||a===n.onGetLegth()&&t===a-1)&&H(a,e,s,p,()=>{fn(e,S==1,i.initial)})};return j(),$(e),[Bt,Se]}const An=(e,t)=>{e&&Te(t,e)},xn=()=>{Ie(document.body,[`.${Q}{touch-action:manipulation;user-select:none;box-sizing:border-box!important;-webkit-user-select:none;}`,`.${Ot}{pointer-events:auto!important;}`,`.${oe}{cursor:grab;}`,".temp-child{touch-action:none;pointer-events:none;box-sizing:border-box!important;}",".droppable{box-sizing:border-box!important;}",`.${Ht}{position:fixed;z-index:5000;width:var(--fixedWidth)!important;height:var(--fixedHeight)!important;}`,`.${Yt}{pointer-events:none!important;}`,`.${Wt}{pointer-events:none!important;}`,`.${se}{cursor:grabbing;}`,".disable-transition{transition:none!important;}"])};function wn(e,t,n,s="index"){const o=s;let r=[],c=[];const{droppableGroup:l}=e;if(!n)return[r,c];const u=yt(l).map(d=>`droppable-group-${d}`).join(" ");xn(),An(u,n);for(const d of n.children){const m=d.getAttribute(o),v=Ce(m),B=d;if(B&&v>=0){const[O,F]=yn(B,v,e,n,t);r.push(O),c.push(F)}}return[r,c]}function Bn(e,t,n,s="index"){let o=[],r=[];const c=Sn(e,n),l=h=>{for(const S of o)S(h)},u=(h,S)=>{if(c.onGetLegth()===0)e.insertToListEmpty(c,h,S);else for(const R of r)R(h,S)},d=h=>{const[S,y]=wn(c,t,h,s);o=S,r=y},m=h=>{const S=h.addedNodes.values().filter(R=>!ee(R)).toArray(),y=h.removedNodes.values().filter(R=>!ee(R)).toArray();return S.length>0||y.length>0},v=h=>{kt(()=>{d(h)},h,{childList:!0},m)},B=h=>{U(h,It)},O=h=>{lt.addConfig(h,c)};return[l,u,h=>{h&&(B(h),O(h),v(h),d(h),lt.removeObsoleteConfigs())}]}exports.GRAB_CLASS=oe;exports.addClass=U;exports.dragAndDrop=Bn;exports.insertToListEmpty=mn;exports.toggleClass=gt;
package/dist/index.d.ts DELETED
@@ -1,4 +0,0 @@
1
- import { DragEndEventData, DragStartEventData, Direction } from "./core";
2
- import dragAndDrop from "./core/dragAndDrop";
3
- export type { DragStartEventData, DragEndEventData, Direction };
4
- export { dragAndDrop };