@scalar/api-client
Version:
the open source API testing client
46 lines (45 loc) • 1.32 kB
JavaScript
import { useModal as d } from "@scalar/components";
import { reactive as p, createApp as u } from "vue";
import m from "../Modal.vue.js";
const M = ({ el: n, workspaceStore: o, mountOnInitialize: l = !0 }) => {
const c = {
path: "default",
method: "default",
example: "default",
documentSlug: o.workspace["x-scalar-active-document"] || "default"
}, s = p(c), t = d(), a = u(m, {
workspaceStore: o,
modalState: t
});
a.config.idPrefix = "scalar-client";
const r = (e = n) => {
if (!e) {
console.error(
"[@scalar/api-client] Could not create the API client Modal.",
"Invalid HTML element provided.",
"Read more: https://github.com/scalar/scalar/tree/main/packages/api-client"
);
return;
}
a.mount(e);
};
l && r();
const i = (e) => Object.assign(s, c, e);
return {
/** The vue app instance for the modal, be careful with this */
app: a,
/** Open the API client modal and optionally route to an example */
open: (e) => {
t.open = !0, e && i(e);
},
/** Mount the client to a given element */
mount: r,
/** "Route" to the specified path, method and example */
route: i,
/** Controls the visibility of the modal */
modalState: t
};
};
export {
M as createApiClientModal
};