filepond
Version:
FilePond, where files go to stretch their bits.
47 lines (46 loc) • 1.47 kB
JavaScript
/*!
* FilePond v5.0.2
* Copyright (c) 2017-2026 Pqina B.V.
* Released under the MIT License
* https://filepond.com
*/
import { boundsFromRect as E } from "../../utils/bounds.js";
import { rectCenter as g } from "../../utils/rect.js";
import { isVectorPointingTowardsPoint as i } from "../../utils/vector.js";
import { getClosestElement as a } from "./dom.js";
function T(o, t, f, m) {
if (!o)
return -1;
const s = o.closest("ul");
if (!s)
return -1;
const l = Array.from(s.children), e = a(l, t, m), n = e ? l.indexOf(e) : -1, r = o.getBoundingClientRect(), d = g(r);
return i(f, t, d) ? l.indexOf(o) : n;
}
function b(o, t, f, m) {
const s = Array.from(o.querySelectorAll("ul"));
if (!s.length)
return -1;
const l = a(s, t, m);
if (!l)
return -1;
const e = Array.from(l.children);
if (!e.length)
return -1;
const n = a(e, t, m), r = e.find((c) => c.dataset.placeholder === ""), d = r ? e.indexOf(r) : -1;
if (!r) {
const c = e.indexOf(n), u = n.getBoundingClientRect(), x = E(u), R = g(u);
return e.every((y) => y.getBoundingClientRect().x === u.x) ? t.y > R.y ? c + 1 : c : c === e.length - 1 && (t.x > x.right || t.y > x.bottom) ? c + 1 : c;
}
if (n === r)
return d;
const I = r.getBoundingClientRect(), h = g(I);
if (i(f, t, h))
return d;
const C = n.getBoundingClientRect(), p = g(C);
return i(f, t, p) ? e.indexOf(n) : d;
}
export {
T as getDragTargetIndex,
b as getDropTargetIndex
};