import SideDrawer from "@/components/common/SideDrawer.vue"; import { Component } from "vue"; export type DrawerWidth = "md" | "xl" | "lg"; export const drawerContext = Symbol("drawer") as InjectionKey< (c: Component, p: Record, s?: DrawerWidth) => void >; export const createDrawer = (drawer: Ref>) => { const component = shallowRef(null); const properties = shallowRef>({}); const width = ref("md"); const showDrawer = (c: Component, p: Record, w: DrawerWidth = "md") => { component.value = c; properties.value = p; width.value = w; drawer.value?.open(); }; provide(drawerContext, showDrawer); return { component, properties, showDrawer, width }; }; export const useDrawer = () => inject(drawerContext, () => { console.error("No drawer context provided"); });