@scalar/api-client
Version:
the open source API testing client
52 lines (51 loc) • 2.28 kB
JavaScript
import { defineComponent as h, useId as x, computed as c, createElementBlock as a, openBlock as n, normalizeClass as k, createElementVNode as d, createCommentVNode as u, mergeProps as S, unref as s, createVNode as l, toDisplayString as g, withModifiers as y } from "vue";
import { ScalarListboxCheckbox as w, ScalarMarkdown as C } from "@scalar/components";
import O from "../../../components/Server/ServerVariablesForm.vue.js";
const V = ["aria-expanded"], _ = { class: "overflow-hidden text-ellipsis whitespace-nowrap" }, E = ["id"], I = { key: 0 }, N = { class: "description text-c-3 px-3 py-1.5" }, j = /* @__PURE__ */ h({
__name: "ServerDropdownItem",
props: {
server: {},
serverOption: {}
},
emits: ["update:variable", "update:selectedServer"],
setup(o, { emit: m }) {
const v = m, p = x(), b = () => Object.keys(o.server?.variables ?? {}).length > 0, t = c(() => o.serverOption.id === o.server?.url), i = c(() => t.value && b()), f = (e, r) => {
v("update:variable", e, r);
};
return (e, r) => (n(), a("div", {
class: k(["group/item flex min-h-fit flex-col rounded border", { "border-transparent": !t.value }])
}, [
d("button", S(i.value ? { "aria-controls": s(p) } : {}, {
"aria-expanded": i.value,
class: ["flex min-h-8 cursor-pointer items-center gap-1.5 rounded px-1.5", t.value ? "text-c-1 bg-b-2" : "hover:bg-b-2"],
type: "button",
onClick: r[0] || (r[0] = (B) => v("update:selectedServer", { id: e.serverOption.id }))
}), [
l(s(w), { selected: t.value }, null, 8, ["selected"]),
d("span", _, g(e.serverOption.label), 1)
], 16, V),
i.value ? (n(), a("div", {
key: 0,
id: s(p),
class: "bg-b-2 divide divide-y rounded-b border-t *:pl-4",
onClick: r[1] || (r[1] = y(() => {
}, ["stop"]))
}, [
l(O, {
variables: e.server?.variables,
"onUpdate:variable": f
}, null, 8, ["variables"]),
e.server?.description ? (n(), a("div", I, [
d("div", N, [
l(s(C), {
value: e.server.description
}, null, 8, ["value"])
])
])) : u("", !0)
], 8, E)) : u("", !0)
], 2));
}
});
export {
j as default
};