@bitrix24/b24ui-nuxt
Version:
Bitrix24 UI-Kit for developing web applications REST API for NUXT & VUE
18 lines (17 loc) • 650 B
JavaScript
import { inject, provide, computed } from "vue";
export const portalTargetInjectionKey = Symbol("bitrix24-ui.portal-target");
export function usePortal(portal) {
const portalTarget = inject(portalTargetInjectionKey, void 0);
const to = computed(() => {
if (typeof portal.value === "boolean" || portal.value === void 0) {
return portalTarget?.value ?? "body";
}
return portal.value;
});
const disabled = computed(() => typeof portal.value === "boolean" ? !portal.value : false);
provide(portalTargetInjectionKey, computed(() => to.value));
return computed(() => ({
to: to.value,
disabled: disabled.value
}));
}