vue-fluid-dnd
Advanced tools
Comparing version 0.6.14 to 0.6.15
import { Direction } from "../composables"; | ||
import { BeforeMargin, AfterMargin, GapStyle, BorderWidth, Distance, Before, Axis, Offset, Scroll, InnerDistance, Page, After, OffsetElement, ScrollElement } from "../../index"; | ||
import { BeforeMargin, AfterMargin, GapStyle, BorderWidth, Distance, Before, Axis, Offset, Scroll, InnerDistance, Page, After, OffsetElement, ScrollElement, ScrollDistance, ClientDistance } from "../../index"; | ||
export declare const getScroll: (element: HTMLElement | undefined | null) => { | ||
@@ -40,2 +40,4 @@ scrollLeft: number; | ||
offsetElement: OffsetElement; | ||
scrollDistance: ScrollDistance; | ||
clientDistance: ClientDistance; | ||
}; | ||
@@ -42,0 +44,0 @@ export declare const getSiblings: (current: HTMLElement, parent: HTMLElement) => { |
@@ -1,3 +0,4 @@ | ||
import { CoreConfig } from "../composables"; | ||
export declare const addTempChild: <T>(droppable: HTMLElement, draggedElement: HTMLElement | undefined, parent: Element, config: CoreConfig<T>) => void; | ||
import { DroppableConfig } from "../composables/configHandler"; | ||
import { DraggingState } from "."; | ||
export declare const addTempChild: <T>(draggedElement: HTMLElement | undefined, parent: Element, state: DraggingState, droppableConfig?: DroppableConfig<T> | undefined) => void; | ||
export declare const removeTempChildrens: (droppable: HTMLElement, parent: HTMLElement, droppableGroupClass: string | null, animationDuration: number) => void; |
@@ -1,6 +0,6 @@ | ||
var Xt = Object.defineProperty; | ||
var Yt = (t, e, n) => e in t ? Xt(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n; | ||
var gt = (t, e, n) => (Yt(t, typeof e != "symbol" ? e + "" : e, n), n); | ||
import { ref as M, watch as st } from "vue"; | ||
const Vt = (t, e) => { | ||
var zt = Object.defineProperty; | ||
var Xt = (t, e, n) => e in t ? zt(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n; | ||
var ft = (t, e, n) => (Xt(t, typeof e != "symbol" ? e + "" : e, n), n); | ||
import { ref as M, watch as rt } from "vue"; | ||
const Wt = (t, e) => { | ||
const n = t.value; | ||
@@ -11,5 +11,5 @@ if (n.length <= 0) | ||
return o; | ||
}, zt = (t, e, n) => { | ||
}, Yt = (t, e, n) => { | ||
t.value.splice(e, 0, n); | ||
}, Wt = (t) => { | ||
}, Vt = (t) => { | ||
if (t) { | ||
@@ -23,3 +23,3 @@ const { scrollLeft: e, scrollTop: n } = t; | ||
return { scrollX: t, scrollY: e }; | ||
}, ct = (t) => !t || t.trim().length == 0 || t == "normal" ? 0 : parseFloat(t), Ft = (t) => t ? parseInt(t) : -1, $t = (t) => { | ||
}, at = (t) => !t || t.trim().length == 0 || t == "normal" ? 0 : parseFloat(t), Ft = (t) => t ? parseInt(t) : -1, $t = (t) => { | ||
const e = getComputedStyle(t), n = new DOMMatrixReadOnly(e.transform); | ||
@@ -30,5 +30,5 @@ return { | ||
}; | ||
}, It = (t, e) => t.x1 > e.x1 ? It(e, t) : t.x2 < e.x1 ? 0 : t.x2 >= e.x2 ? t.x2 - t.x1 : t.x2 - e.x1, K = (t, e) => !qt(t, e), qt = (t, e) => { | ||
const n = t.getBoundingClientRect(), o = e.getBoundingClientRect(), s = yt(n, o, "vertical"), c = yt(n, o, "horizontal"); | ||
return s >= Math.min(n.height, o.height) / 2 && c >= Math.min(n.width, o.width) / 2; | ||
}, It = (t, e) => t.x1 > e.x1 ? It(e, t) : t.x2 < e.x1 ? 0 : t.x2 >= e.x2 ? t.x2 - t.x1 : t.x2 - e.x1, Q = (t, e) => !qt(t, e), qt = (t, e) => { | ||
const n = t.getBoundingClientRect(), o = e.getBoundingClientRect(), s = yt(n, o, "vertical"), i = yt(n, o, "horizontal"); | ||
return s >= Math.min(n.height, o.height) / 2 && i >= Math.min(n.width, o.width) / 2; | ||
}, yt = (t, e, n) => { | ||
@@ -46,3 +46,3 @@ const { before: o, distance: s } = R(n); | ||
); | ||
}, at = (t, e) => t ? ct(getComputedStyle(t)[e]) : 0, B = (t, e) => t ? ct(getComputedStyle(t)[e]) : 0, Gt = (t) => { | ||
}, lt = (t, e) => t ? at(getComputedStyle(t)[e]) : 0, B = (t, e) => t ? at(getComputedStyle(t)[e]) : 0, Gt = (t) => { | ||
const { scrollLeft: e, scrollTop: n } = t; | ||
@@ -64,3 +64,5 @@ return { scrollLeft: e, scrollTop: n }; | ||
inner: "innerWidth", | ||
offsetElement: "offsetLeft" | ||
offsetElement: "offsetLeft", | ||
scrollDistance: "scrollWidth", | ||
clientDistance: "clientWidth" | ||
} : { | ||
@@ -80,3 +82,5 @@ beforeMargin: "marginTop", | ||
inner: "innerHeight", | ||
offsetElement: "offsetTop" | ||
offsetElement: "offsetTop", | ||
scrollDistance: "scrollHeight", | ||
clientDistance: "clientHeight" | ||
}, dt = (t, e) => kt(t, e), kt = (t, e) => { | ||
@@ -93,4 +97,4 @@ const n = [...e.children].filter( | ||
}; | ||
}, vt = (t) => window.TouchEvent && t instanceof TouchEvent, Q = (t) => t instanceof HTMLElement, Ut = ["onmouseup", "onmousedown", "onmousemove"], ot = (t, e, n) => { | ||
!t || !Q(t) || (n == 0 && e == 0 ? t.style.transform = "" : t.style.transform = `translate(${n}px,${e}px)`); | ||
}, vt = (t) => window.TouchEvent && t instanceof TouchEvent, tt = (t) => t instanceof HTMLElement, Ut = ["onmouseup", "onmousedown", "onmousemove"], st = (t, e, n) => { | ||
!t || !tt(t) || (n == 0 && e == 0 ? t.style.transform = "" : t.style.transform = `translate(${n}px,${e}px)`); | ||
}, Zt = (t, e, n) => { | ||
@@ -103,3 +107,3 @@ t[e] = (o) => { | ||
}; | ||
}, At = (t, e, n) => { | ||
}, Rt = (t, e, n) => { | ||
n && (jt(e) ? t[e] = n : Zt(t, e, n)); | ||
@@ -135,10 +139,10 @@ }, jt = (t) => Ut.includes(t), Jt = (t) => { | ||
return Jt(t); | ||
const { offsetX: n, offsetY: o } = Kt(t, e), { clientX: s, clientY: c, pageX: r, pageY: l, screenX: g, screenY: h, target: d } = e; | ||
const { offsetX: n, offsetY: o } = Kt(t, e), { clientX: s, clientY: i, pageX: r, pageY: a, screenX: g, screenY: f, target: d } = e; | ||
return { | ||
clientX: s, | ||
clientY: c, | ||
clientY: i, | ||
pageX: r, | ||
pageY: l, | ||
pageY: a, | ||
screenX: g, | ||
screenY: h, | ||
screenY: f, | ||
target: d, | ||
@@ -154,8 +158,8 @@ offsetX: n, | ||
}, te = (t, e, n, o) => { | ||
const { page: s, scroll: c, before: r, borderBeforeWidth: l } = R(n), g = o.getBoundingClientRect(); | ||
return t[s] - e[c] - g[r] - at(o, l); | ||
const { page: s, scroll: i, before: r, borderBeforeWidth: a } = R(n), g = o.getBoundingClientRect(); | ||
return t[s] - e[i] - g[r] - lt(o, a); | ||
}, Et = (t, e, n = "ease-out", o = "transform") => { | ||
Q(t) && (t.style.transition = `${e}ms ${n}`, t.style.transitionProperty = `${o}`); | ||
tt(t) && (t.style.transition = `${e}ms ${n}`, t.style.transitionProperty = `${o}`); | ||
}, ee = (t, e, n) => { | ||
!t || !Q(t) || (t[e] = () => { | ||
!t || !tt(t) || (t[e] = () => { | ||
n(); | ||
@@ -173,4 +177,4 @@ }); | ||
for (const s of t.cssRules) { | ||
const [c] = s.cssText.match(n) || []; | ||
if (o === c) | ||
const [i] = s.cssText.match(n) || []; | ||
if (o === i) | ||
return !0; | ||
@@ -187,60 +191,63 @@ } | ||
n.sheet && (oe(n.sheet, e) || (o = n.sheet) == null || o.insertRule(e, n.sheet.cssRules.length)); | ||
}, ie = (t) => { | ||
}, ie = (t, e, n) => { | ||
n != 0 && (e === "vertical" ? t.scrollBy(0, n) : t.scrollBy(n, 0)); | ||
}, ce = (t, e, n) => { | ||
const { scrollDistance: o, clientDistance: s, scrollElement: i } = R(t); | ||
return n[i] / (e[o] - e[s]); | ||
}, ae = (t) => { | ||
const e = M({ offsetX: 0, offsetY: 0 }), n = M({ top: 0, left: 0 }), o = M({ x: 0, y: 0 }); | ||
st( | ||
rt( | ||
o, | ||
(r) => { | ||
const l = t.value; | ||
l && (l.style.transform = `translate( ${r.x}px, ${r.y}px)`); | ||
const a = t.value; | ||
a && (a.style.transform = `translate( ${r.x}px, ${r.y}px)`); | ||
}, | ||
{ deep: !0 } | ||
), st( | ||
), rt( | ||
n, | ||
(r) => { | ||
const l = t.value; | ||
l && (l.style.top = `${r.top}px`, l.style.left = `${r.left}px`); | ||
const a = t.value; | ||
a && (a.style.top = `${r.top}px`, a.style.left = `${r.left}px`); | ||
}, | ||
{ deep: !0 } | ||
); | ||
function s(r, l, g, h) { | ||
const d = (S) => { | ||
function s(r, a, g, f) { | ||
const d = (b) => { | ||
const { | ||
beforeMargin: x, | ||
borderBeforeWidth: T, | ||
before: z, | ||
offset: _, | ||
scroll: W, | ||
page: $, | ||
inner: k, | ||
distance: I, | ||
borderBeforeWidth: A, | ||
before: T, | ||
offset: O, | ||
scroll: z, | ||
page: k, | ||
inner: X, | ||
distance: W, | ||
axis: C | ||
} = R(S), H = g.value[$], P = window[W], F = window[k], X = r.getBoundingClientRect()[I], a = at(r, T), u = B(r, x), f = H - e.value[_]; | ||
if (f >= P - X / 2 && f <= P + F) { | ||
const y = f - n.value[z] - a - u - P; | ||
return A(S), y; | ||
} = R(b), Y = g.value[k], V = window[z], H = window[X], F = r.getBoundingClientRect()[W], I = lt(r, A), l = B(r, x), u = Y - e.value[O]; | ||
if (u >= V - F / 2 && u <= V + H) { | ||
const v = u - n.value[T] - I - l - V; | ||
return E(b), v; | ||
} | ||
return o.value[C]; | ||
}, A = (S) => { | ||
if (r && r.classList.contains("dragging") && S === h) { | ||
const { before: x, distance: T, axis: z } = R(h), _ = r.getBoundingClientRect()[T], W = l.getBoundingClientRect(), $ = n.value[x] - W[x] + o.value[z], I = W[T] - _, C = $ / I, H = _ / I, P = 0.1, F = 0.25, X = 0.75; | ||
let a = 0; | ||
const u = K(r, l); | ||
!u && C < F && C > -H ? a = C / F - 1 : !u && C > X && C < 1 + H && (a = 1 / (1 - X) * (C - X)); | ||
const f = P * _ * a; | ||
D(l, h, f); | ||
}, E = (b) => { | ||
if (r && r.classList.contains("dragging") && b === f) { | ||
const { before: x, distance: A, axis: T } = R(f), O = r.getBoundingClientRect()[A], z = a.getBoundingClientRect(), k = n.value[x] - z[x] + o.value[T], W = z[A] - O, C = k / W, Y = O / W, V = 0.1, H = 0.2, F = 0.8; | ||
let I = 0; | ||
const l = Q(r, a); | ||
!l && C < H && C > -Y ? I = C / H - 1 : !l && C > F && C < 1 + Y && (I = 1 / (1 - F) * (C - F)); | ||
const u = V * O * I; | ||
ie(a, f, u); | ||
} | ||
}, D = (S, x, T) => { | ||
T != 0 && (x === "vertical" ? S.scrollBy(0, T) : S.scrollBy(T, 0)); | ||
}, E = (S) => { | ||
const { axis: x } = R(S); | ||
o.value[x] = d(S); | ||
}, m = (b) => { | ||
const { axis: x } = R(b); | ||
o.value[x] = d(b); | ||
}; | ||
E("horizontal"), E("vertical"); | ||
m("horizontal"), m("vertical"); | ||
} | ||
return { | ||
setTransform: s, | ||
updateTransformState: (r, l) => { | ||
const { offsetX: g, offsetY: h, top: d, left: A } = ae( | ||
updateTransformState: (r, a) => { | ||
const { offsetX: g, offsetY: f, top: d, left: E } = ue( | ||
r, | ||
l, | ||
a, | ||
t.value | ||
@@ -250,21 +257,21 @@ ); | ||
top: d, | ||
left: A | ||
}, e.value = { offsetX: g, offsetY: h }; | ||
left: E | ||
}, e.value = { offsetX: g, offsetY: f }; | ||
} | ||
}; | ||
}, Rt = (t, e, n) => { | ||
}, At = (t, e, n) => { | ||
const { borderBeforeWidth: o, before: s } = R(t); | ||
return e.getBoundingClientRect()[s] - n.getBoundingClientRect()[s] - at(n, o); | ||
}, ce = (t, e) => { | ||
return e.getBoundingClientRect()[s] - n.getBoundingClientRect()[s] - lt(n, o); | ||
}, le = (t, e) => { | ||
let { offsetX: n, offsetY: o, target: s } = t; | ||
return e && s && e != s && (n += Rt( | ||
return e && s && e != s && (n += At( | ||
"horizontal", | ||
s, | ||
e | ||
), o += Rt("vertical", s, e)), { offsetX: n, offsetY: o }; | ||
), o += At("vertical", s, e)), { offsetX: n, offsetY: o }; | ||
}, Ct = (t, e, n, o) => { | ||
const { offset: s, beforeMargin: c, page: r, borderBeforeWidth: l, scroll: g } = R(t); | ||
return e[r] - o[s] - B(n, c) - at(n, l) - window[g]; | ||
}, ae = (t, e, n) => { | ||
const { offsetX: o, offsetY: s } = ce(t, n); | ||
const { offset: s, beforeMargin: i, page: r, borderBeforeWidth: a, scroll: g } = R(t); | ||
return e[r] - o[s] - B(n, i) - lt(n, a) - window[g]; | ||
}, ue = (t, e, n) => { | ||
const { offsetX: o, offsetY: s } = le(t, n); | ||
return { | ||
@@ -282,9 +289,9 @@ top: Ct("vertical", t, e, { | ||
}; | ||
}, le = "drag", ue = "startDrop", fe = "drop", ge = (t) => t === fe || t === ue; | ||
var V = /* @__PURE__ */ ((t) => (t[t.NOT_DRAGGING = 0] = "NOT_DRAGGING", t[t.START_DRAGGING = 1] = "START_DRAGGING", t[t.DRAGING = 2] = "DRAGING", t[t.END_DRAGGING = 3] = "END_DRAGGING", t))(V || {}); | ||
const Dt = (t) => !t || t.length == 0 ? 0 : ct(t.replace("px", "")), de = (t, e) => { | ||
}, ge = "drag", fe = "startDrop", de = "drop", pe = (t) => t === de || t === fe; | ||
var $ = /* @__PURE__ */ ((t) => (t[t.NOT_DRAGGING = 0] = "NOT_DRAGGING", t[t.START_DRAGGING = 1] = "START_DRAGGING", t[t.DRAGING = 2] = "DRAGING", t[t.END_DRAGGING = 3] = "END_DRAGGING", t))($ || {}); | ||
const Dt = (t) => !t || t.length == 0 ? 0 : at(t.replace("px", "")), he = (t, e) => { | ||
const n = getComputedStyle(t)[e]; | ||
if (n.match("%")) { | ||
const s = ct(n.replace("%", "")), { width: c } = t.getBoundingClientRect(); | ||
return c * (s / 100); | ||
const s = at(n.replace("%", "")), { width: i } = t.getBoundingClientRect(); | ||
return i * (s / 100); | ||
} | ||
@@ -298,3 +305,3 @@ return Dt(n); | ||
}; | ||
const n = de(t, e), o = getComputedStyle(t).display, s = n > 0 || o === "flex"; | ||
const n = he(t, e), o = getComputedStyle(t).display, s = n > 0 || o === "flex"; | ||
return { | ||
@@ -304,3 +311,3 @@ gap: n, | ||
}; | ||
}, pe = (t) => { | ||
}, ve = (t) => { | ||
const { top: e, left: n } = getComputedStyle(t); | ||
@@ -311,39 +318,39 @@ return { | ||
}; | ||
}, he = (t, e) => { | ||
}, me = (t, e) => { | ||
const { gap: n } = R(e), { gap: o, hasGaps: s } = xt(t, n); | ||
return s ? o : 0; | ||
}; | ||
function Tt(t, e, n, o, s = t.previousElementSibling, c = t.nextElementSibling) { | ||
let { height: r, width: l } = ve( | ||
function bt(t, e, n, o, s = t.previousElementSibling, i = t.nextElementSibling) { | ||
let { height: r, width: a } = De( | ||
n, | ||
t, | ||
s, | ||
c | ||
i | ||
); | ||
return K(t, o) && e == le && (r = 0, l = 0), { height: r, width: l }; | ||
return Q(t, o) && e == ge && (r = 0, a = 0), { height: r, width: a }; | ||
} | ||
function ve(t, e, n, o) { | ||
function De(t, e, n, o) { | ||
const { | ||
afterMargin: s, | ||
beforeMargin: c, | ||
beforeMargin: i, | ||
distance: r, | ||
gap: l | ||
} = R(t), g = B(e, s), h = B(e, c), d = B(o, c), { gap: A, hasGaps: D } = xt( | ||
gap: a | ||
} = R(t), g = B(e, s), f = B(e, i), d = B(o, i), { gap: E, hasGaps: m } = xt( | ||
e.parentElement, | ||
l | ||
), E = e.getBoundingClientRect()[r]; | ||
if (D) | ||
return Nt(E, h, g, A, 0, t); | ||
const { afterSpace: S, beforeScace: x, rest: T } = me( | ||
a | ||
), b = e.getBoundingClientRect()[r]; | ||
if (m) | ||
return Nt(b, f, g, E, 0, t); | ||
const { afterSpace: x, beforeScace: A, rest: T } = be( | ||
n, | ||
d, | ||
g, | ||
h, | ||
f, | ||
s | ||
); | ||
return Nt(E, x, S, 0, T, t); | ||
return Nt(b, A, x, 0, T, t); | ||
} | ||
const me = (t, e, n, o, s) => { | ||
const c = Math.max(e, n); | ||
let r = o, l = e; | ||
const be = (t, e, n, o, s) => { | ||
const i = Math.max(e, n); | ||
let r = o, a = e; | ||
if (t) { | ||
@@ -354,8 +361,8 @@ const g = B( | ||
); | ||
r = Math.max(g, o), l = Math.max(l, g); | ||
r = Math.max(g, o), a = Math.max(a, g); | ||
} | ||
return { afterSpace: c, beforeScace: r, rest: l }; | ||
}, Nt = (t, e, n, o, s, c) => De(c, t + e + n + o - s), De = (t, e) => t == "horizontal" ? { width: e, height: 0 } : { width: 0, height: e }, Te = (t, e, n) => { | ||
return { afterSpace: i, beforeScace: r, rest: a }; | ||
}, Nt = (t, e, n, o, s, i) => Te(i, t + e + n + o - s), Te = (t, e) => t == "horizontal" ? { width: e, height: 0 } : { width: 0, height: e }, Se = (t, e, n) => { | ||
console.log(n); | ||
const { beforeMargin: o } = R("vertical"), { beforeMargin: s } = R("horizontal"), c = B( | ||
const { beforeMargin: o } = R("vertical"), { beforeMargin: s } = R("horizontal"), i = B( | ||
e, | ||
@@ -366,86 +373,88 @@ o | ||
s | ||
), { top: l, left: g } = pe(e), { top: h, left: d } = t.getBoundingClientRect(), { x: A, y: D } = $t(t); | ||
), { top: a, left: g } = ve(e), { top: f, left: d } = t.getBoundingClientRect(), { x: E, y: m } = $t(t); | ||
return console.log( | ||
h - B(t, o) - D - (l - c) - 13, | ||
h - l - D - c - 25 | ||
f - B(t, o) - m - (a - i) - 13, | ||
f - a - m - i - 25 | ||
), { | ||
y: h - l - D - c, | ||
x: d - g - A - r | ||
y: f - a - m - i, | ||
x: d - g - E - r | ||
}; | ||
}; | ||
function Se(t, e, n, o, s, c, r, l, g) { | ||
let h = 0, d = 0, A = !1; | ||
function Ee(t, e, n, o, s, i, r, a, g) { | ||
let f = 0, d = 0, E = !1; | ||
if (n === o) | ||
return Lt( | ||
{ height: h, width: d }, | ||
{ height: f, width: d }, | ||
t, | ||
s, | ||
r | ||
r, | ||
E | ||
); | ||
if (n < 0 && g) { | ||
A = !0; | ||
const [m] = e, { x: G, y: N } = Te( | ||
m, | ||
E = !0; | ||
const [D] = e, { x: G, y: N } = Se( | ||
D, | ||
g, | ||
t | ||
); | ||
h += N, d += G; | ||
f += N, d += G; | ||
} | ||
const { sourceElement: D, targetElement: E, siblingsBetween: S, isDraggedFoward: x } = xe(e, n, o, g), { | ||
const { sourceElement: m, targetElement: b, siblingsBetween: x, isDraggedFoward: A } = Ge(e, n, o, g), { | ||
scrollElement: T, | ||
beforeMargin: z, | ||
afterMargin: _, | ||
distance: W, | ||
gap: $ | ||
} = R(t), { gap: k, hasGaps: I } = xt(l, $), { | ||
beforeMargin: C, | ||
afterMargin: H, | ||
spaceBeforeDraggedElement: P | ||
} = Ge( | ||
beforeMargin: O, | ||
afterMargin: z, | ||
distance: k, | ||
gap: X | ||
} = R(t), { gap: W, hasGaps: C } = xt(a, X), { | ||
beforeMargin: Y, | ||
afterMargin: V, | ||
spaceBeforeDraggedElement: H | ||
} = Ae( | ||
O, | ||
z, | ||
_, | ||
D, | ||
E == null ? void 0 : E.previousElementSibling, | ||
m, | ||
b == null ? void 0 : b.previousElementSibling, | ||
A, | ||
C | ||
), { beforeSpace: F, space: I, afterSpace: l } = Re( | ||
O, | ||
z, | ||
k, | ||
x, | ||
I | ||
), { beforeSpace: F, space: X, afterSpace: a } = ye( | ||
z, | ||
_, | ||
W, | ||
S, | ||
k, | ||
I | ||
), u = Ee( | ||
X, | ||
C | ||
), u = ye( | ||
I, | ||
F, | ||
a, | ||
C, | ||
H, | ||
k | ||
), f = A ? 0 : be(T, l, c), y = (x ? u - P : P - u) - f; | ||
return t === "vertical" ? h += y : t === "horizontal" && (d += y), Lt( | ||
{ height: h, width: d }, | ||
l, | ||
Y, | ||
V, | ||
W | ||
), h = E ? 0 : xe(T, a, i), y = (A ? u - H : H - u) - h; | ||
return t === "vertical" ? f += y : t === "horizontal" && (d += y), Lt( | ||
{ height: f, width: d }, | ||
t, | ||
s, | ||
r | ||
r, | ||
E | ||
); | ||
} | ||
const be = (t, e, n) => { | ||
const xe = (t, e, n) => { | ||
const o = e[t], s = n[t]; | ||
return o - s; | ||
}, Ee = (t, e, n, o, s, c) => { | ||
}, ye = (t, e, n, o, s, i) => { | ||
const r = Math.max(e, s); | ||
return Math.max(n, o) + t + r + c; | ||
}, xe = (t, e, n, o) => { | ||
const s = e < n, [c, r] = [e, n].toSorted( | ||
(d, A) => d - A | ||
), l = t[e] ?? o, g = t[n]; | ||
let h = s ? t.slice(c + 1, r + 1) : t.slice(c, r); | ||
return c < 0 && o && (h = t.slice(c + 1, r)), { | ||
sourceElement: l, | ||
return Math.max(n, o) + t + r + i; | ||
}, Ge = (t, e, n, o) => { | ||
const s = e < n, [i, r] = [e, n].toSorted( | ||
(d, E) => d - E | ||
), a = t[e] ?? o, g = t[n]; | ||
let f = s ? t.slice(i + 1, r + 1) : t.slice(i, r); | ||
return i < 0 && o && (f = t.slice(i + 1, r)), { | ||
sourceElement: a, | ||
targetElement: g, | ||
siblingsBetween: h, | ||
siblingsBetween: f, | ||
isDraggedFoward: s | ||
}; | ||
}, ye = (t, e, n, o, s, c) => { | ||
}, Re = (t, e, n, o, s, i) => { | ||
if (o.length == 0) | ||
@@ -458,14 +467,14 @@ return { | ||
const r = B(o[0], t); | ||
let l = 0, g = -r; | ||
for (const [h, d] of o.entries()) { | ||
const A = d.getBoundingClientRect()[n], D = B(d, t); | ||
c && (l += D), c && h > 0 ? l += s : l = Math.max(l, D), g += l + A, l = B(d, e); | ||
let a = 0, g = -r; | ||
for (const [f, d] of o.entries()) { | ||
const E = d.getBoundingClientRect()[n], m = B(d, t); | ||
i && (a += m), i && f > 0 ? a += s : a = Math.max(a, m), g += a + E, a = B(d, e); | ||
} | ||
return { beforeSpace: r, space: g, afterSpace: l }; | ||
}, Lt = (t, e, n, o) => { | ||
const { scroll: s, distance: c } = R(e), r = window[s], g = n[s] - 2 * r + o[s]; | ||
return t[c] += g, t; | ||
}, Ge = (t, e, n, o, s, c) => { | ||
return { beforeSpace: r, space: g, afterSpace: a }; | ||
}, Lt = (t, e, n, o, s) => { | ||
const { scroll: i, distance: r } = R(e), a = window[i], g = n[i], f = s ? 0 : g - 2 * a + o[i]; | ||
return t[r] += f, t; | ||
}, Ae = (t, e, n, o, s, i) => { | ||
const r = s ? n.previousElementSibling : o; | ||
return Ae( | ||
return Ce( | ||
t, | ||
@@ -475,5 +484,5 @@ e, | ||
n, | ||
c | ||
i | ||
); | ||
}, Ae = (t, e, n, o, s) => { | ||
}, Ce = (t, e, n, o, s) => { | ||
if (s) | ||
@@ -485,32 +494,32 @@ return { | ||
}; | ||
const c = B( | ||
const i = B( | ||
n, | ||
e | ||
), r = B(o, t); | ||
let l = Math.max(c, r); | ||
let a = Math.max(i, r); | ||
return { | ||
afterMargin: c, | ||
afterMargin: i, | ||
beforeMargin: r, | ||
spaceBeforeDraggedElement: l | ||
spaceBeforeDraggedElement: a | ||
}; | ||
}, Mt = "dragging-handler-class", Re = "dragging", Ce = "draggable", pt = "temp-child", Ne = "startDrop", Le = "drag", Me = "startDrag", Bt = "dropping", Be = "cubic-bezier(0.2, 0, 0, 1)"; | ||
function Oe(t, e, n, o, s, c) { | ||
const r = M(s), { direction: l, handlerSelector: g, onRemoveAtEvent: h, animationDuration: d } = t, A = (a, u, f, v, y) => { | ||
}, Mt = "dragging-handler-class", Ne = "dragging", Le = "draggable", pt = "temp-child", Me = "startDrop", Be = "drag", Oe = "startDrag", Bt = "dropping", we = "cubic-bezier(0.2, 0, 0, 1)"; | ||
function _e(t, e, n, o, s, i) { | ||
const r = M(s), { direction: a, handlerSelector: g, onRemoveAtEvent: f, animationDuration: d } = t, E = (l, u, h, v, y) => { | ||
if (!v) | ||
return; | ||
const { droppable: m, config: G } = v, N = Tt( | ||
a, | ||
const { droppable: D, config: G } = v, N = bt( | ||
l, | ||
u, | ||
G.direction, | ||
m | ||
D | ||
); | ||
ge(u) ? z( | ||
a, | ||
pe(u) ? O( | ||
l, | ||
u, | ||
N, | ||
f, | ||
h, | ||
v, | ||
y | ||
) : D( | ||
a, | ||
) : m( | ||
l, | ||
u, | ||
@@ -520,66 +529,66 @@ N, | ||
); | ||
}, D = (a, u, f, v) => { | ||
const { config: y, droppable: m } = v, { siblings: G } = dt(a, m), N = K(a, m); | ||
for (const [L, O] of G.entries()) { | ||
if (!O.classList.contains(Ce)) | ||
}, m = (l, u, h, v) => { | ||
const { config: y, droppable: D } = v, { siblings: G } = dt(l, D), N = Q(l, D); | ||
for (const [L, w] of G.entries()) { | ||
if (!w.classList.contains(Le)) | ||
continue; | ||
const Y = E( | ||
const P = b( | ||
y.direction, | ||
a, | ||
O, | ||
f | ||
l, | ||
w, | ||
h | ||
); | ||
if (!N && Y) | ||
f = Y; | ||
if (!N && P) | ||
h = P; | ||
else if (!N) | ||
continue; | ||
const U = G.length - L; | ||
S( | ||
f, | ||
x( | ||
h, | ||
U, | ||
y.direction, | ||
G | ||
), u === Me ? x(O, f) : u === Le && T(O, f); | ||
), u === Oe ? A(w, h) : u === Be && T(w, h); | ||
} | ||
}, E = (a, u, f, v) => { | ||
const { before: y, distance: m, axis: G } = R(a), N = u.getBoundingClientRect(), L = f.getBoundingClientRect(), O = N[y], Y = L[y], U = L[m], tt = Y + U / 2; | ||
if (f.getAnimations().length !== 0) | ||
}, b = (l, u, h, v) => { | ||
const { before: y, distance: D, axis: G } = R(l), N = u.getBoundingClientRect(), L = h.getBoundingClientRect(), w = N[y], P = L[y], U = L[D], et = P + U / 2; | ||
if (h.getAnimations().length !== 0) | ||
return; | ||
const Z = $t(f)[G], J = tt - Z; | ||
return O > J ? { height: 0, width: 0 } : v; | ||
}, S = (a, u, f, v) => { | ||
const Z = $t(h)[G], J = et - Z; | ||
return w > J ? { height: 0, width: 0 } : v; | ||
}, x = (l, u, h, v) => { | ||
const y = v.filter( | ||
(G) => G.classList.contains("draggable") | ||
).length, { distance: m } = R(f); | ||
a[m] == 0 ? r.value = Math.max(r.value, u) : r.value = Math.min(r.value, u - 1), r.value = Math.min(r.value, y); | ||
}, x = (a, u) => { | ||
const { width: f, height: v } = u; | ||
ot(a, v, f); | ||
}, T = (a, u) => { | ||
const { width: f, height: v } = u; | ||
ot(a, v, f), Et(a, d, Be); | ||
}, z = (a, u, f, v, y, m) => { | ||
const { droppable: G, droppableScroll: N, config: L } = y, { siblings: O, positionOnDroppable: Y } = dt( | ||
a, | ||
).length, { distance: D } = R(h); | ||
l[D] == 0 ? r.value = Math.max(r.value, u) : r.value = Math.min(r.value, u - 1), r.value = Math.min(r.value, y); | ||
}, A = (l, u) => { | ||
const { width: h, height: v } = u; | ||
st(l, v, h); | ||
}, T = (l, u) => { | ||
const { width: h, height: v } = u; | ||
st(l, v, h), Et(l, d, we); | ||
}, O = (l, u, h, v, y, D) => { | ||
const { droppable: G, droppableScroll: N, config: L } = y, { siblings: w, positionOnDroppable: P } = dt( | ||
l, | ||
G | ||
), U = O.toReversed(); | ||
U.splice(Y, 0, a); | ||
const { previousElement: tt, nextElement: et, targetIndex: Z } = _( | ||
a, | ||
Y, | ||
), U = w.toReversed(); | ||
U.splice(P, 0, l); | ||
const { previousElement: et, nextElement: nt, targetIndex: Z } = z( | ||
l, | ||
P, | ||
U, | ||
G | ||
); | ||
f = Tt( | ||
a, | ||
h = bt( | ||
l, | ||
u, | ||
L.direction, | ||
c, | ||
tt, | ||
et | ||
i, | ||
et, | ||
nt | ||
); | ||
const J = Ht(), lt = Se( | ||
const J = Ht(), ut = Ee( | ||
L.direction, | ||
U, | ||
Y, | ||
P, | ||
Z, | ||
@@ -590,69 +599,69 @@ J, | ||
G, | ||
a | ||
l | ||
); | ||
for (const [ut, rt] of O.toReversed().entries()) { | ||
let nt = f; | ||
Z - 1 >= ut && (nt = { height: 0, width: 0 }), u === Ne && !rt.classList.contains(pt) && W( | ||
rt, | ||
nt, | ||
a, | ||
lt | ||
for (const [gt, it] of w.toReversed().entries()) { | ||
let ot = h; | ||
Z - 1 >= gt && (ot = { height: 0, width: 0 }), u === Me && !it.classList.contains(pt) && k( | ||
it, | ||
ot, | ||
l, | ||
ut | ||
); | ||
} | ||
$( | ||
X( | ||
Z, | ||
a, | ||
l, | ||
L.onInsertEvent, | ||
G, | ||
m | ||
D | ||
); | ||
}, _ = (a, u, f, v) => { | ||
const m = K(a, v) ? u : r.value, G = () => u < m ? [m, m + 1] : u > m ? [m - 1, m] : [m - 1, m + 1], [N, L] = G(), O = f[N] ?? null, Y = f[L] ?? null; | ||
}, z = (l, u, h, v) => { | ||
const D = Q(l, v) ? u : r.value, G = () => u < D ? [D, D + 1] : u > D ? [D - 1, D] : [D - 1, D + 1], [N, L] = G(), w = h[N] ?? null, P = h[L] ?? null; | ||
return { | ||
previousElement: O, | ||
nextElement: Y, | ||
targetIndex: m | ||
previousElement: w, | ||
nextElement: P, | ||
targetIndex: D | ||
}; | ||
}, W = (a, u, f, v) => { | ||
ot(a, u.height, u.width), ot( | ||
f, | ||
}, k = (l, u, h, v) => { | ||
st(l, u.height, u.width), st( | ||
h, | ||
v.height, | ||
v.width | ||
); | ||
}, $ = (a, u, f, v, y) => { | ||
u.classList.add(Bt), k(v), setTimeout(() => { | ||
if (u.classList.remove(Bt), I(c), I(v), y != null) { | ||
const m = h(y); | ||
m && f(a, m); | ||
}, X = (l, u, h, v, y) => { | ||
u.classList.add(Bt), W(v), setTimeout(() => { | ||
if (u.classList.remove(Bt), C(i), C(v), y != null) { | ||
const D = f(y); | ||
D && h(l, D); | ||
} | ||
P(u), C(u, c), C(u, v); | ||
H(u), Y(u, i), Y(u, v); | ||
}, d); | ||
}, k = (a) => { | ||
if (c.isSameNode(a)) | ||
}, W = (l) => { | ||
if (i.isSameNode(l)) | ||
return; | ||
var [u] = c.querySelectorAll(`.${pt}`); | ||
var [u] = i.querySelectorAll(`.${pt}`); | ||
if (!u) | ||
return; | ||
const { distance: f } = R(l); | ||
Q(u) && (u.style[f] = "0px"); | ||
}, I = (a) => { | ||
var u = a.querySelectorAll(`.${pt}`); | ||
u.forEach((f) => { | ||
a.removeChild(f); | ||
const { distance: h } = R(a); | ||
tt(u) && (u.style[h] = "0px"); | ||
}, C = (l) => { | ||
var u = l.querySelectorAll(`.${pt}`); | ||
u.forEach((h) => { | ||
l.removeChild(h); | ||
}); | ||
}, C = (a, u) => { | ||
const { siblings: f } = dt(a, u); | ||
for (const v of [...f, a]) | ||
H(v); | ||
}, H = (a) => { | ||
Q(a) && (a.style.transition = "", a.style.transform = ""); | ||
}, P = (a) => { | ||
e.value = V.NOT_DRAGGING, X(a, !1), a.style.transform = "", a.style.transition = "", a.style.top = "", a.style.left = "", n.value = "", o.value = ""; | ||
}, F = (a, u) => { | ||
const f = u.querySelector(g); | ||
f ? f.classList.toggle(Mt, a) : u.classList.toggle(Mt, a); | ||
}, X = (a, u) => { | ||
a.classList.toggle(Re, u), F(u, a); | ||
}, Y = (l, u) => { | ||
const { siblings: h } = dt(l, u); | ||
for (const v of [...h, l]) | ||
V(v); | ||
}, V = (l) => { | ||
tt(l) && (l.style.transition = "", l.style.transform = ""); | ||
}, H = (l) => { | ||
e.value = $.NOT_DRAGGING, I(l, !1), l.style.transform = "", l.style.transition = "", l.style.top = "", l.style.left = "", n.value = "", o.value = ""; | ||
}, F = (l, u) => { | ||
const h = u.querySelector(g); | ||
h ? h.classList.toggle(Mt, l) : u.classList.toggle(Mt, l); | ||
}, I = (l, u) => { | ||
l.classList.toggle(Ne, u), F(u, l); | ||
}; | ||
return { emitEventToSiblings: A, toggleDraggingClass: X }; | ||
return { emitEventToSiblings: E, toggleDraggingClass: I }; | ||
} | ||
@@ -662,3 +671,3 @@ const q = class q { | ||
const o = q.configs.filter( | ||
(c) => !c.droppable.isSameNode(e) | ||
(i) => !i.droppable.isSameNode(e) | ||
), s = Gt(e); | ||
@@ -683,3 +692,3 @@ o.push({ | ||
}; | ||
gt(q, "configs", []), gt(q, "removeObsoleteConfigs", () => { | ||
ft(q, "configs", []), ft(q, "removeObsoleteConfigs", () => { | ||
const e = q.configs.filter( | ||
@@ -698,25 +707,40 @@ ({ droppable: n }) => document.contains(n) | ||
o.observe(e, n); | ||
}, St = "temp-child", we = "startDrag", _e = "cubic-bezier(0.2, 0, 0, 1)", $e = (t, e, n) => { | ||
let o = Tt( | ||
}, Tt = "temp-child", $e = "startDrag", Ie = "cubic-bezier(0.2, 0, 0, 1)", Pe = (t, e, n) => { | ||
let o = bt( | ||
e, | ||
we, | ||
$e, | ||
n, | ||
t | ||
); | ||
const s = he(t, n), { distance: c } = R(n); | ||
return o[c] -= s, o; | ||
}, bt = (t, e, n) => { | ||
t.style.height = `${e}px`, t.style.minWidth = `${n}px`; | ||
}, Ie = (t, e, n) => (o) => { | ||
e.contains(t) && (bt(t, n.height, n.width), o.disconnect()); | ||
const s = me(t, n), { distance: i } = R(n); | ||
o[i] -= s; | ||
const { large: r, largeDistance: a } = ze(n, e); | ||
return o[a] = r, o; | ||
}, ze = (t, e) => { | ||
const n = t == "horizontal" ? "vertical" : "horizontal", { distance: o } = R(n); | ||
return { | ||
large: e.getBoundingClientRect()[o], | ||
largeDistance: o | ||
}; | ||
}, St = (t, e, n) => { | ||
t.style.height = `${e}px`, t.style.width = `${n}px`, t.style.width = `${n}px`, t.style.minWidth = `${n}px`; | ||
}, Xe = (t, e, n) => (o) => { | ||
e.contains(t) && (St(t, n.height, n.width), o.disconnect()); | ||
}, We = (t, e) => { | ||
if (e != $.START_DRAGGING) | ||
return; | ||
const { droppable: n, config: o, droppableScroll: s } = t, { direction: i } = o, r = ce(o.direction, n, s) > 0.99, { scrollDistance: a, clientDistance: g, scrollElement: f } = R(i); | ||
r && (n[f] = n[a] - n[g]); | ||
}, Ot = (t, e, n, o) => { | ||
const { direction: s, animationDuration: c } = o; | ||
if (t.querySelector(`.${St}`) || !e) | ||
if (!o) | ||
return; | ||
var r = document.createElement("div"); | ||
r.classList.add(St), bt(r, 0, 0); | ||
const l = $e(t, e, s); | ||
Et(r, c, _e, "height, width"), n.isSameNode(t) && bt(r, l.height, l.width), Pt( | ||
Ie(r, t, l), | ||
t, | ||
const { droppable: s, config: i } = o, { direction: r, animationDuration: a } = i; | ||
if (We(o, n), s.querySelector(`.${Tt}`) || !t) | ||
return; | ||
var g = document.createElement("div"); | ||
g.classList.add(Tt), St(g, 0, 0); | ||
const f = Pe(s, t, r); | ||
Et(g, a, Ie, "height, width"), e.isSameNode(s) && St(g, f.height, f.width), Pt( | ||
Xe(g, s, f), | ||
s, | ||
{ | ||
@@ -726,88 +750,99 @@ childList: !0, | ||
} | ||
), t.appendChild(r); | ||
}, Pe = (t, e, n, o) => { | ||
), s.appendChild(g); | ||
}, Ye = (t, e, n, o) => { | ||
if (n) { | ||
var s = document.querySelectorAll( | ||
`.${n} .${St}` | ||
`.${n} .${Tt}` | ||
); | ||
s.forEach((c) => { | ||
const r = c.parentElement; | ||
s.forEach((i) => { | ||
const r = i.parentElement; | ||
if (r != null && r.isSameNode(e) || r != null && r.isSameNode(t)) | ||
return; | ||
const l = c; | ||
l.style.width = "0px", l.style.height = "0px", setTimeout(() => { | ||
const a = i; | ||
a.style.width = "0px", a.style.height = "0px", setTimeout(() => { | ||
var g; | ||
(g = c.parentNode) == null || g.removeChild(c); | ||
(g = i.parentNode) == null || g.removeChild(i); | ||
}, o); | ||
}); | ||
} | ||
}, ht = "draggable", it = "handler-class", Xe = "dragging-handler-class", Ye = "droppable", Ve = "dropping", wt = "drag", ze = "startDrag", We = "startDrop", He = "cubic-bezier(0.2, 0, 0, 1)"; | ||
function Fe(t, e, n, o) { | ||
const { handlerSelector: s, isDraggable: c, droppableGroup: r, animationDuration: l } = n, g = r ? `droppable-group-${r}` : null, h = M(V.NOT_DRAGGING), d = M(t), A = M({ scrollLeft: 0, scrollTop: 0 }), D = M({ | ||
}, ht = "draggable", ct = "handler-class", Ve = "dragging-handler-class", He = "droppable", Fe = "dropping", wt = "drag", qe = "startDrag", ke = "startDrop", Ue = "cubic-bezier(0.2, 0, 0, 1)"; | ||
function Ze(t, e, n, o) { | ||
const { handlerSelector: s, isDraggable: i, droppableGroup: r, animationDuration: a } = n, g = r ? `droppable-group-${r}` : null, f = M($.NOT_DRAGGING), d = M(t), E = M({ scrollLeft: 0, scrollTop: 0 }), m = M({ | ||
scrollX: 0, | ||
scrollY: 0 | ||
}), E = M({ pageX: 0, pageY: 0 }), S = M(""), x = M(""), T = M(), z = M(), { setTransform: _, updateTransformState: W } = ie(d), { emitEventToSiblings: $, toggleDraggingClass: k } = Oe( | ||
}), b = M({ pageX: 0, pageY: 0 }), x = M(""), A = M(""), T = M(), O = M(), { setTransform: z, updateTransformState: k } = ae(d), { emitEventToSiblings: X, toggleDraggingClass: W } = _e( | ||
n, | ||
h, | ||
f, | ||
A, | ||
x, | ||
S, | ||
e, | ||
o | ||
), I = () => { | ||
), C = () => { | ||
d.value && d.value.classList.add(ht); | ||
}, C = () => { | ||
if (d.value && c(d.value)) { | ||
const i = d.value.querySelector(s); | ||
i ? i.classList.add(it) : d.value.classList.add(it); | ||
}, Y = () => { | ||
if (d.value && i(d.value)) { | ||
const c = d.value.querySelector(s); | ||
c ? c.classList.add(ct) : d.value.classList.add(ct); | ||
} | ||
}, H = () => { | ||
}, V = () => { | ||
se(o, [ | ||
`.${ht} { touch-action: manipulation; user-select: none; box-sizing: border-box !important; -webkit-user-select: none; }`, | ||
`.${it} { cursor: grab; pointer-events: auto !important; }`, | ||
`.${ct} { cursor: grab; pointer-events: auto !important; }`, | ||
`.${ht} * { pointer-events: none; }`, | ||
".temp-child { touch-action: none; pointer-events: none; box-sizing: border-box !important; }", | ||
".temp-child { display: block ;touch-action: none; pointer-events: none; box-sizing: border-box !important; }", | ||
".temp-child { display: block ;touch-action: none; pointer-events: none; box-sizing: border-box !important; }", | ||
".droppable { box-sizing: border-box !important; }", | ||
".dragging { position: fixed; z-index: 5000; width: var(--fixedWidth) !important; height: var(--fixedHeight) !important; }", | ||
`.${Xe} { cursor: grabbing; cursor: grabbing; }`, | ||
`.${Ve} { pointer-events: none !important; }` | ||
]), C(), I(), P(); | ||
}, P = () => { | ||
`.${Ve} { cursor: grabbing; cursor: grabbing; }`, | ||
`.${Fe} { pointer-events: none !important; }` | ||
]), Y(), C(), H(); | ||
}, H = () => { | ||
g && o.classList.add(g); | ||
}, F = (i) => { | ||
const p = (i == null ? void 0 : i.querySelector(`.${it}`)) ?? i; | ||
p && i && c(i) && (At( | ||
}, F = (c) => { | ||
const p = (c == null ? void 0 : c.querySelector(`.${ct}`)) ?? c; | ||
p && c && i(c) && (Rt( | ||
p, | ||
"onmousedown", | ||
L("mousemove", "mouseup") | ||
), At( | ||
), Rt( | ||
p, | ||
"ontouchstart", | ||
L("touchmove", "touchend") | ||
)), o.classList.add(Ye); | ||
}, X = function(i) { | ||
T.value = m(i), h.value === V.START_DRAGGING ? (Ot(o, d.value, o, n), Y(i)) : h.value === V.DRAGING && (a(), tt(i)); | ||
}, a = () => { | ||
)), o.classList.add(He); | ||
}, I = function(c) { | ||
T.value = D(c), f.value === $.START_DRAGGING ? (Ot( | ||
d.value, | ||
o, | ||
f.value, | ||
T.value | ||
), P(c)) : f.value === $.DRAGING && (l(), et(c)); | ||
}, l = () => { | ||
if (!T.value) | ||
return; | ||
const { droppable: i, config: p } = T.value; | ||
Pe( | ||
i, | ||
const { droppable: c } = T.value; | ||
Ye( | ||
c, | ||
o, | ||
g, | ||
l | ||
), Ot(i, d.value, o, p); | ||
}, u = (i, p, b) => document.elementsFromPoint(i, p).filter((w) => !w.isSameNode(b)), f = (i, p) => { | ||
i.hidden = !0; | ||
const [b] = u( | ||
a | ||
), Ot( | ||
d.value, | ||
o, | ||
f.value, | ||
T.value | ||
); | ||
}, u = (c, p, S) => document.elementsFromPoint(c, p).filter((_) => !_.isSameNode(S)), h = (c, p) => { | ||
c.hidden = !0; | ||
const [S] = u( | ||
p.clientX, | ||
p.clientY, | ||
i | ||
c | ||
); | ||
return i.hidden = !1, !g || !b ? void 0 : b.closest(`.${g}`); | ||
}, v = (i) => Array.from( | ||
return c.hidden = !1, !g || !S ? void 0 : S.closest(`.${g}`); | ||
}, v = (c) => Array.from( | ||
document.querySelectorAll(`.${g}`) | ||
).every( | ||
(b) => K(i, b) | ||
), y = (i, p) => !K(i, p) || v(i), m = (i) => { | ||
var w; | ||
(S) => Q(c, S) | ||
), y = (c, p) => !Q(c, p) || v(c), D = (c) => { | ||
var _, K; | ||
const p = d.value; | ||
@@ -818,103 +853,106 @@ if (!p) | ||
p, | ||
(w = T.value) == null ? void 0 : w.droppable | ||
(_ = T.value) == null ? void 0 : _.droppable | ||
) || T.value && y( | ||
p, | ||
(K = T.value) == null ? void 0 : K.droppable | ||
)) | ||
return T.value; | ||
const b = f(p, i); | ||
return b ? (Q(b) && !b.onscroll && et(b), j.getConfig(b)) : j.getConfig(o); | ||
}, G = (i) => { | ||
if (vt(i) && i.cancelable) | ||
i.preventDefault(); | ||
else if (vt(i)) | ||
const S = h(p, c); | ||
return S ? (tt(S) && !S.onscroll && nt(S), j.getConfig(S)) : j.getConfig(o); | ||
}, G = (c) => { | ||
if (vt(c) && c.cancelable) | ||
c.preventDefault(); | ||
else if (vt(c)) | ||
return; | ||
const p = mt(i); | ||
X(p); | ||
}, N = (i, p) => { | ||
i == "touchmove" ? z.value = setTimeout(() => { | ||
const p = mt(c); | ||
I(p); | ||
}, N = (c, p) => { | ||
c == "touchmove" ? O.value = setTimeout(() => { | ||
p(); | ||
}, 200) : p(); | ||
}, L = (i, p) => () => { | ||
const b = d.value; | ||
}, L = (c, p) => () => { | ||
const S = d.value; | ||
j.updateScrolls(o, g); | ||
const { scrollX: w, scrollY: ft } = window; | ||
D.value = { scrollX: w, scrollY: ft }, h.value === V.NOT_DRAGGING && (h.value = V.START_DRAGGING, N(i, () => { | ||
document.addEventListener(i, G, { | ||
const { scrollX: _, scrollY: K } = window; | ||
m.value = { scrollX: _, scrollY: K }, f.value === $.NOT_DRAGGING && (f.value = $.START_DRAGGING, N(c, () => { | ||
document.addEventListener(c, G, { | ||
passive: !1 | ||
}); | ||
}), et(o), b && document.addEventListener(p, O(i), { | ||
}), nt(o), S && document.addEventListener(p, w(c), { | ||
once: !0 | ||
})); | ||
}, O = (i) => (p) => { | ||
const b = mt(p); | ||
clearTimeout(z.value), lt(), document.removeEventListener(i, G); | ||
const w = m(b); | ||
if (w) { | ||
const { droppable: ft } = w; | ||
ft.onscroll = null; | ||
}, w = (c) => (p) => { | ||
const S = mt(p); | ||
clearTimeout(O.value), ut(), document.removeEventListener(c, G); | ||
const _ = D(S); | ||
if (_) { | ||
const { droppable: K } = _; | ||
K.onscroll = null; | ||
} | ||
o.onscroll = null; | ||
}, Y = (i) => { | ||
}, P = (c) => { | ||
const p = d.value; | ||
p && (U(), $( | ||
p && (U(), X( | ||
p, | ||
ze, | ||
D.value, | ||
qe, | ||
m.value, | ||
T.value | ||
), W(i, p), rt(p)); | ||
), k(c, p), it(p)); | ||
}, U = () => { | ||
A.value = Wt(o), h.value = V.DRAGING; | ||
}, tt = (i) => { | ||
const { pageX: p, pageY: b } = i; | ||
E.value = { pageX: p, pageY: b }, J(); | ||
}, et = (i) => { | ||
ee(i, "onscroll", Z); | ||
E.value = Vt(o), f.value = $.DRAGING; | ||
}, et = (c) => { | ||
const { pageX: p, pageY: S } = c; | ||
b.value = { pageX: p, pageY: S }, J(); | ||
}, nt = (c) => { | ||
ee(c, "onscroll", Z); | ||
}, Z = () => { | ||
J(); | ||
}, J = () => { | ||
const i = d.value; | ||
if (E.value.pageX == 0 && E.value.pageY == 0 || !T.value) | ||
const c = d.value; | ||
if (b.value.pageX == 0 && b.value.pageY == 0 || !T.value) | ||
return; | ||
const { droppable: p, config: b } = T.value; | ||
_(i, p, E, b.direction), $( | ||
i, | ||
const { droppable: p, config: S } = T.value; | ||
z(c, p, b, S.direction), X( | ||
c, | ||
wt, | ||
D.value, | ||
m.value, | ||
T.value | ||
); | ||
}, lt = () => { | ||
if (h.value !== V.DRAGING) { | ||
h.value = V.NOT_DRAGGING; | ||
}, ut = () => { | ||
if (f.value !== $.DRAGING) { | ||
f.value = $.NOT_DRAGGING; | ||
return; | ||
} | ||
h.value = V.END_DRAGGING; | ||
const i = d.value; | ||
i && (ut(i), $( | ||
i, | ||
We, | ||
D.value, | ||
f.value = $.END_DRAGGING; | ||
const c = d.value; | ||
c && (gt(c), X( | ||
c, | ||
ke, | ||
m.value, | ||
T.value, | ||
e | ||
)); | ||
}, ut = (i) => { | ||
Et(i, l, He), ot(i, 0, 0); | ||
}, rt = (i) => { | ||
const { height: p, width: b } = i.getBoundingClientRect(); | ||
x.value = `${p}px`, S.value = `${b}px`, k(i, !0), i.style.transition = ""; | ||
}, nt = (i, p) => { | ||
st(i, (b) => { | ||
const w = d.value; | ||
w && w.style.setProperty(p, b); | ||
}, gt = (c) => { | ||
Et(c, a, Ue), st(c, 0, 0); | ||
}, it = (c) => { | ||
const { height: p, width: S } = c.getBoundingClientRect(); | ||
A.value = `${p}px`, x.value = `${S}px`, W(c, !0), c.style.transition = ""; | ||
}, ot = (c, p) => { | ||
rt(c, (S) => { | ||
const _ = d.value; | ||
_ && _.style.setProperty(p, S); | ||
}); | ||
}; | ||
st(T, (i, p) => { | ||
d.value && p && h.value == V.DRAGING && !(i != null && i.droppable.isSameNode(p.droppable)) && $( | ||
rt(T, (c, p) => { | ||
d.value && p && f.value == $.DRAGING && !(c != null && c.droppable.isSameNode(p.droppable)) && X( | ||
d.value, | ||
wt, | ||
D.value, | ||
m.value, | ||
p | ||
); | ||
}, { deep: !0 }), nt(S, "--fixedWidth"), nt(x, "--fixedHeight"), H(), F(d.value); | ||
}, { deep: !0 }), ot(x, "--fixedWidth"), ot(A, "--fixedHeight"), V(), F(d.value); | ||
} | ||
const qe = "vertical", _t = (t, e, n) => { | ||
const je = "vertical", _t = (t, e, n) => { | ||
const o = { | ||
direction: qe, | ||
direction: je, | ||
handlerSelector: "draggable", | ||
@@ -936,15 +974,15 @@ isDraggable: () => !0, | ||
}; | ||
function je(t, e) { | ||
const n = "index", o = M(), s = (D) => (E) => Vt(D, E), c = (D) => (E, S) => zt(D, E, S), r = s(t), l = c(t), g = () => { | ||
function tn(t, e) { | ||
const n = "index", o = M(), s = (m) => (b) => Wt(m, b), i = (m) => (b, x) => Yt(m, b, x), r = s(t), a = i(t), g = () => { | ||
if (o.value) | ||
for (const D of o.value.children) { | ||
const E = D.getAttribute(n), S = Ft(E), x = D; | ||
x && S >= 0 && Fe( | ||
for (const m of o.value.children) { | ||
const b = m.getAttribute(n), x = Ft(b), A = m; | ||
A && x >= 0 && Ze( | ||
A, | ||
x, | ||
S, | ||
_t(r, l, e), | ||
_t(r, a, e), | ||
o.value | ||
); | ||
} | ||
}, h = () => { | ||
}, f = () => { | ||
o.value && Pt( | ||
@@ -959,14 +997,14 @@ () => { | ||
o.value && o.value.classList.add("droppable"); | ||
}, A = () => { | ||
}, E = () => { | ||
o.value && j.addConfig( | ||
o.value, | ||
_t(r, l, e) | ||
_t(r, a, e) | ||
); | ||
}; | ||
return st(o, () => { | ||
d(), A(), h(), g(), j.removeObsoleteConfigs(); | ||
return rt(o, () => { | ||
d(), E(), f(), g(), j.removeObsoleteConfigs(); | ||
}), { parent: o }; | ||
} | ||
export { | ||
je as useDragAndDrop | ||
tn as useDragAndDrop | ||
}; |
{ | ||
"name": "vue-fluid-dnd", | ||
"version": "0.6.14", | ||
"version": "0.6.15", | ||
"description": "A Vue 3 drag and drop library to sort all kind of lists", | ||
@@ -5,0 +5,0 @@ "type": "module", |
Sorry, the diff of this file is not supported yet
63759
24
1305