UNPKG

fluid-dnd

Version:

An agnostic drag and drop library to sort all kind of lists. With current support for vue, react and svelte

2 lines (1 loc) 1.2 kB
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-GR-moYK4.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;