@scalar/api-reference
Version:
Generate beautiful API references from OpenAPI documents
108 lines (107 loc) • 4.07 kB
JavaScript
import { defineComponent as S, computed as f, resolveComponent as b, createElementBlock as I, openBlock as r, Fragment as T, renderList as L, createBlock as i, unref as a, withCtx as v, createCommentVNode as k, createVNode as y } from "vue";
import { getCurrentIndex as V } from "./get-current-index.js";
import B from "../../Lazy/Lazy.vue2.js";
import E from "../../Section/SectionContainer.vue.js";
import z from "../../../features/Operation/Operation.vue.js";
import M from "../Tags/Tag.vue.js";
const P = /* @__PURE__ */ S({
__name: "TraversedEntry",
props: {
level: { default: 0 },
hash: {},
rootIndex: {},
entries: {},
paths: {},
webhooks: {},
security: {},
activeCollection: {},
activeServer: {},
store: {},
options: {}
},
setup(t, { expose: g }) {
const n = (e) => e.type === "tag" && e.isGroup === !0, p = (e) => e.type === "tag" && !n(e), C = (e) => e.type === "operation", s = (e) => e.type === "webhook", c = f(() => t.level === 0), l = f(() => c.value ? t.rootIndex : V(t.hash, t.entries)), h = (e, u) => n(e) ? null : u < l.value ? "prev" : u > l.value + 2 ? "after" : null;
function w(e) {
return s(e) ? t.webhooks[e.name] : t.paths[e.path];
}
return g({
currentIndex: l,
isLazy: h
}), (e, u) => {
const d = b("TraversedEntry", !0);
return r(!0), I(T, null, L(e.entries, (o, m) => (r(), i(a(B), {
id: o.id,
key: o.id,
isLazy: !!h(o, m),
prev: h(o, m) === "prev"
}, {
default: v(() => [
C(o) || s(o) ? (r(), i(a(E), {
key: 0,
omit: !c.value
}, {
default: v(() => [
y(a(z), {
id: o.id,
collection: e.activeCollection,
method: o.method,
options: {
...e.options,
isWebhook: s(o)
},
path: s(o) ? o.name : o.path,
pathValue: w(o),
security: e.security,
server: e.activeServer,
store: e.store
}, null, 8, ["id", "collection", "method", "options", "path", "pathValue", "security", "server", "store"])
]),
_: 2
}, 1032, ["omit"])) : p(o) ? (r(), i(a(M), {
key: 1,
isLoading: !1,
layout: e.options.layout,
moreThanOneTag: e.entries.filter(p).length > 1,
onShowMore: e.options.onShowMore,
tag: o
}, {
default: v(() => [
"children" in o && o.children?.length ? (r(), i(d, {
key: 0,
activeCollection: e.activeCollection,
activeServer: e.activeServer,
entries: o.children,
hash: e.hash,
level: e.level + 1,
options: e.options,
paths: e.paths,
rootIndex: e.rootIndex,
security: e.security,
store: e.store,
webhooks: e.webhooks
}, null, 8, ["activeCollection", "activeServer", "entries", "hash", "level", "options", "paths", "rootIndex", "security", "store", "webhooks"])) : k("", !0)
]),
_: 2
}, 1032, ["layout", "moreThanOneTag", "onShowMore", "tag"])) : n(o) ? (r(), i(d, {
key: 2,
activeCollection: e.activeCollection,
activeServer: e.activeServer,
entries: o.children || [],
hash: e.hash,
level: e.level + 1,
options: e.options,
paths: e.paths,
rootIndex: e.rootIndex,
security: e.security,
store: e.store,
webhooks: e.webhooks
}, null, 8, ["activeCollection", "activeServer", "entries", "hash", "level", "options", "paths", "rootIndex", "security", "store", "webhooks"])) : k("", !0)
]),
_: 2
}, 1032, ["id", "isLazy", "prev"]))), 128);
};
}
});
export {
P as default
};