fluid-dnd
Version:
An agnostic drag and drop library to sort all kind of lists. With current support for vue, react and svelte
52 lines (51 loc) • 1.26 kB
JavaScript
var a = Object.defineProperty;
var u = (n, t, e) => t in n ? a(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
var i = (n, t, e) => u(n, typeof t != "symbol" ? t + "" : t, e);
import { ref as c, watch as m } from "vue";
import { H as h } from "../HandlerPublisher-FfZFZOWF.js";
import { n as p } from "../index-CU_UvYra.js";
const v = (n, t) => {
const e = n.value;
if (e.length <= 0)
return;
const [r] = e.splice(t, 1);
return r;
}, g = (n, t, e) => {
n.value.splice(t, 0, e);
}, d = (n) => n.value.length, V = (n, t) => n.value[t];
class f {
constructor(t, e) {
i(this, "items");
i(this, "parent");
this.items = t, this.parent = e;
}
removeAtEvent(t) {
return v(this.items, t);
}
insertEvent(t, e) {
return g(this.items, t, e);
}
getLength() {
return d(this.items);
}
getValue(t) {
return V(this.items, t);
}
insertToListEmpty(t, e, r) {
import("../insert-C4OmG7nn.js").then(({ insertToListEmpty: s }) => {
s(t, this.parent.value, e, r);
});
}
}
const A = new h();
function D(n, t) {
const e = c();
var r = new f(n, e);
const [s, o, l] = p(r, A, t);
return m(e, () => {
l(e.value);
}), [e, o, s];
}
export {
D as useDragAndDrop
};