@scalar/api-reference
Version:
Generate beautiful API references from OpenAPI documents
85 lines (84 loc) • 3.79 kB
JavaScript
import { defineComponent, createBlock, openBlock, unref, createSlots, withCtx, createElementVNode, normalizeClass, createTextVNode, createElementBlock, createCommentVNode, toDisplayString, Fragment, createVNode } from "vue";
import { ScalarSearchResultItem } from "@scalar/components";
import { ScalarIconTerminalWindow, ScalarIconTag, ScalarIconBracketsCurly, ScalarIconTextAlignLeft } from "@scalar/icons";
import { HttpMethod } from "@scalar/sidebar";
const _hoisted_1 = { class: "sr-only" };
const _hoisted_2 = { class: "inline-flex items-center gap-1" };
const _hoisted_3 = { class: "sr-only" };
const _sfc_main = /* @__PURE__ */ defineComponent({
__name: "SearchResult",
props: {
id: {},
isSelected: { type: Boolean },
result: {}
},
setup(__props) {
const ENTRY_ICONS = {
heading: ScalarIconTextAlignLeft,
model: ScalarIconBracketsCurly,
operation: ScalarIconTerminalWindow,
tag: ScalarIconTag,
webhook: ScalarIconTerminalWindow
};
const ENTRY_LABELS = {
heading: "Heading",
operation: "Operation",
tag: "Tag",
model: "Model",
webhook: "Webhook"
};
return (_ctx, _cache) => {
return openBlock(), createBlock(unref(ScalarSearchResultItem), {
id: __props.id,
icon: ENTRY_ICONS[__props.result.item.type],
selected: __props.isSelected
}, createSlots({
default: withCtx(() => [
createElementVNode("span", {
class: normalizeClass({
"text-decoration-line": __props.result.item.entry.type === "operation" && __props.result.item.entry.isDeprecated
})
}, [
createElementVNode("span", _hoisted_1, [
createTextVNode(toDisplayString(ENTRY_LABELS[__props.result.item.type]) + ": ", 1),
__props.result.item.entry.type === "operation" && __props.result.item.entry.isDeprecated ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
createTextVNode(" (Deprecated) ")
], 64)) : createCommentVNode("", true)
]),
createTextVNode(" " + toDisplayString(__props.result.item.title) + " ", 1),
_cache[0] || (_cache[0] = createElementVNode("span", { class: "sr-only" }, ",", -1))
], 2)
]),
_: 2
}, [
__props.result.item.type !== "webhook" && (__props.result.item.method || __props.result.item.path) && __props.result.item.path !== __props.result.item.title ? {
name: "description",
fn: withCtx(() => [
createElementVNode("span", _hoisted_2, [
__props.result.item.type === "operation" ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
createVNode(unref(HttpMethod), {
"aria-hidden": "true",
method: __props.result.item.method ?? "get"
}, null, 8, ["method"]),
createElementVNode("span", _hoisted_3, " HTTP Method: " + toDisplayString(__props.result.item.method ?? "get"), 1)
], 64)) : createCommentVNode("", true),
_cache[1] || (_cache[1] = createElementVNode("span", { class: "sr-only" }, "Path: ", -1)),
createTextVNode(" " + toDisplayString(__props.result.item.path), 1)
])
]),
key: "0"
} : __props.result.item.description ? {
name: "description",
fn: withCtx(() => [
_cache[2] || (_cache[2] = createElementVNode("span", { class: "sr-only" }, "Description: ", -1)),
createTextVNode(" " + toDisplayString(__props.result.item.description), 1)
]),
key: "1"
} : void 0
]), 1032, ["id", "icon", "selected"]);
};
}
});
export {
_sfc_main as default
};