UNPKG

@scalar/api-reference

Version:

Generate beautiful API references from OpenAPI documents

70 lines (69 loc) 2.35 kB
import { defineComponent as f, useId as p, computed as b, watch as S, nextTick as x, createElementBlock as g, openBlock as n, Fragment as k, createElementVNode as u, createVNode as y, createBlock as i, createCommentVNode as c, normalizeClass as V, unref as o } from "vue"; import { ServerVariablesForm as h } from "@scalar/api-client/components/Server"; import { ScalarMarkdown as C } from "@scalar/components"; import { emitCustomEvent as v } from "@scalar/workspace-store/events"; import { templateRef as R } from "@vueuse/core"; import _ from "./Selector.vue.js"; const B = ["id"], E = {}, M = /* @__PURE__ */ f({ ...E, __name: "ServerSelector", props: { xSelectedServer: {}, servers: {} }, setup(t) { const s = p(), d = (e) => { v(a.value, "scalar-update-selected-server", { value: e }); }, m = (e, l) => { a.value && v( a.value, "scalar-update-selected-server-variables", { key: e, value: l } ); }, r = b(() => t.servers.find((e) => e.url === t.xSelectedServer)); S( () => t.servers, (e) => { e.length && (t.xSelectedServer || x(() => { d(e[0].url); })); }, { immediate: !0 } ); const a = R("containerRef"); return (e, l) => (n(), g(k, null, [ l[0] || (l[0] = u("label", { class: "bg-b-2 flex h-8 items-center rounded-t-lg border border-b-0 px-3 py-2.5 font-medium" }, " Server ", -1)), u("div", { id: o(s), ref_key: "containerRef", ref: a, class: V(["border", { "rounded-b-lg": !r.value?.description && !r.value?.variables }]) }, [ e.servers.length ? (n(), i(_, { key: 0, servers: e.servers, target: o(s), xSelectedServer: e.xSelectedServer, "onUpdate:modelValue": d }, null, 8, ["servers", "target", "xSelectedServer"])) : c("", !0) ], 10, B), y(o(h), { layout: "reference", variables: r.value?.variables, "onUpdate:variable": m }, null, 8, ["variables"]), r.value?.description ? (n(), i(o(C), { key: 0, class: "text-c-3 rounded-b-lg border border-t-0 px-3 py-1.5", value: r.value.description }, null, 8, ["value"])) : c("", !0) ], 64)); } }); export { M as default };