@scalar/draggable
Advanced tools
Comparing version 0.1.8 to 0.1.9
# @scalar/draggable | ||
## 0.1.9 | ||
### Patch Changes | ||
- f500435: chore: stricter TypeScript configuration | ||
- 34e6f52: feat: upgrade to stricter tsconfig | ||
## 0.1.8 | ||
@@ -4,0 +11,0 @@ |
@@ -66,10 +66,5 @@ import { type DraggingItem, type HoveredItem } from './store'; | ||
}, string, import("vue").PublicProps, Readonly<DraggableProps> & Readonly<{ | ||
onOnDragEnd?: ((draggingItem: DraggingItem, hoveredItem: HoveredItem) => any) | undefined; | ||
onOnDragStart?: ((draggingItem: DraggingItem) => any) | undefined; | ||
}>, { | ||
ceiling: number; | ||
floor: number; | ||
isDraggable: boolean; | ||
isDroppable: boolean | ((draggingItem: DraggingItem, hoveredItem: HoveredItem) => boolean); | ||
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, HTMLDivElement>; | ||
onOnDragEnd?: (draggingItem: DraggingItem, hoveredItem: HoveredItem) => any; | ||
onOnDragStart?: (draggingItem: DraggingItem) => any; | ||
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, HTMLDivElement>; | ||
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>; | ||
@@ -76,0 +71,0 @@ export default _default; |
@@ -1,64 +0,4 @@ | ||
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), n = b(null), C = (s, d) => { | ||
let o = !1; | ||
return function(...t) { | ||
o || (s(...t), o = !0, setTimeout(() => o = !1, d)); | ||
}; | ||
}, L = ["draggable"], k = /* @__PURE__ */ S({ | ||
__name: "Draggable", | ||
props: { | ||
ceiling: { default: 0.8 }, | ||
floor: { default: 0.2 }, | ||
isDraggable: { type: Boolean, default: !0 }, | ||
isDroppable: { type: [Boolean, Function], default: !0 }, | ||
parentIds: {}, | ||
id: {} | ||
}, | ||
emits: ["onDragEnd", "onDragStart"], | ||
setup(s, { expose: d, emit: o }) { | ||
const t = s, f = o, u = v(() => t.parentIds.at(-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: u.value }, f("onDragStart", { id: t.id, parentId: u.value })); | ||
}, _ = (e) => typeof t.isDroppable == "function" ? t.isDroppable(r.value, { | ||
id: t.id, | ||
parentId: u.value, | ||
offset: e | ||
}) : t.isDroppable, c = C((e) => { | ||
if (!r.value || r.value.id === t.id || t.parentIds.includes(r.value?.id ?? "")) | ||
return; | ||
const a = n.value?.offset, l = e.target.offsetHeight, g = t.floor * l, p = t.ceiling * l; | ||
let i = 3; | ||
e.offsetY <= 0 && a && a !== 3 ? i = a : e.offsetY <= g ? i = 0 : e.offsetY >= p ? i = 1 : e.offsetY > g && e.offsetY < p && (i = 2), _(i) && (n.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-${h[n.value.offset]}`), e; | ||
}), y = () => { | ||
if (!n.value || !r.value) return; | ||
const e = { ...r.value }, a = { ...n.value }; | ||
r.value = null, n.value = null, document.querySelectorAll("div.dragging").forEach((l) => l.classList.remove("dragging")), e.id !== a.id && f("onDragEnd", e, a); | ||
}; | ||
return d({ | ||
draggingItem: r, | ||
hoveredItem: n | ||
}), (e, a) => (T(), Y("div", { | ||
class: w(E.value), | ||
draggable: e.isDraggable, | ||
onDragend: y, | ||
onDragover: a[0] || (a[0] = m( | ||
//@ts-ignore | ||
(...l) => D(c) && D(c)(...l), | ||
["prevent", "stop"] | ||
)), | ||
onDragstart: m(I, ["stop"]) | ||
}, [ | ||
B(e.$slots, "default", {}, void 0, !0) | ||
], 42, L)); | ||
} | ||
}), O = (s, d) => { | ||
const o = s.__vccOpts || s; | ||
for (const [t, f] of d) | ||
o[t] = f; | ||
return o; | ||
}, A = /* @__PURE__ */ O(k, [["__scopeId", "data-v-1c336fff"]]); | ||
import { default as r } from "./Draggable.vue.js"; | ||
export { | ||
A as Draggable | ||
r as Draggable | ||
}; |
@@ -16,3 +16,3 @@ { | ||
], | ||
"version": "0.1.8", | ||
"version": "0.1.9", | ||
"engines": { | ||
@@ -26,6 +26,15 @@ "node": ">=18" | ||
"import": "./dist/index.js", | ||
"require": "./dist/index.cjs", | ||
"types": "./dist/index.d.ts" | ||
"types": "./dist/index.d.ts", | ||
"default": "./dist/index.js" | ||
}, | ||
"./*.css": "./dist/*.css" | ||
"./css/*.css": { | ||
"import": "./dist/css/*.css", | ||
"require": "./dist/css/*.css", | ||
"default": "./dist/css/*.css" | ||
}, | ||
"./*.css": { | ||
"import": "./dist/*.css", | ||
"require": "./dist/*.css", | ||
"default": "./dist/*.css" | ||
} | ||
}, | ||
@@ -43,8 +52,8 @@ "files": [ | ||
"vite": "^5.4.10", | ||
"vite-plugin-dts": "^4.3.0", | ||
"vite-svg-loader": "^5.1.0", | ||
"vue": "^3.5.12" | ||
"vue": "^3.5.12", | ||
"@scalar/build-tooling": "0.1.12" | ||
}, | ||
"scripts": { | ||
"build": "vite build && pnpm types:build && tsc-alias -p tsconfig.build.json", | ||
"build": "scalar-build-vite", | ||
"dev": "vite", | ||
@@ -55,5 +64,5 @@ "lint:check": "eslint .", | ||
"test": "vitest", | ||
"types:build": "vue-tsc -p tsconfig.build.json", | ||
"types:check": "vue-tsc --noEmit --skipLibCheck --composite false" | ||
"types:build": "scalar-types-build-vue", | ||
"types:check": "scalar-types-check-vue" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
19
219
1
16338