UNPKG

bootstrap-vue-next

Version:

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

70 lines (69 loc) 2.21 kB
import { _ as orchestratorRegistryKey } from "../../../keys-BgLwJbLV.js"; import { buildController, getOrchestratorControllerId } from "../orchestratorShared/index.mjs"; import { u as BPopover_default } from "../../../floatingUi-BlKoACvc.js"; import { t as BTooltip_default } from "../../../BTooltip-BxaUtV4m.js"; import { computed, inject, markRaw, onScopeDispose, ref } from "vue"; //#region src/composables/usePopover/index.ts var usePopover = () => { const orchestratorRegistry = inject(orchestratorRegistryKey, null); if (!orchestratorRegistry) throw new Error("usePopover() must be called within setup(), and BApp, useRegistry or plugin must be installed/provided."); const { store, _isOrchestratorInstalled } = orchestratorRegistry; function create(obj, tooltip = false) { if (!_isOrchestratorInstalled.value) throw new Error("The BApp component must be mounted to use the popover controller"); const comp = markRaw(tooltip ? BTooltip_default : BPopover_default); const resolvedProps = ref(obj); const type = tooltip ? "tooltip" : "popover"; const pickedStore = computed(() => store.value[type]); const { htmlAttributeId, storeId } = getOrchestratorControllerId(resolvedProps.value.id); const { controller, resolve } = buildController(storeId, pickedStore); const value = computed({ get: () => { const { component = comp, options, slots, ...props } = resolvedProps.value; return { component, options, slots, id: storeId, fns: { resolve, setRef: (v) => { controller.ref = v; }, destroy: controller.destroy }, props: { ...props, id: htmlAttributeId } }; }, set: (v) => { resolvedProps.value = { ...resolvedProps.value, ...v.props }; } }); pickedStore.value.set(storeId, value); onScopeDispose(async () => { await controller[Symbol.asyncDispose](); }, true); return controller; } function tooltip(obj) { return create(obj, true); } function popover(obj) { return create(obj, false); } return { _isOrchestratorInstalled, create, popover, tooltip, store }; }; //#endregion export { usePopover }; //# sourceMappingURL=index.mjs.map