UNPKG

vuestic-ui

Version:
44 lines (43 loc) 1.12 kB
import { shallowReactive, computed } from "vue"; import { u as useComponentUuid } from "./useComponentUuid.mjs"; const modalsStack = shallowReactive([]); const useModalLevel = () => { const modalId = useComponentUuid(); const modalLevel = computed( () => modalsStack.findIndex(({ id }) => id === String(modalId)) ); const registerModal = () => { if (modalLevel.value !== -1) { return; } modalsStack.push({ id: String(modalId) }); }; const unregisterModal = () => { if (modalLevel.value === -1) { return; } modalsStack.splice(modalLevel.value, 1); }; const isTopLevelModal = computed( () => modalLevel.value !== -1 && modalLevel.value === modalsStack.length - 1 ); const isLowestLevelModal = computed( () => modalLevel.value === 0 ); const isMoreThenOneModalOpen = computed(() => modalsStack.length > 1); return { modalId, modalLevel, registerModal, unregisterModal, isTopLevelModal, isLowestLevelModal, isMoreThenOneModalOpen }; }; export { useModalLevel as u }; //# sourceMappingURL=useModalLevel.mjs.map