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