fluid-dnd 1.2.0-beta.0 → 1.3.0-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.
@@ -1,7 +1,7 @@
1
1
  var d = Object.defineProperty;
2
2
  var e = (a, s, l) => s in a ? d(a, s, { enumerable: !0, configurable: !0, writable: !0, value: l }) : a[s] = l;
3
3
  var r = (a, s, l) => e(a, typeof s != "symbol" ? s + "" : s, l);
4
- import { a as h, t as n, G as t } from "./index-ekBJgYrv.js";
4
+ import { a as h, t as n, G as t } from "./index-DFUAc_q_.js";
5
5
  class c {
6
6
  constructor() {
7
7
  r(this, "handlers");
@@ -1 +1 @@
1
- "use strict";var d=Object.defineProperty;var n=(e,s,l)=>s in e?d(e,s,{enumerable:!0,configurable:!0,writable:!0,value:l}):e[s]=l;var a=(e,s,l)=>n(e,typeof s!="symbol"?s+"":s,l);const r=require("./index-_CLUJ2Ve.cjs");class h{constructor(){a(this,"handlers");this.handlers=[]}addSubscriber(s){this.handlers.includes(s)||(this.handlers.push(s),r.addClass(s,r.GRAB_CLASS))}toggleGrabClass(s){for(const l of this.handlers)r.toggleClass(l,r.GRAB_CLASS,s)}}exports.HandlerPublisher=h;
1
+ "use strict";var d=Object.defineProperty;var n=(e,s,l)=>s in e?d(e,s,{enumerable:!0,configurable:!0,writable:!0,value:l}):e[s]=l;var a=(e,s,l)=>n(e,typeof s!="symbol"?s+"":s,l);const r=require("./index-D7zMRS0J.cjs");class h{constructor(){a(this,"handlers");this.handlers=[]}addSubscriber(s){this.handlers.includes(s)||(this.handlers.push(s),r.addClass(s,r.GRAB_CLASS))}toggleGrabClass(s){for(const l of this.handlers)r.toggleClass(l,r.GRAB_CLASS,s)}}exports.HandlerPublisher=h;
@@ -1,4 +1,4 @@
1
1
  import { ListCondig, Config } from '.';
2
2
  import { default as HandlerPublisher } from './HandlerPublisher';
3
3
 
4
- export default function dragAndDrop<T>(listCondig: ListCondig<T>, handlerPublisher: HandlerPublisher, config?: Config<T>, indexAttr?: string): readonly [(index: number) => void, (index: number, value: T) => void, (parent: HTMLElement | null | undefined) => void];
4
+ export default function dragAndDrop<T>(listCondig: ListCondig<T>, handlerPublisher: HandlerPublisher, config?: Config<T>, indexAttr?: string, reactChildrenChanges?: Boolean): readonly [(index: number) => void, (index: number, value: T) => void, (parent: HTMLElement | null | undefined) => void];
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../index-_CLUJ2Ve.cjs");exports.dragAndDrop=e.dragAndDrop;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../index-D7zMRS0J.cjs");exports.dragAndDrop=e.dragAndDrop;
@@ -1,4 +1,4 @@
1
- import { d as o } from "../index-ekBJgYrv.js";
1
+ import { d as o } from "../index-DFUAc_q_.js";
2
2
  export {
3
3
  o as dragAndDrop
4
4
  };
@@ -0,0 +1 @@
1
+ "use strict";var Te=Object.defineProperty;var Ee=(t,e,n)=>e in t?Te(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var k=(t,e,n)=>Ee(t,typeof e!="symbol"?e+"":e,n);const Q="draggable",It="droppable",Lt="handler-class",qt="dragging",Yt="dragging-handler-class",Xt="dropping",se="grabbing",oe="grab",Jt="disable-transition",nt=(t,e)=>t.classList.contains(e),gt=(t,e,n=!1)=>{t.classList.toggle(e,n)},U=(t,e)=>{t.classList.add(e)},yt=(t,e)=>{t.classList.remove(e)},Ce=(t,e)=>At(e).every(n=>nt(t,n)),pt=t=>t?`.${At(t).join(".")}`:"",ye=(t,e)=>{if(!e)return;const n=At(e);t.classList.add(...n)},At=t=>t?t.split(" ").filter(e=>e):[],V="horizontal",tt="vertical",Ae=()=>{const{scrollX:t,scrollY:e}=window;return{scrollX:t,scrollY:e}},zt=t=>!t||t.trim().length==0||t=="normal"?0:parseFloat(t),xe=t=>t?parseInt(t):-1,Be=t=>{const e=getComputedStyle(t),n=new DOMMatrixReadOnly(e.transform);return{x:n.m41,y:n.m42}},re=(t,e)=>t.x1>e.x1?re(e,t):t.x2<e.x1?0:t.x2>=e.x2?t.x2-t.x1:t.x2-e.x1,ht=(t,e)=>!we(t,e),we=(t,e)=>{const n=Ot(t),s=Ot(e),o=Kt(n,s,tt),r=Kt(n,s,V);return o>=Math.min(n.height,s.height)/2&&r>=Math.min(n.width,s.width)/2},Kt=(t,e,n)=>{const{before:s,distance:o}=B(n);return re({x1:t[s],x2:t[s]+t[o]},{x1:e[s],x2:e[s]+e[o]})},O=(t,e)=>t?zt(getComputedStyle(t)[e]):0,Qt=t=>{const{scrollLeft:e,scrollTop:n}=t;return{scrollLeft:e,scrollTop:n}},Ot=t=>t.getBoundingClientRect(),B=t=>{const e=t==V;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}},wt=(t,e)=>Re(t,e),ie=t=>[...t.children].filter(n=>nt(n,Q)),Re=(t,e)=>{const n=[...e.children].filter(o=>nt(o,Q)&&!o.isEqualNode(t)).toReversed(),s=[...e.children].findLastIndex(o=>o.isEqualNode(t));return[n,s,e]},Le=t=>{let e=t.parentElement;for(;e;){if(window.getComputedStyle(e).position==="fixed")return e;e=e.parentElement}return null},ce=(t,e)=>{const{before:n,borderBeforeWidth:s}=B(e),o=Le(t);return o?Ot(o)[n]+O(o,s):0},Wt=t=>window.TouchEvent&&t instanceof TouchEvent,rt=t=>t instanceof HTMLElement,ae=t=>t instanceof MouseEvent,Oe=["onmouseup","onmousedown","onmousemove"],Me=(t,e,n)=>{t&&(t.style.height=`${e}px`,t.style.width=`${n}px`)},Et=(t,e,n)=>{!t||!rt(t)||(n==0&&e==0?t.style.transform="":t.style.transform=`translate(${n}px,${e}px)`)},Ne=(t,e,n)=>{t[e]=s=>{if(s.defaultPrevented)return;const o=_t(s);n(o)}},$t=(t,e,n)=>{n&&(Fe(e)?t[e]=n:Ne(t,e,n))},Fe=t=>Oe.includes(t),Pe=t=>{const{target:e}=t;return{clientX:0,clientY:0,pageX:0,pageY:0,screenX:0,screenY:0,target:e,offsetX:0,offsetY:0}},$e=(t,e)=>{const n=(s,o)=>Ie(e,window,o,s);if(ae(t)){const{offsetX:s,offsetY:o}=t;return[s,o]}else{const s=t.target;return[n(s,V),n(s,tt)]}},_t=t=>{const e=Ge(t);if(!e)return Pe(t);const[n,s]=$e(t,e),{clientX:o,clientY:r,pageX:a,pageY:l,screenX:u,screenY:g,target:m}=e;return{clientX:o,clientY:r,pageX:a,pageY:l,screenX:u,screenY:g,target:m,offsetX:n,offsetY:s}},Ge=t=>{if(Wt(t))return t.touches[0]??t.changedTouches[0];if(ae(t))return t},Ie=(t,e,n,s)=>{const{page:o,scroll:r,before:a,borderBeforeWidth:l,getRect:u}=B(n),g=u(s);return t[o]-e[r]-g[a]-O(s,l)},Nt=(t,e,n="ease-out",s="transform")=>{rt(t)&&(t.style.transitionDuration=`${e}ms`,t.style.transitionTimingFunction=`${n}`,t.style.transitionProperty=`${s}`)},le=(t,e,n)=>{!t||!rt(t)||(t[e]=()=>{n()})},Ye=t=>{var e=t.querySelector("style");if(!e){var n=document.createElement("style");return t.appendChild(n),n}return e},Xe=(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},We=(t,e)=>{e.forEach(n=>{_e(t,n)})},_e=(t,e)=>{var s;var n=Ye(t);n.sheet&&(Xe(n.sheet,e)||(s=n.sheet)==null||s.insertRule(e,n.sheet.cssRules.length))},ue=(t,e={})=>{for(const n of Object.keys(e)){const s=e[n];s!=null&&Ve(t,`--${n}`,s)}},Ve=(t,e,n)=>t&&t.style.setProperty(e,n),fe="startDrag",Mt="drag",jt="startDrop",He="drop",at="temp-child",de="cubic-bezier(0.2, 0, 0, 1)",qe=t=>t===He||t===jt,Vt=t=>!t||t.length==0?0:zt(t.replace("px","")),ze=(t,e)=>{const n=getComputedStyle(t)[e];if(n.match("%")){const o=zt(n.replace("%","")),{width:r}=t.getBoundingClientRect();return r*(o/100)}return Vt(n)},kt=(t,e)=>{if(!(t instanceof Element))return[0,!1];const n=ze(t,e),s=getComputedStyle(t).display,o=n>0||s==="flex";return[n,o]},je=t=>{const{top:e,left:n}=getComputedStyle(t);return[Vt(e),Vt(n)]},ke=(t,e)=>{const{gap:n}=B(e),[s,o]=kt(t,n);return o?s:0};function Ct(t,e,n,s,o=t.previousElementSibling,r=t.nextElementSibling){let{height:a,width:l}=Ze(n,t,o,r);return ht(t,s)&&e==Mt&&(a=0,l=0),{height:a,width:l}}const Ze=(t,e,n,s)=>{const{afterMargin:o,beforeMargin:r,distance:a,gap:l,getRect:u}=B(t),g=O(e,o),m=O(e,r),D=O(s,r),[w,M]=kt(e.parentElement,l),F=u(e)[a];if(M)return Ut(F,m,g,w,0,t);const[C,p,b]=Je(n,D,g,m,o);return Ut(F,p,C,0,b,t)},Je=(t,e,n,s,o)=>{const r=Math.max(e,n);let a=s,l=e;if(t){const u=O(t,o);a=Math.max(u,s),l=Math.max(l,u)}return[r,a,l]},Ut=(t,e,n,s,o,r)=>Ke(r,t+e+n+s-o),Ke=(t,e)=>t==V?{width:e,height:0}:{width:0,height:e},te=(t,e)=>{const{borderBeforeWidth:n,paddingBefore:s,axis:o,getRect:r}=B(t),a=O(e,n),l=O(e,s),u=r(e)[o];return a+l+u},Qe=(t,e)=>{const[n,s]=je(e),o=te(tt,t);return[te(V,t)-s,o-n]};function Ue(t,e,n,s,o,r,a,l,u){let g=0,m=0;const D=!!(n<0&&u);if(n===s&&!D)return ee({height:g,width:m},t,o,a,D);const[w,M,F,C]=nn(e,n,s,u);if(D){const[et,ot]=Qe(l,u);g+=ot,m+=et}const{scrollElement:p,beforeMargin:b,afterMargin:R,distance:L,gap:Y}=B(t),[X,$]=kt(l,Y),[st,H,P]=on(b,R,w,M==null?void 0:M.previousElementSibling,C,$,D),[Z,q,z]=sn(b,R,L,F,X,$),W=en(q,Z,z,H,st,X),j=D?l[p]:tn(p,l,r),G=(C?W-P:P-W)-j;return t===tt?g+=G:t===V&&(m+=G),ee({height:g,width:m},t,o,a,D)}const tn=(t,e,n)=>{const s=e[t],o=n[t];return s-o},en=(t,e,n,s,o,r)=>{const a=Math.max(e,o);return Math.max(n,s)+t+a+r},nn=(t,e,n,s)=>{const o=e<n,[r,a]=[e,n].toSorted((m,D)=>m-D),l=t[e]??s,u=t[n];let g=o?t.slice(r+1,a+1):t.slice(r,a);return r<0&&s&&(g=t.slice(r+1,a)),[l,u,g,o]},sn=(t,e,n,s,o,r)=>{if(s.length==0)return[0,0,0];const a=O(s[0],t);let l=0,u=-a;for(const[g,m]of s.entries()){const D=m.getBoundingClientRect()[n],w=O(m,t);r&&(l+=w),r&&g>0?l+=o:l=Math.max(l,w),u+=l+D,l=O(m,e)}return[a,u,l]},ee=(t,e,n,s,o)=>{const{scroll:r,distance:a}=B(e),l=window[r],u=n[r],g=o?0:u-2*l+s[r];return t[a]+=g,t},on=(t,e,n,s,o,r,a)=>{const l=o?n.previousElementSibling:s;return rn(t,e,l,n,r,a)},rn=(t,e,n,s,o,r)=>{if(o)return[0,0,0];const a=O(r?null:n,e),l=O(s,t);let u=Math.max(a,l);return[a,l,u]},Zt=(t,e,n,s=()=>!0)=>{const o=new MutationObserver(r=>{if(r=r.filter(s),r.length>0){const a=r[0];t(o,a)}});return o.observe(e,n),o},cn=(t,e,n)=>{n!=0&&(e==="vertical"?t.scrollBy(0,n):t.scrollBy(n,0))},an=(t,e,n)=>{const{scrollDistance:s,clientDistance:o,scrollElement:r}=B(t);return n[r]/(e[s]-e[o])},ln="startDrag",ge="cubic-bezier(0.2, 0, 0, 1)",pe=50,Ht=t=>rt(t)?t.classList.contains(at):!1,un=(t,e,n)=>{let s=Ct(e,ln,n,t);const o=ke(t,n),{distance:r}=B(n);s[r]-=o;const[a,l]=fn(n,e);return s[l]=a,s},fn=(t,e)=>{const n=t==V?tt:V,{distance:s,getRect:o}=B(n);return[o(e)[s],s]},mt=(t,e,n)=>{Me(t,e,n),t.style.minWidth=`${n}px`},dn=(t,e,n)=>s=>{e.contains(t)&&(mt(t,n.height,n.width),s.disconnect())},gn=(t,e)=>{if(!e)return;const{droppable:n,config:s,scroll:o}=t,{direction:r}=s,a=an(s.direction,n,o)>.99,{scrollDistance:l,clientDistance:u,scrollElement:g}=B(r);a&&(n[g]=n[l]-n[u])},he=(t,e,n,s)=>{if(!n)return;const{droppable:o,config:r}=n,{direction:a,animationDuration:l}=r;if(gn(n,e),o.querySelector(`.${at}`)||!t)return;var u=t.tagName=="LI"?"DIV":t.tagName,g=document.createElement(u);U(g,at),mt(g,0,0);const m=un(o,t,a);return Nt(g,l,ge,"width, min-width, height"),[g,m,o]},Gt=(t,e,n,s,o)=>{const r=he(t,n,s);if(!r)return;const[a,l,u]=r;e.isSameNode(u)&&mt(a,l.height,l.width),Zt(dn(a,u,l),u,{childList:!0,subtree:!0}),u.appendChild(a)},pn=(t,e,n)=>{const s=he(t,e,n);if(!s)return;const[o,r,a]=s;a.appendChild(o),hn(o,r)},hn=(t,e)=>requestAnimationFrame(()=>{mt(t,e.height,e.width),requestAnimationFrame(()=>{Nt(t,0,ge,"width, min-width, height")})}),mn=(t,e,n,s,o=!0)=>{if(n){var r=document.querySelectorAll(`${pt(n)} > .${at}`);r.forEach(a=>{const l=a.parentElement;if(l!=null&&l.isSameNode(e)||!o&&(l!=null&&l.isSameNode(t)))return;mt(a,0,0),setTimeout(()=>{var g;(g=a.parentNode)==null||g.removeChild(a)},s+pe)})}},Tt=(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+pe)):t.removeChild(o)})},Sn=50;function vn(t,e,n,s,o,r){let a=e;const{direction:l,handlerSelector:u,onRemoveAtEvent:g,animationDuration:m,delayBeforeInsert:D,draggingClass:w}=t,M=(i,f,h,S,y)=>{if(!S)return;const{droppable:v,config:T}=S,A=Ct(i,f,T.direction,v);qe(f)?$(i,f,A,h,S,y):b(i,f,A,S)},F=(i,f,h,S,y)=>{const v=Ct(f,"insert",t.direction,h),{onInsertEvent:T}=t,A=ie(h);for(const[N,x]of A.entries())nt(x,Q)&&N>=i&&X(x,v);y(),setTimeout(()=>{T(i,S),me(i,h,t),et(f),_(f,n),Tt(n,0,!0)},D)},C=(i,f,h,S)=>{if(!h||!h.droppable||!h.config)return;const{droppable:y,config:v}=h;let[T]=wt(f,y);T=[f,...T].toReversed();const A=Ct(f,"remove",v.direction,y);for(const[N,x]of T.entries())N>=i&&(Y(x,A),setTimeout(()=>{S(x)},m))},p=i=>{Tt(n,m,!0),setTimeout(()=>{et(i),_(i,n)},m)},b=(i,f,h,S)=>{const{config:y,droppable:v}=S,[T]=wt(i,v),A=ht(i,v);T.length==0&&L(h,1,y.direction,T);for(const[N,x]of T.entries()){if(!nt(x,Q))continue;const I=R(y.direction,i,x,h);if(!A&&I)h=I;else if(!A)continue;const J=T.length-N;L(h,J,y.direction,T),f===fe?Y(x,h):f===Mt&&X(x,h)}},R=(i,f,h,S)=>{const{before:y,distance:v,axis:T,getRect:A}=B(i),N=A(f),x=A(h),I=N[y],J=x[y],ft=x[v],St=J+ft/2,vt=Be(h)[T],it=St-vt;return I>it?{height:0,width:0}:S},L=(i,f,h,S)=>{const y=S.filter(T=>nt(T,Q)).length,{distance:v}=B(h);i[v]==0?a=Math.max(a,f):a=Math.min(a,f-1),a=Math.min(a,y)},Y=(i,f)=>{const{width:h,height:S}=f;Et(i,S,h)},X=(i,f)=>{const{width:h,height:S}=f;Et(i,S,h),Nt(i,m,de)},$=(i,f,h,S,y,v)=>{const{droppable:T,scroll:A,config:N}=y,[x,I]=wt(i,T),J=x.toReversed(),ft=I===-1?J.length:I;J.splice(ft,0,i);const[St,vt,it]=st(i,I,J,T);h=Ct(i,f,N.direction,n,St,vt);const Ft=Ae(),xt=Ue(N.direction,J,I,it,Ft,A,S,T,i);x.length==0&&H(void 0,h,i,xt);for(const[Pt,Bt]of x.toReversed().entries()){let Dt=h;it-1>=Pt&&(Dt={height:0,width:0}),f===jt&&!nt(Bt,at)&&H(Bt,Dt,i,xt)}P(it,i,N,T,v)},st=(i,f,h,S)=>{const v=ht(i,S)?f:a,T=()=>f<v?[v,v+1]:f>v?[v-1,v]:[v-1,v+1],[A,N]=T(),x=h[A]??null,I=h[N]??null;return[x,I,v]},H=(i,f,h,S)=>{Et(i,f.height,f.width),Et(h,S.height,S.width)},P=(i,f,h,S,y)=>{const{onInsertEvent:v,onDragEnd:T}=h;U(f,Xt),z(f,n,S,()=>{if(yt(f,Xt),y!=null){const A=g(y,!0);A!=null&&(v(i,A,!0),T({value:A,index:i})),q(f),Z()}})},Z=()=>{if(s){var i=document.querySelectorAll(`${pt(s)} > .${Q}`);for(const f of i)G(f)}},q=i=>{setTimeout(()=>{yt(i,w)},Sn)},z=(i,f,h,S)=>{setTimeout(()=>{S&&S(),W(f,h),j(h),et(i),_(i,f),_(i,h)},m)},W=(i,f)=>{i.isSameNode(f)?Tt(i,m):(Tt(i,m,!0),Tt(f,m))},j=i=>{if(n.isSameNode(i))return;var[f]=n.querySelectorAll(`.${at}`);if(!f)return;const{distance:h}=B(l);rt(f)&&(f.style[h]="0px")},_=(i,f)=>{const[h]=wt(i,f);for(const S of[...h,i])G(S)},G=i=>{rt(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 h=f.querySelector(u);gt(document.body,se,i),gt(h||f,Yt,i)},ut=(i,f)=>{gt(i,qt,f),ot(f,i),o.toggleGrabClass(!f)};return[M,C,F,p,ut]}const Dn=t=>t.addedNodes.values().filter(n=>!Ht(n)).toArray().length>0,me=(t,e,n)=>{const{insertingFromClass:s,animationDuration:o}=n,r=Zt(()=>{const l=ie(e)[t];U(l,s),U(l,Jt),setTimeout(()=>{yt(l,Jt),yt(l,s),r.disconnect()},o)},e,{childList:!0},Dn)},bn=(t,e,n,s)=>{if(!e)return;const{onInsertEvent:o,delayBeforeInsert:r}=t;setTimeout(()=>{o(n,s),me(n,e,t)},r)},Tn=(t,e)=>{const n=(l,u)=>t.removeAtEvent(l,u),s=(l,u,g)=>t.insertEvent(l,u,g),o=()=>t.getLength(),r=l=>t.getValue(l),a=l=>l;return{direction:(e==null?void 0:e.direction)??tt,handlerSelector:(e==null?void 0:e.handlerSelector)??Q,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)??a}},En=(t,e)=>{const{config:n,droppable:s}=t,{onInsertEvent:o,onDragEnd:r}=n;return{...n,onDragEnd:u=>{const{index:g,value:m}=u;r({index:g,value:e(m,s)})},onInsertEvent:(u,g)=>o(u,e(g,s),!0)}},Cn=t=>{let e={offsetX:0,offsetY:0},n={top:0,left:0},s={x:0,y:0};const o=u=>{t.style.transform=`translate( ${u.x}px, ${u.y}px)`},r=u=>{t.style.top=`${u.top}px`,t.style.left=`${u.left}px`};return[(u,g,m,D)=>{const w=C=>{const{beforeMargin:p,borderBeforeWidth:b,before:R,offset:L,scroll:Y,page:X,inner:$,distance:st,axis:H,getRect:P}=B(C),Z=m[X],q=window[Y],z=window[$],W=P(u)[st],j=O(u,b),_=O(u,p),G=Z-e[L],et=ce(u,C);if(G>=q-W/2&&G<=q+z){const ut=G-n[R]-j-_-q-et;return M(C),ut}return s[H]},M=C=>{if(u&&nt(u,qt)&&C===D){const{before:p,distance:b,axis:R,getRect:L}=B(D),Y=L(u)[b],X=L(g),$=n[p]-X[p]+s[R],H=X[b]-Y,P=$/H,Z=Y/H,q=.1,z=.2,W=.8;let j=0;const _=ht(u,g);!_&&P<z&&P>-Z?j=P/z-1:!_&&P>W&&P<1+Z&&(j=1/(1-W)*(P-W));const G=q*Y*j;cn(g,D,G)}},F=C=>{const{axis:p}=B(C);s[p]=w(C),o(s)};F(V),F(tt)},(u,g)=>{const[m,D,w,M]=xn(u,g,t);n={top:m,left:D},r(n),e={offsetX:w,offsetY:M}}]},Rt=(t,e,n)=>{const{borderBeforeWidth:s,before:o,getRect:r}=B(t);return r(e)[o]-r(n)[o]-O(n,s)},yn=(t,e)=>{let{offsetX:n,offsetY:s,target:o}=t,r=An(o,e);const a=o;return a&&r&&!a.isSameNode(r)&&(n+=Rt(V,a,r),s+=Rt(tt,a,r)),r&&e!=o&&(n+=Rt(V,r,e),s+=Rt(tt,r,e)),[n,s]},An=(t,e)=>{const n=t==null?void 0:t.closest(`.${Lt}`);return n&&n.isSameNode(e)?t:n},ne=(t,e,n,s)=>{const{offset:o,beforeMargin:r,page:a,borderBeforeWidth:l,scroll:u}=B(t),g=ce(n,t);return e[a]-s[o]-O(n,r)-O(n,l)-window[u]-g},xn=(t,e,n)=>{const[s,o]=yn(t,n);return[ne(tt,t,e,{offsetX:s,offsetY:o}),ne(V,t,e,{offsetX:s,offsetY:o}),s,o]},K=class K{static addConfig(e,n){const s=K.configs.filter(r=>!r.droppable.isSameNode(e)),o=Qt(e);s.push({droppable:e,config:n,scroll:o}),K.configs=s}static updateScrolls(e,n){for(const s of K.configs){const{droppable:o}=s;(n&&Ce(o,n)||o.isSameNode(e))&&(s.scroll=Qt(o))}}static getConfig(e){return K.configs.find(({droppable:s})=>s.isSameNode(e))}};k(K,"configs",[]),k(K,"removeObsoleteConfigs",()=>{const e=K.configs.filter(({droppable:n})=>document.contains(n));K.configs=e});let lt=K;class Bn{constructor(e,n,s,o,r,a){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=e,this.groupClass=n,this.dragEvent=o,this.mapFrom=a,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=a=>{const[l]=a.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){le(e,"onscroll",()=>{this.onScrollEvent()})}getConfigFrom(e){const n=lt.getConfig(e);if(n)return e.isSameNode(this.parent)?n:{...n,config:En(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?(rt(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 wn(t,e,n,s,o){const{handlerSelector:r,isDraggable:a,droppableGroup:l,animationDuration:u,delayBeforeRemove:g,draggingClass:m,removingClass:D,onRemoveAtEvent:w,droppableClass:M,onDragStart:F}=n,C=At(l).map(c=>`droppable-group-${c}`).join(" ");let p=0,b={scrollX:0,scrollY:0},R={pageX:0,pageY:0},L;const[Y,X]=Cn(t),[$,st,H,P,Z]=vn(n,e,s,C,o,()=>p=0),q=()=>{U(t,Q)},z=c=>{U(c,Lt),o.addSubscriber(c)},W=()=>{if(a(t)){const c=t.querySelector(r);z(c||t)}},j=()=>{W(),q()},_=c=>{const d=c==null?void 0:c.querySelector(`.${Lt}`),E=d==null?void 0:d.parentElement;return d&&E&&nt(E,It)&&!E.isSameNode(s)?null:d},G=c=>{const d=_(c)??c;d&&a(c)&&($t(d,"onmousedown",x("mousemove","mouseup")),$t(d,"ontouchstart",x("touchmove","touchend")),et(d)),c!=null&&c.isSameNode(d)||$t(c,"onmousedown",I),U(s,It)},et=c=>{const d=c.querySelectorAll("img");Array.from(d).forEach(E=>{E.onmousedown=()=>!1})},ot=()=>{if(R.pageX==0&&R.pageY==0||!i.current)return;const{droppable:c,config:d}=i.current;Y(t,c,R,d.direction),$(t,Mt,b,i.current)},ut=(c,d)=>{d&&p==2&&!(c!=null&&c.droppable.isSameNode(d.droppable))&&$(t,Mt,b,d)},i=new Bn(t,C,s,ot,ut,n.mapFrom),f=c=>{if(!i.current)return;const d=C?Array.from(document.querySelectorAll(pt(C))):[s];for(const E of d)E.classList.toggle(M,!c&&E.isSameNode(i.current.droppable))},h=c=>{i.updateConfig(c);const d=i.isOutside(c);f(d),p===1?vt(c):p===2&&(S(d),Ft(c))},S=(c=!0)=>{if(!i.current)return;const{droppable:d}=i.current;mn(d,s,C,u,c),!c&&Gt(t,s,p==1,i.current)},y=c=>{const d=t.getBoundingClientRect();return c.clientX>=d.left&&c.clientX<=d.right&&c.clientY>=d.top&&c.clientY<=d.bottom},v=c=>{const d=_t(c);if(Wt(c)&&c.cancelable&&c.preventDefault(),Wt(c)&&!c.cancelable||!y(d)){ft("touchmove",c);return}h(d)},T=(c,d)=>{c=="touchmove"?L=setTimeout(()=>{d()},200):d()},A=(c,d)=>{const{clientX:E,clientY:dt}=c,ct=document.elementFromPoint(E,dt),bt=ct==null?void 0:ct.closest(`.${Q}`);return bt&&d.isSameNode(bt)},N=c=>{const d=n.onGetValue(e);return{index:e,element:c,value:d}},x=(c,d)=>E=>{if(!A(E,t))return;lt.updateScrolls(s,C);const{scrollX:dt,scrollY:ct}=window;if(b={scrollX:dt,scrollY:ct},p===0){p=1;const bt=N(t);bt&&F(bt),T(c,()=>{document.addEventListener(c,v,{passive:!1})}),xt(s),document.addEventListener(d,J(c),{once:!0})}},I=c=>i.updateConfig(c),J=c=>d=>{ft(c,d)},ft=(c,d)=>{f(!0);const E=_t(d);clearTimeout(L),Bt(i.isOutside(E,!1)),document.removeEventListener(c,v),i.updateConfig(E);const dt=i.getCurrentConfig(E);if(dt){const{droppable:ct}=dt;St(ct)}s.onscroll=null},St=c=>{if(c.onscroll=null,!C)return;const d=Array.from(document.querySelectorAll(pt(C)));for(const E of d)rt(E)&&(E.onscroll=null)},vt=c=>{Gt(t,s,p==1,i.current),it(),$(t,fe,b,i.current),Se(t),X(c,t)},it=()=>{p=2},Ft=c=>{const{pageX:d,pageY:E}=c;R={pageX:d,pageY:E},ot()},xt=c=>le(c,"onscroll",Pt),Pt=()=>ot(),Bt=c=>{if(p!==2){p=0;return}p=3,Dt(t),$(t,jt,b,c?i.initial:i.current,e)},Dt=c=>{Nt(c,u,de),Et(c,0,0)},Se=c=>{const{height:d,width:E}=c.getBoundingClientRect();ue(c,{fixedHeight:`${d}px`,fixedWidth:`${E}px`}),Z(c,!0),gt(c,m,!0),c.style.transition=""},ve=(c,d)=>{yt(t,D),Gt(t,s,p==1,i.initial),st(c,t,d,E=>{Dt(E),P(t)}),w(e,!0)},De=c=>{if(!i.initial)return;const d=i.initial;c==e&&(U(t,D),setTimeout(()=>{ve(c,d)},g))},be=(c,d)=>{(c===e||c===n.onGetLegth()&&e===c-1)&&H(c,t,s,d,()=>{pn(t,p==1,i.initial)})};return j(),G(t),[De,be]}const Rn=(t,e)=>{t&&ye(e,t)},Ln=()=>{We(document.body,[`.${Q}{touch-action:manipulation;user-select:none;box-sizing:border-box!important;-webkit-user-select:none;}`,`.${Lt}{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;}",`.${qt}{position:fixed;z-index:5000;width:var(--fixedWidth)!important;height:var(--fixedHeight)!important;}`,`.${Yt}{pointer-events:none!important;}`,`.${Xt}{pointer-events:none!important;}`,`.${se}{cursor:grabbing;}`,".disable-transition{transition:none!important;}"])};function On(t,e,n,s="index"){const o=s;let r=[],a=[];const{droppableGroup:l}=t;if(!n)return[r,a];const u=At(l).map(g=>`droppable-group-${g}`).join(" ");Ln(),Rn(u,n);for(const g of n.children){const m=g.getAttribute(o),D=xe(m),w=g;if(w&&D>=0){const[M,F]=wn(w,D,t,n,e);r.push(M),a.push(F)}}return[r,a]}function Mn(t,e,n,s="index",o=!0){let r=[],a=[];const l=Tn(t,n),u=p=>{for(const b of r)b(p)},g=(p,b)=>{if(l.onGetLegth()===0)t.insertToListEmpty(l,p,b);else for(const L of a)L(p,b)},m=p=>{const[b,R]=On(l,e,p,s);r=b,a=R},D=p=>{const b=p.addedNodes.values().filter(L=>!Ht(L)).toArray(),R=p.removedNodes.values().filter(L=>!Ht(L)).toArray();return b.length>0||R.length>0},w=p=>{Zt(b=>{m(p),o||b.disconnect()},p,{childList:!0},D)},M=p=>{U(p,It)},F=p=>{lt.addConfig(p,l)};return[u,g,p=>{p&&(M(p),F(p),w(p),m(p),lt.removeObsoleteConfigs())}]}exports.GRAB_CLASS=oe;exports.addClass=U;exports.dragAndDrop=Mn;exports.insertToListEmpty=bn;exports.toggleClass=gt;