UNPKG

bootstrap-vue-next

Version:

Seamless integration of Vue 3, Bootstrap 5, and TypeScript for modern, type-safe UI development

34 lines (33 loc) 1.37 kB
import { i as getSafeDocument } from "../../../dom-AhkaSoh8.mjs"; import { i as omit } from "../../../object-CHQkkner.mjs"; import { useScrollspy } from "../../composables/useScrollspy/index.mjs"; import { r as getDirectiveUid } from "../../../utils-CgwCsk6U.mjs"; import "vue"; //#region src/directives/BScrollspy/index.ts var bind = (el, binding) => { if (getSafeDocument() === null) return; const uid = getDirectiveUid(binding); const elWithScrollspy = el; elWithScrollspy.$__scrollspy = elWithScrollspy.$__scrollspy ?? Object.create(null); const existingInstance = elWithScrollspy.$__scrollspy[uid]; if (existingInstance) existingInstance.cleanup(); const { arg, value } = binding; const isObject = typeof value === "object" && value !== null; const content = arg ? arg : typeof value === "string" ? value : isObject ? value.content || value.element : null; elWithScrollspy.$__scrollspy[uid] = useScrollspy(content, el, isObject ? omit(value, ["content", "element"]) : {}); }; var vBScrollspy = { mounted: bind, updated: bind, beforeUnmount(el, binding) { const uid = getDirectiveUid(binding); const elWithScrollspy = el; const instance = elWithScrollspy.$__scrollspy?.[uid]; if (!instance) return; instance.cleanup(); delete elWithScrollspy.$__scrollspy[uid]; } }; //#endregion export { vBScrollspy }; //# sourceMappingURL=index.mjs.map