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