UNPKG

@scalar/api-client

Version:

the open source API testing client

45 lines (44 loc) 1.26 kB
import { ref as f } from "vue"; import { initializeWorkspaceEventHandlers as x } from "../../workspace-events.js"; function s({ eventBus: i, isSidebarOpen: o, sidebarState: n, modalState: m, store: c }) { x({ eventBus: i, store: f(c), hooks: {} }), i.on("scroll-to:nav-item", ({ id: e }) => n.handleSelectItem(e)), i.on("ui:toggle:sidebar", () => o.value = !o.value), i.on("ui:close:client-modal", () => m.hide()), i.on("ui:open:client-modal", (e) => { if (!e) { m.show(); return; } if ("id" in e && e.id) { let l = e.id; if ("exampleName" in e && e.exampleName) { const t = n.state.getEntryById(e.id); if (t && "children" in t && t.children) { const r = t.children.find( (h) => h.type === "example" && h.name === e.exampleName ); r && (l = r.id); } } n.handleSelectItem(l); } else "method" in e && "path" in e && n.handleSelectItem( n.getEntryByLocation({ document: c.workspace.activeDocument?.["x-scalar-navigation"]?.id ?? "", path: e.path, method: e.method, example: e.exampleName })?.id ?? "" ); m.show(); }); } export { s as initializeModalEvents };