fluid-dnd 1.0.6-beta.0 → 1.0.8-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 +12 -12
- package/dist/{HandlerPublisher-BbGTnlu0.js → HandlerPublisher-Bp-hKsuU.js} +1 -1
- package/dist/{HandlerPublisher-Bd4_qrME.cjs → HandlerPublisher-DiASUxtT.cjs} +1 -1
- package/dist/index/index.cjs +1 -1
- package/dist/index/index.mjs +1 -1
- package/dist/index-TH8hx6fO.cjs +1 -0
- package/dist/{index-D1rUx9iZ.js → index-WuPwAM50.js} +63 -62
- 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 +3 -3
- package/dist/index-GRcZUS5t.cjs +0 -1
package/README.md
CHANGED
@@ -1,22 +1,22 @@
|
|
1
1
|
<h1 align="center">
|
2
|
-
<img src="https://github.com/carlosjorger/
|
2
|
+
<img src="https://github.com/carlosjorger/fluid-dnd/assets/50055316/dab15832-5290-42ca-b425-db177a2e589e" alt="Icon" width="150" height="140" />
|
3
3
|
<br>Fluid DnD<br>
|
4
4
|
</h1>
|
5
5
|
|
6
6
|
<div align="center">
|
7
7
|
|
8
|
-

|
9
|
+
[](https://github.com/carlosjorger/fluid-dnd/blob/main/LICENSE)
|
10
|
+
[](https://www.npmjs.com/package/fluid-dnd)
|
11
|
+

|
12
|
+

|
13
13
|
[](https://twitter.com/carlosjorgerc)
|
14
|
-
[](https://codeclimate.com/github/carlosjorger/
|
14
|
+
[](https://codeclimate.com/github/carlosjorger/fluid-dnd/test_coverage)
|
15
15
|
|
16
16
|
</div>
|
17
17
|
|
18
18
|
Fluid DnD is a [**fluid**, **agnostic** and **versatil** drag and drop
|
19
|
-
library for lists with support for Vue 3 and Svelte](https://
|
19
|
+
library for lists with support for Vue 3 and Svelte](https://fluid-dnd.netlify.app/). It's a**lightweight** tool ~7 Kb (gzip) with no depenencies.
|
20
20
|
|
21
21
|
<img src="https://github.com/user-attachments/assets/b350f9a4-7dd7-40ca-ae3f-ecca166a9081" width="100%"/>
|
22
22
|
|
@@ -52,14 +52,14 @@ library for lists with support for Vue 3 and Svelte](https://vue-fluid-dnd.netli
|
|
52
52
|
|
53
53
|
3. **Documentation**
|
54
54
|
|
55
|
-
- 📚 Check out all the [docs](https://
|
55
|
+
- 📚 Check out all the [docs](https://fluid-dnd.netlify.app/).
|
56
56
|
- 🛠️ Edit the previous [here](https://codesandbox.io/s/nifty-hooks-5plkpl).
|
57
|
-
- 📘 See others examples [here](https://
|
57
|
+
- 📘 See others examples [here](https://fluid-dnd.netlify.app/example/vertical-list/single-vertical-list/).
|
58
58
|
|
59
59
|
## 🤝 Contributing
|
60
60
|
|
61
|
-
If you're interested in contributing to [
|
61
|
+
If you're interested in contributing to [fluid-dnd](https://github.com/carlosjorger/fluid-dnd), please read our contributing docs before submitting a pull request [CONTRIBUTING](./CONTRIBUTING.md).
|
62
62
|
|
63
63
|
## 🔑 License
|
64
64
|
|
65
|
-
- [MIT](https://github.com/carlosjorger/
|
65
|
+
- [MIT](https://github.com/carlosjorger/fluid-dnd/blob/main/LICENSE).
|
@@ -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-
|
4
|
+
import { a as h, t as n, G as t } from "./index-WuPwAM50.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-
|
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-TH8hx6fO.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;
|
package/dist/index/index.cjs
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../index-
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../index-TH8hx6fO.cjs");exports.dragAndDrop=e.dragAndDrop;
|
package/dist/index/index.mjs
CHANGED
@@ -0,0 +1 @@
|
|
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)},Ct=(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)=>!Ce(t,e),Ce=(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}=w(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(),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}},Rt=(t,e)=>Ee(t,e),re=t=>[...t.children].filter(n=>nt(n,Q)),Ee=(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}=w(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"],we=(t,e,n)=>{t&&(t.style.height=`${e}px`,t.style.width=`${n}px`)},Tt=(t,e,n)=>{!t||!at(t)||(n==0&&e==0?t.style.transform="":t.style.transform=`translate(${n}px,${e}px)`)},Be=(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:Be(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:p,target:h}=e;return{clientX:o,clientY:i,pageX:c,pageY:l,screenX:f,screenY:p,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}=w(n),p=f(s);return t[o]-e[i]-p[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}=w(e),[s,o]=jt(t,n);return o?s:0};function yt(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}=w(t),p=L(e,o),h=L(e,i),b=L(s,i),[B,M]=jt(e.parentElement,l),S=f(e)[c];if(M)return Qt(S,h,p,B,0,t);const[D,v,R]=qe(n,b,p,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}=w(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 p=0,h=0;const b=!!(n<0&&f);if(n===s&&!b)return te({height:p,width:h},t,o,c,b);const[B,M,S,D]=Ke(e,n,s,f);if(b){const[et,ot]=je(l,f);p+=ot,h+=et}const{scrollElement:v,beforeMargin:R,afterMargin:N,distance:I,gap:W}=w(t),[X,F]=jt(l,W),[st,H,P]=Ue(R,N,B,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?p+=$:t===_&&(h+=$),te({height:p,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 p=o?t.slice(i+1,c+1):t.slice(i,c);return i<0&&s&&(p=t.slice(i+1,c)),[l,f,p,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[p,h]of s.entries()){const b=h.getBoundingClientRect()[n],B=L(h,t);i&&(l+=B),i&&p>0?l+=o:l=Math.max(l,B),f+=l+b,l=L(h,e)}return[c,f,l]},te=(t,e,n,s,o)=>{const{scroll:i,distance:c}=w(e),l=window[i],f=n[i],p=o?0:f-2*l+s[i];return t[c]+=p,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}=w(t);return n[i]/(e[s]-e[o])},sn="startDrag",ge="cubic-bezier(0.2, 0, 0, 1)",on=(t,e,n)=>{let s=yt(e,sn,n,t);const o=_e(t,n),{distance:i}=w(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}=w(n);return[o(e)[s],s]},mt=(t,e,n)=>{we(t,e,n),t.style.minWidth=`${n}px`},cn=(t,e,n)=>s=>{e.contains(t)&&(mt(t,n.height,n.width),s.disconnect())},an=(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:p}=w(i);c&&(n[p]=n[l]-n[f])},de=(t,e,n,s)=>{if(!n)return;const{droppable:o,config:i}=n,{direction:c,animationDuration:l}=i;if(an(n,e),o.querySelector(`.${ht}`)||!t)return;var f=t.tagName=="LI"?"DIV":t.tagName,p=document.createElement(f);U(p,ht),mt(p,0,0);const h=on(o,t,c);return Nt(p,l,ge,"width, min-width, height"),[p,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)&&mt(c,l.height,l.width),kt(cn(c,f,l),f,{childList:!0,subtree:!0}),f.appendChild(c)},ln=(t,e,n)=>{const s=de(t,e,n);if(!s)return;const[o,i,c]=s;c.appendChild(o),un(o,i)},un=(t,e)=>requestAnimationFrame(()=>{mt(t,e.height,e.width),requestAnimationFrame(()=>{Nt(t,0,ge,"width, min-width, height")})}),fn=(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;mt(c,0,0),setTimeout(()=>{var p;(p=c.parentNode)==null||p.removeChild(c)},s)})}},bt=(t,e,n=!1)=>{var s=t.querySelectorAll(`.${ht}`);s.forEach(o=>{n?(mt(o,0,0),setTimeout(()=>{t.contains(o)&&t.removeChild(o)},e)):t.removeChild(o)})},gn=50;function dn(t,e,n,s,o,i){let c=e;const{direction:l,handlerSelector:f,onRemoveAtEvent:p,animationDuration:h,delayBeforeInsert:b,draggingClass:B}=t,M=(r,u,g,m,E)=>{if(!m)return;const{droppable:T,config:y}=m,A=yt(r,u,y.direction,T);Xe(u)?F(r,u,A,g,m,E):R(r,u,A,m)},S=(r,u,g,m,E)=>{const T=yt(u,"insert",t.direction,g),{onInsertEvent:y}=t,A=re(g);for(const[O,x]of A.entries())nt(x,Q)&&O>=r&&X(x,T);E(),setTimeout(()=>{y(r,m),bt(n,0,!0),pe(r,g,t),et(u),V(u,n)},b)},D=(r,u,g,m)=>{if(!g||!g.droppable||!g.config)return;const{droppable:E,config:T}=g;let[y]=Rt(u,E);y=[u,...y].toReversed();const A=yt(u,"remove",T.direction,E);for(const[O,x]of y.entries())O>=r&&(W(x,A),setTimeout(()=>{m(x)},h))},v=r=>{bt(n,h,!0),setTimeout(()=>{et(r),V(r,n)},h)},R=(r,u,g,m)=>{const{config:E,droppable:T}=m,[y]=Rt(r,T),A=pt(r,T);y.length==0&&I(g,1,E.direction,y);for(const[O,x]of y.entries()){if(!nt(x,Q))continue;const G=N(E.direction,r,x,g);if(!A&&G)g=G;else if(!A)continue;const Z=y.length-O;I(g,Z,E.direction,y),u===ue?W(x,g):u===Pt&&X(x,g)}},N=(r,u,g,m)=>{const{before:E,distance:T,axis:y,getRect:A}=w(r),O=A(u),x=A(g),G=O[E],Z=x[E],ut=x[T],St=Z+ut/2,Dt=ye(g)[y],ct=St-Dt;return G>ct?{height:0,width:0}:m},I=(r,u,g,m)=>{const E=m.filter(y=>nt(y,Q)).length,{distance:T}=w(g);r[T]==0?c=Math.max(c,u):c=Math.min(c,u-1),c=Math.min(c,E)},W=(r,u)=>{const{width:g,height:m}=u;Tt(r,m,g)},X=(r,u)=>{const{width:g,height:m}=u;Tt(r,m,g),Nt(r,h,fe)},F=(r,u,g,m,E,T)=>{const{droppable:y,scroll:A,config:O}=E,[x,G]=Rt(r,y),Z=x.toReversed(),ut=G===-1?Z.length:G;Z.splice(ut,0,r);const[St,Dt,ct]=st(r,G,Z,y);g=yt(r,u,O.direction,n,St,Dt);const Ft=be(),At=ke(O.direction,Z,G,ct,Ft,A,m,y,r);x.length==0&&H(void 0,g,r,At);for(const[xt,wt]of x.toReversed().entries()){let Bt=g;ct-1>=xt&&(Bt={height:0,width:0}),u===zt&&!nt(wt,ht)&&H(wt,Bt,r,At)}P(ct,r,O,y,T)},st=(r,u,g,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=g[A]??null,G=g[O]??null;return[x,G,T]},H=(r,u,g,m)=>{Tt(r,u.height,u.width),Tt(g,m.height,m.width)},P=(r,u,g,m,E)=>{const{onInsertEvent:T,onDragEnd:y}=g;U(u,Xt),z(u,n,m,()=>{if(Ct(u,Xt),E!=null){const A=p(E);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(()=>{Ct(r,B)},gn)},z=(r,u,g,m)=>{setTimeout(()=>{m&&m(),Y(u,g),j(g),et(r),V(r,u),V(r,g)},h)},Y=(r,u)=>{r.isSameNode(u)?bt(r,h):(bt(r,h,!0),bt(u,h))},j=r=>{if(n.isSameNode(r))return;var[u]=n.querySelectorAll(`.${ht}`);if(!u)return;const{distance:g}=w(l);at(u)&&(u.style[g]="0px")},V=(r,u)=>{const[g]=Rt(r,u);for(const m of[...g,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 g=u.querySelector(f);gt(document.body,ne,r),gt(g||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(()=>{Ct(l,Zt),Ct(l,s),i.disconnect()},o)},e,{childList:!0})},pn=(t,e,n,s)=>{if(!e)return;const{onInsertEvent:o,delayBeforeInsert:i}=t;setTimeout(()=>{o(n,s),pe(n,e,t)},i)},hn=(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}},mn=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,p,h,b)=>{const B=D=>{const{beforeMargin:v,borderBeforeWidth:R,before:N,offset:I,scroll:W,page:X,inner:F,distance:st,axis:H,getRect:P}=w(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}=w(b),W=I(f)[R],X=I(p),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,p);!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(p,b,$)}},S=D=>{const{axis:v}=w(D);s[v]=B(D),o(s)};S(_),S(tt)},(f,p)=>{const[h,b,B,M]=vn(f,p,t);n={top:h,left:b},i(n),e={offsetX:B,offsetY:M}}]},Lt=(t,e,n)=>{const{borderBeforeWidth:s,before:o,getRect:i}=w(t);return i(e)[o]-i(n)[o]-L(n,s)},Sn=(t,e)=>{let{offsetX:n,offsetY:s,target:o}=t,i=Dn(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]},Dn=(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}=w(t),p=ie(n,t);return e[c]-s[o]-L(n,i)-L(n,l)-window[f]-p},vn=(t,e,n)=>{const[s,o]=Sn(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 bn{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 Tn(t,e,n,s,o){const{handlerSelector:i,isDraggable:c,droppableGroup:l,animationDuration:f,delayBeforeRemove:p,draggingClass:h,removingClass:b,onRemoveAtEvent:B,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]=mn(t),[F,st,H,P,k]=dn(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 d=a==null?void 0:a.querySelector(`.${Ot}`),C=d==null?void 0:d.parentElement;return d&&C&&nt(C,It)&&!C.isSameNode(s)?null:d},$=a=>{const d=V(a)??a;d&&c(a)&&($t(d,"onmousedown",O("mousemove","mouseup")),$t(d,"ontouchstart",O("touchmove","touchend")),et(d)),a!=null&&a.isSameNode(d)||$t(a,"onmousedown",x),U(s,It)},et=a=>{const d=a.querySelectorAll("img");Array.from(d).forEach(C=>{C.onmousedown=()=>!1})},ot=()=>{if(N.pageX==0&&N.pageY==0||!r.current)return;const{droppable:a,config:d}=r.current;W(t,a,N,d.direction),F(t,Pt,R,r.current)},lt=(a,d)=>{d&&v==2&&!(a!=null&&a.droppable.isSameNode(d.droppable))&&F(t,Pt,R,d)},r=new bn(t,D,s,ot,lt),u=a=>{if(!r.current)return;const d=D?Array.from(document.querySelectorAll(dt(D))):[s];for(const C of d)C.classList.toggle(M,!a&&C.isSameNode(r.current.droppable))},g=a=>{r.updateConfig(a);const d=r.isOutside(a);u(d),v===1?ut(a):v===2&&(m(d),Dt(a))},m=(a=!0)=>{if(!r.current)return;const{droppable:d}=r.current;fn(d,s,D,f,a),!a&&Gt(t,s,v==1,r.current)},E=a=>{if(Yt(a)&&a.cancelable)a.preventDefault();else if(Yt(a))return;const d=Vt(a);g(d)},T=(a,d)=>{a=="touchmove"?I=setTimeout(()=>{d()},200):d()},y=(a,d)=>{const{clientX:C,clientY:ft}=a,rt=document.elementFromPoint(C,ft),vt=rt==null?void 0:rt.closest(`.${Q}`);return rt&&d&&vt&&!d.isSameNode(vt)},A=a=>{const d=n.onGetValue(e);return{index:e,element:a,value:d}},O=(a,d)=>C=>{if(y(C,t))return;it.updateScrolls(s,D);const{scrollX:ft,scrollY:rt}=window;if(R={scrollX:ft,scrollY:rt},v===0){v=1;const vt=A(t);vt&&S(vt),T(a,()=>{a=="touchmove"&&(r.updateConfig(C),u(r.isOutside(C)),ut(C)),document.addEventListener(a,E,{passive:!1})}),ct(s),document.addEventListener(d,G(a),{once:!0})}},x=a=>r.updateConfig(a),G=a=>d=>{u(!0);const C=Vt(d);clearTimeout(I),At(r.isOutside(C,!1)),document.removeEventListener(a,E),r.updateConfig(C);const ft=r.getCurrentConfig(C);if(ft){const{droppable:rt}=ft;Z(rt)}s.onscroll=null},Z=a=>{if(a.onscroll=null,!D)return;const d=Array.from(document.querySelectorAll(dt(D)));for(const C of d)at(C)&&(C.onscroll=null)},ut=a=>{Gt(t,s,v==1,r.current),St(),F(t,ue,R,r.current),wt(t),X(a,t)},St=()=>{v=2},Dt=a=>{const{pageX:d,pageY:C}=a;N={pageX:d,pageY:C},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),Tt(a,0,0)},wt=a=>{const{height:d,width:C}=a.getBoundingClientRect();le(a,{fixedHeight:`${d}px`,fixedWidth:`${C}px`}),k(a,!0),gt(a,h,!0),a.style.transition=""},Bt=a=>{if(!r.initial)return;const d=r.initial;a==e&&(U(t,b),setTimeout(()=>{B(e),Ct(t,b),Gt(t,s,v==1,r.initial),st(a,t,d,C=>{xt(C),P(t)})},p))},he=(a,d)=>{(a===e||a===n.onGetLegth()&&e===a-1)&&H(a,t,s,d,()=>{ln(t,v==1,r.initial)})};return j(),$(t),[Bt,he]}const yn=(t,e)=>{t&&ve(e,t)};function Cn(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(p=>`droppable-group-${p}`).join(" ");yn(f,n);for(const p of n.children){const h=p.getAttribute(o),b=Te(h),B=p;if(B&&b>=0){const[M,S]=Tn(B,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=hn(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)},p=S=>{const[D,v]=Cn(c,e,S,s);o=D,i=v},h=S=>{kt(()=>{p(S)},S,{childList:!0})},b=S=>{U(S,It)},B=S=>{it.addConfig(S,c)};return[l,f,S=>{S&&(b(S),B(S),h(S),p(S),it.removeObsoleteConfigs())}]}exports.GRAB_CLASS=se;exports.addClass=U;exports.dragAndDrop=En;exports.insertToListEmpty=pn;exports.toggleClass=gt;
|
@@ -5,7 +5,7 @@ const Q = "draggable", It = "droppable", Ot = "handler-class", _t = "dragging",
|
|
5
5
|
t.classList.toggle(e, n);
|
6
6
|
}, nt = (t, e) => {
|
7
7
|
t.classList.add(e);
|
8
|
-
},
|
8
|
+
}, Et = (t, e) => {
|
9
9
|
t.classList.remove(e);
|
10
10
|
}, De = (t, e) => Ct(e).every(
|
11
11
|
(n) => et(t, n)
|
@@ -17,13 +17,13 @@ const Q = "draggable", It = "droppable", Ot = "handler-class", _t = "dragging",
|
|
17
17
|
}, Ct = (t) => t ? t.split(" ").filter((e) => e) : [], H = "horizontal", U = "vertical", be = () => {
|
18
18
|
const { scrollX: t, scrollY: e } = window;
|
19
19
|
return { scrollX: t, scrollY: e };
|
20
|
-
}, qt = (t) => !t || t.trim().length == 0 || t == "normal" ? 0 : parseFloat(t), Te = (t) => t ? parseInt(t) : -1,
|
20
|
+
}, qt = (t) => !t || t.trim().length == 0 || t == "normal" ? 0 : parseFloat(t), Te = (t) => t ? parseInt(t) : -1, ye = (t) => {
|
21
21
|
const e = getComputedStyle(t), n = new DOMMatrixReadOnly(e.transform);
|
22
22
|
return {
|
23
23
|
x: n.m41,
|
24
24
|
y: n.m42
|
25
25
|
};
|
26
|
-
}, se = (t, e) => t.x1 > e.x1 ? se(e, t) : t.x2 < e.x1 ? 0 : t.x2 >= e.x2 ? t.x2 - t.x1 : t.x2 - e.x1, dt = (t, e) => !
|
26
|
+
}, se = (t, e) => t.x1 > e.x1 ? se(e, t) : t.x2 < e.x1 ? 0 : t.x2 >= e.x2 ? t.x2 - t.x1 : t.x2 - e.x1, dt = (t, e) => !Ee(t, e), Ee = (t, e) => {
|
27
27
|
const n = Mt(t), s = Mt(e), o = Jt(n, s, U), i = Jt(n, s, H);
|
28
28
|
return o >= Math.min(n.height, s.height) / 2 && i >= Math.min(n.width, s.width) / 2;
|
29
29
|
}, Jt = (t, e, n) => {
|
@@ -208,7 +208,7 @@ const Q = "draggable", It = "droppable", Ot = "handler-class", _t = "dragging",
|
|
208
208
|
const { gap: n } = w(e), [s, o] = jt(t, n);
|
209
209
|
return o ? s : 0;
|
210
210
|
};
|
211
|
-
function
|
211
|
+
function yt(t, e, n, s, o = t.previousElementSibling, i = t.nextElementSibling) {
|
212
212
|
let { height: c, width: l } = _e(
|
213
213
|
n,
|
214
214
|
t,
|
@@ -372,9 +372,10 @@ const Ze = (t, e, n) => {
|
|
372
372
|
return [c, l, f];
|
373
373
|
}, kt = (t, e, n) => {
|
374
374
|
const s = new MutationObserver((o) => {
|
375
|
-
o.
|
375
|
+
if (o.length > 0) {
|
376
|
+
const i = o[0];
|
376
377
|
t(s, i);
|
377
|
-
}
|
378
|
+
}
|
378
379
|
});
|
379
380
|
return s.observe(e, n), s;
|
380
381
|
}, en = (t, e, n) => {
|
@@ -383,7 +384,7 @@ const Ze = (t, e, n) => {
|
|
383
384
|
const { scrollDistance: s, clientDistance: o, scrollElement: i } = w(t);
|
384
385
|
return n[i] / (e[s] - e[o]);
|
385
386
|
}, sn = "startDrag", fe = "cubic-bezier(0.2, 0, 0, 1)", on = (t, e, n) => {
|
386
|
-
let s =
|
387
|
+
let s = yt(
|
387
388
|
e,
|
388
389
|
sn,
|
389
390
|
n,
|
@@ -486,10 +487,10 @@ function dn(t, e, n, s, o, i) {
|
|
486
487
|
} = t, M = (r, u, g, m, C) => {
|
487
488
|
if (!m)
|
488
489
|
return;
|
489
|
-
const { droppable: T, config:
|
490
|
+
const { droppable: T, config: y } = m, A = yt(
|
490
491
|
r,
|
491
492
|
u,
|
492
|
-
|
493
|
+
y.direction,
|
493
494
|
T
|
494
495
|
);
|
495
496
|
Xe(u) ? F(
|
@@ -506,30 +507,30 @@ function dn(t, e, n, s, o, i) {
|
|
506
507
|
m
|
507
508
|
);
|
508
509
|
}, S = (r, u, g, m, C) => {
|
509
|
-
const T =
|
510
|
+
const T = yt(
|
510
511
|
u,
|
511
512
|
"insert",
|
512
513
|
t.direction,
|
513
514
|
g
|
514
|
-
), { onInsertEvent:
|
515
|
+
), { onInsertEvent: y } = t, A = oe(g);
|
515
516
|
for (const [O, x] of A.entries())
|
516
517
|
et(x, Q) && O >= r && X(x, T);
|
517
518
|
C(), setTimeout(() => {
|
518
|
-
|
519
|
+
y(r, m), vt(n, 0, !0), de(r, g, t), tt(u), V(u, n);
|
519
520
|
}, b);
|
520
521
|
}, D = (r, u, g, m) => {
|
521
522
|
if (!g || !g.droppable || !g.config)
|
522
523
|
return;
|
523
524
|
const { droppable: C, config: T } = g;
|
524
|
-
let [
|
525
|
-
|
526
|
-
const A =
|
525
|
+
let [y] = Rt(u, C);
|
526
|
+
y = [u, ...y].toReversed();
|
527
|
+
const A = yt(
|
527
528
|
u,
|
528
529
|
"remove",
|
529
530
|
T.direction,
|
530
531
|
C
|
531
532
|
);
|
532
|
-
for (const [O, x] of
|
533
|
+
for (const [O, x] of y.entries())
|
533
534
|
O >= r && (W(x, A), setTimeout(() => {
|
534
535
|
m(x);
|
535
536
|
}, h));
|
@@ -538,14 +539,14 @@ function dn(t, e, n, s, o, i) {
|
|
538
539
|
tt(r), V(r, n);
|
539
540
|
}, h);
|
540
541
|
}, R = (r, u, g, m) => {
|
541
|
-
const { config: C, droppable: T } = m, [
|
542
|
-
|
542
|
+
const { config: C, droppable: T } = m, [y] = Rt(r, T), A = dt(r, T);
|
543
|
+
y.length == 0 && I(
|
543
544
|
g,
|
544
545
|
1,
|
545
546
|
C.direction,
|
546
|
-
|
547
|
+
y
|
547
548
|
);
|
548
|
-
for (const [O, x] of
|
549
|
+
for (const [O, x] of y.entries()) {
|
549
550
|
if (!et(x, Q))
|
550
551
|
continue;
|
551
552
|
const G = N(
|
@@ -558,20 +559,20 @@ function dn(t, e, n, s, o, i) {
|
|
558
559
|
g = G;
|
559
560
|
else if (!A)
|
560
561
|
continue;
|
561
|
-
const Z =
|
562
|
+
const Z = y.length - O;
|
562
563
|
I(
|
563
564
|
g,
|
564
565
|
Z,
|
565
566
|
C.direction,
|
566
|
-
|
567
|
+
y
|
567
568
|
), u === le ? W(x, g) : u === Pt && X(x, g);
|
568
569
|
}
|
569
570
|
}, N = (r, u, g, m) => {
|
570
|
-
const { before: C, distance: T, axis:
|
571
|
+
const { before: C, distance: T, axis: y, getRect: A } = w(r), O = A(u), x = A(g), G = O[C], Z = x[C], ut = x[T], mt = Z + ut / 2, St = ye(g)[y], ct = mt - St;
|
571
572
|
return G > ct ? { height: 0, width: 0 } : m;
|
572
573
|
}, I = (r, u, g, m) => {
|
573
574
|
const C = m.filter(
|
574
|
-
(
|
575
|
+
(y) => et(y, Q)
|
575
576
|
).length, { distance: T } = w(g);
|
576
577
|
r[T] == 0 ? c = Math.max(c, u) : c = Math.min(c, u - 1), c = Math.min(c, C);
|
577
578
|
}, W = (r, u) => {
|
@@ -581,18 +582,18 @@ function dn(t, e, n, s, o, i) {
|
|
581
582
|
const { width: g, height: m } = u;
|
582
583
|
Tt(r, m, g), Nt(r, h, ue);
|
583
584
|
}, F = (r, u, g, m, C, T) => {
|
584
|
-
const { droppable:
|
585
|
+
const { droppable: y, scroll: A, config: O } = C, [x, G] = Rt(
|
585
586
|
r,
|
586
|
-
|
587
|
+
y
|
587
588
|
), Z = x.toReversed(), ut = G === -1 ? Z.length : G;
|
588
589
|
Z.splice(ut, 0, r);
|
589
590
|
const [mt, St, ct] = st(
|
590
591
|
r,
|
591
592
|
G,
|
592
593
|
Z,
|
593
|
-
|
594
|
+
y
|
594
595
|
);
|
595
|
-
g =
|
596
|
+
g = yt(
|
596
597
|
r,
|
597
598
|
u,
|
598
599
|
O.direction,
|
@@ -608,7 +609,7 @@ function dn(t, e, n, s, o, i) {
|
|
608
609
|
Ft,
|
609
610
|
A,
|
610
611
|
m,
|
611
|
-
|
612
|
+
y,
|
612
613
|
r
|
613
614
|
);
|
614
615
|
x.length == 0 && _(
|
@@ -630,11 +631,11 @@ function dn(t, e, n, s, o, i) {
|
|
630
631
|
ct,
|
631
632
|
r,
|
632
633
|
O,
|
633
|
-
|
634
|
+
y,
|
634
635
|
T
|
635
636
|
);
|
636
637
|
}, st = (r, u, g, m) => {
|
637
|
-
const T = dt(r, m) ? u : c,
|
638
|
+
const T = dt(r, m) ? u : c, y = () => u < T ? [T, T + 1] : u > T ? [T - 1, T] : [T - 1, T + 1], [A, O] = y(), x = g[A] ?? null, G = g[O] ?? null;
|
638
639
|
return [
|
639
640
|
x,
|
640
641
|
G,
|
@@ -647,11 +648,11 @@ function dn(t, e, n, s, o, i) {
|
|
647
648
|
m.width
|
648
649
|
);
|
649
650
|
}, P = (r, u, g, m, C) => {
|
650
|
-
const { onInsertEvent: T, onDragEnd:
|
651
|
+
const { onInsertEvent: T, onDragEnd: y } = g;
|
651
652
|
nt(u, Xt), z(u, n, m, () => {
|
652
|
-
if (
|
653
|
+
if (Et(u, Xt), C != null) {
|
653
654
|
const A = p(C);
|
654
|
-
A != null && (T(r, A),
|
655
|
+
A != null && (T(r, A), y({ value: A, index: r })), q(u), k();
|
655
656
|
}
|
656
657
|
});
|
657
658
|
}, k = () => {
|
@@ -664,7 +665,7 @@ function dn(t, e, n, s, o, i) {
|
|
664
665
|
}
|
665
666
|
}, q = (r) => {
|
666
667
|
setTimeout(() => {
|
667
|
-
|
668
|
+
Et(r, B);
|
668
669
|
}, gn);
|
669
670
|
}, z = (r, u, g, m) => {
|
670
671
|
setTimeout(() => {
|
@@ -709,7 +710,7 @@ const de = (t, e, n) => {
|
|
709
710
|
const { insertingFromClass: s, animationDuration: o } = n, i = kt(() => {
|
710
711
|
const l = oe(e)[t];
|
711
712
|
nt(l, s), nt(l, Zt), setTimeout(() => {
|
712
|
-
|
713
|
+
Et(l, Zt), Et(l, s), i.disconnect();
|
713
714
|
}, o);
|
714
715
|
}, e, {
|
715
716
|
childList: !0
|
@@ -981,8 +982,8 @@ function bn(t, e, n, s, o) {
|
|
981
982
|
".disable-transition{transition:none!important;}"
|
982
983
|
]), Y(), q();
|
983
984
|
}, V = (a) => {
|
984
|
-
const d = a == null ? void 0 : a.querySelector(`.${Ot}`),
|
985
|
-
return d &&
|
985
|
+
const d = a == null ? void 0 : a.querySelector(`.${Ot}`), E = d == null ? void 0 : d.parentElement;
|
986
|
+
return d && E && et(E, It) && !E.isSameNode(s) ? null : d;
|
986
987
|
}, $ = (a) => {
|
987
988
|
const d = V(a) ?? a;
|
988
989
|
d && c(a) && ($t(
|
@@ -996,8 +997,8 @@ function bn(t, e, n, s, o) {
|
|
996
997
|
), tt(d)), a != null && a.isSameNode(d) || $t(a, "onmousedown", x), nt(s, It);
|
997
998
|
}, tt = (a) => {
|
998
999
|
const d = a.querySelectorAll("img");
|
999
|
-
Array.from(d).forEach((
|
1000
|
-
|
1000
|
+
Array.from(d).forEach((E) => {
|
1001
|
+
E.onmousedown = () => !1;
|
1001
1002
|
});
|
1002
1003
|
}, ot = () => {
|
1003
1004
|
if (N.pageX == 0 && N.pageY == 0 || !r.current)
|
@@ -1028,10 +1029,10 @@ function bn(t, e, n, s, o) {
|
|
1028
1029
|
const d = D ? Array.from(
|
1029
1030
|
document.querySelectorAll(gt(D))
|
1030
1031
|
) : [s];
|
1031
|
-
for (const
|
1032
|
-
|
1032
|
+
for (const E of d)
|
1033
|
+
E.classList.toggle(
|
1033
1034
|
M,
|
1034
|
-
!a &&
|
1035
|
+
!a && E.isSameNode(r.current.droppable)
|
1035
1036
|
);
|
1036
1037
|
}, g = (a) => {
|
1037
1038
|
r.updateConfig(a);
|
@@ -1064,14 +1065,14 @@ function bn(t, e, n, s, o) {
|
|
1064
1065
|
a == "touchmove" ? I = setTimeout(() => {
|
1065
1066
|
d();
|
1066
1067
|
}, 200) : d();
|
1067
|
-
},
|
1068
|
-
const { clientX:
|
1068
|
+
}, y = (a, d) => {
|
1069
|
+
const { clientX: E, clientY: ft } = a, rt = document.elementFromPoint(E, ft), Dt = rt == null ? void 0 : rt.closest(`.${Q}`);
|
1069
1070
|
return rt && d && Dt && !d.isSameNode(Dt);
|
1070
1071
|
}, A = (a) => {
|
1071
1072
|
const d = n.onGetValue(e);
|
1072
1073
|
return { index: e, element: a, value: d };
|
1073
|
-
}, O = (a, d) => (
|
1074
|
-
if (E
|
1074
|
+
}, O = (a, d) => (E) => {
|
1075
|
+
if (y(E, t))
|
1075
1076
|
return;
|
1076
1077
|
it.updateScrolls(s, D);
|
1077
1078
|
const { scrollX: ft, scrollY: rt } = window;
|
@@ -1079,7 +1080,7 @@ function bn(t, e, n, s, o) {
|
|
1079
1080
|
v = 1;
|
1080
1081
|
const Dt = A(t);
|
1081
1082
|
Dt && S(Dt), T(a, () => {
|
1082
|
-
a == "touchmove" && (r.updateConfig(
|
1083
|
+
a == "touchmove" && (r.updateConfig(E), u(r.isOutside(E)), ut(E)), document.addEventListener(a, C, {
|
1083
1084
|
passive: !1
|
1084
1085
|
});
|
1085
1086
|
}), ct(s), document.addEventListener(d, G(a), {
|
@@ -1088,9 +1089,9 @@ function bn(t, e, n, s, o) {
|
|
1088
1089
|
}
|
1089
1090
|
}, x = (a) => r.updateConfig(a), G = (a) => (d) => {
|
1090
1091
|
u(!0);
|
1091
|
-
const
|
1092
|
-
clearTimeout(I), At(r.isOutside(
|
1093
|
-
const ft = r.getCurrentConfig(
|
1092
|
+
const E = Vt(d);
|
1093
|
+
clearTimeout(I), At(r.isOutside(E, !1)), document.removeEventListener(a, C), r.updateConfig(E);
|
1094
|
+
const ft = r.getCurrentConfig(E);
|
1094
1095
|
if (ft) {
|
1095
1096
|
const { droppable: rt } = ft;
|
1096
1097
|
Z(rt);
|
@@ -1102,8 +1103,8 @@ function bn(t, e, n, s, o) {
|
|
1102
1103
|
const d = Array.from(
|
1103
1104
|
document.querySelectorAll(gt(D))
|
1104
1105
|
);
|
1105
|
-
for (const
|
1106
|
-
at(
|
1106
|
+
for (const E of d)
|
1107
|
+
at(E) && (E.onscroll = null);
|
1107
1108
|
}, ut = (a) => {
|
1108
1109
|
Gt(
|
1109
1110
|
t,
|
@@ -1119,8 +1120,8 @@ function bn(t, e, n, s, o) {
|
|
1119
1120
|
}, mt = () => {
|
1120
1121
|
v = 2;
|
1121
1122
|
}, St = (a) => {
|
1122
|
-
const { pageX: d, pageY:
|
1123
|
-
N = { pageX: d, pageY:
|
1123
|
+
const { pageX: d, pageY: E } = a;
|
1124
|
+
N = { pageX: d, pageY: E }, ot();
|
1124
1125
|
}, ct = (a) => ce(a, "onscroll", Ft), Ft = () => ot(), At = (a) => {
|
1125
1126
|
if (v !== 2) {
|
1126
1127
|
v = 0;
|
@@ -1136,17 +1137,17 @@ function bn(t, e, n, s, o) {
|
|
1136
1137
|
}, xt = (a) => {
|
1137
1138
|
Nt(a, f, ue), Tt(a, 0, 0);
|
1138
1139
|
}, wt = (a) => {
|
1139
|
-
const { height: d, width:
|
1140
|
+
const { height: d, width: E } = a.getBoundingClientRect();
|
1140
1141
|
ae(a, {
|
1141
1142
|
fixedHeight: `${d}px`,
|
1142
|
-
fixedWidth: `${
|
1143
|
+
fixedWidth: `${E}px`
|
1143
1144
|
}), k(a, !0), bt(a, h, !0), a.style.transition = "";
|
1144
1145
|
}, Bt = (a) => {
|
1145
1146
|
if (!r.initial)
|
1146
1147
|
return;
|
1147
1148
|
const d = r.initial;
|
1148
1149
|
a == e && (nt(t, b), setTimeout(() => {
|
1149
|
-
B(e),
|
1150
|
+
B(e), Et(t, b), Gt(
|
1150
1151
|
t,
|
1151
1152
|
s,
|
1152
1153
|
v == 1,
|
@@ -1155,8 +1156,8 @@ function bn(t, e, n, s, o) {
|
|
1155
1156
|
a,
|
1156
1157
|
t,
|
1157
1158
|
d,
|
1158
|
-
(
|
1159
|
-
xt(
|
1159
|
+
(E) => {
|
1160
|
+
xt(E), P(t);
|
1160
1161
|
}
|
1161
1162
|
);
|
1162
1163
|
}, p));
|
@@ -1180,7 +1181,7 @@ function bn(t, e, n, s, o) {
|
|
1180
1181
|
const Tn = (t, e) => {
|
1181
1182
|
t && ve(e, t);
|
1182
1183
|
};
|
1183
|
-
function
|
1184
|
+
function yn(t, e, n, s = "index") {
|
1184
1185
|
const o = s;
|
1185
1186
|
let i = [], c = [];
|
1186
1187
|
const { droppableGroup: l } = t;
|
@@ -1221,7 +1222,7 @@ function An(t, e, n, s = "index") {
|
|
1221
1222
|
for (const R of i)
|
1222
1223
|
R(S, D);
|
1223
1224
|
}, p = (S) => {
|
1224
|
-
const [D, v] =
|
1225
|
+
const [D, v] = yn(c, e, S, s);
|
1225
1226
|
o = D, i = v;
|
1226
1227
|
}, h = (S) => {
|
1227
1228
|
kt(
|
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-DiASUxtT.cjs"),o=require("../index-TH8hx6fO.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-Bp-hKsuU.js";
|
5
|
+
import { i as m, d as u } from "../index-WuPwAM50.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-DiASUxtT.cjs"),u=require("../index-TH8hx6fO.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-Bp-hKsuU.js";
|
6
|
+
import { i as p, d as v } from "../index-WuPwAM50.js";
|
7
7
|
const g = (n, t) => {
|
8
8
|
const e = n.value;
|
9
9
|
if (e.length <= 0)
|
package/package.json
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
{
|
2
2
|
"name": "fluid-dnd",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.8-beta.0",
|
4
4
|
"description": "An agnostic drag and drop library to sort all kind of lists. With current support for vue 3 and svelte",
|
5
5
|
"type": "module",
|
6
|
-
"homepage": "https://
|
6
|
+
"homepage": "https://fluid-dnd.netlify.app",
|
7
7
|
"repository": {
|
8
8
|
"type": "git",
|
9
|
-
"url": "https://github.com/carlosjorger/
|
9
|
+
"url": "https://github.com/carlosjorger/fluid-dnd.git"
|
10
10
|
},
|
11
11
|
"files": [
|
12
12
|
"dist"
|
package/dist/index-GRcZUS5t.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)=>Ct(e).every(n=>nt(t,n)),dt=t=>t?`.${Ct(t).join(".")}`:"",ve=(t,e)=>{if(!e)return;const n=Ct(e);t.classList.add(...n)},Ct=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,Ee=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)=>!ye(t,e),ye=(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}=w(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(),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}},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}=w(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"],we=(t,e,n)=>{t&&(t.style.height=`${e}px`,t.style.width=`${n}px`)},Tt=(t,e,n)=>{!t||!at(t)||(n==0&&e==0?t.style.transform="":t.style.transform=`translate(${n}px,${e}px)`)},Be=(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:Be(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:p,target:h}=e;return{clientX:o,clientY:i,pageX:c,pageY:l,screenX:f,screenY:p,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}=w(n),p=f(s);return t[o]-e[i]-p[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}=w(e),[s,o]=jt(t,n);return o?s:0};function Et(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}=w(t),p=L(e,o),h=L(e,i),b=L(s,i),[B,M]=jt(e.parentElement,l),S=f(e)[c];if(M)return Qt(S,h,p,B,0,t);const[D,v,R]=qe(n,b,p,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}=w(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 p=0,h=0;const b=!!(n<0&&f);if(n===s&&!b)return te({height:p,width:h},t,o,c,b);const[B,M,S,D]=Ke(e,n,s,f);if(b){const[et,ot]=je(l,f);p+=ot,h+=et}const{scrollElement:v,beforeMargin:R,afterMargin:N,distance:I,gap:W}=w(t),[X,F]=jt(l,W),[st,H,P]=Ue(R,N,B,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?p+=$:t===_&&(h+=$),te({height:p,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 p=o?t.slice(i+1,c+1):t.slice(i,c);return i<0&&s&&(p=t.slice(i+1,c)),[l,f,p,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[p,h]of s.entries()){const b=h.getBoundingClientRect()[n],B=L(h,t);i&&(l+=B),i&&p>0?l+=o:l=Math.max(l,B),f+=l+b,l=L(h,e)}return[c,f,l]},te=(t,e,n,s,o)=>{const{scroll:i,distance:c}=w(e),l=window[i],f=n[i],p=o?0:f-2*l+s[i];return t[c]+=p,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=>{o.forEach(i=>{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}=w(t);return n[i]/(e[s]-e[o])},sn="startDrag",ge="cubic-bezier(0.2, 0, 0, 1)",on=(t,e,n)=>{let s=Et(e,sn,n,t);const o=_e(t,n),{distance:i}=w(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}=w(n);return[o(e)[s],s]},mt=(t,e,n)=>{we(t,e,n),t.style.minWidth=`${n}px`},cn=(t,e,n)=>s=>{e.contains(t)&&(mt(t,n.height,n.width),s.disconnect())},an=(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:p}=w(i);c&&(n[p]=n[l]-n[f])},de=(t,e,n,s)=>{if(!n)return;const{droppable:o,config:i}=n,{direction:c,animationDuration:l}=i;if(an(n,e),o.querySelector(`.${ht}`)||!t)return;var f=t.tagName=="LI"?"DIV":t.tagName,p=document.createElement(f);U(p,ht),mt(p,0,0);const h=on(o,t,c);return Nt(p,l,ge,"width, min-width, height"),[p,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)&&mt(c,l.height,l.width),kt(cn(c,f,l),f,{childList:!0,subtree:!0}),f.appendChild(c)},ln=(t,e,n)=>{const s=de(t,e,n);if(!s)return;const[o,i,c]=s;c.appendChild(o),un(o,i)},un=(t,e)=>requestAnimationFrame(()=>{mt(t,e.height,e.width),requestAnimationFrame(()=>{Nt(t,0,ge,"width, min-width, height")})}),fn=(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;mt(c,0,0),setTimeout(()=>{var p;(p=c.parentNode)==null||p.removeChild(c)},s)})}},bt=(t,e,n=!1)=>{var s=t.querySelectorAll(`.${ht}`);s.forEach(o=>{n?(mt(o,0,0),setTimeout(()=>{t.contains(o)&&t.removeChild(o)},e)):t.removeChild(o)})},gn=50;function dn(t,e,n,s,o,i){let c=e;const{direction:l,handlerSelector:f,onRemoveAtEvent:p,animationDuration:h,delayBeforeInsert:b,draggingClass:B}=t,M=(r,u,g,m,C)=>{if(!m)return;const{droppable:T,config:E}=m,A=Et(r,u,E.direction,T);Xe(u)?F(r,u,A,g,m,C):R(r,u,A,m)},S=(r,u,g,m,C)=>{const T=Et(u,"insert",t.direction,g),{onInsertEvent:E}=t,A=re(g);for(const[O,x]of A.entries())nt(x,Q)&&O>=r&&X(x,T);C(),setTimeout(()=>{E(r,m),bt(n,0,!0),pe(r,g,t),et(u),V(u,n)},b)},D=(r,u,g,m)=>{if(!g||!g.droppable||!g.config)return;const{droppable:C,config:T}=g;let[E]=Rt(u,C);E=[u,...E].toReversed();const A=Et(u,"remove",T.direction,C);for(const[O,x]of E.entries())O>=r&&(W(x,A),setTimeout(()=>{m(x)},h))},v=r=>{bt(n,h,!0),setTimeout(()=>{et(r),V(r,n)},h)},R=(r,u,g,m)=>{const{config:C,droppable:T}=m,[E]=Rt(r,T),A=pt(r,T);E.length==0&&I(g,1,C.direction,E);for(const[O,x]of E.entries()){if(!nt(x,Q))continue;const G=N(C.direction,r,x,g);if(!A&&G)g=G;else if(!A)continue;const Z=E.length-O;I(g,Z,C.direction,E),u===ue?W(x,g):u===Pt&&X(x,g)}},N=(r,u,g,m)=>{const{before:C,distance:T,axis:E,getRect:A}=w(r),O=A(u),x=A(g),G=O[C],Z=x[C],ut=x[T],St=Z+ut/2,Dt=Ee(g)[E],ct=St-Dt;return G>ct?{height:0,width:0}:m},I=(r,u,g,m)=>{const C=m.filter(E=>nt(E,Q)).length,{distance:T}=w(g);r[T]==0?c=Math.max(c,u):c=Math.min(c,u-1),c=Math.min(c,C)},W=(r,u)=>{const{width:g,height:m}=u;Tt(r,m,g)},X=(r,u)=>{const{width:g,height:m}=u;Tt(r,m,g),Nt(r,h,fe)},F=(r,u,g,m,C,T)=>{const{droppable:E,scroll:A,config:O}=C,[x,G]=Rt(r,E),Z=x.toReversed(),ut=G===-1?Z.length:G;Z.splice(ut,0,r);const[St,Dt,ct]=st(r,G,Z,E);g=Et(r,u,O.direction,n,St,Dt);const Ft=be(),At=ke(O.direction,Z,G,ct,Ft,A,m,E,r);x.length==0&&H(void 0,g,r,At);for(const[xt,wt]of x.toReversed().entries()){let Bt=g;ct-1>=xt&&(Bt={height:0,width:0}),u===zt&&!nt(wt,ht)&&H(wt,Bt,r,At)}P(ct,r,O,E,T)},st=(r,u,g,m)=>{const T=pt(r,m)?u:c,E=()=>u<T?[T,T+1]:u>T?[T-1,T]:[T-1,T+1],[A,O]=E(),x=g[A]??null,G=g[O]??null;return[x,G,T]},H=(r,u,g,m)=>{Tt(r,u.height,u.width),Tt(g,m.height,m.width)},P=(r,u,g,m,C)=>{const{onInsertEvent:T,onDragEnd:E}=g;U(u,Xt),z(u,n,m,()=>{if(yt(u,Xt),C!=null){const A=p(C);A!=null&&(T(r,A),E({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,B)},gn)},z=(r,u,g,m)=>{setTimeout(()=>{m&&m(),Y(u,g),j(g),et(r),V(r,u),V(r,g)},h)},Y=(r,u)=>{r.isSameNode(u)?bt(r,h):(bt(r,h,!0),bt(u,h))},j=r=>{if(n.isSameNode(r))return;var[u]=n.querySelectorAll(`.${ht}`);if(!u)return;const{distance:g}=w(l);at(u)&&(u.style[g]="0px")},V=(r,u)=>{const[g]=Rt(r,u);for(const m of[...g,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 g=u.querySelector(f);gt(document.body,ne,r),gt(g||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})},pn=(t,e,n,s)=>{if(!e)return;const{onInsertEvent:o,delayBeforeInsert:i}=t;setTimeout(()=>{o(n,s),pe(n,e,t)},i)},hn=(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}},mn=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,p,h,b)=>{const B=D=>{const{beforeMargin:v,borderBeforeWidth:R,before:N,offset:I,scroll:W,page:X,inner:F,distance:st,axis:H,getRect:P}=w(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}=w(b),W=I(f)[R],X=I(p),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,p);!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(p,b,$)}},S=D=>{const{axis:v}=w(D);s[v]=B(D),o(s)};S(_),S(tt)},(f,p)=>{const[h,b,B,M]=vn(f,p,t);n={top:h,left:b},i(n),e={offsetX:B,offsetY:M}}]},Lt=(t,e,n)=>{const{borderBeforeWidth:s,before:o,getRect:i}=w(t);return i(e)[o]-i(n)[o]-L(n,s)},Sn=(t,e)=>{let{offsetX:n,offsetY:s,target:o}=t,i=Dn(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]},Dn=(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}=w(t),p=ie(n,t);return e[c]-s[o]-L(n,i)-L(n,l)-window[f]-p},vn=(t,e,n)=>{const[s,o]=Sn(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 bn{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 Tn(t,e,n,s,o){const{handlerSelector:i,isDraggable:c,droppableGroup:l,animationDuration:f,delayBeforeRemove:p,draggingClass:h,removingClass:b,onRemoveAtEvent:B,droppableClass:M,onDragStart:S}=n,D=Ct(l).map(a=>`droppable-group-${a}`).join(" ");let v=0,R={scrollX:0,scrollY:0},N={pageX:0,pageY:0},I;const[W,X]=mn(t),[F,st,H,P,k]=dn(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 d=a==null?void 0:a.querySelector(`.${Ot}`),y=d==null?void 0:d.parentElement;return d&&y&&nt(y,It)&&!y.isSameNode(s)?null:d},$=a=>{const d=V(a)??a;d&&c(a)&&($t(d,"onmousedown",O("mousemove","mouseup")),$t(d,"ontouchstart",O("touchmove","touchend")),et(d)),a!=null&&a.isSameNode(d)||$t(a,"onmousedown",x),U(s,It)},et=a=>{const d=a.querySelectorAll("img");Array.from(d).forEach(y=>{y.onmousedown=()=>!1})},ot=()=>{if(N.pageX==0&&N.pageY==0||!r.current)return;const{droppable:a,config:d}=r.current;W(t,a,N,d.direction),F(t,Pt,R,r.current)},lt=(a,d)=>{d&&v==2&&!(a!=null&&a.droppable.isSameNode(d.droppable))&&F(t,Pt,R,d)},r=new bn(t,D,s,ot,lt),u=a=>{if(!r.current)return;const d=D?Array.from(document.querySelectorAll(dt(D))):[s];for(const y of d)y.classList.toggle(M,!a&&y.isSameNode(r.current.droppable))},g=a=>{r.updateConfig(a);const d=r.isOutside(a);u(d),v===1?ut(a):v===2&&(m(d),Dt(a))},m=(a=!0)=>{if(!r.current)return;const{droppable:d}=r.current;fn(d,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 d=Vt(a);g(d)},T=(a,d)=>{a=="touchmove"?I=setTimeout(()=>{d()},200):d()},E=(a,d)=>{const{clientX:y,clientY:ft}=a,rt=document.elementFromPoint(y,ft),vt=rt==null?void 0:rt.closest(`.${Q}`);return rt&&d&&vt&&!d.isSameNode(vt)},A=a=>{const d=n.onGetValue(e);return{index:e,element:a,value:d}},O=(a,d)=>y=>{if(E(y,t))return;it.updateScrolls(s,D);const{scrollX:ft,scrollY:rt}=window;if(R={scrollX:ft,scrollY:rt},v===0){v=1;const vt=A(t);vt&&S(vt),T(a,()=>{a=="touchmove"&&(r.updateConfig(y),u(r.isOutside(y)),ut(y)),document.addEventListener(a,C,{passive:!1})}),ct(s),document.addEventListener(d,G(a),{once:!0})}},x=a=>r.updateConfig(a),G=a=>d=>{u(!0);const y=Vt(d);clearTimeout(I),At(r.isOutside(y,!1)),document.removeEventListener(a,C),r.updateConfig(y);const ft=r.getCurrentConfig(y);if(ft){const{droppable:rt}=ft;Z(rt)}s.onscroll=null},Z=a=>{if(a.onscroll=null,!D)return;const d=Array.from(document.querySelectorAll(dt(D)));for(const y of d)at(y)&&(y.onscroll=null)},ut=a=>{Gt(t,s,v==1,r.current),St(),F(t,ue,R,r.current),wt(t),X(a,t)},St=()=>{v=2},Dt=a=>{const{pageX:d,pageY:y}=a;N={pageX:d,pageY:y},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),Tt(a,0,0)},wt=a=>{const{height:d,width:y}=a.getBoundingClientRect();le(a,{fixedHeight:`${d}px`,fixedWidth:`${y}px`}),k(a,!0),gt(a,h,!0),a.style.transition=""},Bt=a=>{if(!r.initial)return;const d=r.initial;a==e&&(U(t,b),setTimeout(()=>{B(e),yt(t,b),Gt(t,s,v==1,r.initial),st(a,t,d,y=>{xt(y),P(t)})},p))},he=(a,d)=>{(a===e||a===n.onGetLegth()&&e===a-1)&&H(a,t,s,d,()=>{ln(t,v==1,r.initial)})};return j(),$(t),[Bt,he]}const En=(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=Ct(l).map(p=>`droppable-group-${p}`).join(" ");En(f,n);for(const p of n.children){const h=p.getAttribute(o),b=Te(h),B=p;if(B&&b>=0){const[M,S]=Tn(B,b,t,n,e);i.push(M),c.push(S)}}return[i,c]}function Cn(t,e,n,s="index"){let o=[],i=[];const c=hn(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)},p=S=>{const[D,v]=yn(c,e,S,s);o=D,i=v},h=S=>{kt(()=>{p(S)},S,{childList:!0})},b=S=>{U(S,It)},B=S=>{it.addConfig(S,c)};return[l,f,S=>{S&&(b(S),B(S),h(S),p(S),it.removeObsoleteConfigs())}]}exports.GRAB_CLASS=se;exports.addClass=U;exports.dragAndDrop=Cn;exports.insertToListEmpty=pn;exports.toggleClass=gt;
|