UNPKG

@shopware-ag/meteor-component-library

Version:

The meteor component library is a Vue component library developed by Shopware. It is based on the [Meteor Design System](https://shopware.design/).

23 lines (16 loc) 618 B
import { inject, type InjectionKey, type Ref } from "vue"; interface StateDefinition { isOpen: Ref<boolean>; setIsOpen: (value: boolean) => void; closable: Ref<boolean>; } export const DialogContext = Symbol("DialogContext") as InjectionKey<StateDefinition>; export function useModalContext(component: string) { const context = inject(DialogContext, null); if (context === null) { const error = new Error(`<${component} /> is missing a parent <mt-modal-root /> component.`); if (Error.captureStackTrace) Error.captureStackTrace(error, useModalContext); throw error; } return context; }