@scalar/draggable
Advanced tools
Comparing version 0.1.4 to 0.1.5
# @scalar/draggable | ||
## 0.1.5 | ||
### Patch Changes | ||
- e9253af: fix(api-client): scope api client draggable styles | ||
## 0.1.4 | ||
@@ -4,0 +10,0 @@ |
@@ -1,8 +0,8 @@ | ||
import { ref as b, defineComponent as T, computed as v, openBlock as Y, createElementBlock as w, normalizeClass as y, withModifiers as m, unref as D, renderSlot as B } from "vue"; | ||
const r = b(null), n = b(null), C = (d, f) => { | ||
let l = !1; | ||
import { ref as b, defineComponent as S, computed as v, openBlock as T, createElementBlock as Y, normalizeClass as w, withModifiers as m, unref as D, renderSlot as B } from "vue"; | ||
const r = b(null), o = b(null), C = (s, d) => { | ||
let n = !1; | ||
return function(...t) { | ||
l || (d(...t), l = !0, setTimeout(() => l = !1, f)); | ||
n || (s(...t), n = !0, setTimeout(() => n = !1, d)); | ||
}; | ||
}, L = ["draggable"], A = /* @__PURE__ */ T({ | ||
}, L = ["draggable"], k = /* @__PURE__ */ S({ | ||
__name: "Draggable", | ||
@@ -18,10 +18,10 @@ props: { | ||
emits: ["onDragEnd", "onDragStart"], | ||
setup(d, { expose: f, emit: l }) { | ||
const t = d, u = l, i = v( | ||
setup(s, { expose: d, emit: n }) { | ||
const t = s, f = n, u = v( | ||
() => (t.parentIds.length ?? 0) > 0 ? t.parentIds[t.parentIds.length - 1] : null | ||
), I = (e) => { | ||
!e.dataTransfer || !(e.target instanceof HTMLElement) || !t.isDraggable || (e.target.classList.add("dragging"), e.dataTransfer.dropEffect = "move", e.dataTransfer.effectAllowed = "move", r.value = { id: t.id, parentId: i.value }, u("onDragStart", { id: t.id, parentId: i.value })); | ||
}, h = (e) => typeof t.isDroppable == "function" ? t.isDroppable(r.value, { | ||
!e.dataTransfer || !(e.target instanceof HTMLElement) || !t.isDraggable || (e.target.classList.add("dragging"), e.dataTransfer.dropEffect = "move", e.dataTransfer.effectAllowed = "move", r.value = { id: t.id, parentId: u.value }, f("onDragStart", { id: t.id, parentId: u.value })); | ||
}, _ = (e) => typeof t.isDroppable == "function" ? t.isDroppable(r.value, { | ||
id: t.id, | ||
parentId: i.value, | ||
parentId: u.value, | ||
offset: e | ||
@@ -31,23 +31,23 @@ }) : t.isDroppable, g = C((e) => { | ||
return; | ||
const a = n.value?.offset, o = e.target.offsetHeight, c = t.floor * o, p = t.ceiling * o; | ||
let s = 3; | ||
e.offsetY <= 0 && a && a !== 3 ? s = a : e.offsetY <= c ? s = 0 : e.offsetY >= p ? s = 1 : e.offsetY > c && e.offsetY < p && (s = 2), h(s) && (n.value = { id: t.id, parentId: i.value, offset: s }); | ||
}, 25), E = ["above", "below", "asChild"], _ = v(() => { | ||
const a = o.value?.offset, l = e.target.offsetHeight, c = t.floor * l, p = t.ceiling * l; | ||
let i = 3; | ||
e.offsetY <= 0 && a && a !== 3 ? i = a : e.offsetY <= c ? i = 0 : e.offsetY >= p ? i = 1 : e.offsetY > c && e.offsetY < p && (i = 2), _(i) && (o.value = { id: t.id, parentId: u.value, offset: i }); | ||
}, 25), h = ["above", "below", "asChild"], E = v(() => { | ||
let e = "sidebar-indent-nested"; | ||
return t.id === n.value?.id && (e += ` dragover-${E[n.value.offset]}`), e; | ||
}), S = () => { | ||
if (!n.value || !r.value) return; | ||
const e = { ...r.value }, a = { ...n.value }; | ||
r.value = null, n.value = null, document.querySelectorAll("div.dragging").forEach((o) => o.classList.remove("dragging")), e.id !== a.id && u("onDragEnd", e, a); | ||
return t.id === o.value?.id && (e += ` dragover-${h[o.value.offset]}`), e; | ||
}), y = () => { | ||
if (!o.value || !r.value) return; | ||
const e = { ...r.value }, a = { ...o.value }; | ||
r.value = null, o.value = null, document.querySelectorAll("div.dragging").forEach((l) => l.classList.remove("dragging")), e.id !== a.id && f("onDragEnd", e, a); | ||
}; | ||
return f({ | ||
return d({ | ||
draggingItem: r, | ||
hoveredItem: n | ||
}), (e, a) => (Y(), w("div", { | ||
class: y(_.value), | ||
hoveredItem: o | ||
}), (e, a) => (T(), Y("div", { | ||
class: w(E.value), | ||
draggable: e.isDraggable, | ||
onDragend: S, | ||
onDragend: y, | ||
onDragover: a[0] || (a[0] = m( | ||
//@ts-ignore | ||
(...o) => D(g) && D(g)(...o), | ||
(...l) => D(g) && D(g)(...l), | ||
["prevent", "stop"] | ||
@@ -57,8 +57,13 @@ )), | ||
}, [ | ||
B(e.$slots, "default") | ||
B(e.$slots, "default", {}, void 0, !0) | ||
], 42, L)); | ||
} | ||
}); | ||
}), O = (s, d) => { | ||
const n = s.__vccOpts || s; | ||
for (const [t, f] of d) | ||
n[t] = f; | ||
return n; | ||
}, A = /* @__PURE__ */ O(k, [["__scopeId", "data-v-1c55d212"]]); | ||
export { | ||
A as Draggable | ||
}; |
@@ -16,3 +16,3 @@ { | ||
], | ||
"version": "0.1.4", | ||
"version": "0.1.5", | ||
"engines": { | ||
@@ -19,0 +19,0 @@ "node": ">=18" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
26474
213