fluid-dnd 2.5.1 → 2.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{HandlerPublisher-CRu7xI9p.js → HandlerPublisher-CGKPF_jz.js} +1 -1
- package/dist/{HandlerPublisher-CrUNmzg-.cjs → HandlerPublisher-DBjTX_j6.cjs} +1 -1
- package/dist/core/dragAndDrop.js +4 -3
- package/dist/core/events/dragAndDrop/dragAndDrop.js +8 -1
- package/dist/core/events/insert.js +1 -1
- package/dist/core/index.d.ts +16 -0
- package/dist/core/positioning/usePositioning.js +3 -3
- package/dist/core/utils/GetStyles.d.ts +1 -1
- package/dist/core/utils/GetStyles.js +5 -5
- package/dist/{index-CJpjY7r7.js → index-B_TA81tq.js} +271 -263
- package/dist/index-rI7KLmXk.cjs +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.mjs +1 -1
- package/dist/{insert--mO_a1mv.js → insert-BXGi8i8T.js} +9 -9
- package/dist/insert-Be2OwrVW.cjs +1 -0
- package/dist/react/index.cjs +1 -1
- package/dist/react/index.mjs +3 -3
- package/dist/{remove-C4YcWK2S.js → remove-Dg1WsaSC.js} +1 -1
- package/dist/{remove-dSzXNYxs.cjs → remove-FDZxr31Z.cjs} +1 -1
- package/dist/svelte/index.cjs +1 -1
- package/dist/svelte/index.mjs +3 -3
- package/dist/vue/index.cjs +1 -1
- package/dist/vue/index.mjs +3 -3
- package/package.json +1 -1
- package/dist/index-BOqB07mI.cjs +0 -1
- package/dist/insert-CEcy9QNd.cjs +0 -1
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";var $e=Object.defineProperty;var Ve=(t,e,n)=>e in t?$e(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var X=(t,e,n)=>Ve(t,typeof e!="symbol"?e+"":e,n);const Y="horizontal",q="vertical",W="draggable",Yt="droppable",wt="handler-class",Ft="dragging",Xt="dragging-handler-class",Wt="dropping",ae="grabbing",le="grab",Ye="disable-transition",U=(t,e)=>t.classList.contains(e),it=(t,e,n=!1)=>{t.classList.toggle(e,n)},st=(t,e)=>{t.classList.add(e)},_t=(t,e)=>{t.classList.remove(e)},Xe=(t,e)=>Et(e).every(n=>U(t,n)),lt=t=>`.${Et(t).join(".")}`,We=(t,e)=>{const n=Et(e);t.classList.add(...n)},Et=t=>((t==null?void 0:t.split(" "))??[]).filter(e=>e),_e=()=>{const{scrollX:t,scrollY:e}=window;return{scrollX:t,scrollY:e}},Zt=t=>!t||t.trim().length==0||t=="normal"?0:parseFloat(t),He=t=>t?parseInt(t):-1,qe=t=>{const e=getComputedStyle(t),n=new DOMMatrixReadOnly(e.transform);return{x:n.m41,y:n.m42}},ue=(t,e)=>t.x1>e.x1?ue(e,t):t.x2<e.x1?0:t.x2>=e.x2?t.x2-t.x1:t.x2-e.x1,vt=(t,e)=>!ze(t,e),ze=(t,e)=>{const{intersectionX:n,intersectionY:s,rect1:o,rect2:r}=ge(t,e);return s>=Math.min(o.height,r.height)/2&&n>=Math.min(o.width,r.width)/2},je=(t,e)=>!Ze(t,e),Ze=(t,e)=>{const{intersectionX:n,intersectionY:s}=ge(t,e);return s>=0&&n>=0},ge=(t,e)=>{const n=B(t),s=B(e),o=ee(n,s,q),r=ee(n,s,Y);return{rect1:n,rect2:s,intersectionX:r,intersectionY:o}},ee=(t,e,n)=>{const{before:s,distance:o}=I(n);return ue({x1:t[s],x2:t[s]+t[o]},{x1:e[s],x2:e[s]+e[o]})},Ct=(t,e)=>t?Zt(getComputedStyle(t)[e]):0,ne=t=>{const{scrollLeft:e,scrollTop:n}=t;return{scrollLeft:e,scrollTop:n}},B=t=>t.getBoundingClientRect(),z=(t,e)=>{const{distance:n}=I(t);return[e[n],n]},Nt=(t,e)=>{const{axis:n}=I(t);return e[n]},ut=(t,e)=>{const{borderBeforeWidth:n}=I(t);return Ct(e,n)},Lt=(t,e)=>{const{beforeMargin:n}=I(t);return Ct(e,n)},fe=(t,e)=>{const{beforeMargin:n}=I(t);return Ct(e,n)},Dt=(t,e)=>{const{afterMargin:n}=I(t);return Ct(e,n)},j=(t,e)=>{const{before:n}=I(t);return e[n]},Tt=(t,e)=>{const{scrollElement:n}=I(t);return[e[n],n]},at=(t,e)=>{const{scroll:n}=I(t);return e[n]},ke=(t,e)=>{const{inner:n}=I(t);return e[n]},kt=(t,e)=>{const{page:n}=I(t);return e[n]},pe=(t,e)=>{const{offset:n}=I(t);return e[n]},I=t=>{const e=t==Y;return{beforeMargin:e?"marginLeft":"marginTop",afterMargin:e?"marginRight":"marginBottom",borderBeforeWidth:e?"borderLeftWidth":"borderTopWidth",before:e?"left":"top",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",scrollDistance:e?"scrollWidth":"scrollHeight",clientDistance:e?"clientWidth":"clientHeight",paddingBefore:e?"paddingLeft":"paddingTop",getRect:B}},Ot=(t,e)=>Je(t,e),Ue=t=>[...t.children].filter(n=>U(n,W)),Je=(t,e)=>{const n=[...e.children].filter(o=>U(o,W)&&!o.isEqualNode(t)).toReversed(),s=[...e.children].findLastIndex(o=>o.isEqualNode(t));return[n,s,e]},Ke=t=>{let e=t.parentElement;for(;e;){if(window.getComputedStyle(e).translate!=="none")return e;e=e.parentElement}return null},he=(t,e)=>{const n=Ke(t);return n?j(e,B(n))+ut(e,n):0},P=(t,e)=>t==null?void 0:t.isSameNode(e),Qe=t=>t&&getComputedStyle(t).transform!=="none",de="startDrag",Pt="drag",me="startDrop",rt="temp-child",Ut="cubic-bezier(0.2, 0, 0, 1)",Rt={height:0,width:0},mt=t=>window.TouchEvent&&t instanceof TouchEvent,Q=t=>t instanceof HTMLElement,Se=t=>t instanceof MouseEvent,tn=["onmouseup","onmousedown","onmousemove"],en=(t,e)=>{t.style.height=`${e.height}px`,t.style.width=`${e.width}px`},ot=(t,e=Rt)=>{!t||!Q(t)||(e.width==0&&e.height==0?t.style.transform="":t.style.transform=`translate(${e.width}px,${e.height}px)`)},nn=(t,e,n,s)=>{t[e]=o=>{if(o.defaultPrevented)return;s&&s(o);const r=Ht(o);n(r)}},Vt=(t,e,n,s)=>{n&&(sn(e)?t[e]=n:nn(t,e,n,s))},sn=t=>tn.includes(t),on=t=>{const{target:e}=t;return{clientX:0,clientY:0,pageX:0,pageY:0,screenX:0,screenY:0,target:e,offsetX:0,offsetY:0}},rn=(t,e)=>{const n=(s,o)=>an(e,window,o,s);if(Se(t)){const{offsetX:s,offsetY:o}=t;return[s,o]}else{const s=t.target;return[n(s,Y),n(s,q)]}},Ht=t=>{const e=cn(t);if(!e)return on(t);const[n,s]=rn(t,e),{clientX:o,clientY:r,pageX:i,pageY:a,screenX:f,screenY:g,target:d}=e;return{clientX:o,clientY:r,pageX:i,pageY:a,screenX:f,screenY:g,target:d,offsetX:n,offsetY:s}},cn=t=>{if(mt(t))return t.touches[0]??t.changedTouches[0];if(Se(t))return t},an=(t,e,n,s)=>{const o=B(s);return kt(n,t)-at(n,e)-j(n,o)-ut(n,s)},yt=(t,e,n="ease-out",s="transform")=>{Q(t)&&(t.style.transitionDuration=`${e}ms`,t.style.transitionTimingFunction=`${n}`,t.style.transitionProperty=`${s}`)},ve=(t,e,n)=>{!t||!Q(t)||(t[e]=()=>{n()})},ln=t=>{var e=t.querySelector("style");if(!e){var n=document.createElement("style");return t.appendChild(n),n}return e},un=(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},gn=(t,e)=>{e.forEach(n=>{fn(t,n)})},fn=(t,e)=>{var s;var n=ln(t);n.sheet&&!un(n.sheet,e)&&((s=n.sheet)==null||s.insertRule(e,n.sheet.cssRules.length))},De=(t,e={})=>{for(const n of Object.keys(e)){const s=e[n];s!=null&&pn(t,`--${n}`,s)}},pn=(t,e,n)=>t&&t.style.setProperty(e,n),It=t=>{Q(t)&&(t.style.transition="",t.style.transform="")},hn=(t,e,n)=>{n!=0&&(e==="vertical"?t.scrollBy(0,n):t.scrollBy(n,0))},dn=t=>{let e=.5;const n=.03,s=(i,a,f,g)=>{const[d]=z(i,B(t)),h=B(a),x=j(i,f)-j(i,h)+Nt(i,g),[R]=z(i,h),b=R-d,C=x/b,D=d/b,A=.25,T=.2,M=.8;let F=0;const _=je(t,a);!_&&C<T&&C>-D?F=o(C<0?0:C,T):!_&&C>M&&C<1+D&&(F=r(C,M));const G=A*d*F;e=Math.sign(G)*Math.min(Math.abs(G),Math.abs(e)+n),hn(a,i,e)},o=(i,a)=>Math.pow(i/a,1/3)-1,r=(i,a)=>Math.pow(1/(1-a)*(i-a),3);return[s]},mn=(t,e)=>{let n={offsetX:0,offsetY:0},s={top:0,left:0},o={x:0,y:0};const[r]=dn(t),i=h=>{t.style.transform=`translate( ${h.x}px, ${h.y}px)`},a=h=>{t.style.top=`${h.top}px`,t.style.left=`${h.left}px`},f=(h,x,R,b)=>{const C=T=>{const M=kt(T,R),F=at(T,window),_=ke(T,window),[G]=z(T,B(h)),Z=ut(T,h),J=Lt(T,h),k=M-pe(T,n),tt=he(h,T);if(k>=F-G/2&&k<=F+_){const u=Te(T,x),p=k-j(T,s)-Z-J-F-tt-u;return D(T),p}return Nt(T,o)},D=T=>{h&&U(h,Ft)&&T===b&&r(b,x,s,o)},A=T=>{const{axis:M}=I(T);o[M]=C(T),i(g())};A(Y),A(q)},g=()=>{let h=o;for(const x of e)h=x(h,t);return h};return[f,(h,x)=>{const[R,b]=Tn(h,x,t);s=R,a(s),n=b}]},Mt=(t,e,n)=>j(t,B(e))-j(t,B(n))-ut(t,n),Sn=(t,e)=>{let{offsetX:n,offsetY:s,target:o}=t,r=vn(o,e);const i=o;return i&&r&&!P(i,r)&&(n+=Mt(Y,i,r),s+=Mt(q,i,r)),r&&e!=o&&(n+=Mt(Y,r,e),s+=Mt(q,r,e)),{offsetX:n,offsetY:s}},vn=(t,e)=>{const n=t==null?void 0:t.closest(`.${wt}`);return n&&P(e,n)?t:n},se=(t,e,n,s)=>{const o=he(n,t),r=n.parentElement,i=Te(t,r);return kt(t,e)-pe(t,s)-Lt(t,n)-ut(t,n)-at(t,window)-o-i},Te=(t,e)=>e&&Dn(e)?j(t,B(e)):0,Dn=t=>{let e=t;for(;e;){if(Qe(e))return!0;e=e.parentElement}return!1},Tn=(t,e,n)=>{const s=Sn(t,n);return[{top:se(q,t,e,s),left:se(Y,t,e,s)},s]},H=class H{static addConfig(e,n){const s=H.configs.filter(r=>!P(r.droppable,e)),o=ne(e);s.push({droppable:e,config:n,scroll:o}),H.configs=s}static updateScrolls(e,n){for(const s of H.configs){const{droppable:o}=s;(n&&Xe(o,n)||P(e,o))&&(s.scroll=ne(o))}}static getConfig(e){return H.configs.find(({droppable:s})=>P(e,s))}};X(H,"configs",[]),X(H,"removeObsoleteConfigs",()=>{const e=H.configs.filter(({droppable:n})=>document.contains(n));H.configs=e});let ct=H;const qt=t=>t.length==0?0:Zt(t.replace("px","")),En=(t,e)=>{const n=getComputedStyle(t)[e];if(n.match("%")){const o=Zt(n.replace("%","")),{width:r}=B(t);return r*(o/100)}return qt(n)},Cn=(t,e)=>{if(!(t instanceof Element))return[0,!1];const n=En(t,e),s=getComputedStyle(t).display,o=n>0||s==="flex";return[n,o]},yn=t=>{const{top:e,left:n}=getComputedStyle(t);return[qt(e),qt(n)]},Jt=(t,e)=>{const{gap:n}=I(e);return Cn(t,n)},bn=(t,e)=>{const[n,s]=Jt(t,e);return s?n:0},Kt=(t,e,n,s=()=>!0)=>{const o=new MutationObserver(r=>{if(r=r.filter(s),r.length>0){const i=r[0];t(o,i)}});return o.observe(e,n),o},zt=t=>Q(t)?t.classList.contains(rt):!1;function St(t,e,n,s,o=t.previousElementSibling,r=t.nextElementSibling){let{height:i,width:a}=An(n,t,o,r);return vt(t,s)&&e==Pt&&(i=0,a=0),{height:i,width:a}}const An=(t,e,n,s)=>{const o=Dt(t,e),r=Lt(t,e),i=Lt(t,s),[a,f]=Jt(e.parentElement,t),[g]=z(t,B(e));if(f)return oe(g,r,o,a,0,t);const[d,h,x]=xn(n,i,o,r,t);return oe(g,h,d,0,x,t)},xn=(t,e,n,s,o)=>{const r=Math.max(e,n);let i=s,a=e;if(t){const f=Dt(o,t);i=Math.max(f,s),a=Math.max(a,f)}return[r,i,a]},oe=(t,e,n,s,o,r)=>Mn(r,t+e+n+s-o),Mn=(t,e)=>t==Y?{width:e,height:0}:{width:0,height:e},On="startDrag",Ee="cubic-bezier(0.2, 0, 0, 1)",Ce=50,ye="width, min-width, height",Bn=(t,e,n)=>{let s=St(e,On,n,t);const o=bn(t,n),[,r]=z(n,s);s[r]-=o;const[i,a]=wn(n,e);return s[a]=i,s},wn=(t,e)=>{const n=t==Y?q:Y;return z(n,B(e))},gt=(t,e=Rt)=>{en(t,e),t.style.minWidth=`${e.width}px`},Ln=(t,e,n)=>s=>{e.contains(t)&&(gt(t,n),s.disconnect())},be=(t,e)=>{const{scrollDistance:n,clientDistance:s}=I(e);return t[n]-t[s]},Pn=(t,e,n)=>{const[s]=Tt(t,n);return s/be(e,t)},Rn=(t,e,n,s)=>{if(!s)return;const{direction:o}=e,r=Pn(o,t,n)>.99,[,i]=Tt(o,t);r&&(t[i]=be(t,o))},Ae=(t,e,n,s)=>{const{droppable:o,config:r,scroll:i}=n,{direction:a,animationDuration:f}=r;if(Rn(o,r,i,e),o.querySelector(`.${rt}`)||!t)return;var g=t.tagName=="LI"?"DIV":t.tagName,d=document.createElement(g);st(d,rt),gt(d);const h=Bn(o,t,a);return yt(d,f,Ee,ye),[d,h,o]},jt=(t,e,n,s,o)=>{const r=Ae(t,n,s);if(!r)return;const[i,a,f]=r;P(e,f)&>(i,a),Kt(Ln(i,f,a),f,{childList:!0,subtree:!0}),f.appendChild(i)},In=(t,e,n)=>{const s=Ae(t,e,n);if(!s)return;const[o,r,i]=s;i.appendChild(o),Fn(o,r)},Fn=(t,e)=>requestAnimationFrame(()=>{gt(t,e),requestAnimationFrame(()=>{yt(t,0,Ee,ye)})}),Nn=(t,e,n,s,o=!0)=>{if(n){var r=document.querySelectorAll(`${lt(n)} > .${rt}`);r.forEach(i=>{const a=i.parentElement;if(P(e,a)||!o&&P(t,a))return;gt(i),setTimeout(()=>{var g;(g=i.parentNode)==null||g.removeChild(i)},s+Ce)})}},Bt=(t,e,n=!1)=>{var s=t.querySelectorAll(`.${rt}`);s.forEach(o=>{const r=o;n?(gt(r),setTimeout(()=>{t.contains(r)&&t.removeChild(r)},e+Ce)):t.removeChild(o)})},Gn=(t,e)=>{const{config:n,droppable:s}=t,{onInsertEvent:o,onDragEnd:r}=n;return{...n,onDragEnd:f=>{const{index:g,value:d}=f;r({index:g,value:e(d,s)})},onInsertEvent:(f,g)=>o(f,e(g,s),!0)}};class $n{constructor(e,n,s,o,r,i){X(this,"initial");X(this,"current");X(this,"parent");X(this,"draggableElement");X(this,"groupClass");X(this,"dragEvent");X(this,"changeDroppable");X(this,"mapFrom");this.parent=s,this.draggableElement=e,this.groupClass=n,this.dragEvent=o,this.mapFrom=i,this.initial=ct.getConfig(s),this.changeDroppable=r}getDraggableAncestor(e,n,s){return document.elementsFromPoint(e,n).filter(o=>!P(s,o))}getElementBelow(e,n){return(o=>{const[r]=o.getDraggableAncestor(n.clientX,n.clientY,e);return r})(this)}getCurrent(e,n){const s=this.getElementBelow(e,n);return!this.groupClass||!s?void 0:s.closest(lt(this.groupClass))}isOutsideOfAllDroppables(e){return(this.groupClass?Array.from(document.querySelectorAll(lt(this.groupClass))):[this.parent]).every(s=>vt(e,s))}isNotInsideAnotherDroppable(e,n){return!vt(e,n)||this.isOutsideOfAllDroppables(e)}onScrollEvent(){this.dragEvent()}setOnScroll(e){ve(e,"onscroll",()=>{this.onScrollEvent()})}getConfigFrom(e){const n=ct.getConfig(e);if(n)return P(this.parent,e)?n:{...n,config:Gn(n,this.mapFrom)}}droppableIfInsideCurrent(e,n){return e&&!P(n,e)&&n.contains(e)}getCurrentConfig(e){var o,r;const n=this.draggableElement,s=this.getCurrent(n,e);return this.current&&this.isNotInsideAnotherDroppable(n,(o=this.current)==null?void 0:o.droppable)&&!this.droppableIfInsideCurrent(s,(r=this.current)==null?void 0:r.droppable)?this.current:s?(Q(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){const n=this.draggableElement;return!this.getCurrent(n,e)}}const re=(t,e)=>{const{paddingBefore:n}=I(t),s=ut(t,e),o=Ct(e,n),r=Nt(t,B(e));return s+o+r},Vn=(t,e)=>{const[n,s]=yn(e),o=re(q,t);return[re(Y,t)-s,o-n]};function Yn(t,e,n,s,o,r,i,a,f){let g=0,d=0;const h=!!(n<0&&f);if(n===s&&!h)return ce({height:g,width:d},t,o,i,h);const[x,R,b,C]=_n(e,n,s,f);if(h){const[p,m]=Vn(a,f);g+=m,d+=p}const[D,A]=Jt(a,t),[T,M,F]=qn(x,R==null?void 0:R.previousElementSibling,C,A,h,t),[_,G,Z]=Hn(b,D,A,t),J=Wn(G,_,Z,M,T,D),[k]=Tt(t,a),tt=h?k:Xn(a,r,t),u=(C?J-F:F-J)-tt;return t===q?g+=u:t===Y&&(d+=u),ce({height:g,width:d},t,o,i,h)}const Xn=(t,e,n)=>{const[s]=Tt(n,t),[o]=Tt(n,e);return s-o},Wn=(t,e,n,s,o,r)=>{const i=Math.max(e,o);return Math.max(n,s)+t+i+r},_n=(t,e,n,s)=>{const o=e<n,[r,i]=[e,n].toSorted((d,h)=>d-h),a=t[e]??s,f=t[n];let g=o?t.slice(r+1,i+1):t.slice(r,i);return r<0&&s&&(g=t.slice(r+1,i)),[a,f,g,o]},Hn=(t,e,n,s)=>{if(t.length==0)return[0,0,0];const o=Dt(s,t[0]);let r=0,i=-o;for(const[a,f]of t.entries()){const[g]=z(s,B(f)),d=fe(s,f);n&&(r+=d),n&&a>0?r+=e:r=Math.max(r,d),i+=r+g,r=Dt(s,f)}return[o,i,r]},ce=(t,e,n,s,o)=>{const r=at(e,window),i=at(e,n),a=o?0:i-2*r+at(e,s),[,f]=z(e,t);return t[f]+=a,t},qn=(t,e,n,s,o,r)=>{const i=n?t.previousElementSibling:e;return zn(i,t,s,o,r)},zn=(t,e,n,s,o)=>{if(n)return[0,0,0];const r=Dt(o,s?null:t),i=fe(o,e);let a=Math.max(r,i);return[r,i,a]},xe=(t,e,n)=>{const{handlerSelector:s,animationDuration:o}=t,r=g=>{n(),i(g,!1),It(g),g.style.top="",g.style.left="",De(g,{fixedHeight:"",fixedWidth:""})},i=(g,d)=>{it(g,Ft,d),a(d,g),e.toggleGrabClass(!d)},a=(g,d)=>{const h=d.querySelector(s);it(document.body,ae,g),it(h||d,Xt,g)};return[r,i,(g,d)=>{yt(g,o,Ut),ot(g,d)}]},jn=50;function Zn(t,e,n,s,o,r){let i=e;const{onRemoveAtEvent:a,animationDuration:f,draggingClass:g}=t,[d,h,x]=xe(t,o,r),R=(u,p,m,y)=>{const O=St(u,p,y.direction,m);C(u,p,O,m,y)},b=(u,p,m,y,O)=>{if(!m)return;const{droppable:E,scroll:w,config:L}=m,S=St(u,p,L.direction,E);T(u,p,S,y,E,w,L,O)},C=(u,p,m,y,O)=>{const[E]=Ot(u,y),w=vt(u,y),{direction:L,onDragOver:S}=O;S({element:u,index:e,targetIndex:i,value:t.onGetValue(e),droppable:y}),E.length==0&&A(m,1,L,E);for(const[$,N]of E.entries()){if(!U(N,W))continue;const K=D(L,u,N,m);if(!w&&K)m=K;else if(!w)continue;const ft=E.length-$;A(m,ft,L,E),p===de?ot(N,m):p===Pt&&x(N,m)}},D=(u,p,m,y)=>{const O=B(p),E=B(m),w=j(u,O),L=j(u,E),[S]=z(u,E),$=L+S/2,N=Nt(u,qe(m)),K=$-N;return w>K?Rt:y},A=(u,p,m,y)=>{const O=y.filter(w=>U(w,W)).length,[E]=z(m,u);E==0?i=Math.max(i,p):i=Math.min(i,p-1),i=Math.min(i,O)},T=(u,p,m,y,O,E,w,L)=>{const[S,$]=Ot(u,O),N=S.toReversed(),K=$===-1?N.length:$;N.splice(K,0,u);const[ft,bt,pt]=M(u,$,N,O);m=St(u,p,w.direction,n,ft,bt);const Gt=_e(),At=Yn(w.direction,N,$,pt,Gt,E,y,O,u);S.length==0&&F(void 0,m,u,At);for(const[$t,ht]of S.toReversed().entries()){let xt=m;pt-1>=$t&&(xt=Rt),p===me&&!U(ht,rt)&&F(ht,xt,u,At)}_(pt,u,w,O,L)},M=(u,p,m,y)=>{const E=vt(u,y)?p:i,w=()=>p<E?[E,E+1]:p>E?[E-1,E]:[E-1,E+1],[L,S]=w(),$=m[L]??null,N=m[S]??null;return[$,N,E]},F=(u,p,m,y)=>{ot(u,p),ot(m,y)},_=(u,p,m,y,O)=>{const{onInsertEvent:E,onDragEnd:w}=m;st(p,Wt),J(p,n,y,()=>{if(_t(p,Wt),O!=null){const L=a(O,!0);L!=null&&(E(u,L,!0),w({value:L,index:u})),Z(p),G()}})},G=()=>{if(s){var u=document.querySelectorAll(`${lt(s)} > .${W}`);for(const p of u)It(p)}},Z=u=>{setTimeout(()=>{_t(u,g)},jn)},J=(u,p,m,y)=>{setTimeout(()=>{y&&y(),k(p,m),tt(m),d(u),et(u,p),et(u,m)},f)},k=(u,p)=>{P(u,p)?Bt(u,f):(Bt(u,f,!0),Bt(p,f))},tt=u=>{if(!P(n,u)){var[p]=n.querySelectorAll(`.${rt}`);p&&Q(p)&&(p.style.height="0px",p.style.width="0px")}},et=(u,p)=>{const[m]=Ot(u,p);for(const y of[...m,u])It(y)};return[R,b,h]}const ie="onmousedown";function kn(t,e,n,s,o){const{handlerSelector:r,isDraggable:i,droppableGroup:a,animationDuration:f,draggingClass:g,droppableClass:d,onDragStart:h,delayBeforeTouchMoveEvent:x,coordinateTransform:R}=n,b=Et(a).map(c=>`droppable-group-${c}`).join(" ");let C=0,D={scrollX:0,scrollY:0},A={pageX:0,pageY:0},T,M;const[F,_]=mn(t,R),G=()=>{C=0},[Z,J,k]=Zn(n,e,s,b,o,G),tt=()=>{st(t,W)},et=c=>{st(c,wt),o.addSubscriber(c)},u=()=>{if(i(t)){const c=t.querySelector(r);et(c||t)}},p=()=>{u(),tt()},m=c=>{const l=c==null?void 0:c.querySelector(`.${wt}`),v=l==null?void 0:l.parentElement;return l&&v&&U(v,Yt)&&!P(s,v)?null:l},y=c=>{const l=m(c)??c;l&&i(c)&&(Vt(l,ie,ht("mousemove","mouseup")),Vt(l,"ontouchstart",ht("touchmove","touchend"),v=>{const V=v.touches[0];M={x:V.clientX,y:V.clientY}}),O(l)),P(c,l)||Vt(c,ie,xt),st(s,Yt)},O=c=>{const l=c.querySelectorAll("img");Array.from(l).forEach(v=>{v.onmousedown=()=>!1})},E=()=>{if(A.pageX==0&&A.pageY==0||!S.current)return;const{droppable:c,config:l}=S.current;F(t,c,A,l.direction),Z(t,Pt,c,l)},w=c=>{const l=c.querySelectorAll(`.${W}`);for(const v of l)ot(v)},L=(c,l)=>{l&&C==2&&!P(c==null?void 0:c.droppable,l.droppable)&&(Z(t,Pt,l.droppable,l.config),w(l.droppable))},S=new $n(t,b,s,E,L,n.mapFrom),$=c=>{if(!S.current)return;const l=b?Array.from(document.querySelectorAll(lt(b))):[s];for(const v of l)v.classList.toggle(d,!c&&P(v,S.current.droppable))},N=(c,l=!1)=>{S.updateConfig(c);const v=S.isOutside(c);$(v),C===1&&!l?te(c):C===2&&(K(v),we(c))},K=(c=!0)=>{if(!S.current)return;const{droppable:l}=S.current;Nn(l,s,b,f,c),!c&&jt(t,s,C==1,S.current)},ft=c=>{if(mt(c)&&M&&C==1){const l=c.touches[0],v=Math.abs(l.clientX-M.x),V=Math.abs(l.clientY-M.y);if(Math.abs(v)>5&&Math.abs(V)>5)return clearTimeout(T),!1}return!0},bt=c=>{clearTimeout(T);const l=Ht(c);if(mt(c)&&c.cancelable&&C==2&&c.preventDefault(),mt(c)&&!c.cancelable||!ft(c)){Qt("touchmove",c);return}N(l,mt(c))},pt=(c,l)=>{c=="touchmove"?T=setTimeout(()=>{l()},x):l()},Gt=(c,l)=>{const{clientX:v,clientY:V}=c,nt=document.elementFromPoint(v,V),dt=nt==null?void 0:nt.closest(`.${W}`);return dt&&P(l,dt)},At=c=>{const l=n.onGetValue(e);return{index:e,element:c,value:l}},$t=c=>{S.updateConfig(c),$(S.isOutside(c)),te(c)},ht=(c,l)=>v=>{if(!Gt(v,t))return;ct.updateScrolls(s,b);const{scrollX:V,scrollY:nt}=window;if(D={scrollX:V,scrollY:nt},C===0){C=1;const dt=At(t);dt&&h(dt),pt(c,()=>{c=="touchmove"&&$t(v)}),document.addEventListener(c,bt,{passive:!1}),Le(s),document.addEventListener(l,Me(c),{once:!0})}},xt=c=>S.updateConfig(c),Me=c=>l=>{Qt(c,l)},Qt=(c,l)=>{$(!0);const v=Ht(l);Re(S.isOutside(v)),clearTimeout(T),document.removeEventListener(c,bt),S.updateConfig(v);const V=S.getCurrentConfig(v);if(V){const{droppable:nt}=V;Oe(nt)}s.onscroll=null,G()},Oe=c=>{if(c.onscroll=null,!b)return;const l=Array.from(document.querySelectorAll(lt(b)));for(const v of l)Q(v)&&(v.onscroll=null)},te=c=>{S.current&&jt(t,s,C==1,S.current),Be(),S.current&&Z(t,de,S.current.droppable,S.current.config),Fe(t),_(c,t)},Be=()=>{C=2},we=c=>{const{pageX:l,pageY:v}=c;A={pageX:l,pageY:v},E()},Le=c=>ve(c,"onscroll",Pe),Pe=()=>E(),Re=c=>{if(C!==2&&C!==1){G();return}C=3,Ie(t),t.classList.contains(Ft)&&J(t,me,c?S.initial:S.current,D,e)},Ie=c=>{yt(c,f,Ut),ot(c)},Fe=c=>{const{height:l,width:v}=B(c);De(c,{fixedHeight:`${l}px`,fixedWidth:`${v}px`}),k(c,!0),it(c,g,!0),c.style.transition=""},Ne=c=>{Promise.resolve().then(()=>require("./remove-FDZxr31Z.cjs")).then(l=>{const[v]=l.default(n,s,o,G);S.initial&&v(e,c,t,S.initial)})},Ge=(c,l)=>{(c===e||c===n.onGetLegth()&&e===c-1)&&Promise.resolve().then(()=>require("./insert-Be2OwrVW.cjs")).then(v=>{const[V]=v.default(n,s,o,G);S.initial&&V(c,t,s,l,S.initial)})};return p(),y(t),[Ne,Ge]}const Un=(t,e)=>{t&&We(e,t)},Jn=()=>{gn(document.body,[`.${W}{touch-action:manipulation;user-select:none;box-sizing:border-box!important;-webkit-user-select:none;}`,`.${wt}{pointer-events:auto!important;}`,`.${le}{cursor:grab;}`,".temp-child{touch-action:none;pointer-events:none;box-sizing:border-box!important;}",".droppable{box-sizing:border-box!important;}",`.${Ft}{position:fixed;z-index:5000;width:var(--fixedWidth)!important;height:var(--fixedHeight)!important;}`,`.${Xt}{pointer-events:none!important;}`,`.${Wt}{pointer-events:none!important;}`,`.${ae}{cursor:grabbing;}`,".disable-transition{transition:none!important;}"])};function Kn(t,e,n,s="index"){const o=s;let r=[],i=[];const{droppableGroup:a}=t;if(!n)return[r,i];const f=Et(a).map(g=>`droppable-group-${g}`).join(" ");Jn(),Un(f,n);for(const g of n.children){const d=g.getAttribute(o),h=He(d),x=g;if(x&&h>=0){const[R,b]=kn(x,h,t,n,e);r.push(R),i.push(b)}}return[r,i]}const Qn=(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),i=a=>a;return{direction:(e==null?void 0:e.direction)??q,handlerSelector:(e==null?void 0:e.handlerSelector)??W,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)??(()=>{}),onDragOver:(e==null?void 0:e.onDragOver)??(()=>{}),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)??i,delayBeforeTouchMoveEvent:(e==null?void 0:e.delayBeforeTouchMoveEvent)??150,coordinateTransform:(e==null?void 0:e.coordinateTransform)??[a=>a]}};function ts(t,e,n,s="index"){let o=[],r=[],i;const a=Qn(t,n),f=D=>{for(const A of o)A(D)},g=(D,A)=>{if(a.onGetLegth()===0)t.insertToListEmpty(a,D,A);else for(const M of r)M(D,A)},d=D=>{const[A,T]=Kn(a,e,D,s);o=A,r=T},h=D=>{const A=Array.from(D.addedNodes??[]).values().filter(M=>!zt(M)).toArray(),T=Array.from(D.removedNodes??[]).values().filter(M=>!zt(M)).toArray();return A.length>0||T.length>0},x=D=>{i=Kt(()=>{d(D)},D,{childList:!0},h)},R=D=>{st(D,Yt)},b=D=>{ct.addConfig(D,a)};return[f,g,D=>{if(D)return R(D),b(D),x(D),d(D),ct.removeObsoleteConfigs(),i}]}exports.DISABLE_TRANSITION=Ye;exports.DRAGGABLE_CLASS=W;exports.GRAB_CLASS=le;exports.addClass=st;exports.addTempChild=jt;exports.addTempChildOnInsert=In;exports.containClass=U;exports.dragAndDrop=ts;exports.draggableTargetTimingFunction=Ut;exports.getParentDraggableChildren=Ue;exports.getSiblings=Ot;exports.getTranslationByDraggingAndEvent=St;exports.isTempElement=zt;exports.moveTranslate=ot;exports.observeMutation=Kt;exports.removeClass=_t;exports.removeTempChild=Bt;exports.removeTranslateWhitoutTransition=It;exports.setTranistion=yt;exports.toggleClass=it;exports.useChangeDraggableStyles=xe;
|
package/dist/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-rI7KLmXk.cjs");exports.dragAndDrop=e.dragAndDrop;
|
package/dist/index.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { DragEndEventData, DragStartEventData, Direction, CoordinateMap, Coordinate } from './core';
|
1
|
+
import { DragOverEventData, DragEndEventData, DragStartEventData, Direction, CoordinateMap, Coordinate } from './core';
|
2
2
|
import dragAndDrop from './core/dragAndDrop';
|
3
|
-
export type { DragStartEventData, DragEndEventData, Direction, CoordinateMap, Coordinate };
|
3
|
+
export type { DragOverEventData, DragStartEventData, DragEndEventData, Direction, CoordinateMap, Coordinate };
|
4
4
|
export { dragAndDrop };
|
package/dist/index.mjs
CHANGED
@@ -1,20 +1,20 @@
|
|
1
|
-
import { u as B, c as C, h as g, i as L, D as N, j as F, e as O, g as _, f as G, o as M, a as u, k as v, r as T, l as R } from "./index-
|
1
|
+
import { u as B, c as C, h as g, i as L, D as N, j as F, e as O, g as _, f as G, o as M, a as u, k as v, r as T, l as R } from "./index-B_TA81tq.js";
|
2
2
|
function w(s, n, t, e) {
|
3
|
-
const { delayBeforeInsert: r } = s, [l,
|
3
|
+
const { delayBeforeInsert: r } = s, [l, E, i] = B(
|
4
4
|
s,
|
5
5
|
t,
|
6
6
|
e
|
7
7
|
), h = (o, a, c, m, S) => {
|
8
|
-
const
|
8
|
+
const y = C(
|
9
9
|
a,
|
10
10
|
"insert",
|
11
11
|
s.direction,
|
12
12
|
c
|
13
|
-
), { onInsertEvent:
|
14
|
-
for (const [
|
15
|
-
L(d, N) &&
|
13
|
+
), { onInsertEvent: A } = s, D = g(c);
|
14
|
+
for (const [I, d] of D.entries())
|
15
|
+
L(d, N) && I >= o && i(d, y);
|
16
16
|
F(a, !1, S), setTimeout(() => {
|
17
|
-
|
17
|
+
A(o, m), f(o, c, s), l(a), b(a, n), O(n, 0, !0);
|
18
18
|
}, r);
|
19
19
|
}, b = (o, a) => {
|
20
20
|
const [c] = _(o, a);
|
@@ -23,7 +23,7 @@ function w(s, n, t, e) {
|
|
23
23
|
};
|
24
24
|
return [h];
|
25
25
|
}
|
26
|
-
const j = (s) => s.addedNodes.values().filter((t) => !R(t)).toArray().length > 0,
|
26
|
+
const j = (s) => Array.from(s.addedNodes ?? []).values().filter((t) => !R(t)).toArray().length > 0, f = (s, n, t) => {
|
27
27
|
const { insertingFromClass: e, animationDuration: r } = t, l = M(
|
28
28
|
() => {
|
29
29
|
const i = g(n)[s];
|
@@ -42,7 +42,7 @@ const j = (s) => s.addedNodes.values().filter((t) => !R(t)).toArray().length > 0
|
|
42
42
|
return;
|
43
43
|
const { onInsertEvent: r, delayBeforeInsert: l } = s;
|
44
44
|
setTimeout(() => {
|
45
|
-
r(t, e),
|
45
|
+
r(t, e), f(t, n, s);
|
46
46
|
}, l);
|
47
47
|
};
|
48
48
|
export {
|
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-rI7KLmXk.cjs");function h(s,t,n,i){const{delayBeforeInsert:a}=s,[c,g,o]=e.useChangeDraggableStyles(s,n,i),v=(r,l,d,m,S)=>{const b=e.getTranslationByDraggingAndEvent(l,"insert",s.direction,d),{onInsertEvent:y}=s,I=e.getParentDraggableChildren(d);for(const[f,u]of I.entries())e.containClass(u,e.DRAGGABLE_CLASS)&&f>=r&&o(u,b);e.addTempChildOnInsert(l,!1,S),setTimeout(()=>{y(r,m),T(r,d,s),c(l),E(l,t),e.removeTempChild(t,0,!0)},a)},E=(r,l)=>{const[d]=e.getSiblings(r,l);for(const m of[...d,r])e.removeTranslateWhitoutTransition(m)};return[v]}const A=s=>Array.from(s.addedNodes??[]).values().filter(n=>!e.isTempElement(n)).toArray().length>0,T=(s,t,n)=>{const{insertingFromClass:i,animationDuration:a}=n,c=e.observeMutation(()=>{const o=e.getParentDraggableChildren(t)[s];e.addClass(o,i),e.addClass(o,e.DISABLE_TRANSITION),setTimeout(()=>{e.removeClass(o,e.DISABLE_TRANSITION),e.removeClass(o,i),c.disconnect()},a)},t,{childList:!0},A)},D=(s,t,n,i)=>{if(!t)return;const{onInsertEvent:a,delayBeforeInsert:c}=s;setTimeout(()=>{a(n,i),T(n,t,s)},c)};exports.default=h;exports.insertToListEmpty=D;
|
package/dist/react/index.cjs
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react"),b=require("../HandlerPublisher-
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react"),b=require("../HandlerPublisher-DBjTX_j6.cjs"),v=require("../index-rI7KLmXk.cjs"),S=require("react-dom");function y(f,i){const[e,r]=u.useState(f),a=u.useRef(e);u.useEffect(()=>{a.current=e},[e]);function d(t,s=!1){const c=a.current[t],n=()=>{r(o=>[...o.slice(0,t),...o.slice(t+1)])};return s?S.flushSync(n):n(),c}function g(t,s,c=!1){const n=()=>{r(o=>[...o.slice(0,t),s,...o.slice(t)])};c?S.flushSync(n):n()}function h(){return e.length}function m(t){return e[t]}function l(t,s,c){Promise.resolve().then(()=>require("../insert-Be2OwrVW.cjs")).then(({insertToListEmpty:n})=>{n(t,i.current,s,c)})}return[e,r,{removeAtEvent:d,insertEvent:g,getLength:h,getValue:m,insertToListEmpty:l}]}const A=new b.HandlerPublisher;function D(f,i){const e=u.useRef(null),[r,a,d]=y(f,e),[g,h,m]=v.dragAndDrop(d,A,i,"data-index");return u.useEffect(()=>{const l=m(e.current);return()=>{l&&l.disconnect()}},[r.length,i]),[e,r,a,h,g]}exports.useDragAndDrop=D;
|
package/dist/react/index.mjs
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import { useState as b, useRef as d, useEffect as S } from "react";
|
2
|
-
import { H as A } from "../HandlerPublisher-
|
3
|
-
import { n as C } from "../index-
|
2
|
+
import { H as A } from "../HandlerPublisher-CGKPF_jz.js";
|
3
|
+
import { n as C } from "../index-B_TA81tq.js";
|
4
4
|
import { flushSync as p } from "react-dom";
|
5
5
|
function E(l, i) {
|
6
6
|
const [t, r] = b(l), u = d(t);
|
@@ -26,7 +26,7 @@ function E(l, i) {
|
|
26
26
|
return t[e];
|
27
27
|
}
|
28
28
|
function a(e, s, o) {
|
29
|
-
import("../insert
|
29
|
+
import("../insert-BXGi8i8T.js").then(({ insertToListEmpty: n }) => {
|
30
30
|
n(e, i.current, s, o);
|
31
31
|
});
|
32
32
|
}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { u as B, a as C, r as d, b as W, g as l, c as j, m as T, s as k, d as p, e as q, f as w } from "./index-
|
1
|
+
import { u as B, a as C, r as d, b as W, g as l, c as j, m as T, s as k, d as p, e as q, f as w } from "./index-B_TA81tq.js";
|
2
2
|
function z(r, m, u, g) {
|
3
3
|
const { animationDuration: v } = r, [f] = B(
|
4
4
|
r,
|
@@ -1 +1 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./index-
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./index-rI7KLmXk.cjs");function d(a,l,T,u){const{animationDuration:m}=a,[g]=o.useChangeDraggableStyles(a,T,u),S=(s,t,e,i)=>{if(!e||!e.droppable||!e.config)return;const{droppable:n,config:r}=e;let[v]=o.getSiblings(t,n);v=[t,...v].toReversed();const D=o.getTranslationByDraggingAndEvent(t,"remove",r.direction,n);for(const[A,c]of v.entries())A>=s&&(o.moveTranslate(c,D),setTimeout(()=>{i(c)},m))},b=s=>{o.removeTempChild(l,m,!0),setTimeout(()=>{g(s),f(s,l)},m)},f=(s,t)=>{const[e]=o.getSiblings(s,t);for(const i of[...e,s])o.removeTranslateWhitoutTransition(i)},y=(s,t,e,i)=>{const{removingClass:n,delayBeforeRemove:r}=a;t==s&&(o.addClass(e,n),setTimeout(()=>{R(s,t,e,i)},r))},R=(s,t,e,i)=>{const{removingClass:n,onRemoveAtEvent:r}=a;o.removeClass(e,n),o.addTempChild(e,l,!1,i),S(t,e,i,v=>{h(v),b(e)}),r(s,!0)},h=s=>{o.setTranistion(s,m,o.draggableTargetTimingFunction),o.moveTranslate(s)};return[y]}exports.default=d;
|
package/dist/svelte/index.cjs
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";var a=Object.defineProperty;var u=(n,e,t)=>e in n?a(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var i=(n,e,t)=>u(n,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("../HandlerPublisher-
|
1
|
+
"use strict";var a=Object.defineProperty;var u=(n,e,t)=>e in n?a(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var i=(n,e,t)=>u(n,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("../HandlerPublisher-DBjTX_j6.cjs"),c=require("../index-rI7KLmXk.cjs");class h{constructor(e){i(this,"items");i(this,"parent");this.items=e}setParent(e){this.parent=e}removeAtEvent(e){const t=this.items;if(t.length<=0)return;const[r]=t.splice(e,1);return r}insertEvent(e,t){this.items.splice(e,0,t)}getLength(){return this.items.length}getValue(e){return this.items[e]}insertToListEmpty(e,t,r){Promise.resolve().then(()=>require("../insert-Be2OwrVW.cjs")).then(({insertToListEmpty:s})=>{s(e,this.parent,t,r)})}}const g=new d.HandlerPublisher;function m(n,e){const t=new h(n),[r,s,l]=c.dragAndDrop(t,g,e,"data-index");return[o=>(t.setParent(o),l(o),{destroy(){}}),s,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 i = (n, t, e) => d(n, typeof t != "symbol" ? t + "" : t, e);
|
4
|
-
import { H as c } from "../HandlerPublisher-
|
5
|
-
import { n as h } from "../index-
|
4
|
+
import { H as c } from "../HandlerPublisher-CGKPF_jz.js";
|
5
|
+
import { n as h } from "../index-B_TA81tq.js";
|
6
6
|
class m {
|
7
7
|
constructor(t) {
|
8
8
|
i(this, "items");
|
@@ -29,7 +29,7 @@ class m {
|
|
29
29
|
return this.items[t];
|
30
30
|
}
|
31
31
|
insertToListEmpty(t, e, r) {
|
32
|
-
import("../insert
|
32
|
+
import("../insert-BXGi8i8T.js").then(({ insertToListEmpty: s }) => {
|
33
33
|
s(t, this.parent, e, r);
|
34
34
|
});
|
35
35
|
}
|
package/dist/vue/index.cjs
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";var a=Object.defineProperty;var c=(n,e,t)=>e in n?a(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var i=(n,e,t)=>c(n,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("vue"),h=require("../HandlerPublisher-
|
1
|
+
"use strict";var a=Object.defineProperty;var c=(n,e,t)=>e in n?a(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var i=(n,e,t)=>c(n,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("vue"),h=require("../HandlerPublisher-DBjTX_j6.cjs"),v=require("../index-rI7KLmXk.cjs"),g=(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){i(this,"items");i(this,"parent");this.items=e,this.parent=t}removeAtEvent(e){return g(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){Promise.resolve().then(()=>require("../insert-Be2OwrVW.cjs")).then(({insertToListEmpty:s})=>{s(e,this.parent.value,t,r)})}}const A=new h.HandlerPublisher;function L(n,e){const t=u.ref();var r=new V(n,t);const[s,l,o]=v.dragAndDrop(r,A,e);return u.watch(t,()=>{o(t.value)}),[t,l,s]}exports.useDragAndDrop=L;
|
package/dist/vue/index.mjs
CHANGED
@@ -2,8 +2,8 @@ var a = Object.defineProperty;
|
|
2
2
|
var u = (n, t, e) => t in n ? a(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
|
3
3
|
var i = (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 { n as p } from "../index-
|
5
|
+
import { H as h } from "../HandlerPublisher-CGKPF_jz.js";
|
6
|
+
import { n as p } from "../index-B_TA81tq.js";
|
7
7
|
const v = (n, t) => {
|
8
8
|
const e = n.value;
|
9
9
|
if (e.length <= 0)
|
@@ -32,7 +32,7 @@ class f {
|
|
32
32
|
return V(this.items, t);
|
33
33
|
}
|
34
34
|
insertToListEmpty(t, e, r) {
|
35
|
-
import("../insert
|
35
|
+
import("../insert-BXGi8i8T.js").then(({ insertToListEmpty: s }) => {
|
36
36
|
s(t, this.parent.value, e, r);
|
37
37
|
});
|
38
38
|
}
|
package/package.json
CHANGED
package/dist/index-BOqB07mI.cjs
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
"use strict";var $e=Object.defineProperty;var Ve=(t,e,n)=>e in t?$e(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var X=(t,e,n)=>Ve(t,typeof e!="symbol"?e+"":e,n);const Y="horizontal",q="vertical",_="draggable",Yt="droppable",Bt="handler-class",Ft="dragging",Xt="dragging-handler-class",_t="dropping",ae="grabbing",le="grab",Ye="disable-transition",U=(t,e)=>t.classList.contains(e),it=(t,e,n=!1)=>{t.classList.toggle(e,n)},st=(t,e)=>{t.classList.add(e)},Wt=(t,e)=>{t.classList.remove(e)},Xe=(t,e)=>vt(e).every(n=>U(t,n)),lt=t=>`.${vt(t).join(".")}`,_e=(t,e)=>{const n=vt(e);t.classList.add(...n)},vt=t=>((t==null?void 0:t.split(" "))??[]).filter(e=>e),We=()=>{const{scrollX:t,scrollY:e}=window;return{scrollX:t,scrollY:e}},Zt=t=>!t||t.trim().length==0||t=="normal"?0:parseFloat(t),He=t=>t?parseInt(t):-1,qe=t=>{const e=getComputedStyle(t),n=new DOMMatrixReadOnly(e.transform);return{x:n.m41,y:n.m42}},ue=(t,e)=>t.x1>e.x1?ue(e,t):t.x2<e.x1?0:t.x2>=e.x2?t.x2-t.x1:t.x2-e.x1,St=(t,e)=>!ze(t,e),ze=(t,e)=>{const{intersectionX:n,intersectionY:s,rect1:o,rect2:r}=ge(t,e);return s>=Math.min(o.height,r.height)/2&&n>=Math.min(o.width,r.width)/2},je=(t,e)=>!Ze(t,e),Ze=(t,e)=>{const{intersectionX:n,intersectionY:s}=ge(t,e);return s>=0&&n>=0},ge=(t,e)=>{const n=B(t),s=B(e),o=ee(n,s,q),r=ee(n,s,Y);return{rect1:n,rect2:s,intersectionX:r,intersectionY:o}},ee=(t,e,n)=>{const{before:s,distance:o}=I(n);return ue({x1:t[s],x2:t[s]+t[o]},{x1:e[s],x2:e[s]+e[o]})},Et=(t,e)=>t?Zt(getComputedStyle(t)[e]):0,ne=t=>{const{scrollLeft:e,scrollTop:n}=t;return{scrollLeft:e,scrollTop:n}},B=t=>t.getBoundingClientRect(),z=(t,e)=>{const{distance:n}=I(t);return[e[n],n]},It=(t,e)=>{const{axis:n}=I(t);return e[n]},ut=(t,e)=>{const{borderBeforeWidth:n}=I(t);return Et(e,n)},wt=(t,e)=>{const{beforeMargin:n}=I(t);return Et(e,n)},fe=(t,e)=>{const{beforeMargin:n}=I(t);return Et(e,n)},Dt=(t,e)=>{const{afterMargin:n}=I(t);return Et(e,n)},j=(t,e)=>{const{before:n}=I(t);return e[n]},Tt=(t,e)=>{const{scrollElement:n}=I(t);return[e[n],n]},at=(t,e)=>{const{scroll:n}=I(t);return e[n]},ke=(t,e)=>{const{inner:n}=I(t);return e[n]},kt=(t,e)=>{const{page:n}=I(t);return e[n]},pe=(t,e)=>{const{offset:n}=I(t);return e[n]},I=t=>{const e=t==Y;return{beforeMargin:e?"marginLeft":"marginTop",afterMargin:e?"marginRight":"marginBottom",borderBeforeWidth:e?"borderLeftWidth":"borderTopWidth",before:e?"left":"top",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",scrollDistance:e?"scrollWidth":"scrollHeight",clientDistance:e?"clientWidth":"clientHeight",paddingBefore:e?"paddingLeft":"paddingTop",getRect:B}},Mt=(t,e)=>Je(t,e),Ue=t=>[...t.children].filter(n=>U(n,_)),Je=(t,e)=>{const n=[...e.children].filter(o=>U(o,_)&&!o.isEqualNode(t)).toReversed(),s=[...e.children].findLastIndex(o=>o.isEqualNode(t));return[n,s,e]},Ke=t=>{let e=t.parentElement;for(;e;){if(window.getComputedStyle(e).position==="fixed")return e;e=e.parentElement}return null},de=(t,e)=>{const n=Ke(t);return n?j(e,B(n))+ut(e,n):0},P=(t,e)=>t==null?void 0:t.isSameNode(e),Qe=t=>t&&getComputedStyle(t).transform!=="none",he="startDrag",Lt="drag",me="startDrop",rt="temp-child",Ut="cubic-bezier(0.2, 0, 0, 1)",Pt={height:0,width:0},ht=t=>window.TouchEvent&&t instanceof TouchEvent,K=t=>t instanceof HTMLElement,Se=t=>t instanceof MouseEvent,tn=["onmouseup","onmousedown","onmousemove"],en=(t,e)=>{t.style.height=`${e.height}px`,t.style.width=`${e.width}px`},ot=(t,e=Pt)=>{!t||!K(t)||(e.width==0&&e.height==0?t.style.transform="":t.style.transform=`translate(${e.width}px,${e.height}px)`)},nn=(t,e,n,s)=>{t[e]=o=>{if(o.defaultPrevented)return;s&&s(o);const r=Ht(o);n(r)}},Vt=(t,e,n,s)=>{n&&(sn(e)?t[e]=n:nn(t,e,n,s))},sn=t=>tn.includes(t),on=t=>{const{target:e}=t;return{clientX:0,clientY:0,pageX:0,pageY:0,screenX:0,screenY:0,target:e,offsetX:0,offsetY:0}},rn=(t,e)=>{const n=(s,o)=>an(e,window,o,s);if(Se(t)){const{offsetX:s,offsetY:o}=t;return[s,o]}else{const s=t.target;return[n(s,Y),n(s,q)]}},Ht=t=>{const e=cn(t);if(!e)return on(t);const[n,s]=rn(t,e),{clientX:o,clientY:r,pageX:i,pageY:a,screenX:f,screenY:u,target:h}=e;return{clientX:o,clientY:r,pageX:i,pageY:a,screenX:f,screenY:u,target:h,offsetX:n,offsetY:s}},cn=t=>{if(ht(t))return t.touches[0]??t.changedTouches[0];if(Se(t))return t},an=(t,e,n,s)=>{const o=B(s);return kt(n,t)-at(n,e)-j(n,o)-ut(n,s)},Ct=(t,e,n="ease-out",s="transform")=>{K(t)&&(t.style.transitionDuration=`${e}ms`,t.style.transitionTimingFunction=`${n}`,t.style.transitionProperty=`${s}`)},De=(t,e,n)=>{!t||!K(t)||(t[e]=()=>{n()})},ln=t=>{var e=t.querySelector("style");if(!e){var n=document.createElement("style");return t.appendChild(n),n}return e},un=(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},gn=(t,e)=>{e.forEach(n=>{fn(t,n)})},fn=(t,e)=>{var s;var n=ln(t);n.sheet&&!un(n.sheet,e)&&((s=n.sheet)==null||s.insertRule(e,n.sheet.cssRules.length))},Te=(t,e={})=>{for(const n of Object.keys(e)){const s=e[n];s!=null&&pn(t,`--${n}`,s)}},pn=(t,e,n)=>t&&t.style.setProperty(e,n),Rt=t=>{K(t)&&(t.style.transition="",t.style.transform="")},dn=(t,e,n)=>{n!=0&&(e==="vertical"?t.scrollBy(0,n):t.scrollBy(n,0))},hn=t=>{let e=.5;const n=.03,s=(i,a,f,u)=>{const[h]=z(i,B(t)),d=B(a),x=j(i,f)-j(i,d)+It(i,u),[R]=z(i,d),b=R-h,C=x/b,T=h/b,A=.25,v=.2,M=.8;let N=0;const W=je(t,a);!W&&C<v&&C>-T?N=o(C<0?0:C,v):!W&&C>M&&C<1+T&&(N=r(C,M));const G=A*h*N;e=Math.sign(G)*Math.min(Math.abs(G),Math.abs(e)+n),dn(a,i,e)},o=(i,a)=>Math.pow(i/a,1/3)-1,r=(i,a)=>Math.pow(1/(1-a)*(i-a),3);return[s]},mn=(t,e)=>{let n={offsetX:0,offsetY:0},s={top:0,left:0},o={x:0,y:0};const[r]=hn(t),i=d=>{t.style.transform=`translate( ${d.x}px, ${d.y}px)`},a=d=>{t.style.top=`${d.top}px`,t.style.left=`${d.left}px`},f=(d,x,R,b)=>{const C=v=>{const M=kt(v,R),N=at(v,window),W=ke(v,window),[G]=z(v,B(d)),Z=ut(v,d),J=wt(v,d),k=M-pe(v,n),Q=de(d,v);if(k>=N-G/2&&k<=N+W){const g=ve(v,x),p=k-j(v,s)-Z-J-N-Q-g;return T(v),p}return It(v,o)},T=v=>{d&&U(d,Ft)&&v===b&&r(b,x,s,o)},A=v=>{const{axis:M}=I(v);o[M]=C(v),i(u())};A(Y),A(q)},u=()=>{let d=o;for(const x of e)d=x(d,t);return d};return[f,(d,x)=>{const[R,b]=vn(d,x,t);s=R,a(s),n=b}]},xt=(t,e,n)=>j(t,B(e))-j(t,B(n))-ut(t,n),Sn=(t,e)=>{let{offsetX:n,offsetY:s,target:o}=t,r=Dn(o,e);const i=o;return i&&r&&!P(i,r)&&(n+=xt(Y,i,r),s+=xt(q,i,r)),r&&e!=o&&(n+=xt(Y,r,e),s+=xt(q,r,e)),{offsetX:n,offsetY:s}},Dn=(t,e)=>{const n=t==null?void 0:t.closest(`.${Bt}`);return n&&P(e,n)?t:n},se=(t,e,n,s)=>{const o=de(n,t),r=n.parentElement,i=ve(t,r);return kt(t,e)-pe(t,s)-wt(t,n)-ut(t,n)-at(t,window)-o-i},ve=(t,e)=>e&&Tn(e)?j(t,B(e)):0,Tn=t=>{let e=t;for(;e;){if(Qe(e))return!0;e=e.parentElement}return!1},vn=(t,e,n)=>{const s=Sn(t,n);return[{top:se(q,t,e,s),left:se(Y,t,e,s)},s]},H=class H{static addConfig(e,n){const s=H.configs.filter(r=>!P(r.droppable,e)),o=ne(e);s.push({droppable:e,config:n,scroll:o}),H.configs=s}static updateScrolls(e,n){for(const s of H.configs){const{droppable:o}=s;(n&&Xe(o,n)||P(e,o))&&(s.scroll=ne(o))}}static getConfig(e){return H.configs.find(({droppable:s})=>P(e,s))}};X(H,"configs",[]),X(H,"removeObsoleteConfigs",()=>{const e=H.configs.filter(({droppable:n})=>document.contains(n));H.configs=e});let ct=H;const qt=t=>t.length==0?0:Zt(t.replace("px","")),En=(t,e)=>{const n=getComputedStyle(t)[e];if(n.match("%")){const o=Zt(n.replace("%","")),{width:r}=B(t);return r*(o/100)}return qt(n)},Cn=(t,e)=>{if(!(t instanceof Element))return[0,!1];const n=En(t,e),s=getComputedStyle(t).display,o=n>0||s==="flex";return[n,o]},yn=t=>{const{top:e,left:n}=getComputedStyle(t);return[qt(e),qt(n)]},Jt=(t,e)=>{const{gap:n}=I(e);return Cn(t,n)},bn=(t,e)=>{const[n,s]=Jt(t,e);return s?n:0},Kt=(t,e,n,s=()=>!0)=>{const o=new MutationObserver(r=>{if(r=r.filter(s),r.length>0){const i=r[0];t(o,i)}});return o.observe(e,n),o},zt=t=>K(t)?t.classList.contains(rt):!1;function mt(t,e,n,s,o=t.previousElementSibling,r=t.nextElementSibling){let{height:i,width:a}=An(n,t,o,r);return St(t,s)&&e==Lt&&(i=0,a=0),{height:i,width:a}}const An=(t,e,n,s)=>{const o=Dt(t,e),r=wt(t,e),i=wt(t,s),[a,f]=Jt(e.parentElement,t),[u]=z(t,B(e));if(f)return oe(u,r,o,a,0,t);const[h,d,x]=xn(n,i,o,r,t);return oe(u,d,h,0,x,t)},xn=(t,e,n,s,o)=>{const r=Math.max(e,n);let i=s,a=e;if(t){const f=Dt(o,t);i=Math.max(f,s),a=Math.max(a,f)}return[r,i,a]},oe=(t,e,n,s,o,r)=>Mn(r,t+e+n+s-o),Mn=(t,e)=>t==Y?{width:e,height:0}:{width:0,height:e},On="startDrag",Ee="cubic-bezier(0.2, 0, 0, 1)",Ce=50,ye="width, min-width, height",Bn=(t,e,n)=>{let s=mt(e,On,n,t);const o=bn(t,n),[,r]=z(n,s);s[r]-=o;const[i,a]=wn(n,e);return s[a]=i,s},wn=(t,e)=>{const n=t==Y?q:Y;return z(n,B(e))},gt=(t,e=Pt)=>{en(t,e),t.style.minWidth=`${e.width}px`},Ln=(t,e,n)=>s=>{e.contains(t)&&(gt(t,n),s.disconnect())},be=(t,e)=>{const{scrollDistance:n,clientDistance:s}=I(e);return t[n]-t[s]},Pn=(t,e,n)=>{const[s]=Tt(t,n);return s/be(e,t)},Rn=(t,e,n,s)=>{if(!s)return;const{direction:o}=e,r=Pn(o,t,n)>.99,[,i]=Tt(o,t);r&&(t[i]=be(t,o))},Ae=(t,e,n,s)=>{const{droppable:o,config:r,scroll:i}=n,{direction:a,animationDuration:f}=r;if(Rn(o,r,i,e),o.querySelector(`.${rt}`)||!t)return;var u=t.tagName=="LI"?"DIV":t.tagName,h=document.createElement(u);st(h,rt),gt(h);const d=Bn(o,t,a);return Ct(h,f,Ee,ye),[h,d,o]},jt=(t,e,n,s,o)=>{const r=Ae(t,n,s);if(!r)return;const[i,a,f]=r;P(e,f)&>(i,a),Kt(Ln(i,f,a),f,{childList:!0,subtree:!0}),f.appendChild(i)},Fn=(t,e,n)=>{const s=Ae(t,e,n);if(!s)return;const[o,r,i]=s;i.appendChild(o),In(o,r)},In=(t,e)=>requestAnimationFrame(()=>{gt(t,e),requestAnimationFrame(()=>{Ct(t,0,Ee,ye)})}),Nn=(t,e,n,s,o=!0)=>{if(n){var r=document.querySelectorAll(`${lt(n)} > .${rt}`);r.forEach(i=>{const a=i.parentElement;if(P(e,a)||!o&&P(t,a))return;gt(i),setTimeout(()=>{var u;(u=i.parentNode)==null||u.removeChild(i)},s+Ce)})}},Ot=(t,e,n=!1)=>{var s=t.querySelectorAll(`.${rt}`);s.forEach(o=>{const r=o;n?(gt(r),setTimeout(()=>{t.contains(r)&&t.removeChild(r)},e+Ce)):t.removeChild(o)})},Gn=(t,e)=>{const{config:n,droppable:s}=t,{onInsertEvent:o,onDragEnd:r}=n;return{...n,onDragEnd:f=>{const{index:u,value:h}=f;r({index:u,value:e(h,s)})},onInsertEvent:(f,u)=>o(f,e(u,s),!0)}};class $n{constructor(e,n,s,o,r,i){X(this,"initial");X(this,"current");X(this,"parent");X(this,"draggableElement");X(this,"groupClass");X(this,"dragEvent");X(this,"changeDroppable");X(this,"mapFrom");this.parent=s,this.draggableElement=e,this.groupClass=n,this.dragEvent=o,this.mapFrom=i,this.initial=ct.getConfig(s),this.changeDroppable=r}getDraggableAncestor(e,n,s){return document.elementsFromPoint(e,n).filter(o=>!P(s,o))}getElementBelow(e,n){return(o=>{const[r]=o.getDraggableAncestor(n.clientX,n.clientY,e);return r})(this)}getCurrent(e,n){const s=this.getElementBelow(e,n);return!this.groupClass||!s?void 0:s.closest(lt(this.groupClass))}isOutsideOfAllDroppables(e){return(this.groupClass?Array.from(document.querySelectorAll(lt(this.groupClass))):[this.parent]).every(s=>St(e,s))}isNotInsideAnotherDroppable(e,n){return!St(e,n)||this.isOutsideOfAllDroppables(e)}onScrollEvent(){this.dragEvent()}setOnScroll(e){De(e,"onscroll",()=>{this.onScrollEvent()})}getConfigFrom(e){const n=ct.getConfig(e);if(n)return P(this.parent,e)?n:{...n,config:Gn(n,this.mapFrom)}}droppableIfInsideCurrent(e,n){return e&&!P(n,e)&&n.contains(e)}getCurrentConfig(e){var o,r;const n=this.draggableElement,s=this.getCurrent(n,e);return this.current&&this.isNotInsideAnotherDroppable(n,(o=this.current)==null?void 0:o.droppable)&&!this.droppableIfInsideCurrent(s,(r=this.current)==null?void 0:r.droppable)?this.current:s?(K(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){const n=this.draggableElement;return!this.getCurrent(n,e)}}const re=(t,e)=>{const{paddingBefore:n}=I(t),s=ut(t,e),o=Et(e,n),r=It(t,B(e));return s+o+r},Vn=(t,e)=>{const[n,s]=yn(e),o=re(q,t);return[re(Y,t)-s,o-n]};function Yn(t,e,n,s,o,r,i,a,f){let u=0,h=0;const d=!!(n<0&&f);if(n===s&&!d)return ce({height:u,width:h},t,o,i,d);const[x,R,b,C]=Wn(e,n,s,f);if(d){const[p,m]=Vn(a,f);u+=m,h+=p}const[T,A]=Jt(a,t),[v,M,N]=qn(x,R==null?void 0:R.previousElementSibling,C,A,d,t),[W,G,Z]=Hn(b,T,A,t),J=_n(G,W,Z,M,v,T),[k]=Tt(t,a),Q=d?k:Xn(a,r,t),g=(C?J-N:N-J)-Q;return t===q?u+=g:t===Y&&(h+=g),ce({height:u,width:h},t,o,i,d)}const Xn=(t,e,n)=>{const[s]=Tt(n,t),[o]=Tt(n,e);return s-o},_n=(t,e,n,s,o,r)=>{const i=Math.max(e,o);return Math.max(n,s)+t+i+r},Wn=(t,e,n,s)=>{const o=e<n,[r,i]=[e,n].toSorted((h,d)=>h-d),a=t[e]??s,f=t[n];let u=o?t.slice(r+1,i+1):t.slice(r,i);return r<0&&s&&(u=t.slice(r+1,i)),[a,f,u,o]},Hn=(t,e,n,s)=>{if(t.length==0)return[0,0,0];const o=Dt(s,t[0]);let r=0,i=-o;for(const[a,f]of t.entries()){const[u]=z(s,B(f)),h=fe(s,f);n&&(r+=h),n&&a>0?r+=e:r=Math.max(r,h),i+=r+u,r=Dt(s,f)}return[o,i,r]},ce=(t,e,n,s,o)=>{const r=at(e,window),i=at(e,n),a=o?0:i-2*r+at(e,s),[,f]=z(e,t);return t[f]+=a,t},qn=(t,e,n,s,o,r)=>{const i=n?t.previousElementSibling:e;return zn(i,t,s,o,r)},zn=(t,e,n,s,o)=>{if(n)return[0,0,0];const r=Dt(o,s?null:t),i=fe(o,e);let a=Math.max(r,i);return[r,i,a]},xe=(t,e,n)=>{const{handlerSelector:s,animationDuration:o}=t,r=u=>{n(),i(u,!1),Rt(u),u.style.top="",u.style.left="",Te(u,{fixedHeight:"",fixedWidth:""})},i=(u,h)=>{it(u,Ft,h),a(h,u),e.toggleGrabClass(!h)},a=(u,h)=>{const d=h.querySelector(s);it(document.body,ae,u),it(d||h,Xt,u)};return[r,i,(u,h)=>{Ct(u,o,Ut),ot(u,h)}]},jn=50;function Zn(t,e,n,s,o,r){let i=e;const{onRemoveAtEvent:a,animationDuration:f,draggingClass:u}=t,[h,d,x]=xe(t,o,r),R=(g,p,m,y)=>{const O=mt(g,p,y.direction,m);C(g,p,O,m,y)},b=(g,p,m,y,O)=>{if(!m)return;const{droppable:E,scroll:w,config:L}=m,S=mt(g,p,L.direction,E);v(g,p,S,y,E,w,L,O)},C=(g,p,m,y,O)=>{const[E]=Mt(g,y),w=St(g,y),{direction:L}=O;E.length==0&&A(m,1,L,E);for(const[S,F]of E.entries()){if(!U(F,_))continue;const $=T(L,g,F,m);if(!w&&$)m=$;else if(!w)continue;const et=E.length-S;A(m,et,L,E),p===he?ot(F,m):p===Lt&&x(F,m)}},T=(g,p,m,y)=>{const O=B(p),E=B(m),w=j(g,O),L=j(g,E),[S]=z(g,E),F=L+S/2,$=It(g,qe(m)),et=F-$;return w>et?Pt:y},A=(g,p,m,y)=>{const O=y.filter(w=>U(w,_)).length,[E]=z(m,g);E==0?i=Math.max(i,p):i=Math.min(i,p-1),i=Math.min(i,O)},v=(g,p,m,y,O,E,w,L)=>{const[S,F]=Mt(g,O),$=S.toReversed(),et=F===-1?$.length:F;$.splice(et,0,g);const[Nt,yt,ft]=M(g,F,$,O);m=mt(g,p,w.direction,n,Nt,yt);const Gt=We(),bt=Yn(w.direction,$,F,ft,Gt,E,y,O,g);S.length==0&&N(void 0,m,g,bt);for(const[$t,pt]of S.toReversed().entries()){let At=m;ft-1>=$t&&(At=Pt),p===me&&!U(pt,rt)&&N(pt,At,g,bt)}W(ft,g,w,O,L)},M=(g,p,m,y)=>{const E=St(g,y)?p:i,w=()=>p<E?[E,E+1]:p>E?[E-1,E]:[E-1,E+1],[L,S]=w(),F=m[L]??null,$=m[S]??null;return[F,$,E]},N=(g,p,m,y)=>{ot(g,p),ot(m,y)},W=(g,p,m,y,O)=>{const{onInsertEvent:E,onDragEnd:w}=m;st(p,_t),J(p,n,y,()=>{if(Wt(p,_t),O!=null){const L=a(O,!0);L!=null&&(E(g,L,!0),w({value:L,index:g})),Z(p),G()}})},G=()=>{if(s){var g=document.querySelectorAll(`${lt(s)} > .${_}`);for(const p of g)Rt(p)}},Z=g=>{setTimeout(()=>{Wt(g,u)},jn)},J=(g,p,m,y)=>{setTimeout(()=>{y&&y(),k(p,m),Q(m),h(g),tt(g,p),tt(g,m)},f)},k=(g,p)=>{P(g,p)?Ot(g,f):(Ot(g,f,!0),Ot(p,f))},Q=g=>{if(!P(n,g)){var[p]=n.querySelectorAll(`.${rt}`);p&&K(p)&&(p.style.height="0px",p.style.width="0px")}},tt=(g,p)=>{const[m]=Mt(g,p);for(const y of[...m,g])Rt(y)};return[R,b,d]}const ie="onmousedown";function kn(t,e,n,s,o){const{handlerSelector:r,isDraggable:i,droppableGroup:a,animationDuration:f,draggingClass:u,droppableClass:h,onDragStart:d,delayBeforeTouchMoveEvent:x,coordinateTransform:R}=n,b=vt(a).map(c=>`droppable-group-${c}`).join(" ");let C=0,T={scrollX:0,scrollY:0},A={pageX:0,pageY:0},v,M;const[N,W]=mn(t,R),G=()=>{C=0},[Z,J,k]=Zn(n,e,s,b,o,G),Q=()=>{st(t,_)},tt=c=>{st(c,Bt),o.addSubscriber(c)},g=()=>{if(i(t)){const c=t.querySelector(r);tt(c||t)}},p=()=>{g(),Q()},m=c=>{const l=c==null?void 0:c.querySelector(`.${Bt}`),D=l==null?void 0:l.parentElement;return l&&D&&U(D,Yt)&&!P(s,D)?null:l},y=c=>{const l=m(c)??c;l&&i(c)&&(Vt(l,ie,pt("mousemove","mouseup")),Vt(l,"ontouchstart",pt("touchmove","touchend"),D=>{const V=D.touches[0];M={x:V.clientX,y:V.clientY}}),O(l)),P(c,l)||Vt(c,ie,At),st(s,Yt)},O=c=>{const l=c.querySelectorAll("img");Array.from(l).forEach(D=>{D.onmousedown=()=>!1})},E=()=>{if(A.pageX==0&&A.pageY==0||!S.current)return;const{droppable:c,config:l}=S.current;N(t,c,A,l.direction),Z(t,Lt,c,l)},w=c=>{const l=c.querySelectorAll(`.${_}`);for(const D of l)ot(D)},L=(c,l)=>{l&&C==2&&!P(c==null?void 0:c.droppable,l.droppable)&&(Z(t,Lt,l.droppable,l.config),w(l.droppable))},S=new $n(t,b,s,E,L,n.mapFrom),F=c=>{if(!S.current)return;const l=b?Array.from(document.querySelectorAll(lt(b))):[s];for(const D of l)D.classList.toggle(h,!c&&P(D,S.current.droppable))},$=(c,l=!1)=>{S.updateConfig(c);const D=S.isOutside(c);F(D),C===1&&!l?te(c):C===2&&(et(D),we(c))},et=(c=!0)=>{if(!S.current)return;const{droppable:l}=S.current;Nn(l,s,b,f,c),!c&&jt(t,s,C==1,S.current)},Nt=c=>{if(ht(c)&&M&&C==1){const l=c.touches[0],D=Math.abs(l.clientX-M.x),V=Math.abs(l.clientY-M.y);if(Math.abs(D)>5&&Math.abs(V)>5)return clearTimeout(v),!1}return!0},yt=c=>{clearTimeout(v);const l=Ht(c);if(ht(c)&&c.cancelable&&C==2&&c.preventDefault(),ht(c)&&!c.cancelable||!Nt(c)){Qt("touchmove",c);return}$(l,ht(c))},ft=(c,l)=>{c=="touchmove"?v=setTimeout(()=>{l()},x):l()},Gt=(c,l)=>{const{clientX:D,clientY:V}=c,nt=document.elementFromPoint(D,V),dt=nt==null?void 0:nt.closest(`.${_}`);return dt&&P(l,dt)},bt=c=>{const l=n.onGetValue(e);return{index:e,element:c,value:l}},$t=c=>{S.updateConfig(c),F(S.isOutside(c)),te(c)},pt=(c,l)=>D=>{if(!Gt(D,t))return;ct.updateScrolls(s,b);const{scrollX:V,scrollY:nt}=window;if(T={scrollX:V,scrollY:nt},C===0){C=1;const dt=bt(t);dt&&d(dt),ft(c,()=>{c=="touchmove"&&$t(D)}),document.addEventListener(c,yt,{passive:!1}),Le(s),document.addEventListener(l,Me(c),{once:!0})}},At=c=>S.updateConfig(c),Me=c=>l=>{Qt(c,l)},Qt=(c,l)=>{F(!0);const D=Ht(l);Re(S.isOutside(D)),clearTimeout(v),document.removeEventListener(c,yt),S.updateConfig(D);const V=S.getCurrentConfig(D);if(V){const{droppable:nt}=V;Oe(nt)}s.onscroll=null,G()},Oe=c=>{if(c.onscroll=null,!b)return;const l=Array.from(document.querySelectorAll(lt(b)));for(const D of l)K(D)&&(D.onscroll=null)},te=c=>{S.current&&jt(t,s,C==1,S.current),Be(),S.current&&Z(t,he,S.current.droppable,S.current.config),Ie(t),W(c,t)},Be=()=>{C=2},we=c=>{const{pageX:l,pageY:D}=c;A={pageX:l,pageY:D},E()},Le=c=>De(c,"onscroll",Pe),Pe=()=>E(),Re=c=>{if(C!==2&&C!==1){G();return}C=3,Fe(t),t.classList.contains(Ft)&&J(t,me,c?S.initial:S.current,T,e)},Fe=c=>{Ct(c,f,Ut),ot(c)},Ie=c=>{const{height:l,width:D}=B(c);Te(c,{fixedHeight:`${l}px`,fixedWidth:`${D}px`}),k(c,!0),it(c,u,!0),c.style.transition=""},Ne=c=>{Promise.resolve().then(()=>require("./remove-dSzXNYxs.cjs")).then(l=>{const[D]=l.default(n,s,o,G);S.initial&&D(e,c,t,S.initial)})},Ge=(c,l)=>{(c===e||c===n.onGetLegth()&&e===c-1)&&Promise.resolve().then(()=>require("./insert-CEcy9QNd.cjs")).then(D=>{const[V]=D.default(n,s,o,G);S.initial&&V(c,t,s,l,S.initial)})};return p(),y(t),[Ne,Ge]}const Un=(t,e)=>{t&&_e(e,t)},Jn=()=>{gn(document.body,[`.${_}{touch-action:manipulation;user-select:none;box-sizing:border-box!important;-webkit-user-select:none;}`,`.${Bt}{pointer-events:auto!important;}`,`.${le}{cursor:grab;}`,".temp-child{touch-action:none;pointer-events:none;box-sizing:border-box!important;}",".droppable{box-sizing:border-box!important;}",`.${Ft}{position:fixed;z-index:5000;width:var(--fixedWidth)!important;height:var(--fixedHeight)!important;}`,`.${Xt}{pointer-events:none!important;}`,`.${_t}{pointer-events:none!important;}`,`.${ae}{cursor:grabbing;}`,".disable-transition{transition:none!important;}"])};function Kn(t,e,n,s="index"){const o=s;let r=[],i=[];const{droppableGroup:a}=t;if(!n)return[r,i];const f=vt(a).map(u=>`droppable-group-${u}`).join(" ");Jn(),Un(f,n);for(const u of n.children){const h=u.getAttribute(o),d=He(h),x=u;if(x&&d>=0){const[R,b]=kn(x,d,t,n,e);r.push(R),i.push(b)}}return[r,i]}const Qn=(t,e)=>{const n=(a,f)=>t.removeAtEvent(a,f),s=(a,f,u)=>t.insertEvent(a,f,u),o=()=>t.getLength(),r=a=>t.getValue(a),i=a=>a;return{direction:(e==null?void 0:e.direction)??q,handlerSelector:(e==null?void 0:e.handlerSelector)??_,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)??i,delayBeforeTouchMoveEvent:(e==null?void 0:e.delayBeforeTouchMoveEvent)??150,coordinateTransform:(e==null?void 0:e.coordinateTransform)??[a=>a]}};function ts(t,e,n,s="index"){let o=[],r=[],i;const a=Qn(t,n),f=T=>{for(const A of o)A(T)},u=(T,A)=>{if(a.onGetLegth()===0)t.insertToListEmpty(a,T,A);else for(const M of r)M(T,A)},h=T=>{const[A,v]=Kn(a,e,T,s);o=A,r=v},d=T=>{const A=T.addedNodes.values().filter(M=>!zt(M)).toArray(),v=T.removedNodes.values().filter(M=>!zt(M)).toArray();return A.length>0||v.length>0},x=T=>{i=Kt(()=>{h(T)},T,{childList:!0},d)},R=T=>{st(T,Yt)},b=T=>{ct.addConfig(T,a)};return[f,u,T=>{if(T)return R(T),b(T),x(T),h(T),ct.removeObsoleteConfigs(),i}]}exports.DISABLE_TRANSITION=Ye;exports.DRAGGABLE_CLASS=_;exports.GRAB_CLASS=le;exports.addClass=st;exports.addTempChild=jt;exports.addTempChildOnInsert=Fn;exports.containClass=U;exports.dragAndDrop=ts;exports.draggableTargetTimingFunction=Ut;exports.getParentDraggableChildren=Ue;exports.getSiblings=Mt;exports.getTranslationByDraggingAndEvent=mt;exports.isTempElement=zt;exports.moveTranslate=ot;exports.observeMutation=Kt;exports.removeClass=Wt;exports.removeTempChild=Ot;exports.removeTranslateWhitoutTransition=Rt;exports.setTranistion=Ct;exports.toggleClass=it;exports.useChangeDraggableStyles=xe;
|
package/dist/insert-CEcy9QNd.cjs
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-BOqB07mI.cjs");function f(s,t,n,i){const{delayBeforeInsert:a}=s,[c,g,o]=e.useChangeDraggableStyles(s,n,i),v=(r,l,d,m,S)=>{const b=e.getTranslationByDraggingAndEvent(l,"insert",s.direction,d),{onInsertEvent:I}=s,h=e.getParentDraggableChildren(d);for(const[y,u]of h.entries())e.containClass(u,e.DRAGGABLE_CLASS)&&y>=r&&o(u,b);e.addTempChildOnInsert(l,!1,S),setTimeout(()=>{I(r,m),T(r,d,s),c(l),E(l,t),e.removeTempChild(t,0,!0)},a)},E=(r,l)=>{const[d]=e.getSiblings(r,l);for(const m of[...d,r])e.removeTranslateWhitoutTransition(m)};return[v]}const A=s=>s.addedNodes.values().filter(n=>!e.isTempElement(n)).toArray().length>0,T=(s,t,n)=>{const{insertingFromClass:i,animationDuration:a}=n,c=e.observeMutation(()=>{const o=e.getParentDraggableChildren(t)[s];e.addClass(o,i),e.addClass(o,e.DISABLE_TRANSITION),setTimeout(()=>{e.removeClass(o,e.DISABLE_TRANSITION),e.removeClass(o,i),c.disconnect()},a)},t,{childList:!0},A)},D=(s,t,n,i)=>{if(!t)return;const{onInsertEvent:a,delayBeforeInsert:c}=s;setTimeout(()=>{a(n,i),T(n,t,s)},c)};exports.default=f;exports.insertToListEmpty=D;
|