UNPKG

fluid-dnd

Version:

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

48 lines (47 loc) 1.1 kB
var l = Object.defineProperty; var d = (n, t, e) => t in n ? l(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e; var i = (n, t, e) => d(n, typeof t != "symbol" ? t + "" : t, e); import { H as c } from "../HandlerPublisher-FfZFZOWF.js"; import { n as h } from "../index-CU_UvYra.js"; class m { constructor(t) { i(this, "items"); i(this, "parent"); this.items = t; } setParent(t) { this.parent = t; } removeAtEvent(t) { const e = this.items; if (e.length <= 0) return; const [r] = e.splice(t, 1); return r; } insertEvent(t, e) { this.items.splice(t, 0, e); } getLength() { return this.items.length; } getValue(t) { return this.items[t]; } insertToListEmpty(t, e, r) { import("../insert-C4OmG7nn.js").then(({ insertToListEmpty: s }) => { s(t, this.parent, e, r); }); } } const u = new c(); function D(n, t) { const e = new m(n), [r, s, a] = h(e, u, t, "data-index"); return [(o) => (e.setParent(o), a(o), { destroy() { } }), s, r]; } export { D as useDragAndDrop };