@scalar/api-client
Version:
the open source API testing client
145 lines (144 loc) • 5.19 kB
JavaScript
import { defineComponent as h, computed as p, createElementBlock as c, openBlock as u, createElementVNode as t, createVNode as o, createBlock as f, createCommentVNode as y, withCtx as n, unref as s, resolveDynamicComponent as g, mergeProps as k } from "vue";
import { ScalarButton as i } from "@scalar/components";
import { ScalarIconFloppyDisk as b } from "@scalar/icons";
import { LibraryIcon as w } from "@scalar/icons/library";
import { RouterView as _ } from "vue-router";
import C from "../../../components/IconSelector.vue.js";
import S from "../../components/callout/Callout.vue.js";
import V from "./components/LabelInput.vue.js";
import B from "./components/Tabs.vue.js";
const D = { class: "custom-scroll h-full" }, N = {
key: 0,
class: "w-full px-3 md:mx-auto md:max-w-180"
}, z = ["aria-label"], I = { class: "flex flex-row items-center gap-2" }, T = { class: "group relative ml-1.25 flex-1" }, U = { class: "px-1.5 py-8" }, $ = {
key: 1,
class: "flex w-full flex-1 items-center justify-center"
}, j = {
name: "DocumentCollection"
}, G = /* @__PURE__ */ h({
...j,
props: {
documentSlug: {},
document: {},
eventBus: {},
layout: {},
path: {},
method: {},
exampleName: {},
environment: {},
securitySchemes: {},
workspaceStore: {},
activeWorkspace: {},
plugins: {},
customThemes: {},
currentTheme: {},
isDarkMode: { type: Boolean }
},
setup(a) {
const l = a, m = p(() => l.document?.info?.title ?? ""), d = p(
() => l.document?.["x-scalar-icon"] || "interface-content-folder"
), x = () => {
l.workspaceStore.revertDocumentChanges(l.documentSlug);
}, v = () => {
l.workspaceStore.saveDocument(l.documentSlug);
};
return (E, e) => (u(), c("div", D, [
a.document ? (u(), c("div", N, [
t("div", {
"aria-label": `title: ${m.value}`,
class: "mx-auto flex h-fit w-full flex-col gap-2 pt-14 pb-3 md:max-w-180 md:pt-6"
}, [
a.document?.["x-scalar-is-dirty"] ? (u(), f(S, {
key: 0,
class: "mb-5",
type: "warning"
}, {
actions: n(() => [
o(s(i), {
class: "text-c-2 hover:text-c-1 flex items-center gap-2",
size: "xs",
type: "button",
variant: "outlined",
onClick: x
}, {
default: n(() => [...e[2] || (e[2] = [
t("span", null, "Undo", -1)
])]),
_: 1
}),
o(s(i), {
class: "text-c-btn flex items-center gap-2",
size: "xs",
type: "button",
variant: "solid",
onClick: v
}, {
default: n(() => [
o(s(b), {
size: "sm",
thickness: "1.5"
}),
e[3] || (e[3] = t("span", null, "Save", -1))
]),
_: 1
})
]),
default: n(() => [
e[4] || (e[4] = t("p", null, " You have unsaved changes. Save your work to keep your changes, or undo to revert them. ", -1))
]),
_: 1
})) : y("", !0),
t("div", I, [
o(C, {
modelValue: d.value,
placement: "bottom-start",
"onUpdate:modelValue": e[0] || (e[0] = (r) => a.eventBus.emit("document:update:icon", r))
}, {
default: n(() => [
o(s(i), {
class: "hover:bg-b-2 aspect-square h-7 w-7 cursor-pointer rounded border border-transparent p-0 hover:border-inherit",
variant: "ghost"
}, {
default: n(() => [
o(s(w), {
class: "text-c-2 size-5",
src: d.value,
"stroke-width": "2"
}, null, 8, ["src"])
]),
_: 1
})
]),
_: 1
}, 8, ["modelValue"]),
t("div", T, [
o(V, {
class: "text-xl font-bold",
inputId: "documentName",
modelValue: m.value,
"onUpdate:modelValue": e[1] || (e[1] = (r) => a.eventBus.emit("document:update:info", { title: r }))
}, null, 8, ["modelValue"])
])
])
], 8, z),
o(B, { type: "document" }),
t("div", U, [
o(s(_), null, {
default: n(({ Component: r }) => [
(u(), f(g(r), k(l, { collectionType: "document" }), null, 16))
]),
_: 1
})
])
])) : (u(), c("div", $, [...e[5] || (e[5] = [
t("div", { class: "flex h-full flex-col items-center justify-center" }, [
t("h1", { class: "text-2xl font-bold" }, "Document not found"),
t("p", { class: "text-gray-500" }, " The document you are looking for does not exist. ")
], -1)
])]))
]));
}
});
export {
G as default
};